diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/Plot2D.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/Plot2D.java index 2a26e52b..66c8fbd6 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/Plot2D.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/plot/Plot2D.java @@ -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()]; diff --git a/meteoinfo-common/src/main/java/org/meteoinfo/common/util/GlobalUtil.java b/meteoinfo-common/src/main/java/org/meteoinfo/common/util/GlobalUtil.java index bd43931c..06fffc2c 100644 --- a/meteoinfo-common/src/main/java/org/meteoinfo/common/util/GlobalUtil.java +++ b/meteoinfo-common/src/main/java/org/meteoinfo/common/util/GlobalUtil.java @@ -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; } diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/drawing/Draw.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/drawing/Draw.java index 3673e212..53e9d318 100644 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/drawing/Draw.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/drawing/Draw.java @@ -3139,10 +3139,12 @@ public class Draw { drawArrowLine(points, (ArrowLineBreak) aPLB, g); } else { if (aPLB.isUsingDashStyle()) { - 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); + 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()) { diff --git a/meteoinfo-geometry/src/main/java/org/meteoinfo/geometry/graphic/Graphic.java b/meteoinfo-geometry/src/main/java/org/meteoinfo/geometry/graphic/Graphic.java index a6dea397..956d9830 100644 --- a/meteoinfo-geometry/src/main/java/org/meteoinfo/geometry/graphic/Graphic.java +++ b/meteoinfo-geometry/src/main/java/org/meteoinfo/geometry/graphic/Graphic.java @@ -33,8 +33,8 @@ package org.meteoinfo.geometry.graphic; public class Graphic { // - private Shape _shape = null; - private ColorBreak _legend = null; + protected Shape shape = null; + protected ColorBreak legend = null; private ResizeAbility _resizeAbility = ResizeAbility.RESIZE_ALL; // // @@ -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(); } // @@ -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; // // + + /** + * 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 points = (List)_shape.getPoints(); - switch (_shape.getShapeType()){ + List points = (List) 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 points = (List)_shape.getPoints(); + List points = (List) 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 points = (List)_shape.getPoints(); + List points = (List) 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(); } diff --git a/meteoinfo-geometry/src/main/java/org/meteoinfo/geometry/graphic/GraphicCollection.java b/meteoinfo-geometry/src/main/java/org/meteoinfo/geometry/graphic/GraphicCollection.java index 7597d4a5..8f1865e1 100644 --- a/meteoinfo-geometry/src/main/java/org/meteoinfo/geometry/graphic/GraphicCollection.java +++ b/meteoinfo-geometry/src/main/java/org/meteoinfo/geometry/graphic/GraphicCollection.java @@ -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(); } diff --git a/meteoinfo-geometry/src/main/java/org/meteoinfo/geometry/graphic/Line2DGraphic.java b/meteoinfo-geometry/src/main/java/org/meteoinfo/geometry/graphic/Line2DGraphic.java new file mode 100644 index 00000000..d17ddf57 --- /dev/null +++ b/meteoinfo-geometry/src/main/java/org/meteoinfo/geometry/graphic/Line2DGraphic.java @@ -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 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 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(); + } +} diff --git a/meteoinfo-lab/milconfig.xml b/meteoinfo-lab/milconfig.xml index d221f504..8241936a 100644 --- a/meteoinfo-lab/milconfig.xml +++ b/meteoinfo-lab/milconfig.xml @@ -1,32 +1,32 @@ - - - - - - - - - - + + + + + + + + + - - + + + - - + + - - - + + + - - - + + + @@ -34,5 +34,5 @@
- + diff --git a/meteoinfo-lab/pylib/mipylib/plotlib/__init__$py.class b/meteoinfo-lab/pylib/mipylib/plotlib/__init__$py.class index 9ea6589a..b28f40bb 100644 Binary files a/meteoinfo-lab/pylib/mipylib/plotlib/__init__$py.class and b/meteoinfo-lab/pylib/mipylib/plotlib/__init__$py.class differ diff --git a/meteoinfo-lab/pylib/mipylib/plotlib/__init__.py b/meteoinfo-lab/pylib/mipylib/plotlib/__init__.py index 4e643554..c1da2c9b 100644 --- a/meteoinfo-lab/pylib/mipylib/plotlib/__init__.py +++ b/meteoinfo-lab/pylib/mipylib/plotlib/__init__.py @@ -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__ diff --git a/meteoinfo-lab/pylib/mipylib/plotlib/_axes$py.class b/meteoinfo-lab/pylib/mipylib/plotlib/_axes$py.class index b3239d55..95e72ce7 100644 Binary files a/meteoinfo-lab/pylib/mipylib/plotlib/_axes$py.class and b/meteoinfo-lab/pylib/mipylib/plotlib/_axes$py.class differ diff --git a/meteoinfo-lab/pylib/mipylib/plotlib/_axes.py b/meteoinfo-lab/pylib/mipylib/plotlib/_axes.py index 20f41b08..36991647 100644 --- a/meteoinfo-lab/pylib/mipylib/plotlib/_axes.py +++ b/meteoinfo-lab/pylib/mipylib/plotlib/_axes.py @@ -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() diff --git a/meteoinfo-lab/pylib/mipylib/plotlib/graphic/__init__.py b/meteoinfo-lab/pylib/mipylib/plotlib/graphic/__init__.py new file mode 100644 index 00000000..448331e9 --- /dev/null +++ b/meteoinfo-lab/pylib/mipylib/plotlib/graphic/__init__.py @@ -0,0 +1,5 @@ +from .lines import * +from .patches import * + +__all__ = lines.__all__ +__all__ += patches.__all__ \ No newline at end of file diff --git a/meteoinfo-lab/pylib/mipylib/plotlib/graphic/lines.py b/meteoinfo-lab/pylib/mipylib/plotlib/graphic/lines.py new file mode 100644 index 00000000..f9a30da8 --- /dev/null +++ b/meteoinfo-lab/pylib/mipylib/plotlib/graphic/lines.py @@ -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) diff --git a/meteoinfo-lab/pylib/mipylib/plotlib/patches.py b/meteoinfo-lab/pylib/mipylib/plotlib/graphic/patches.py similarity index 99% rename from meteoinfo-lab/pylib/mipylib/plotlib/patches.py rename to meteoinfo-lab/pylib/mipylib/plotlib/graphic/patches.py index bce12e11..dfbb11c8 100644 --- a/meteoinfo-lab/pylib/mipylib/plotlib/patches.py +++ b/meteoinfo-lab/pylib/mipylib/plotlib/graphic/patches.py @@ -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'] diff --git a/meteoinfo-lab/pylib/mipylib/plotlib/lines.py b/meteoinfo-lab/pylib/mipylib/plotlib/lines.py deleted file mode 100644 index ac921b34..00000000 --- a/meteoinfo-lab/pylib/mipylib/plotlib/lines.py +++ /dev/null @@ -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 \ No newline at end of file diff --git a/meteoinfo-lab/pylib/mipylib/plotlib/plotutil$py.class b/meteoinfo-lab/pylib/mipylib/plotlib/plotutil$py.class index 7db7a069..74fde4c3 100644 Binary files a/meteoinfo-lab/pylib/mipylib/plotlib/plotutil$py.class and b/meteoinfo-lab/pylib/mipylib/plotlib/plotutil$py.class differ diff --git a/meteoinfo-lab/pylib/mipylib/plotlib/plotutil.py b/meteoinfo-lab/pylib/mipylib/plotlib/plotutil.py index 32c01cac..0c6e3446 100644 --- a/meteoinfo-lab/pylib/mipylib/plotlib/plotutil.py +++ b/meteoinfo-lab/pylib/mipylib/plotlib/plotutil.py @@ -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) diff --git a/pom.xml b/pom.xml index ca78d2a9..34a47baf 100644 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,7 @@ UTF-8 1.8 - 3.7.9 + 3.7.10 8 8 8