mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
add Line2D graphic
This commit is contained in:
parent
58603e0413
commit
bfa8c9b731
@ -26,6 +26,7 @@ import org.meteoinfo.geo.drawing.Draw;
|
||||
import org.meteoinfo.geometry.graphic.Graphic;
|
||||
import org.meteoinfo.geometry.graphic.GraphicCollection;
|
||||
import org.meteoinfo.geometry.graphic.ImageGraphic;
|
||||
import org.meteoinfo.geometry.graphic.Line2DGraphic;
|
||||
import org.meteoinfo.geometry.legend.*;
|
||||
import org.meteoinfo.geometry.shape.Polygon;
|
||||
import org.meteoinfo.geometry.shape.Shape;
|
||||
@ -275,6 +276,11 @@ public class Plot2D extends AbstractPlot2D {
|
||||
}
|
||||
for (int i = 0; i < graphic.getNumGraphics(); i++) {
|
||||
Graphic gg = graphic.getGraphicN(i);
|
||||
if (gg instanceof Line2DGraphic) {
|
||||
this.drawLine2D(g, (Line2DGraphic) gg, area);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!graphic.isSingleLegend()) {
|
||||
cb = gg.getLegend();
|
||||
}
|
||||
@ -435,6 +441,25 @@ public class Plot2D extends AbstractPlot2D {
|
||||
Draw.drawArrow(pf, aPS, aPB, g, zoom);
|
||||
}
|
||||
|
||||
private void drawLine2D(Graphics2D g, Line2DGraphic line2D, Rectangle2D area) {
|
||||
if (line2D.isCurve()) {
|
||||
drawCurveline(g, (PolylineShape) line2D.getShape(), (PolylineBreak) line2D.getLegend(), area);
|
||||
} else {
|
||||
BreakTypes breakType = line2D.getLegend().getBreakType();
|
||||
switch (breakType) {
|
||||
case POINT_BREAK:
|
||||
drawPolyline(g, (PolylineShape) line2D.getShape(), (PointBreak) line2D.getLegend(), area);
|
||||
break;
|
||||
case COLOR_BREAK_COLLECTION:
|
||||
drawPolyline(g, (PolylineShape) line2D.getShape(), (ColorBreakCollection) line2D.getLegend(), area);
|
||||
break;
|
||||
default:
|
||||
drawPolyline(g, (PolylineShape) line2D.getShape(), (PolylineBreak) line2D.getLegend(), area);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawPolyline(Graphics2D g, PolylineShape aPLS, PointBreak aPB, Rectangle2D area) {
|
||||
for (Polyline aline : aPLS.getPolylines()) {
|
||||
double[] sXY;
|
||||
@ -512,7 +537,7 @@ public class Plot2D extends AbstractPlot2D {
|
||||
}
|
||||
}
|
||||
|
||||
private void drawCurveline(Graphics2D g, CurveLineShape aPLS, PolylineBreak aPLB, Rectangle2D area) {
|
||||
private void drawCurveline(Graphics2D g, PolylineShape aPLS, PolylineBreak aPLB, Rectangle2D area) {
|
||||
for (Polyline aline : aPLS.getPolylines()) {
|
||||
double[] sXY;
|
||||
PointF[] points = new PointF[aline.getPointList().size()];
|
||||
|
||||
@ -67,7 +67,7 @@ import java.util.zip.ZipInputStream;
|
||||
public static String getVersion(){
|
||||
String version = GlobalUtil.class.getPackage().getImplementationVersion();
|
||||
if (version == null || version.equals("")) {
|
||||
version = "3.7.9";
|
||||
version = "3.7.10";
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
@ -3139,10 +3139,12 @@ public class Draw {
|
||||
drawArrowLine(points, (ArrowLineBreak) aPLB, g);
|
||||
} else {
|
||||
if (aPLB.isUsingDashStyle()) {
|
||||
if (aPLB.isDrawPolyline()) {
|
||||
g.setColor(aPLB.getColor());
|
||||
float[] dashPattern = getDashPattern(aPLB.getStyle());
|
||||
g.setStroke(new BasicStroke(aPLB.getWidth(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dashPattern, 0.0f));
|
||||
drawPolyline(points, g);
|
||||
}
|
||||
|
||||
//Draw symbol
|
||||
if (aPLB.isDrawSymbol()) {
|
||||
|
||||
@ -33,8 +33,8 @@ package org.meteoinfo.geometry.graphic;
|
||||
public class Graphic {
|
||||
// <editor-fold desc="Variables">
|
||||
|
||||
private Shape _shape = null;
|
||||
private ColorBreak _legend = null;
|
||||
protected Shape shape = null;
|
||||
protected ColorBreak legend = null;
|
||||
private ResizeAbility _resizeAbility = ResizeAbility.RESIZE_ALL;
|
||||
// </editor-fold>
|
||||
// <editor-fold desc="Constructor">
|
||||
@ -52,8 +52,8 @@ package org.meteoinfo.geometry.graphic;
|
||||
* @param legend a legend
|
||||
*/
|
||||
public Graphic(Shape shape, ColorBreak legend) {
|
||||
_shape = shape;
|
||||
_legend = legend;
|
||||
this.shape = shape;
|
||||
this.legend = legend;
|
||||
updateResizeAbility();
|
||||
}
|
||||
// </editor-fold>
|
||||
@ -65,7 +65,7 @@ package org.meteoinfo.geometry.graphic;
|
||||
* @return Shape
|
||||
*/
|
||||
public Shape getShape() {
|
||||
return _shape;
|
||||
return shape;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,7 +74,7 @@ package org.meteoinfo.geometry.graphic;
|
||||
* @param aShape a shape
|
||||
*/
|
||||
public void setShape(Shape aShape) {
|
||||
_shape = aShape;
|
||||
shape = aShape;
|
||||
updateResizeAbility();
|
||||
}
|
||||
|
||||
@ -84,11 +84,11 @@ package org.meteoinfo.geometry.graphic;
|
||||
* @return Legend
|
||||
*/
|
||||
public ColorBreak getLegend() {
|
||||
return _legend;
|
||||
return legend;
|
||||
}
|
||||
|
||||
public void setLegend(ColorBreak legend) {
|
||||
_legend = legend;
|
||||
this.legend = legend;
|
||||
updateResizeAbility();
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ package org.meteoinfo.geometry.graphic;
|
||||
* @return The extent
|
||||
*/
|
||||
public Extent getExtent() {
|
||||
return this._shape.getExtent();
|
||||
return this.shape.getExtent();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,7 +115,7 @@ package org.meteoinfo.geometry.graphic;
|
||||
* @param value The extent
|
||||
*/
|
||||
public void setExtent(Extent value){
|
||||
this._shape.setExtent(value);
|
||||
this.shape.setExtent(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,6 +136,15 @@ package org.meteoinfo.geometry.graphic;
|
||||
|
||||
// </editor-fold>
|
||||
// <editor-fold desc="Methods">
|
||||
|
||||
/**
|
||||
* Get shape type
|
||||
* @return The shape type
|
||||
*/
|
||||
public ShapeTypes getShapeType(){
|
||||
return shape.getShapeType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get graphics number
|
||||
* @return 1
|
||||
@ -164,10 +173,10 @@ package org.meteoinfo.geometry.graphic;
|
||||
}
|
||||
|
||||
private void updateResizeAbility() {
|
||||
if (_shape != null && _legend != null) {
|
||||
switch (_shape.getShapeType()) {
|
||||
if (shape != null && legend != null) {
|
||||
switch (shape.getShapeType()) {
|
||||
case POINT:
|
||||
switch (_legend.getBreakType()) {
|
||||
switch (legend.getBreakType()) {
|
||||
case POINT_BREAK:
|
||||
_resizeAbility = ResizeAbility.SAME_WIDTH_HEIGHT;
|
||||
break;
|
||||
@ -195,8 +204,8 @@ package org.meteoinfo.geometry.graphic;
|
||||
* @param newY New Y
|
||||
*/
|
||||
public void verticeMoveUpdate(int vIdx, double newX, double newY) {
|
||||
List<PointD> points = (List<PointD>)_shape.getPoints();
|
||||
switch (_shape.getShapeType()){
|
||||
List<PointD> points = (List<PointD>) shape.getPoints();
|
||||
switch (shape.getShapeType()){
|
||||
case POLYGON:
|
||||
case CURVE_POLYGON:
|
||||
case RECTANGLE:
|
||||
@ -219,7 +228,7 @@ package org.meteoinfo.geometry.graphic;
|
||||
aP.X = newX;
|
||||
aP.Y = newY;
|
||||
//points.set(vIdx, aP);
|
||||
_shape.setPoints(points);
|
||||
shape.setPoints(points);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -229,9 +238,9 @@ package org.meteoinfo.geometry.graphic;
|
||||
* @param point The add vertice
|
||||
*/
|
||||
public void verticeAddUpdate(int vIdx, PointD point) {
|
||||
List<PointD> points = (List<PointD>)_shape.getPoints();
|
||||
List<PointD> points = (List<PointD>) shape.getPoints();
|
||||
points.add(vIdx, point);
|
||||
_shape.setPoints(points);
|
||||
shape.setPoints(points);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -240,9 +249,9 @@ package org.meteoinfo.geometry.graphic;
|
||||
* @param vIdx Vertice index
|
||||
*/
|
||||
public void verticeRemoveUpdate(int vIdx) {
|
||||
List<PointD> points = (List<PointD>)_shape.getPoints();
|
||||
List<PointD> points = (List<PointD>) shape.getPoints();
|
||||
points.remove(vIdx);
|
||||
_shape.setPoints(points);
|
||||
shape.setPoints(points);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -252,8 +261,8 @@ package org.meteoinfo.geometry.graphic;
|
||||
*/
|
||||
public void exportToXML(Document doc, Element parent) {
|
||||
Element graphic = doc.createElement("Graphic");
|
||||
addShape(doc, graphic, _shape);
|
||||
addLegend(doc, graphic, _legend, _shape.getShapeType());
|
||||
addShape(doc, graphic, shape);
|
||||
addLegend(doc, graphic, legend, shape.getShapeType());
|
||||
|
||||
parent.appendChild(graphic);
|
||||
}
|
||||
@ -508,10 +517,10 @@ package org.meteoinfo.geometry.graphic;
|
||||
*/
|
||||
public void importFromXML(Element graphicNode) {
|
||||
Node shape = graphicNode.getElementsByTagName("Shape").item(0);
|
||||
_shape = loadShape(shape);
|
||||
this.shape = loadShape(shape);
|
||||
|
||||
Node legend = graphicNode.getElementsByTagName("Legend").item(0);
|
||||
_legend = loadLegend(legend, _shape.getShapeType());
|
||||
this.legend = loadLegend(legend, this.shape.getShapeType());
|
||||
|
||||
updateResizeAbility();
|
||||
}
|
||||
|
||||
@ -554,6 +554,7 @@ public class GraphicCollection extends Graphic implements Iterator {
|
||||
*
|
||||
* @return Shape type
|
||||
*/
|
||||
@Override
|
||||
public ShapeTypes getShapeType() {
|
||||
return this.graphics.get(0).getShape().getShapeType();
|
||||
}
|
||||
|
||||
@ -0,0 +1,152 @@
|
||||
package org.meteoinfo.geometry.graphic;
|
||||
|
||||
import org.meteoinfo.common.PointD;
|
||||
import org.meteoinfo.geometry.legend.ColorBreak;
|
||||
import org.meteoinfo.geometry.legend.ColorBreakCollection;
|
||||
import org.meteoinfo.geometry.legend.LegendScheme;
|
||||
import org.meteoinfo.geometry.legend.PolylineBreak;
|
||||
import org.meteoinfo.geometry.shape.PolylineShape;
|
||||
import org.meteoinfo.ndarray.Array;
|
||||
import org.meteoinfo.ndarray.IndexIterator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Line2DGraphic extends Graphic {
|
||||
private Array xData;
|
||||
private Array yData;
|
||||
private Array cData;
|
||||
private boolean curve = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param polylineShape Polyline shape
|
||||
* @param polylineBreak Polyline break
|
||||
*/
|
||||
public Line2DGraphic(PolylineShape polylineShape, PolylineBreak polylineBreak) {
|
||||
this.shape = polylineShape;
|
||||
this.legend = polylineBreak;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param xData X data
|
||||
* @param yData Y data
|
||||
* @param polylineBreak Polyline break
|
||||
*/
|
||||
public Line2DGraphic(Array xData, Array yData, PolylineBreak polylineBreak) {
|
||||
this.xData = xData;
|
||||
this.yData = yData;
|
||||
|
||||
updateShape();
|
||||
if (polylineBreak == null) {
|
||||
polylineBreak = new PolylineBreak();
|
||||
}
|
||||
this.legend = polylineBreak;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param xData X data
|
||||
* @param yData Y data
|
||||
*/
|
||||
public Line2DGraphic(Array xData, Array yData) {
|
||||
this(xData, yData, new PolylineBreak());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param xData X data
|
||||
* @param yData Y data
|
||||
* @param cData Color data
|
||||
* @param legendScheme Legend scheme
|
||||
*/
|
||||
public Line2DGraphic(Array xData, Array yData, Array cData, LegendScheme legendScheme) {
|
||||
this.xData = xData;
|
||||
this.yData = yData;
|
||||
this.cData = cData;
|
||||
|
||||
updateShapeLegend(legendScheme);
|
||||
}
|
||||
|
||||
protected void updateShape() {
|
||||
List<PointD> points = new ArrayList<>();
|
||||
IndexIterator xIter = this.xData.getIndexIterator();
|
||||
IndexIterator yIter = this.yData.getIndexIterator();
|
||||
while (xIter.hasNext()) {
|
||||
points.add(new PointD(xIter.getDoubleNext(), yIter.getDoubleNext()));
|
||||
}
|
||||
if (this.shape == null) {
|
||||
this.shape = new PolylineShape();
|
||||
}
|
||||
this.shape.setPoints(points);
|
||||
}
|
||||
|
||||
protected void updateShapeLegend(LegendScheme legendScheme) {
|
||||
List<PointD> points = new ArrayList<>();
|
||||
IndexIterator xIter = this.xData.getIndexIterator();
|
||||
IndexIterator yIter = this.yData.getIndexIterator();
|
||||
IndexIterator cIter = this.cData.getIndexIterator();
|
||||
ColorBreakCollection cbc = new ColorBreakCollection();
|
||||
ColorBreak cb;
|
||||
double c;
|
||||
while (xIter.hasNext()) {
|
||||
points.add(new PointD(xIter.getDoubleNext(), yIter.getDoubleNext()));
|
||||
c = cIter.getDoubleNext();
|
||||
cb = legendScheme.findLegendBreak(c);
|
||||
cbc.add(cb);
|
||||
}
|
||||
if (this.shape == null) {
|
||||
this.shape = new PolylineShape();
|
||||
}
|
||||
this.shape.setPoints(points);
|
||||
|
||||
this.legend = cbc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return plot as curve line or not
|
||||
* @return Curve line or not
|
||||
*/
|
||||
public boolean isCurve() {
|
||||
return this.curve;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set plot as curve line or not
|
||||
* @param value Curve line or not
|
||||
*/
|
||||
public void setCurve(boolean value) {
|
||||
this.curve = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set x data
|
||||
* @param xData X data
|
||||
*/
|
||||
public void setXData(Array xData) {
|
||||
this.xData = xData;
|
||||
updateShape();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set y data
|
||||
* @param yData Y data
|
||||
*/
|
||||
public void setYData(Array yData) {
|
||||
this.yData = yData;
|
||||
updateShape();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set data
|
||||
* @param xData X data
|
||||
* @param yData Y data
|
||||
*/
|
||||
public void setData(Array xData, Array yData) {
|
||||
this.xData = xData;
|
||||
this.yData = yData;
|
||||
updateShape();
|
||||
}
|
||||
}
|
||||
@ -1,32 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\map\webmap">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\no_opengl"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\geoshow"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\oco-2"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\contour"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\animation"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\plot">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\hdf"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\radar"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\web"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\FY"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\boxplot"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\funny"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\patch"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart\subplot"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\calipso"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart\legend"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\webmap"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\plot"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\chart\subplot\subplot_3.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\chart\subplot\subplot_2.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\map\add_circle.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\satellite\calipso\CALIPSO_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\plot\plot_cdata_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\plot\plot_2.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\chart\subplot\subplot_3.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\chart\subplot\subplot_2.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\map\add_circle.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\satellite\calipso\CALIPSO_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\plot\plot_cdata_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\plot\plot_2.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
@ -34,5 +34,5 @@
|
||||
</Font>
|
||||
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
|
||||
<Figure DoubleBuffering="true"/>
|
||||
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/>
|
||||
<Startup MainFormLocation="-7,0" MainFormSize="1310,788"/>
|
||||
</MeteoInfo>
|
||||
|
||||
Binary file not shown.
@ -6,14 +6,12 @@ from ._axes3d import Axes3D
|
||||
from ._axes3dgl import Axes3DGL
|
||||
from ._figure import Figure
|
||||
from ._glfigure import GLFigure
|
||||
from .patches import *
|
||||
from .lines import *
|
||||
from .colors import *
|
||||
from .io import *
|
||||
from .graphic import *
|
||||
|
||||
__all__ = ['Figure', 'GLFigure', 'Axes', 'PolarAxes', 'MapAxes', 'Axes3D', 'Axes3DGL']
|
||||
__all__ += miplot.__all__
|
||||
__all__ += patches.__all__
|
||||
__all__ += lines.__all__
|
||||
__all__ += colors.__all__
|
||||
__all__ += io.__all__
|
||||
__all__ += graphic.__all__
|
||||
|
||||
Binary file not shown.
@ -35,6 +35,7 @@ from mipylib.geolib.milayer import MILayer, MIXYListData
|
||||
import plotutil
|
||||
import colors
|
||||
import mipylib.miutil as miutil
|
||||
from .graphic import Line2D
|
||||
|
||||
__all__ = ['Axes', 'PolarAxes']
|
||||
|
||||
@ -1085,6 +1086,8 @@ class Axes(object):
|
||||
else:
|
||||
self._axes.addGraphic(zorder, graphic, projection)
|
||||
|
||||
self._axes.setAutoExtent()
|
||||
|
||||
def get_graphics(self):
|
||||
"""
|
||||
Get graphics
|
||||
@ -1364,7 +1367,7 @@ class Axes(object):
|
||||
|
||||
# Add graphics
|
||||
zorder = kwargs.pop('zorder', None)
|
||||
iscurve = kwargs.pop('iscurve', False)
|
||||
iscurve = kwargs.pop('curve', False)
|
||||
graphics = []
|
||||
if isxylistdata:
|
||||
graphic = GraphicFactory.createLineString(dataset, lines)
|
||||
@ -1375,8 +1378,10 @@ class Axes(object):
|
||||
# Add data series
|
||||
snum = len(xdatalist)
|
||||
if snum == 1:
|
||||
xdata = plotutil.getplotdata(xdatalist[0])
|
||||
ydata = plotutil.getplotdata(ydatalist[0])
|
||||
#xdata = plotutil.getplotdata(xdatalist[0])
|
||||
#ydata = plotutil.getplotdata(ydatalist[0])
|
||||
xdata = np.asarray(xdatalist[0])
|
||||
ydata = np.asarray(ydatalist[0])
|
||||
if len(lines) == 1:
|
||||
colors = kwargs.pop('colors', None)
|
||||
if not colors is None:
|
||||
@ -1387,26 +1392,31 @@ class Axes(object):
|
||||
ncb = cb.clone()
|
||||
ncb.setColor(cc)
|
||||
lines.append(ncb)
|
||||
graphic = GraphicFactory.createLineString(xdata, ydata, lines, iscurve)
|
||||
graphic = GraphicFactory.createLineString(xdata._array, ydata._array, lines, iscurve)
|
||||
else:
|
||||
graphic = GraphicFactory.createLineString(xdata, ydata, lines[0], iscurve)
|
||||
#graphic = GraphicFactory.createLineString(xdata, ydata, lines[0], iscurve)
|
||||
graphic = Line2D(xdata, ydata, legend=lines[0], curve=iscurve)
|
||||
else: # >1
|
||||
graphic = GraphicFactory.createLineString(xdata, ydata, lines, iscurve)
|
||||
graphic = GraphicFactory.createLineString(xdata._array, ydata._array, lines, iscurve)
|
||||
self.add_graphic(graphic, zorder=zorder)
|
||||
graphics.append(graphic)
|
||||
else:
|
||||
for i in range(0, snum):
|
||||
label = kwargs.pop('label', 'S_' + str(i + 1))
|
||||
xdata = plotutil.getplotdata(xdatalist[i])
|
||||
ydata = plotutil.getplotdata(ydatalist[i])
|
||||
graphic = GraphicFactory.createLineString(xdata, ydata, lines[i], iscurve)
|
||||
#xdata = plotutil.getplotdata(xdatalist[i])
|
||||
#ydata = plotutil.getplotdata(ydatalist[i])
|
||||
xdata = np.asarray(xdatalist[i])
|
||||
ydata = np.asarray(ydatalist[i])
|
||||
#graphic = GraphicFactory.createLineString(xdata, ydata, lines[i], iscurve)
|
||||
graphic = Line2D(xdata, ydata, legend=lines[i], curve=iscurve)
|
||||
self.add_graphic(graphic)
|
||||
graphics.append(graphic)
|
||||
else:
|
||||
xdata = plotutil.getplotdata(xdatalist[0])
|
||||
ydata = plotutil.getplotdata(ydatalist[0])
|
||||
zdata = plotutil.getplotdata(cdata)
|
||||
graphic = GraphicFactory.createLineString(xdata, ydata, zdata, ls, iscurve)
|
||||
xdata = np.asarray(xdatalist[0])
|
||||
ydata = np.asarray(ydatalist[0])
|
||||
cdata = np.asarray(cdata)
|
||||
#graphic = GraphicFactory.createLineString(xdata, ydata, cdata, ls, iscurve)
|
||||
graphic = Line2D(xdata, ydata, legend=ls, cdata=cdata, curve=iscurve)
|
||||
self.add_graphic(graphic, zorder=zorder)
|
||||
graphics.append(graphic)
|
||||
self._axes.setAutoExtent()
|
||||
|
||||
5
meteoinfo-lab/pylib/mipylib/plotlib/graphic/__init__.py
Normal file
5
meteoinfo-lab/pylib/mipylib/plotlib/graphic/__init__.py
Normal file
@ -0,0 +1,5 @@
|
||||
from .lines import *
|
||||
from .patches import *
|
||||
|
||||
__all__ = lines.__all__
|
||||
__all__ += patches.__all__
|
||||
123
meteoinfo-lab/pylib/mipylib/plotlib/graphic/lines.py
Normal file
123
meteoinfo-lab/pylib/mipylib/plotlib/graphic/lines.py
Normal file
@ -0,0 +1,123 @@
|
||||
from org.meteoinfo.geometry.graphic import Line2DGraphic
|
||||
from org.meteoinfo.geometry.legend import PolylineBreak
|
||||
|
||||
from .. import plotutil
|
||||
|
||||
|
||||
__all__ = ['Line2D']
|
||||
|
||||
class Line2D(Line2DGraphic):
|
||||
"""
|
||||
A line - the line can have both a solid linestyle connecting all
|
||||
the vertices, and a marker at each vertex. Additionally, the
|
||||
drawing of the solid line is influenced by the drawstyle, e.g., one
|
||||
can create "stepped" lines in various styles.
|
||||
"""
|
||||
|
||||
#__slots__ = ('set_data')
|
||||
|
||||
def __init__(self, xdata, ydata, legend=None, cdata=None, curve=False, **kwargs):
|
||||
"""
|
||||
Create a `.Line2D` instance with *x* and *y* data in sequences of
|
||||
*xdata*, *ydata*.
|
||||
"""
|
||||
if legend is None:
|
||||
legend = plotutil.getlegendbreak('line', **kwargs)[0]
|
||||
|
||||
self._x = xdata
|
||||
self._y = ydata
|
||||
self._cdata = cdata
|
||||
|
||||
if cdata is None:
|
||||
super(Line2D, self).__init__(xdata._array, ydata._array, legend)
|
||||
else:
|
||||
super(Line2D, self).__init__(xdata._array, ydata._array, cdata._array, legend)
|
||||
|
||||
if curve:
|
||||
self.setCurve(curve)
|
||||
|
||||
def get_xdata(self):
|
||||
"""
|
||||
Return the xdata.
|
||||
|
||||
:return: (*array*) xdata.
|
||||
"""
|
||||
return self._x
|
||||
|
||||
def set_xdata(self, xdata):
|
||||
"""
|
||||
Set the xdata.
|
||||
|
||||
:param xdata: (*array*) The xdata.
|
||||
"""
|
||||
self._x = xdata
|
||||
self.setXData(xdata._array)
|
||||
|
||||
def get_ydata(self):
|
||||
"""
|
||||
Return the ydata.
|
||||
|
||||
:return: (*array*) ydata.
|
||||
"""
|
||||
return self._y
|
||||
|
||||
def set_ydata(self, ydata):
|
||||
"""
|
||||
Set the ydata.
|
||||
|
||||
:param ydata: (*array*) The ydata.
|
||||
"""
|
||||
self._y = ydata
|
||||
self.setYData(ydata._array)
|
||||
|
||||
def get_data(self):
|
||||
"""
|
||||
Get x, y data.
|
||||
|
||||
:return: x, y data.
|
||||
"""
|
||||
return (self._x, self._y)
|
||||
|
||||
def set_data(self, xdata, ydata):
|
||||
"""
|
||||
Set x, y data.
|
||||
|
||||
:param xdata: (*array*) X data.
|
||||
:param ydata: (*array*) Y data.
|
||||
"""
|
||||
self._x = xdata
|
||||
self._y = ydata
|
||||
self.setData(xdata._array, ydata._array)
|
||||
|
||||
def get_color(self):
|
||||
"""
|
||||
Return the line color.
|
||||
|
||||
:return: (*Color*) The line color.
|
||||
"""
|
||||
return self.legend.getColor()
|
||||
|
||||
def set_color(self, color):
|
||||
"""
|
||||
Set the line color.
|
||||
|
||||
:param color: (*color or str*) The line color.
|
||||
"""
|
||||
color = plotutil.getcolor(color)
|
||||
self.legend.setColor(color)
|
||||
|
||||
def get_curve(self):
|
||||
"""
|
||||
Return curve line or not.
|
||||
|
||||
:return: (*bool*) Curve line or not.
|
||||
"""
|
||||
return self.isCurve()
|
||||
|
||||
def set_curve(self, curve):
|
||||
"""
|
||||
Set curve line or not.
|
||||
|
||||
:param curve: (*bool*) Curve line or not.
|
||||
"""
|
||||
self.setCurve(curve)
|
||||
@ -2,7 +2,7 @@ from org.meteoinfo.geometry.graphic import Graphic
|
||||
from org.meteoinfo.geometry.shape import ShapeUtil, CircleShape, EllipseShape, \
|
||||
RectangleShape, ArcShape
|
||||
|
||||
from . import plotutil
|
||||
from .. import plotutil
|
||||
import mipylib.numeric as np
|
||||
|
||||
__all__ = ['Arc','Circle','Ellipse','Rectangle','Polygon','Wedge']
|
||||
@ -1,38 +0,0 @@
|
||||
from org.meteoinfo.geometry.graphic import Graphic
|
||||
from org.meteoinfo.geometry.shape import ShapeUtil
|
||||
|
||||
from . import plotutil
|
||||
import mipylib.numeric as np
|
||||
|
||||
__all__ = ['Line2D']
|
||||
|
||||
class Line2D(Graphic):
|
||||
"""
|
||||
A line - the line can have both a solid linestyle connecting all the vertices, and a marker
|
||||
at each vertex.
|
||||
"""
|
||||
|
||||
def __init__(self, xdata, ydata, **kwargs):
|
||||
"""
|
||||
Create a `.Line2D` instance with *x* and *y* data in sequences of
|
||||
*xdata*, *ydata*.
|
||||
|
||||
:param xdata: (*array_like*) X data of the line.
|
||||
:param ydata: (*array_like*) Y data of the line.
|
||||
"""
|
||||
xdata = np.asarray(xdata)
|
||||
ydata = np.asarray(ydata)
|
||||
|
||||
self._xdata = xdata
|
||||
self._ydata = ydata
|
||||
shape = ShapeUtil.createPolylineShape(xdata._array, ydata._array)
|
||||
legend, isunique = plotutil.getlegendbreak('line', **kwargs)
|
||||
super(Line2D, self).__init__(shape, legend)
|
||||
|
||||
@property
|
||||
def xdata(self):
|
||||
return self._xdata
|
||||
|
||||
@property
|
||||
def ydata(self):
|
||||
return self._ydata
|
||||
Binary file not shown.
@ -379,22 +379,43 @@ def getplotstyle(style, caption, **kwargs):
|
||||
if not pointStyle is None:
|
||||
fill = kwargs.pop('fill', True)
|
||||
if lineStyle is None:
|
||||
pb = PointBreak()
|
||||
pb.setCaption(caption)
|
||||
if '.' in style:
|
||||
pb.setSize(4)
|
||||
pb.setDrawOutline(False)
|
||||
else:
|
||||
pb.setSize(8)
|
||||
pb.setStyle(pointStyle)
|
||||
pb.setDrawFill(fill)
|
||||
# pb = PointBreak()
|
||||
# pb.setCaption(caption)
|
||||
# if '.' in style:
|
||||
# pb.setSize(4)
|
||||
# pb.setDrawOutline(False)
|
||||
# else:
|
||||
# pb.setSize(8)
|
||||
# pb.setStyle(pointStyle)
|
||||
# pb.setDrawFill(fill)
|
||||
# if not c is None:
|
||||
# pb.setColor(c)
|
||||
# edgecolor = kwargs.pop('edgecolor', pb.getColor())
|
||||
# edgecolor = getcolor(edgecolor)
|
||||
# pb.setOutlineColor(edgecolor)
|
||||
# setpointlegendbreak(pb, **kwargs)
|
||||
# return pb
|
||||
plb = PolylineBreak()
|
||||
plb.setCaption(caption)
|
||||
plb.setDrawPolyline(False)
|
||||
plb.setDrawSymbol(True)
|
||||
plb.setSymbolStyle(pointStyle)
|
||||
plb.setFillSymbol(fill)
|
||||
interval = kwargs.pop('markerinterval', 1)
|
||||
plb.setSymbolInterval(interval)
|
||||
if not c is None:
|
||||
pb.setColor(c)
|
||||
edgecolor = kwargs.pop('edgecolor', pb.getColor())
|
||||
edgecolor = getcolor(edgecolor)
|
||||
pb.setOutlineColor(edgecolor)
|
||||
setpointlegendbreak(pb, **kwargs)
|
||||
return pb
|
||||
plb.setColor(c)
|
||||
markersize = kwargs.pop('markersize', None)
|
||||
if not markersize is None:
|
||||
plb.setSymbolSize(markersize)
|
||||
markercolor = kwargs.pop('markeredgecolor', plb.getColor())
|
||||
markercolor = getcolor(markercolor)
|
||||
plb.setSymbolColor(markercolor)
|
||||
markerfillcolor = kwargs.pop('markerfacecolor', markercolor)
|
||||
markerfillcolor = getcolor(markerfillcolor)
|
||||
plb.setSymbolFillColor(markerfillcolor)
|
||||
plb.setFillSymbol(not markerfillcolor is None)
|
||||
return plb
|
||||
else:
|
||||
plb = PolylineBreak()
|
||||
plb.setCaption(caption)
|
||||
|
||||
2
pom.xml
2
pom.xml
@ -34,7 +34,7 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<revision>3.7.9</revision>
|
||||
<revision>3.7.10</revision>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.release>8</maven.compiler.release>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user