diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/GLChartPanel.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/GLChartPanel.java index a19e568e..074beaad 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/GLChartPanel.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/GLChartPanel.java @@ -680,116 +680,123 @@ public class GLChartPanel extends GLJPanel implements IChartPanel{ void onMouseReleased(MouseEvent e) { this.dragMode = false; - Plot plt = this.chart.findPlot(mouseDownPoint.x, mouseDownPoint.y); - if (!(plt instanceof AbstractPlot2D)) { - return; - } - - AbstractPlot2D xyplot = (AbstractPlot2D) plt; - this.currentPlot = xyplot; + Plot plot = selPlot(this.mouseDownPoint.x, this.mouseDownPoint.y); + this.currentPlot = plot; switch (this.mouseMode) { case ZOOM_IN: if (Math.abs(mouseLastPos.x - mouseDownPoint.x) > 5) { - if (xyplot instanceof MapPlot) { - MapPlot plot = (MapPlot) xyplot; - Rectangle2D graphArea = xyplot.getGraphArea(); - double[] xy1 = plot.screenToProj(mouseDownPoint.x - graphArea.getX(), mouseDownPoint.y - graphArea.getY(), graphArea); - double[] xy2 = plot.screenToProj(mouseLastPos.x - graphArea.getX(), mouseLastPos.y - graphArea.getY(), graphArea); - Extent extent = new Extent(); - extent.minX = Math.min(xy1[0], xy2[0]); - extent.maxX = Math.max(xy1[0], xy2[0]); - extent.minY = Math.min(xy1[1], xy2[1]); - extent.maxY = Math.max(xy1[1], xy2[1]); - plot.setDrawExtent(extent); - //this.paintGraphics(); - this.repaintNew(); - } else { - Rectangle2D graphArea = xyplot.getGraphArea(); - double[] xy1 = xyplot.screenToProj(mouseDownPoint.x - graphArea.getX(), mouseDownPoint.y - graphArea.getY(), graphArea); - double[] xy2 = xyplot.screenToProj(mouseLastPos.x - graphArea.getX(), mouseLastPos.y - graphArea.getY(), graphArea); - Extent extent = new Extent(); - extent.minX = Math.min(xy1[0], xy2[0]); - extent.maxX = Math.max(xy1[0], xy2[0]); - extent.minY = Math.min(xy1[1], xy2[1]); - extent.maxY = Math.max(xy1[1], xy2[1]); - if (xyplot.getXAxis().isInverse()) { - Extent drawExtent = xyplot.getDrawExtent(); - double minx, maxx; - minx = drawExtent.getWidth() - (extent.maxX - drawExtent.minX) + drawExtent.minX; - maxx = drawExtent.getWidth() - (extent.minX - drawExtent.minX) + drawExtent.minX; - extent.minX = minx; - extent.maxX = maxx; - } - if (xyplot.getYAxis().isInverse()) { - Extent drawExtent = xyplot.getDrawExtent(); - double miny, maxy; - miny = drawExtent.getHeight() - (extent.maxY - drawExtent.minY) + drawExtent.minY; - maxy = drawExtent.getHeight() - (extent.minY - drawExtent.minY) + drawExtent.minY; - extent.minY = miny; - extent.maxY = maxy; - } - xyplot.setDrawExtent(extent); - //this.paintGraphics(); - this.repaintNew(); - } - } - break; - case ZOOM_OUT: - if (e.getButton() == MouseEvent.BUTTON1) { - double zoom = 1.5; - Extent extent = xyplot.getDrawExtent(); - double owidth = extent.getWidth(); - double oheight = extent.getHeight(); - double width = owidth * zoom; - double height = oheight * zoom; - double xshift = (owidth - width) * 0.5; - double yshift = (oheight - height) * 0.5; - extent.minX += xshift; - extent.maxX -= xshift; - extent.minY += yshift; - extent.maxY -= yshift; - xyplot.setDrawExtent(extent); - //this.paintGraphics(); - this.repaintNew(); - } - break; - case SELECT: - if (Math.abs(mouseLastPos.x - mouseDownPoint.x) > 5) { - if (xyplot instanceof XY1DPlot) { - XY1DPlot plot = (XY1DPlot) xyplot; - Rectangle2D graphArea = plot.getGraphArea(); - if (graphArea.contains(mouseDownPoint.x, mouseDownPoint.y) || graphArea.contains(mouseLastPos.x, mouseLastPos.y)) { - double[] xy1 = plot.screenToProj(mouseDownPoint.x - graphArea.getX(), mouseDownPoint.y - graphArea.getY(), graphArea); - double[] xy2 = plot.screenToProj(mouseLastPos.x - graphArea.getX(), mouseLastPos.y - graphArea.getY(), graphArea); + if (plot instanceof AbstractPlot2D) { + AbstractPlot2D xyplot = (AbstractPlot2D) plot; + if (xyplot instanceof MapPlot) { + MapPlot mapPlot = (MapPlot) xyplot; + Rectangle2D graphArea = plot.getGraphArea(); + double[] xy1 = mapPlot.screenToProj(mouseDownPoint.x - graphArea.getX(), mouseDownPoint.y - graphArea.getY(), graphArea); + double[] xy2 = mapPlot.screenToProj(mouseLastPos.x - graphArea.getX(), mouseLastPos.y - graphArea.getY(), graphArea); Extent extent = new Extent(); extent.minX = Math.min(xy1[0], xy2[0]); extent.maxX = Math.max(xy1[0], xy2[0]); extent.minY = Math.min(xy1[1], xy2[1]); extent.maxY = Math.max(xy1[1], xy2[1]); - this.selectedPoints = plot.getDataset().selectPoints(extent); - this.firePointSelectedEvent(); + mapPlot.setDrawExtent(extent); + //this.paintGraphics(); + this.repaintNew(); + } else { + Rectangle2D graphArea = xyplot.getGraphArea(); + double[] xy1 = xyplot.screenToProj(mouseDownPoint.x - graphArea.getX(), mouseDownPoint.y - graphArea.getY(), graphArea); + double[] xy2 = xyplot.screenToProj(mouseLastPos.x - graphArea.getX(), mouseLastPos.y - graphArea.getY(), graphArea); + Extent extent = new Extent(); + extent.minX = Math.min(xy1[0], xy2[0]); + extent.maxX = Math.max(xy1[0], xy2[0]); + extent.minY = Math.min(xy1[1], xy2[1]); + extent.maxY = Math.max(xy1[1], xy2[1]); + if (xyplot.getXAxis().isInverse()) { + Extent drawExtent = xyplot.getDrawExtent(); + double minx, maxx; + minx = drawExtent.getWidth() - (extent.maxX - drawExtent.minX) + drawExtent.minX; + maxx = drawExtent.getWidth() - (extent.minX - drawExtent.minX) + drawExtent.minX; + extent.minX = minx; + extent.maxX = maxx; + } + if (xyplot.getYAxis().isInverse()) { + Extent drawExtent = xyplot.getDrawExtent(); + double miny, maxy; + miny = drawExtent.getHeight() - (extent.maxY - drawExtent.minY) + drawExtent.minY; + maxy = drawExtent.getHeight() - (extent.minY - drawExtent.minY) + drawExtent.minY; + extent.minY = miny; + extent.maxY = maxy; + } + xyplot.setDrawExtent(extent); //this.paintGraphics(); this.repaintNew(); } } } break; + case ZOOM_OUT: + if (e.getButton() == MouseEvent.BUTTON1) { + if (plot instanceof AbstractPlot2D) { + AbstractPlot2D xyplot = (AbstractPlot2D) plot; + double zoom = 1.5; + Extent extent = xyplot.getDrawExtent(); + double owidth = extent.getWidth(); + double oheight = extent.getHeight(); + double width = owidth * zoom; + double height = oheight * zoom; + double xshift = (owidth - width) * 0.5; + double yshift = (oheight - height) * 0.5; + extent.minX += xshift; + extent.maxX -= xshift; + extent.minY += yshift; + extent.maxY -= yshift; + xyplot.setDrawExtent(extent); + //this.paintGraphics(); + this.repaintNew(); + } + } + break; + case SELECT: + if (Math.abs(mouseLastPos.x - mouseDownPoint.x) > 5) { + if (plot instanceof AbstractPlot2D) { + AbstractPlot2D xyplot = (AbstractPlot2D) plot; + if (xyplot instanceof XY1DPlot) { + XY1DPlot plt = (XY1DPlot) xyplot; + Rectangle2D graphArea = plt.getGraphArea(); + if (graphArea.contains(mouseDownPoint.x, mouseDownPoint.y) || graphArea.contains(mouseLastPos.x, mouseLastPos.y)) { + double[] xy1 = plt.screenToProj(mouseDownPoint.x - graphArea.getX(), mouseDownPoint.y - graphArea.getY(), graphArea); + double[] xy2 = plt.screenToProj(mouseLastPos.x - graphArea.getX(), mouseLastPos.y - graphArea.getY(), graphArea); + Extent extent = new Extent(); + extent.minX = Math.min(xy1[0], xy2[0]); + extent.maxX = Math.max(xy1[0], xy2[0]); + extent.minY = Math.min(xy1[1], xy2[1]); + extent.maxY = Math.max(xy1[1], xy2[1]); + this.selectedPoints = plt.getDataset().selectPoints(extent); + this.firePointSelectedEvent(); + //this.paintGraphics(); + this.repaintNew(); + } + } + } + } + break; case PAN: if (e.getButton() == MouseEvent.BUTTON1) { - double[] xy1 = xyplot.screenToProj(mouseDownPoint.x, mouseDownPoint.y); - double[] xy2 = xyplot.screenToProj(e.getX(), e.getY()); - Extent extent = xyplot.getDrawExtent(); - extent = extent.shift(xy1[0] - xy2[0], xy1[1] - xy2[1]); - xyplot.setDrawExtent(extent); - /*int deltaX = e.getX() - mouseDownPoint.x; - int deltaY = e.getY() - mouseDownPoint.y; - double minX = -deltaX; - double minY = -deltaY; - double maxX = xyplot.getGraphArea().getWidth() - deltaX; - double maxY = xyplot.getGraphArea().getHeight() - deltaY; - xyplot.zoomToExtentScreen(minX, maxX, minY, maxY);*/ - //this.paintGraphics(); - this.repaintNew(); + if (plot instanceof AbstractPlot2D) { + AbstractPlot2D xyplot = (AbstractPlot2D) plot; + double[] xy1 = xyplot.screenToProj(mouseDownPoint.x, mouseDownPoint.y); + double[] xy2 = xyplot.screenToProj(e.getX(), e.getY()); + Extent extent = xyplot.getDrawExtent(); + extent = extent.shift(xy1[0] - xy2[0], xy1[1] - xy2[1]); + xyplot.setDrawExtent(extent); + /*int deltaX = e.getX() - mouseDownPoint.x; + int deltaY = e.getY() - mouseDownPoint.y; + double minX = -deltaX; + double minY = -deltaY; + double maxX = xyplot.getGraphArea().getWidth() - deltaX; + double maxY = xyplot.getGraphArea().getHeight() - deltaY; + xyplot.zoomToExtentScreen(minX, maxX, minY, maxY);*/ + //this.paintGraphics(); + this.repaintNew(); + } } break; } diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/GLPlot.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/GLPlot.java index f563d605..ec191552 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/GLPlot.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/jogl/GLPlot.java @@ -80,6 +80,7 @@ public class GLPlot extends Plot { protected Extent3D drawExtent; protected Extent3D axesExtent; protected boolean fixExtent; + protected TextRenderer textRenderer; protected ChartText title; protected GridLine gridLine; protected java.util.List legends; @@ -1224,6 +1225,8 @@ public class GLPlot extends Plot { final GL2 gl = drawable.getGL().getGL2(); gl.glLoadIdentity(); + this.updateTextRender(this.xAxis.getTickLabelFont()); + //Set light position - follow glLoadIdentity this.lighting.setPosition(gl); @@ -1299,6 +1302,9 @@ public class GLPlot extends Plot { //Draw title this.drawTitle(); + this.textRenderer.dispose(); + this.textRenderer = null; + gl.glFlush(); /*//Do screenshot @@ -1904,6 +1910,9 @@ public class GLPlot extends Plot { } strWidth = 0.0f; strHeight = 0.0f; + if (this.xAxis.isDrawTickLabel()) { + this.updateTextRender(tlabs.get(0).getFont()); + } for (int i = 0; i < this.xAxis.getTickValues().length; i += skip) { v = (float) this.xAxis.getTickValues()[i]; if (v < axesExtent.minX || v > axesExtent.maxX) { @@ -1924,26 +1933,31 @@ public class GLPlot extends Plot { gl.glEnd(); //Draw tick label - rect = drawString(gl, tlabs.get(i), v, y1, zMin, xAlign, yAlign); - if (strWidth < rect.getWidth()) { - strWidth = (float) rect.getWidth(); - } - if (strHeight < rect.getHeight()) { - strHeight = (float) rect.getHeight(); + if (this.xAxis.isDrawTickLabel()) { + rect = drawString(gl, tlabs.get(i), v, y1, zMin, xAlign, yAlign); + if (strWidth < rect.getWidth()) { + strWidth = (float) rect.getWidth(); + } + if (strHeight < rect.getHeight()) { + strHeight = (float) rect.getHeight(); + } } } //Draw x axis label - ChartText label = this.xAxis.getLabel(); - if (label != null) { - strWidth += this.tickSpace; - float angle = this.toScreenAngle(xMin, y, zMin, xMax, y, zMin); - angle = y < 0 ? 270 - angle : 90 - angle; - float yShift = Math.min(-strWidth, -strWidth); - if (this.angleX <= -120) { - yShift = -yShift; + if (this.xAxis.isDrawLabel()) { + ChartText label = this.xAxis.getLabel(); + if (label != null) { + this.updateTextRender(label.getFont()); + strWidth += this.tickSpace; + float angle = this.toScreenAngle(xMin, y, zMin, xMax, y, zMin); + angle = y < 0 ? 270 - angle : 90 - angle; + float yShift = Math.min(-strWidth, -strWidth); + if (this.angleX <= -120) { + yShift = -yShift; + } + drawString(gl, label, 0.0f, y1, zMin, XAlign.CENTER, yAlign, angle, 0, yShift); } - drawString(gl, label, 0.0f, y1, zMin, XAlign.CENTER, yAlign, angle, 0, yShift); } //////////////////////////////////////////// @@ -1980,6 +1994,9 @@ public class GLPlot extends Plot { } strWidth = 0.0f; strHeight = 0.0f; + if (this.yAxis.isDrawTickLabel()) { + this.updateTextRender(tlabs.get(0).getFont()); + } for (int i = 0; i < this.yAxis.getTickValues().length; i += skip) { v = (float) this.yAxis.getTickValues()[i]; if (v < axesExtent.minY || v > axesExtent.maxY) { @@ -2000,26 +2017,31 @@ public class GLPlot extends Plot { gl.glEnd(); //Draw tick label - rect = drawString(gl, tlabs.get(i), x1, v, zMin, xAlign, yAlign); - if (strWidth < rect.getWidth()) { - strWidth = (float) rect.getWidth(); - } - if (strHeight < rect.getHeight()) { - strHeight = (float) rect.getHeight(); + if (this.yAxis.isDrawTickLabel()) { + rect = drawString(gl, tlabs.get(i), x1, v, zMin, xAlign, yAlign); + if (strWidth < rect.getWidth()) { + strWidth = (float) rect.getWidth(); + } + if (strHeight < rect.getHeight()) { + strHeight = (float) rect.getHeight(); + } } } //Draw y axis label - label = this.yAxis.getLabel(); - if (label != null) { - strWidth += this.tickSpace; - float angle = this.toScreenAngle(x, yMin, zMin, x, yMax, xMin); - angle = x > 0 ? 270 - angle : 90 - angle; - float yShift = Math.min(-strWidth, -strWidth); - if (this.angleX <= -120) { - yShift = -yShift; + if (this.yAxis.isDrawLabel()) { + ChartText label = this.yAxis.getLabel(); + if (label != null) { + this.updateTextRender(label.getFont()); + strWidth += this.tickSpace; + float angle = this.toScreenAngle(x, yMin, zMin, x, yMax, xMin); + angle = x > 0 ? 270 - angle : 90 - angle; + float yShift = Math.min(-strWidth, -strWidth); + if (this.angleX <= -120) { + yShift = -yShift; + } + drawString(gl, label, x1, 0.0f, zMin, XAlign.CENTER, yAlign, angle, 0, yShift); } - drawString(gl, label, x1, 0.0f, zMin, XAlign.CENTER, yAlign, angle, 0, yShift); } } @@ -2087,6 +2109,9 @@ public class GLPlot extends Plot { xAlign = XAlign.RIGHT; yAlign = YAlign.CENTER; strWidth = 0.0f; + if (this.zAxis.isDrawTickLabel()) { + this.updateTextRender(tlabs.get(0).getFont()); + } for (int i = 0; i < this.zAxis.getTickValues().length; i += skip) { v = (float) this.zAxis.getTickValues()[i]; if (v < axesExtent.minZ || v > axesExtent.maxZ) { @@ -2107,17 +2132,22 @@ public class GLPlot extends Plot { gl.glEnd(); //Draw tick label - rect = drawString(gl, tlabs.get(i), x1, y1, v, xAlign, yAlign, -this.tickSpace, 0); - if (strWidth < rect.getWidth()) { - strWidth = (float) rect.getWidth(); + if (this.zAxis.isDrawTickLabel()) { + rect = drawString(gl, tlabs.get(i), x1, y1, v, xAlign, yAlign, -this.tickSpace, 0); + if (strWidth < rect.getWidth()) { + strWidth = (float) rect.getWidth(); + } } } //Draw z axis label - ChartText label = this.zAxis.getLabel(); - if (label != null) { - float yShift = strWidth + this.tickSpace * 3; - drawString(gl, label, x1, y1, 0.0f, XAlign.CENTER, YAlign.BOTTOM, 90.f, 0, yShift); + if (this.zAxis.isDrawLabel()) { + ChartText label = this.zAxis.getLabel(); + if (label != null) { + this.updateTextRender(label.getFont()); + float yShift = strWidth + this.tickSpace * 3; + drawString(gl, label, x1, y1, 0.0f, XAlign.CENTER, YAlign.BOTTOM, 90.f, 0, yShift); + } } } @@ -2234,6 +2264,26 @@ public class GLPlot extends Plot { } } + void updateTextRender(Font font) { + boolean newTR = false; + if (this.textRenderer == null) { + newTR = true; + } else { + if (!this.textRenderer.getFont().equals(font)) { + //this.textRenderer.dispose(); + newTR = true; + } + } + if (newTR) { + if (this.dpiScale == 1) { + textRenderer = new TextRenderer(font, true, true); + } else { + textRenderer = new TextRenderer(new Font(font.getFontName(), font.getStyle(), + (int) (font.getSize() * this.dpiScale)), true, true); + } + } + } + Rectangle2D drawString(GL2 gl, ChartText text, float vx, float vy, float vz, XAlign xAlign, YAlign yAlign) { return drawString(gl, text, vx, vy, vz, xAlign, yAlign, 0, 0); } @@ -2257,13 +2307,6 @@ public class GLPlot extends Plot { float y = coord.y; //Rendering text string - TextRenderer textRenderer; - if (this.dpiScale == 1) { - textRenderer = new TextRenderer(font, true, true); - } else { - textRenderer = new TextRenderer(new Font(font.getFontName(), font.getStyle(), - (int)(font.getSize() * (1 + (this.dpiScale - 1) * 0.8))), true, true); - } textRenderer.beginRendering(this.width, this.height); textRenderer.setColor(color); textRenderer.setSmoothing(true); @@ -2292,22 +2335,22 @@ public class GLPlot extends Plot { Rectangle2D drawString(GL2 gl, ChartText text, float vx, float vy, float vz, XAlign xAlign, YAlign yAlign, float angle) { - return drawString(gl, text.getText(), text.getFont(), text.getColor(), vx, vy, vz, xAlign, yAlign, angle, + return drawString(gl, text.getText(), text.getColor(), vx, vy, vz, xAlign, yAlign, angle, (float)text.getXShift(), (float)text.getYShift()); } Rectangle2D drawString(GL2 gl, ChartText text, float vx, float vy, float vz, XAlign xAlign, YAlign yAlign, float angle, float xShift, float yShift) { - return drawString(gl, text.getText(), text.getFont(), text.getColor(), vx, vy, + return drawString(gl, text.getText(), text.getColor(), vx, vy, vz, xAlign, yAlign, angle, (float)text.getXShift() + xShift, (float)text.getYShift() + yShift); } - Rectangle2D drawString(GL2 gl, String str, Font font, Color color, float vx, float vy, float vz, + Rectangle2D drawString(GL2 gl, String str, Color color, float vx, float vy, float vz, XAlign xAlign, YAlign yAlign, float angle) { - return drawString(gl, str, font, color, vx, vy, vz, xAlign, yAlign, angle, 0, 0); + return drawString(gl, str, color, vx, vy, vz, xAlign, yAlign, angle, 0, 0); } - Rectangle2D drawString(GL2 gl, String str, Font font, Color color, float vx, float vy, float vz, + Rectangle2D drawString(GL2 gl, String str, Color color, float vx, float vy, float vz, XAlign xAlign, YAlign yAlign, float angle, float xShift, float yShift) { //Get screen coordinates Vector2f coord = this.toScreen(vx, vy, vz); @@ -2315,13 +2358,6 @@ public class GLPlot extends Plot { float y = coord.y; //Rendering text string - TextRenderer textRenderer; - if (this.dpiScale == 1) { - textRenderer = new TextRenderer(font, true, true); - } else { - textRenderer = new TextRenderer(new Font(font.getFontName(), font.getStyle(), - (int)(font.getSize() * (1 + (this.dpiScale - 1) * 0.8))), true, true); - } textRenderer.beginRendering(this.width, this.height); textRenderer.setColor(color); textRenderer.setSmoothing(true); @@ -2354,30 +2390,22 @@ public class GLPlot extends Plot { y += yShift; textRenderer.draw(str, (int) x, (int) y); textRenderer.endRendering(); - textRenderer.dispose(); gl.glPopMatrix(); return rect; } Rectangle2D drawString3D(GL2 gl, ChartText3D text3D, float vx, float vy, float vz) { - return drawString3D(gl, text3D.getText(), text3D.getFont(), text3D.getColor(), vx, vy, vz); + return drawString3D(gl, text3D.getText(), text3D.getColor(), vx, vy, vz); } - Rectangle2D drawString3D(GL2 gl, String str, Font font, Color color, float vx, float vy, float vz) { + Rectangle2D drawString3D(GL2 gl, String str, Color color, float vx, float vy, float vz) { //Get screen coordinates Vector2f coord = this.toScreen(vx, vy, vz); float x = coord.x; float y = coord.y; //Rendering text string - TextRenderer textRenderer; - if (this.dpiScale == 1) { - textRenderer = new TextRenderer(font, true, true); - } else { - textRenderer = new TextRenderer(new Font(font.getFontName(), font.getStyle(), - (int)(font.getSize() * (1 + (this.dpiScale - 1) * 0.8))), true, true); - } textRenderer.beginRendering(this.width, this.height, false); //textRenderer.begin3DRendering(); textRenderer.setColor(color); @@ -2395,7 +2423,7 @@ public class GLPlot extends Plot { if (title != null) { //Rendering text string Font font = title.getFont(); - TextRenderer textRenderer; + this.updateTextRender(font); if (this.dpiScale == 1) { textRenderer = new TextRenderer(font, true, true); } else { @@ -2575,6 +2603,7 @@ public class GLPlot extends Plot { protected void drawText(GL2 gl, ChartText3D text) { Vector3f xyz = this.transform.transform((float) text.getX(), (float) text.getY(), (float) text.getZ()); + this.updateTextRender(text.getFont()); if (text.isDraw3D()) { this.drawString3D(gl, text, xyz.x, xyz.y, xyz.z); } else { @@ -4238,6 +4267,8 @@ public class GLPlot extends Plot { GL2 gl = drawable.getGL().getGL2(); this.gl = gl; this.glu = GLU.createGLU(gl); + Font font = this.xAxis.getTickLabelFont(); + updateTextRender(font); //Background //gl.glClearColor(1f, 1f, 1f, 1.0f); gl.glEnable(GL2.GL_POINT_SMOOTH); diff --git a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/render/GraphicRender.java b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/render/GraphicRender.java index 05fd0fad..c023d906 100644 --- a/meteoinfo-chart/src/main/java/org/meteoinfo/chart/render/GraphicRender.java +++ b/meteoinfo-chart/src/main/java/org/meteoinfo/chart/render/GraphicRender.java @@ -7,5 +7,5 @@ public interface GraphicRender { /** * Draw graphic */ - public abstract void draw(); + void draw(); } diff --git a/meteoinfo-chart/src/test/java/VolumeTest.java b/meteoinfo-chart/src/test/java/VolumeTest.java index 8142500a..94219f62 100644 --- a/meteoinfo-chart/src/test/java/VolumeTest.java +++ b/meteoinfo-chart/src/test/java/VolumeTest.java @@ -1,4 +1,7 @@ -import org.meteoinfo.chart.jogl.GLChartPanel; +import org.meteoinfo.chart.GLChart; +import org.meteoinfo.chart.GLChartPanel; +import org.meteoinfo.chart.MouseMode; +import org.meteoinfo.chart.jogl.GLPlot; import org.meteoinfo.chart.jogl.Plot3DGL; import org.meteoinfo.chart.graphic.VolumeGraphic; import org.meteoinfo.chart.render.jogl.RayCastingType; @@ -107,33 +110,30 @@ public class VolumeTest { VolumeGraphic graphics = test.createGraphics(); graphics.setRayCastingType(RayCastingType.SPECULAR); JFrame frame = new JFrame("Volume Test"); - Plot3DGL plot = new Plot3DGL(); + GLPlot plot = new GLPlot(); plot.setOrthographic(false); plot.setClipPlane(false); //plot.setBackground(Color.black); //plot.setForeground(Color.blue); - plot.setDrawBoundingBox(false); - plot.setDrawBase(false); - plot.setBoxed(false); - plot.getGridLine().setDrawXLine(false); - plot.getGridLine().setDrawYLine(false); - plot.getGridLine().setDrawZLine(false); - GLChartPanel canvas = new GLChartPanel(plot); + plot.setDrawBoundingBox(true); + plot.setDrawBase(true); + plot.setBoxed(true); + plot.setDisplayXY(true); + //plot.getXAxis().setDrawTickLabel(false); + //plot.getYAxis().setDrawTickLabel(false); + plot.setDisplayZ(true); + plot.getZAxis().setLabel("Z axis"); + //plot.getGridLine().setDrawXLine(false); + //plot.getGridLine().setDrawYLine(false); + //plot.getGridLine().setDrawZLine(false); plot.addGraphic(graphics); + GLChartPanel canvas = new GLChartPanel(new GLChart()); + canvas.getChart().addPlot(plot); + canvas.setMouseMode(MouseMode.ROTATE); frame.getContentPane().add(canvas); frame.pack(); frame.setSize(600, 400); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); - /*try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - int width = canvas.getWidth(); - int height = canvas.getHeight(); - canvas.setSize(width, height + 1); - canvas.setSize(width, height);*/ - //frame.setSize(600, 401); } } diff --git a/meteoinfo-data/src/main/java/org/meteoinfo/data/GridData.java b/meteoinfo-data/src/main/java/org/meteoinfo/data/GridData.java index 2a1098f2..d395a219 100644 --- a/meteoinfo-data/src/main/java/org/meteoinfo/data/GridData.java +++ b/meteoinfo-data/src/main/java/org/meteoinfo/data/GridData.java @@ -116,7 +116,7 @@ public class GridData { this.missingValue = missingValue; this.projInfo = projInfo; - if (this.getYDelta() < 0) { + /*if (this.getYDelta() < 0) { this.yArray = IntStream.range(0, this.yArray.length) .mapToDouble(i -> this.yArray[this.yArray.length - 1 - i]) .toArray(); @@ -128,7 +128,7 @@ public class GridData { .mapToDouble(i -> this.xArray[this.xArray.length - 1 - i]) .toArray(); this.xReverse(); - } + }*/ } /** diff --git a/meteoinfo-lab/milconfig.xml b/meteoinfo-lab/milconfig.xml index 5564a46f..8667317e 100644 --- a/meteoinfo-lab/milconfig.xml +++ b/meteoinfo-lab/milconfig.xml @@ -1,18 +1,18 @@ - - - - - - - - - - + - + + + + + + + + + + @@ -21,14 +21,14 @@ - + - + @@ -36,5 +36,5 @@
- + diff --git a/meteoinfo-lab/pylib/mipylib/plotlib/miplot$py.class b/meteoinfo-lab/pylib/mipylib/plotlib/miplot$py.class index 0359baf9..3a08a90b 100644 Binary files a/meteoinfo-lab/pylib/mipylib/plotlib/miplot$py.class and b/meteoinfo-lab/pylib/mipylib/plotlib/miplot$py.class differ diff --git a/meteoinfo-lab/pylib/mipylib/plotlib/miplot.py b/meteoinfo-lab/pylib/mipylib/plotlib/miplot.py index 87925a91..64228ad1 100644 --- a/meteoinfo-lab/pylib/mipylib/plotlib/miplot.py +++ b/meteoinfo-lab/pylib/mipylib/plotlib/miplot.py @@ -47,7 +47,7 @@ __all__ = [ 'webmap','gca','gcf','gc_collect','geoshow','get_figure','gifaddframe','gifanimation','giffinish', 'grid','gridshow','gridshowm','hist','imshow','imshowm','isosurface','legend','left_title','lighting','loglog','makecolors', 'makelegend','makesymbolspec','masklayer','material','mesh','particles','pcolor','pcolorm','pie','plot','plot3','plotm','quiver','quiver3', - 'quiverkey','quiverm','readlegend','right_title','savefig','savefig_jpeg','scatter','scatter3','scatterm', + 'quiverkey','quiverm','readlegend','right_title','refresh','savefig','savefig_jpeg','scatter','scatter3','scatterm', 'semilogx','semilogy','show','slice3','stationmodel','stem','stem3','step','streamplot','streamplot3', 'streamplotm','streamslice','subplot','subplots','suptitle','supxlabel','supylabel', 'surf','taylor_diagram','text','text3','title','twinx','twiny','violinplot','volumeplot','weatherspec','xaxis', @@ -1267,11 +1267,12 @@ def zticks(*args, **kwargs): if len(args) > 0: locs = args[0] - if isinstance(locs, (NDArray, DimArray)): - locs = locs.aslist() - if isinstance(locs[0], datetime.datetime): - for i in range(len(locs)): - locs[i] = miutil.date2num(locs[i]) + if len(locs) > 0: + if isinstance(locs, (NDArray, DimArray)): + locs = locs.aslist() + if isinstance(locs[0], datetime.datetime): + for i in range(len(locs)): + locs[i] = miutil.date2num(locs[i]) g_axes.set_zticks(locs) args = args[1:] if len(args) > 0: @@ -2167,4 +2168,11 @@ def gc_collect(): """ clear() import gc - gc.collect() \ No newline at end of file + gc.collect() + +def refresh(): + """ + Refresh the figure + """ + migl.milapp.getFigureDock().setVisible(False) + migl.milapp.getFigureDock().setVisible(True) \ No newline at end of file diff --git a/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSectionPlot.java b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSectionPlot.java index 9c4a3de1..c24e163e 100644 --- a/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSectionPlot.java +++ b/meteoinfo-map/src/main/java/org/meteoinfo/map/forms/FrmSectionPlot.java @@ -2033,7 +2033,6 @@ public class FrmSectionPlot extends javax.swing.JFrame { } private void setXYCoords(GridData aGridData) { - boolean yReverse = aGridData.getYDelta() < 0; int i; int xNum = 0, yNum = 0; switch (_plotDimension) { @@ -2069,9 +2068,6 @@ public class FrmSectionPlot extends javax.swing.JFrame { } aGridData.setXArray(xArray); aGridData.setYArray(yArray); - if (yReverse) { - aGridData.yReverse(); - } } private void zoomToExtent(Extent aExtent) {