From 437e127ebce440fcce4dd244af806cd97a3dd4b2 Mon Sep 17 00:00:00 2001 From: Mark Peters Date: Fri, 25 Jul 2014 09:53:23 -0500 Subject: [PATCH] Omaha #3429 Replace Raytheon plugin calls to deprecated IGraphicsTarget.drawLine() Change-Id: I9de68a9a047a2d6c3744b29de292efb7cfb44bbf Former-commit-id: a222b29ff24bf81d1c8aefd54fa33f52461c9c25 --- .../uf/viz/bufrsigwx/common/SigWxCommon.java | 19 +- .../viz/monitor/scan/resource/ScanDrawer.java | 138 ++++++---- .../uf/viz/ncwf/rsc/NcwfMovementResource.java | 25 +- .../uf/viz/profiler/ProfilerResource.java | 238 +++++++++------- .../graphics/DispatchGraphicsTarget.java | 9 +- .../viz/awipstools/common/DistanceTool.java | 46 +++- .../common/stormtrack/StormTrackDisplay.java | 27 +- .../awipstools/ui/layer/HomeToolLayer.java | 14 +- .../viz/core/graphing/LineStroke.java | 25 +- .../raytheon/viz/core/graphing/WGraphics.java | 73 +---- .../viz/core/graphing/axis/AxisFactory.java | 213 +-------------- .../viz/core/graphing/axis/DateAxis.java | 256 ------------------ .../viz/core/graphing/axis/NumberAxis.java | 52 +++- .../viz/gfe/edittool/FreeformRenderable.java | 11 +- .../gfe/edittool/sample/SamplePainter.java | 21 +- .../gfe/rsc/colorbar/DiscreteColorbar.java | 10 +- .../viz/mpe/ui/rsc/HydroPointResource.java | 25 +- .../viz/mpe/ui/rsc/MPEPolygonResource.java | 20 +- .../mpe/ui/rsc/PointFreezePlotResource.java | 42 +-- .../mpe/ui/rsc/PointPrecipPlotResource.java | 40 +-- .../viz/mpe/ui/rsc/PointTempPlotResource.java | 45 ++- .../viz/radar/ui/xy/CellTrendGraph.java | 104 +++++-- .../viz/radar/ui/xy/RadarGSMResource.java | 112 ++++---- .../viz/radar/ui/xy/RadarXYResource.java | 30 +- .../viz/warngen/gui/WarngenLayer.java | 30 +- 25 files changed, 673 insertions(+), 952 deletions(-) delete mode 100644 cave/com.raytheon.viz.core.graphing/src/com/raytheon/viz/core/graphing/axis/DateAxis.java diff --git a/cave/com.raytheon.uf.viz.bufrsigwx/src/com/raytheon/uf/viz/bufrsigwx/common/SigWxCommon.java b/cave/com.raytheon.uf.viz.bufrsigwx/src/com/raytheon/uf/viz/bufrsigwx/common/SigWxCommon.java index 76bf5b036f..ea68491cfa 100644 --- a/cave/com.raytheon.uf.viz.bufrsigwx/src/com/raytheon/uf/viz/bufrsigwx/common/SigWxCommon.java +++ b/cave/com.raytheon.uf.viz.bufrsigwx/src/com/raytheon/uf/viz/bufrsigwx/common/SigWxCommon.java @@ -23,6 +23,7 @@ import java.util.Formatter; import org.eclipse.swt.graphics.RGB; +import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.map.MapDescriptor; @@ -38,7 +39,7 @@ import com.vividsolutions.jts.geom.Coordinate; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 09/25/2009 jsanchez Initial creation. - * + * 07/24/2014 3429 mapeters Updated deprecated drawLine() calls. * * * @@ -79,13 +80,15 @@ public class SigWxCommon { Double length, Double dir, RGB color) throws VizException { double[] pointPixel = target.getPointOnCircle(center[0], center[1], center[2], length, dir + 210); - target.drawLine(pointPixel[0], pointPixel[1], pointPixel[2], - center[0], - center[1], center[2], color, 1.5f); - pointPixel = target.getPointOnCircle(center[0], center[1], center[2], + DrawableLine line = new DrawableLine(); + line.setCoordinates(pointPixel[0], pointPixel[1], pointPixel[2]); + line.addPoint(center[0], center[1], center[2]); + double[] pointPixel2 = target.getPointOnCircle(center[0], center[1], + center[2], length, dir + 150); - target.drawLine(pointPixel[0], pointPixel[1], pointPixel[2], - center[0], - center[1], center[2], color, 1.5f); + line.addPoint(pointPixel2[0], pointPixel2[1], pointPixel2[2]); + line.basics.color = color; + line.width = 1.5f; + target.drawLine(line); } } diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/resource/ScanDrawer.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/resource/ScanDrawer.java index a789cfb9b2..74ddcc5874 100644 --- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/resource/ScanDrawer.java +++ b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/resource/ScanDrawer.java @@ -66,6 +66,7 @@ import com.vividsolutions.jts.geom.Point; * Apr 22, 2013 1926 njensen Faster rendering * May 09, 2014 3145 mpduff Add getter for font so it can be disposed, javadoc fix * Jul 22, 2014 3422 mapeters Updated deprecated drawArc() call. + * Jul 23, 2014 3429 mapeters Updated deprecated drawLine() call. * * * @author dhladky @@ -74,9 +75,7 @@ import com.vividsolutions.jts.geom.Point; public class ScanDrawer { - private static final int HEX_ANGLE = 60; - - private static final double SIN_HEX_ANGLE = Math.sin(HEX_ANGLE); + private static final double SIN_HEX_ANGLE = Math.sin(60); public static final RGB red = new RGB(255, 0, 0); @@ -394,18 +393,37 @@ public class ScanDrawer { circle.lineWidth = outlineWidth * 4; aTarget.drawCircle(circle); } + + DrawableLine[] lines = new DrawableLine[4]; // top spike - aTarget.drawLine(center[0], topY, 0.0, center[0], topY - size, - 0.0, getResourceColor(), outlineWidth * 4); + lines[0] = new DrawableLine(); + lines[0].setCoordinates(center[0], topY); + lines[0].addPoint(center[0], topY - size); + lines[0].basics.color = getResourceColor(); + lines[0].width = outlineWidth * 4; + // bottom spike - aTarget.drawLine(center[0], bottomY, 0.0, center[0], bottomY - + size, 0.0, getResourceColor(), outlineWidth * 4); + lines[1] = new DrawableLine(); + lines[1].setCoordinates(center[0], bottomY); + lines[1].addPoint(center[0], bottomY + size); + lines[1].basics.color = getResourceColor(); + lines[1].width = outlineWidth * 4; + // right spike - aTarget.drawLine(wRightX, center[1], 0.0, wRightX + size, - center[1], 0.0, getResourceColor(), outlineWidth * 4); + lines[2] = new DrawableLine(); + lines[2].setCoordinates(wRightX, center[1]); + lines[2].addPoint(wRightX + size, center[1]); + lines[2].basics.color = getResourceColor(); + lines[2].width = outlineWidth * 4; + // left spike - aTarget.drawLine(wLeftX, center[1], 0.0, wLeftX - size, - center[1], 0.0, getResourceColor(), outlineWidth * 4); + lines[3] = new DrawableLine(); + lines[3].setCoordinates(wLeftX, center[1]); + lines[3].addPoint(wLeftX - size, center[1]); + lines[3].basics.color = getResourceColor(); + lines[3].width = outlineWidth * 4; + + aTarget.drawLine(lines); } double zoomLevel = this.descriptor.getRenderableDisplay().getZoom(); @@ -472,9 +490,14 @@ public class ScanDrawer { dir, totalLength / 1.25); // draw it - if (sdc.getArrowMode()) { - aTarget.drawLine(center[0], center[1], 0, end[0], end[1], 0, - getColor(), outlineWidth); + DrawableLine[] lines = null; + DrawableLine line = null; + int size; + if (sdc.getArrowMode()) { + line = new DrawableLine(); + line.setCoordinates(center[0], center[1]); + line.addPoint(end[0], end[1]); + line.basics.color = getColor(); } else { // Find the intersection to use instead of the center point. Point intersectPoint = null; @@ -509,16 +532,28 @@ public class ScanDrawer { totalLength / 1.25); labelEnd = getPixelRelativeCoordinate(intersectPoint, totalLength + 1, dir); + + size = ears.size(); + lines = new DrawableLine[size + 1]; + lines[size] = new DrawableLine(); + lines[size].setCoordinates(end[0], end[1]); + lines[size].addPoint(intersect[0], intersect[1]); + lines[size].addPoint(center[0], center[1]); + lines[size].basics.color = getColor(); - aTarget.drawLine(intersect[0], intersect[1], 0, end[0], end[1], - 0, getColor(), outlineWidth); - aTarget.drawLine(center[0], center[1], 0, intersect[0], - intersect[1], 0, getColor(), outlineWidth); } - for (double[] ear : ears) { - aTarget.drawLine(end[0], end[1], 0, ear[0], ear[1], 0, - getColor(), outlineWidth); + size = ears.size(); + if(lines == null) { + lines = new DrawableLine[size + 1]; + lines[size] = line; } + for (int i = 0; i < size; i++) { + lines[i] = new DrawableLine(); + lines[i].setCoordinates(end[0], end[1]); + lines[i].addPoint(ears.get(i)[0], ears.get(i)[1]); + lines[i].basics.color = getColor(); + } + aTarget.drawLine(lines); drawArrowLabel(labelEnd[0], labelEnd[1], new Integer((int) speed).toString()); @@ -909,13 +944,15 @@ public class ScanDrawer { */ public void drawDMDTrack(DMDTableDataRow dtdr) throws VizException { + List lines = new ArrayList(); + if ((dtdr.getFcstLat() != null) && (dtdr.getFcstLon() != null)) { double[] futurePoint = null; double[] pastPoint = null; int count = Math.min(dtdr.getFcstLon().size(), dtdr.getFcstLat() .size()); - + for (int i = 0; i < count; i++) { futurePoint = descriptor.worldToPixel(new double[] { dtdr.getFcstLon().get(i), dtdr.getFcstLat().get(i) }); @@ -924,9 +961,12 @@ public class ScanDrawer { pastPoint = center; } - aTarget.drawLine(pastPoint[0], pastPoint[1], 0.0, - futurePoint[0], futurePoint[1], 0.0, - getResourceColor(), outlineWidth); + DrawableLine line = new DrawableLine(); + line.setCoordinates(pastPoint[0], pastPoint[1]); + line.addPoint(futurePoint[0], futurePoint[1]); + line.basics.color = getResourceColor(); + lines.add(line); + drawPlus(futurePoint, getResourceColor()); pastPoint = futurePoint; } @@ -938,7 +978,7 @@ public class ScanDrawer { double[] pastPoint = null; int count = Math.min(dtdr.getPastLon().size(), dtdr.getPastLat() .size()); - + for (int i = 0; i < count; i++) { try { futurePoint = descriptor @@ -949,10 +989,13 @@ public class ScanDrawer { if (pastPoint == null) { pastPoint = center; } + + DrawableLine line = new DrawableLine(); + line.setCoordinates(pastPoint[0], pastPoint[1]); + line.addPoint(futurePoint[0], futurePoint[1]); + line.basics.color = getResourceColor(); + lines.add(line); - aTarget.drawLine(pastPoint[0], pastPoint[1], 0.0, - futurePoint[0], futurePoint[1], 0.0, - getResourceColor(), outlineWidth); drawFilledCircle(futurePoint, getResourceColor()); pastPoint = futurePoint; } catch (Exception e) { @@ -960,6 +1003,7 @@ public class ScanDrawer { } } } + aTarget.drawLine(lines.toArray(new DrawableLine[0])); } public void drawCellTrack(CellTableDataRow ctdr) throws VizException { @@ -1056,35 +1100,19 @@ public class ScanDrawer { */ public void drawPlus(double[] point, RGB color) throws VizException { // bottom to top - aTarget.drawLine(point[0], (point[1] - 4.0 / screenToWorldRatio), 0.0, - point[0], (point[1] + 4.0 / screenToWorldRatio), 0.0, color, - outlineWidth); + DrawableLine[] lines = new DrawableLine[2]; + lines[0] = new DrawableLine(); + lines[0].setCoordinates(point[0], (point[1] - 4.0 / screenToWorldRatio)); + lines[0].addPoint(point[0], (point[1] + 4.0 / screenToWorldRatio)); + lines[0].basics.color = color; // left to right - aTarget.drawLine((point[0] - 4.0 / screenToWorldRatio), point[1], 0.0, - (point[0] + 4.0 / screenToWorldRatio), point[1], 0.0, color, - outlineWidth); + lines[1] = new DrawableLine(); + lines[1].setCoordinates((point[0] - 4.0 / screenToWorldRatio), point[1]); + lines[1].addPoint((point[0] + 4.0 / screenToWorldRatio), point[1]); + lines[1].basics.color = color; - } + aTarget.drawLine(lines); - /** - * draws the X sign - * - * @param point - * @throws VizException - */ - public void drawX(double[] point) throws VizException { - // uppe left to lower right - aTarget.drawLine((point[0] - 4.0 / screenToWorldRatio), - (point[1] + 4.0 / screenToWorldRatio), 0.0, - (point[0] + 4.0 / screenToWorldRatio), - (point[1] - 4.0 / screenToWorldRatio), 0.0, getResourceColor(), - outlineWidth); - // lower left to upper right - aTarget.drawLine((point[0] - 4.0 / screenToWorldRatio), - (point[1] - 4.0 / screenToWorldRatio), 0.0, - (point[0] + 4.0 / screenToWorldRatio), - (point[1] + 4.0 / screenToWorldRatio), 0.0, getResourceColor(), - outlineWidth); } /** diff --git a/cave/com.raytheon.uf.viz.ncwf/src/com/raytheon/uf/viz/ncwf/rsc/NcwfMovementResource.java b/cave/com.raytheon.uf.viz.ncwf/src/com/raytheon/uf/viz/ncwf/rsc/NcwfMovementResource.java index faf75888eb..d041485994 100644 --- a/cave/com.raytheon.uf.viz.ncwf/src/com/raytheon/uf/viz/ncwf/rsc/NcwfMovementResource.java +++ b/cave/com.raytheon.uf.viz.ncwf/src/com/raytheon/uf/viz/ncwf/rsc/NcwfMovementResource.java @@ -33,6 +33,7 @@ import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintTyp import com.raytheon.uf.common.pointdata.PointDataContainer; import com.raytheon.uf.common.pointdata.PointDataView; import com.raytheon.uf.common.time.DataTime; +import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.DrawableString; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment; @@ -53,6 +54,7 @@ import com.vividsolutions.jts.geom.Coordinate; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Sep 16, 2009 bsteffen Initial creation + * Jul 24, 2014 3429 mapeters Updated deprecated drawLine() calls. * * * @@ -156,9 +158,13 @@ public class NcwfMovementResource extends // Draw the tops string target.drawStrings(topStr); // Draw the body of the arrow - target.drawLine(centerPixel[0], centerPixel[1], centerPixel[2], - or_centerPixel[0], or_centerPixel[1], or_centerPixel[2], - color, 1.5f); + DrawableLine line = new DrawableLine(); + line.setCoordinates(centerPixel[0], centerPixel[1], centerPixel[2]); + line.addPoint(or_centerPixel[0], or_centerPixel[1], or_centerPixel[2]); + line.basics.color = color; + line.width = 1.5f; + target.drawLine(line); + // Draw the wind speed string target.drawStrings(spdStr); @@ -169,12 +175,17 @@ public class NcwfMovementResource extends Double length, Double dir, RGB color) throws VizException { double[] pointPixel = target.getPointOnCircle(center[0], center[1], center[2], length, dir + 210); - target.drawLine(pointPixel[0], pointPixel[1], pointPixel[2], center[0], - center[1], center[2], color, 1.5f); + + DrawableLine line = new DrawableLine(); + line = new DrawableLine(); + line.setCoordinates(pointPixel[0], pointPixel[1], pointPixel[2]); + line.addPoint(center[0], center[1], center[2]); pointPixel = target.getPointOnCircle(center[0], center[1], center[2], length, dir + 150); - target.drawLine(pointPixel[0], pointPixel[1], pointPixel[2], center[0], - center[1], center[2], color, 1.5f); + line.addPoint(pointPixel[0], pointPixel[1], pointPixel[2]); + line.basics.color = color; + line.width = 1.5f; + target.drawLine(line); } private void updateRecords(DataTime displayedDataTime) throws VizException { diff --git a/cave/com.raytheon.uf.viz.profiler/src/com/raytheon/uf/viz/profiler/ProfilerResource.java b/cave/com.raytheon.uf.viz.profiler/src/com/raytheon/uf/viz/profiler/ProfilerResource.java index 4a0ee7a646..16a9791203 100644 --- a/cave/com.raytheon.uf.viz.profiler/src/com/raytheon/uf/viz/profiler/ProfilerResource.java +++ b/cave/com.raytheon.uf.viz.profiler/src/com/raytheon/uf/viz/profiler/ProfilerResource.java @@ -37,9 +37,12 @@ import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.DataTime; +import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.DrawableString; import com.raytheon.uf.viz.core.IGraphicsTarget; +import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment; import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle; +import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment; import com.raytheon.uf.viz.core.PixelCoverage; import com.raytheon.uf.viz.core.drawables.ColorMapLoader; import com.raytheon.uf.viz.core.drawables.IFont; @@ -75,7 +78,8 @@ import com.vividsolutions.jts.geom.Coordinate; * AWIPS2 DR Work * 08/10/2012 1035 jkorman Changed number of 'staffs' from 12 to 13 and changed time * display to match AWIPS I. - * 08/13/2012 1046 jkorman Changed to load colorMap file. + * 08/13/2012 1046 jkorman Changed to load colorMap file. + * 07/25/2014 3429 mapeters Updated deprecated drawLine() calls. * * * @author dhladky @@ -447,55 +451,67 @@ public class ProfilerResource extends public void drawXAxis(PaintProperties paintProps, Double magnification) throws VizException { // left edge of graph - target.drawLine( - ProfilerUtils.profilerRectangle.x, - (ProfilerUtils.profilerRectangle.y + ProfilerUtils.profilerRectangle.height), - 0.0, ProfilerUtils.profilerRectangle.x, - ProfilerUtils.profilerRectangle.y, 0.0, - ProfilerUtils.GRAPH_COLOR, ProfilerUtils.GRAPH_LINE_WIDTH, - IGraphicsTarget.LineStyle.SOLID); + DrawableLine[] lines = new DrawableLine[2]; + lines[0] = new DrawableLine(); + lines[0].setCoordinates(ProfilerUtils.profilerRectangle.x, + (ProfilerUtils.profilerRectangle.y + ProfilerUtils.profilerRectangle.height)); + lines[0].addPoint(ProfilerUtils.profilerRectangle.x, + ProfilerUtils.profilerRectangle.y); + lines[0].basics.color = ProfilerUtils.GRAPH_COLOR; + lines[0].width = ProfilerUtils.GRAPH_LINE_WIDTH; + DrawableString[] parameters = null; if (paintProps.getDataTime() != null) { - DrawableString parameters = new DrawableString("", - ProfilerUtils.GRAPH_COLOR); - parameters.textStyle = TextStyle.BLANKED; - parameters.font = font; - parameters.horizontalAlignment = IGraphicsTarget.HorizontalAlignment.CENTER; - parameters.verticallAlignment = IGraphicsTarget.VerticalAlignment.MIDDLE; - parameters.basics.y = ProfilerUtils.profilerRectangle.y + parameters = new DrawableString[NUM_PROFILE_STAFFS]; + + VerticalAlignment verticalAlignment = IGraphicsTarget.VerticalAlignment.MIDDLE; + double y = ProfilerUtils.profilerRectangle.y + ProfilerUtils.profilerRectangle.height + ProfilerUtils.LABEL_OFFSET; - parameters.magnification = magnification; - - double maxY = paintProps.getView().getExtent().getMaxY(); - Rectangle2D rect = target.getStringsBounds(parameters); - if (parameters.basics.y + (rect.getHeight() / 2) > maxY) { - parameters.basics.y = maxY; - parameters.verticallAlignment = IGraphicsTarget.VerticalAlignment.BOTTOM; - } Calendar c = paintProps.getDataTime().getValidTime(); for (int i = 0; i < NUM_PROFILE_STAFFS; i++) { -// String d = String.format("%1$tH:%1$tM", c); + parameters[i] = new DrawableString("", + ProfilerUtils.GRAPH_COLOR); + parameters[i].textStyle = TextStyle.BLANKED; + parameters[i].font = font; + parameters[i].horizontalAlignment = IGraphicsTarget.HorizontalAlignment.CENTER; + parameters[i].verticallAlignment = verticalAlignment; + parameters[i].basics.y = y; + parameters[i].magnification = magnification; + + if (i == 0) { + double maxY = paintProps.getView().getExtent().getMaxY(); + Rectangle2D rect = target.getStringsBounds(parameters[i]); + if (y + (rect.getHeight() / 2) > maxY) { + y = maxY; + verticalAlignment = IGraphicsTarget.VerticalAlignment.BOTTOM; + } + } + + // String d = String.format("%1$tH:%1$tM", c); String d = String.format("%1$tH", c); - parameters.setText(d, ProfilerUtils.GRAPH_COLOR); - parameters.basics.x = ProfilerUtils.profilerRectangle.x + parameters[i].setText(d, ProfilerUtils.GRAPH_COLOR); + parameters[i].basics.x = ProfilerUtils.profilerRectangle.x + (i * incX) + (incX / 2); - target.drawStrings(parameters); + c.add(Calendar.HOUR, -1); } } // draw right edge - target.drawLine( - (ProfilerUtils.profilerRectangle.x + ProfilerUtils.profilerRectangle.width), - (ProfilerUtils.profilerRectangle.y + ProfilerUtils.profilerRectangle.height), - 0.0, - (ProfilerUtils.profilerRectangle.x + ProfilerUtils.profilerRectangle.width), - ProfilerUtils.profilerRectangle.y, 0.0, - ProfilerUtils.GRAPH_COLOR, ProfilerUtils.GRAPH_LINE_WIDTH, - IGraphicsTarget.LineStyle.SOLID); + lines[1] = new DrawableLine(); + lines[1].setCoordinates((ProfilerUtils.profilerRectangle.x + ProfilerUtils.profilerRectangle.width), + (ProfilerUtils.profilerRectangle.y + ProfilerUtils.profilerRectangle.height)); + lines[1].addPoint((ProfilerUtils.profilerRectangle.x + ProfilerUtils.profilerRectangle.width), + ProfilerUtils.profilerRectangle.y); + lines[1].basics.color = ProfilerUtils.GRAPH_COLOR; + lines[1].width = ProfilerUtils.GRAPH_LINE_WIDTH; + target.drawLine(lines); + if (parameters != null) { + target.drawStrings(parameters); + } } /** @@ -504,60 +520,78 @@ public class ProfilerResource extends */ public void drawYAxis(PaintProperties paintProps, Double magnification) throws VizException { - DrawableString parameters = new DrawableString("18km", + ArrayList parameters = new ArrayList(); + DrawableString string1 = new DrawableString("18km", ProfilerUtils.GRAPH_COLOR); - parameters.textStyle = TextStyle.BLANKED; - parameters.font = font; - parameters.horizontalAlignment = IGraphicsTarget.HorizontalAlignment.RIGHT; - parameters.verticallAlignment = IGraphicsTarget.VerticalAlignment.MIDDLE; - parameters.basics.x = ProfilerUtils.profilerRectangle.x + string1.textStyle = TextStyle.BLANKED; + string1.font = font; + string1.horizontalAlignment = IGraphicsTarget.HorizontalAlignment.RIGHT; + string1.verticallAlignment = IGraphicsTarget.VerticalAlignment.MIDDLE; + string1.basics.x = ProfilerUtils.profilerRectangle.x - ProfilerUtils.LABEL_OFFSET; - parameters.basics.y = ProfilerUtils.profilerRectangle.y; + string1.basics.y = ProfilerUtils.profilerRectangle.y; double minX = paintProps.getView().getExtent().getMinX(); double maxX = paintProps.getView().getExtent().getMaxX(); // top of graph - target.drawLine(ProfilerUtils.profilerRectangle.x, - ProfilerUtils.profilerRectangle.y, 0.0, - ProfilerUtils.profilerRectangle.x - + ProfilerUtils.profilerRectangle.width, - ProfilerUtils.profilerRectangle.y, 0.0, - ProfilerUtils.GRAPH_COLOR, ProfilerUtils.GRAPH_LINE_WIDTH, - IGraphicsTarget.LineStyle.SOLID); + List lines = new ArrayList(); + DrawableLine top = new DrawableLine(); + top.setCoordinates(ProfilerUtils.profilerRectangle.x, + ProfilerUtils.profilerRectangle.y); + top.addPoint(ProfilerUtils.profilerRectangle.x + + ProfilerUtils.profilerRectangle.width, + ProfilerUtils.profilerRectangle.y); + top.basics.color = ProfilerUtils.GRAPH_COLOR; + top.width = ProfilerUtils.GRAPH_LINE_WIDTH; + lines.add(top); - Rectangle2D rect = target.getStringsBounds(parameters); + Rectangle2D rect = target.getStringsBounds(string1); - if (parameters.basics.x - rect.getWidth() < minX) { - parameters.basics.x = minX; - parameters.horizontalAlignment = IGraphicsTarget.HorizontalAlignment.LEFT; + if (string1.basics.x - rect.getWidth() < minX) { + string1.basics.x = minX; + string1.horizontalAlignment = IGraphicsTarget.HorizontalAlignment.LEFT; } - target.drawStrings(parameters); + + parameters.add(string1); + + double x = string1.basics.x; + HorizontalAlignment horizontalAlignment = string1.horizontalAlignment; // loop for heights in meters + boolean changed = false; for (int i = 0; i < ProfilerUtils.HEIGHTS; i += 2) { // draw Y labels - parameters.setText( + DrawableString string = new DrawableString( ProfilerUtils.decimalFormat.format(new Double(i)) + " km", ProfilerUtils.GRAPH_COLOR); - parameters.basics.y = calcY(i * 1000); - rect = target.getStringsBounds(parameters); - if (parameters.basics.x - rect.getWidth() < minX) { - parameters.basics.x = minX; - parameters.horizontalAlignment = IGraphicsTarget.HorizontalAlignment.LEFT; + string.textStyle = TextStyle.BLANKED; + string.font = font; + string.verticallAlignment = IGraphicsTarget.VerticalAlignment.MIDDLE; + string.basics.y = calcY(i * 1000); + rect = target.getStringsBounds(string); + + // Once changed once, these variables stay the same + if (!changed && x - rect.getWidth() < minX) { + x = minX; + horizontalAlignment = IGraphicsTarget.HorizontalAlignment.LEFT; + changed = true; } - target.drawLine( - ProfilerUtils.profilerRectangle.x, - calcY(i * 1000), - 0.0, - (ProfilerUtils.profilerRectangle.x + ProfilerUtils.profilerRectangle.width), - calcY(i * 1000), 0.0, ProfilerUtils.GRAPH_COLOR, - ProfilerUtils.GRAPH_LINE_WIDTH, - IGraphicsTarget.LineStyle.SOLID); - // draw after line so it draws on top - target.drawStrings(parameters); + string.basics.x = x; + string.horizontalAlignment = horizontalAlignment; + parameters.add(string); + + DrawableLine yLabel = new DrawableLine(); + yLabel.setCoordinates(ProfilerUtils.profilerRectangle.x, + calcY(i * 1000)); + yLabel.addPoint( + (ProfilerUtils.profilerRectangle.x + ProfilerUtils.profilerRectangle.width), + calcY(i * 1000)); + yLabel.basics.color = ProfilerUtils.GRAPH_COLOR; + yLabel.width = ProfilerUtils.GRAPH_LINE_WIDTH; + lines.add(yLabel); } double stationElevation = 0; if (!getResourceData().records.isEmpty()) { @@ -565,46 +599,66 @@ public class ProfilerResource extends .getElevation(); } // Draw the surface line. - target.drawLine( - ProfilerUtils.profilerRectangle.x, - calcY(stationElevation), - 0.0, + DrawableLine surface = new DrawableLine(); + surface.setCoordinates(ProfilerUtils.profilerRectangle.x, + calcY(stationElevation)); + surface.addPoint( (ProfilerUtils.profilerRectangle.x + ProfilerUtils.profilerRectangle.width), - calcY(stationElevation), 0.0, ProfilerUtils.GRAPH_COLOR, - ProfilerUtils.GRAPH_LINE_WIDTH, IGraphicsTarget.LineStyle.SOLID); + calcY(stationElevation)); + surface.basics.color = ProfilerUtils.GRAPH_COLOR; + surface.width = ProfilerUtils.GRAPH_LINE_WIDTH; + lines.add(surface); - // loop for pressure levels and labels - parameters.horizontalAlignment = IGraphicsTarget.HorizontalAlignment.LEFT; - parameters.basics.x = ProfilerUtils.profilerRectangle.x + x = ProfilerUtils.profilerRectangle.x + ProfilerUtils.profilerRectangle.width + ProfilerUtils.LABEL_OFFSET; + horizontalAlignment = IGraphicsTarget.HorizontalAlignment.LEFT; + // loop for pressure levels and labels + changed = false; for (int i = 0; i < ProfilerUtils.PRESSURES.length; i++) { double height = WxMath.pressureToHeight(ProfilerUtils.PRESSURES[i]); if (height <= MAX_Y) { - parameters.setText( + DrawableString string = new DrawableString( ProfilerUtils.decimalFormat.format(new Double( ProfilerUtils.PRESSURES[i])) + " mb", ProfilerUtils.GRAPH_COLOR); - parameters.basics.y = calcY(height); - rect = target.getStringsBounds(parameters); - if (parameters.basics.x + rect.getWidth() > maxX) { - parameters.basics.x = maxX; - parameters.horizontalAlignment = IGraphicsTarget.HorizontalAlignment.RIGHT; + string.textStyle = TextStyle.BLANKED; + string.font = font; + string.verticallAlignment = IGraphicsTarget.VerticalAlignment.MIDDLE; + string.basics.y = calcY(height); + rect = target.getStringsBounds(string); + + // Once changed once, these variables stay the same + if (!changed && x + rect.getWidth() > maxX) { + x = maxX; + horizontalAlignment = IGraphicsTarget.HorizontalAlignment.RIGHT; + changed = true; } - target.drawStrings(parameters); + + string.basics.x = x; + string.horizontalAlignment = horizontalAlignment; + + parameters.add(string); } } // bottom of graph - target.drawLine( + DrawableLine bottom = new DrawableLine(); + bottom.setCoordinates( ProfilerUtils.profilerRectangle.x, - (ProfilerUtils.profilerRectangle.y + ProfilerUtils.profilerRectangle.height), - 0.0, + (ProfilerUtils.profilerRectangle.y + ProfilerUtils.profilerRectangle.height)); + bottom.addPoint( (ProfilerUtils.profilerRectangle.x + ProfilerUtils.profilerRectangle.width), - (ProfilerUtils.profilerRectangle.y + ProfilerUtils.profilerRectangle.height), - 0.0, ProfilerUtils.GRAPH_COLOR, ProfilerUtils.GRAPH_LINE_WIDTH, - IGraphicsTarget.LineStyle.SOLID); + (ProfilerUtils.profilerRectangle.y + ProfilerUtils.profilerRectangle.height)); + bottom.basics.color = ProfilerUtils.GRAPH_COLOR; + bottom.width = ProfilerUtils.GRAPH_LINE_WIDTH; + lines.add(bottom); + + target.drawLine(lines.toArray(new DrawableLine[0])); + + // draw strings after lines so they draw on top + target.drawStrings(parameters); } /** diff --git a/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/DispatchGraphicsTarget.java b/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/DispatchGraphicsTarget.java index 5de754d663..bd8910ed85 100644 --- a/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/DispatchGraphicsTarget.java +++ b/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/DispatchGraphicsTarget.java @@ -115,6 +115,7 @@ import com.raytheon.uf.viz.remote.graphics.objects.DispatchingWireframeShape; * Apr 04, 2014 2920 bsteffen Allow strings to use mulitple styles. * May 16, 2014 3163 bsteffen Remove references to deprecated * {@link IGraphicsTarget} methods. + * Jul 28, 2014 3429 mapeters Updated deprecated drawLine() calls. * * * @@ -1278,7 +1279,13 @@ public class DispatchGraphicsTarget extends DispatchingObject @Deprecated public void drawLine(double x1, double y1, double z1, double x2, double y2, double z2, RGB color, float width) throws VizException { - drawLine(x1, y1, z1, x2, y2, z2, color, width, LineStyle.DEFAULT); + DrawableLine line = new DrawableLine(); + line.setCoordinates(x1, y1, z1); + line.addPoint(x2, y2, z2); + line.basics.color = color; + line.width = width; + line.lineStyle = LineStyle.DEFAULT; + drawLine(line); } /* diff --git a/cave/com.raytheon.viz.awipstools/src/com/raytheon/viz/awipstools/common/DistanceTool.java b/cave/com.raytheon.viz.awipstools/src/com/raytheon/viz/awipstools/common/DistanceTool.java index 56e9ac9381..b8334e81b9 100644 --- a/cave/com.raytheon.viz.awipstools/src/com/raytheon/viz/awipstools/common/DistanceTool.java +++ b/cave/com.raytheon.viz.awipstools/src/com/raytheon/viz/awipstools/common/DistanceTool.java @@ -21,6 +21,8 @@ package com.raytheon.viz.awipstools.common; import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.List; import javax.measure.converter.UnitConverter; import javax.measure.quantity.Length; @@ -35,6 +37,7 @@ import org.opengis.referencing.crs.CoordinateReferenceSystem; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment; @@ -63,6 +66,7 @@ import com.raytheon.uf.viz.core.rsc.tools.GenericToolsResourceData; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 1/10/08 562 bphillip Initial Creation. + * 7/23/14 3429 mapeters Updated deprecated drawLine() calls. * * * @@ -170,30 +174,54 @@ public class DistanceTool extends DecimalFormat df = new DecimalFormat("0.###"); IFont font = target.getDefaultFont(); - target.drawLine(x0, y0 - yOff, 0.0, x0, y0 + yOff, 0.0, color, 1); + int max = Math.max(0, selectedIndex - 3); + List lines = new ArrayList(selectedIndex + - max + 3); + + DrawableLine line1 = new DrawableLine(); + line1.setCoordinates(x0, y0 - yOff); + line1.addPoint(x0, y0 + yOff); + line1.basics.color = color; + lines.add(line1); + target.drawString(font, "0", x0, y0 - yOff, 0.0, TextStyle.NORMAL, color, HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM, null); - - for (int i = Math.max(0, selectedIndex - 3); i < selectedIndex; i++) { + + for (int i = max; i < selectedIndex; i++) { double l = length * scales[i] / scales[selectedIndex]; String s = df.format(scales[i]); - target.drawLine(x0 + l, y0 - yOff, 0.0, x0 + l, y0 + yOff, 0.0, - color, 1); + + DrawableLine line2 = new DrawableLine(); + line2.setCoordinates(x0 + l, y0 - yOff); + line2.addPoint(x0 + l, y0 + yOff); + line2.basics.color = color; + lines.add(line2); + target.drawString(font, s, x0 + l, y0 - yOff, 0.0, TextStyle.NORMAL, color, HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM, null); } - target.drawLine(x0 + length, y0 - yOff, 0.0, x0 + length, y0 + yOff, - 0.0, color, 1); + DrawableLine line3 = new DrawableLine(); + line3.setCoordinates(x0 + length, y0 - yOff); + line3.addPoint(x0 + length, y0 + yOff); + line3.basics.color = color; + lines.add(line3); + target.drawString(font, df.format(scales[selectedIndex]) + displayUnit.toString(), x0 + length, y0 - yOff, 0.0, TextStyle.NORMAL, color, HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM, null); - target.drawLine(x0, y0, 0.0, x0 + length, y0, 0.0, color, 1); - + DrawableLine line4 = new DrawableLine(); + line4.setCoordinates(x0, y0); + line4.addPoint(x0 + length, y0); + line4.basics.color = color; + lines.add(line4); + + target.drawLine(lines.toArray(new DrawableLine[0])); + target.setupClippingPlane(screenExtent); } diff --git a/cave/com.raytheon.viz.awipstools/src/com/raytheon/viz/awipstools/common/stormtrack/StormTrackDisplay.java b/cave/com.raytheon.viz.awipstools/src/com/raytheon/viz/awipstools/common/stormtrack/StormTrackDisplay.java index e967fcc336..41e0b46d25 100644 --- a/cave/com.raytheon.viz.awipstools/src/com/raytheon/viz/awipstools/common/stormtrack/StormTrackDisplay.java +++ b/cave/com.raytheon.viz.awipstools/src/com/raytheon/viz/awipstools/common/stormtrack/StormTrackDisplay.java @@ -40,6 +40,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.common.time.SimulatedTime; import com.raytheon.uf.viz.core.DrawableCircle; +import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.DrawableString; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment; @@ -106,6 +107,7 @@ import com.vividsolutions.jts.geom.LineString; * 06-03-14 3191 njensen Fix postData to not retrieve * 06-17-2014 DR17409 mgamazaychikov Fix futurePoints calculation in generateNewTrackInfo() * and generateExistingTrackInfo() + * 07-24-2014 3429 mapeters Updated deprecated drawLine() calls. * * * @@ -454,7 +456,7 @@ public class StormTrackDisplay implements IRenderable { * @param editable * if the line is editable * @throws VizException - */ + */ private void paintLine(IGraphicsTarget target, Coordinate[] coords, RGB color, float lineWidth, boolean editable, double circleSize, LineStyle style) throws VizException { @@ -463,7 +465,11 @@ public class StormTrackDisplay implements IRenderable { circle.radius = circleSize; circle.filled = true; - Coordinate lastCoord = null; + DrawableLine line = new DrawableLine(); + line.basics.color = color; + line.width = lineWidth; + line.lineStyle = style; + double[] p1; for (int i = 0; i < coords.length; ++i) { Coordinate currCoord = coords[i]; if (currCoord != null) { @@ -471,25 +477,18 @@ public class StormTrackDisplay implements IRenderable { if (editable) { paintPoint(target, currCoord, color, circleSize); } else { - double[] p1 = descriptor.worldToPixel(new double[] { + p1 = descriptor.worldToPixel(new double[] { currCoord.x, currCoord.y }); circle.setCoordinates(p1[0], p1[1]); target.drawCircle(circle); } - // paint line if lastCoord not null - if (lastCoord != null) { - double[] p1 = descriptor.worldToPixel(new double[] { - currCoord.x, currCoord.y }); - double[] p2 = descriptor.worldToPixel(new double[] { - lastCoord.x, lastCoord.y }); - - target.drawLine(p1[0], p1[1], 0.0, p2[0], p2[1], 0.0, - color, lineWidth, style); - } + p1 = descriptor.worldToPixel(new double[] { + currCoord.x, currCoord.y }); + line.addPoint(p1[0], p1[1]); } - lastCoord = currCoord; } + target.drawLine(line); } /** diff --git a/cave/com.raytheon.viz.awipstools/src/com/raytheon/viz/awipstools/ui/layer/HomeToolLayer.java b/cave/com.raytheon.viz.awipstools/src/com/raytheon/viz/awipstools/ui/layer/HomeToolLayer.java index 1ee3cfcc90..d6614b20f8 100644 --- a/cave/com.raytheon.viz.awipstools/src/com/raytheon/viz/awipstools/ui/layer/HomeToolLayer.java +++ b/cave/com.raytheon.viz.awipstools/src/com/raytheon/viz/awipstools/ui/layer/HomeToolLayer.java @@ -34,6 +34,7 @@ import org.opengis.referencing.FactoryException; import org.opengis.referencing.operation.TransformException; import com.raytheon.uf.common.geospatial.ReferencedCoordinate; +import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.DrawableString; import com.raytheon.uf.viz.core.IDisplayPaneContainer; import com.raytheon.uf.viz.core.IGraphicsTarget; @@ -70,6 +71,7 @@ import com.vividsolutions.jts.geom.Coordinate; * 15Jan2007 ebabin Update for lat/lon put home cursor bug. * 10-21-09 #1049 bsteffen Refactor to common MovableTool model * 15Mar2013 15693 mgamazaychikov Added magnification capability. + * 23Jul2014 3429 mapeters Updated deprecated drawLine() calls. * 28Jul2014 3430 mapeters Updated move function to prevent errors when * MB3 clicking off the map in editable mode. * @@ -159,10 +161,18 @@ public class HomeToolLayer extends AbstractMovableToolLayer radius, 45); double[] p2 = target.getPointOnCircle(center[0], center[1], 0.0, radius, 225); - target.drawLine(p1[0], p1[1], 0, p2[0], p2[1], 0, color, 1.0f); + DrawableLine[] lines = new DrawableLine[2]; + lines[0] = new DrawableLine(); + lines[0].setCoordinates(p1[0], p1[1]); + lines[0].addPoint(p2[0], p2[1]); + lines[0].basics.color = color; p1 = target.getPointOnCircle(center[0], center[1], 0.0, radius, 135); p2 = target.getPointOnCircle(center[0], center[1], 0.0, radius, 315); - target.drawLine(p1[0], p1[1], 0, p2[0], p2[1], 0, color, 1.0f); + lines[1] = new DrawableLine(); + lines[1].setCoordinates(p1[0], p1[1]); + lines[1].addPoint(p2[0], p2[1]); + lines[1].basics.color = color; + target.drawLine(lines); double labelLoc[] = target.getPointOnCircle(center[0], center[1], 0.0, radius, 0); DrawableString dString = new DrawableString("Home", color); diff --git a/cave/com.raytheon.viz.core.graphing/src/com/raytheon/viz/core/graphing/LineStroke.java b/cave/com.raytheon.viz.core.graphing/src/com/raytheon/viz/core/graphing/LineStroke.java index 12f3fc58bb..a93f6adcbf 100644 --- a/cave/com.raytheon.viz.core.graphing/src/com/raytheon/viz/core/graphing/LineStroke.java +++ b/cave/com.raytheon.viz.core.graphing/src/com/raytheon/viz/core/graphing/LineStroke.java @@ -19,9 +19,6 @@ **/ package com.raytheon.viz.core.graphing; -import org.eclipse.swt.graphics.RGB; - -import com.raytheon.uf.viz.core.IGraphicsTarget; import com.vividsolutions.jts.geom.Coordinate; /** @@ -33,6 +30,7 @@ import com.vividsolutions.jts.geom.Coordinate; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * 06 Nov 2006 jkorman Initial Coding + * 28 Jul 2014 3429 mapeters Removed unused render() method. * * * @author jkorman @@ -180,27 +178,6 @@ public class LineStroke { } } - /** - * Render the stroke. - * - * @param world - * The world graphics system. - * @param drawColor - * The color to draw with. - */ - public void render(IGraphicsTarget target, WGraphics world, RGB drawColor) { - switch (type) { - case MOVETO: { - world.moveTo(point.x, point.y); - break; - } - case DRAWTO: { - world.drawTo(target, point.x, point.y, drawColor); - break; - } - } - } - /** * Create a string representation of this stroke. * diff --git a/cave/com.raytheon.viz.core.graphing/src/com/raytheon/viz/core/graphing/WGraphics.java b/cave/com.raytheon.viz.core.graphing/src/com/raytheon/viz/core/graphing/WGraphics.java index bd946189b6..7934f6eaef 100644 --- a/cave/com.raytheon.viz.core.graphing/src/com/raytheon/viz/core/graphing/WGraphics.java +++ b/cave/com.raytheon.viz.core.graphing/src/com/raytheon/viz/core/graphing/WGraphics.java @@ -19,14 +19,12 @@ **/ package com.raytheon.viz.core.graphing; -import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; -import com.raytheon.uf.viz.core.IGraphicsTarget; -import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle; import com.vividsolutions.jts.geom.Coordinate; /** + * @Deprecated TODO * Implements a world coordinate to graphics viewport transform. * *
@@ -35,17 +33,17 @@ import com.vividsolutions.jts.geom.Coordinate;
  * Date         Ticket#    Engineer    Description
  * ------------ ---------- ----------- --------------------------
  * 06 Nov 2006             jkorman     Initial Coding
+ * 24 Jul 2014             mapeters    Removed unused methods/fields/imports 
+ *                                     and marked as deprecated.
+ * 
  * 
* * @author jkorman * @version 1.0 */ +@Deprecated public class WGraphics { - private double cursorX = 0; - - private double cursorY = 0; - private double worldXmin = -1; /** @@ -96,9 +94,6 @@ public class WGraphics { // private IGraphicsTarget graphicsContext; - /** Default text color */ - private RGB textColor = new RGB(255, 255, 255); - /** * Create a World coordinates graph * @@ -211,77 +206,19 @@ public class WGraphics { return dataPoint; } - /** - * Move the drawing cursor to point x1, y1. - * - * @param x1 - * The world x value. - * @param y1 - * The world y value. - */ - public void moveTo(double x, double y) { - cursorX = mapX(x); - cursorY = mapY(y); - } // moveTo() - - /** - * Draw to point x1, y1 using a specified color. - * - * @param x1 - * The world x value. - * @param y1 - * The world y value. - * @param color - * The drawing color. - */ - public void drawTo(IGraphicsTarget target, double x, double y, RGB color) { - this.drawTo(target, x, y, color, LineStyle.SOLID); - } // drawTo() - - public void drawTo(IGraphicsTarget target, double x, double y, RGB color, - LineStyle lineStyle) { - try { - double mx = mapX(x); - double my = mapY(y); - target.drawLine(cursorX, cursorY, 0.0, mx, my, 0.0, color, 1, - lineStyle); - cursorX = mx; - cursorY = my; - - } catch (Exception e) { - e.printStackTrace(); - } - } // drawTo() - public double getViewXmin() { return viewXmin; } - public void setViewXmin(double viewX1) { - this.viewXmin = viewX1; - } - public double getViewYmin() { return viewYmin; } - public void setViewYmin(double viewY1) { - this.viewYmin = viewY1; - } - public double getViewXmax() { return viewXmax; } - public void setViewXmax(double viewX2) { - this.viewXmax = viewX2; - } - public double getViewYmax() { return viewYmax; } - - public void setViewYmax(double viewY2) { - this.viewYmax = viewY2; - } } diff --git a/cave/com.raytheon.viz.core.graphing/src/com/raytheon/viz/core/graphing/axis/AxisFactory.java b/cave/com.raytheon.viz.core.graphing/src/com/raytheon/viz/core/graphing/axis/AxisFactory.java index 2a55a22f0e..8260b56949 100644 --- a/cave/com.raytheon.viz.core.graphing/src/com/raytheon/viz/core/graphing/axis/AxisFactory.java +++ b/cave/com.raytheon.viz.core.graphing/src/com/raytheon/viz/core/graphing/axis/AxisFactory.java @@ -21,27 +21,6 @@ package com.raytheon.viz.core.graphing.axis; import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Calendar; -import java.util.HashMap; - -import javax.measure.unit.Unit; - -import org.eclipse.swt.graphics.RGB; - -import com.raytheon.uf.common.style.graph.AxisScale; -import com.raytheon.uf.common.style.graph.GraphPreferences; -import com.raytheon.uf.common.style.level.SingleLevel; -import com.raytheon.uf.common.time.DataTime; -import com.raytheon.uf.viz.core.IGraphicsTarget; -import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.viz.core.ColorUtil; -import com.raytheon.viz.core.graphing.DataAxisInfo; -import com.raytheon.viz.core.graphing.GraphUtil; -import com.raytheon.viz.core.graphing.util.GraphPrefsFactory; -import com.raytheon.viz.core.graphing.util.GraphUtilPorted; -import com.raytheon.viz.core.slice.request.HeightScale; -import com.raytheon.viz.core.slice.request.HeightScale.ScaleType; /** * Factory methods for generating axes. @@ -51,6 +30,8 @@ import com.raytheon.viz.core.slice.request.HeightScale.ScaleType; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Oct 4, 2007 njensen Initial creation + * Jul 28, 2014 3429 mapeters Removed unused methods, variables, + * and imports * * * @@ -73,61 +54,10 @@ public class AxisFactory { protected static final SimpleDateFormat FCST_TIME_FORMAT = new SimpleDateFormat( "HH'Z' EEE"); - // never really figured out what absMin should be from the - // ported code - private static float ABS_MIN = Float.NEGATIVE_INFINITY; - private AxisFactory() { } - /** - * Builds a number axis from style rules - * - * @param parameter - * the parameter of the data - * @param level - * the level of the parameter - * @param orientation - * the orientation of the axis - * @param dataMinValue - * the minimum value of the data to be graphed - * @param dataMaxValue - * the maximum value of the data to be graphed - * @param zeroYes - * if the data has a point at zero - * @return - * @throws VizException - */ - public static NumberAxis buildNumberAxis(GraphPreferences preferences, - IAxis.Orientation orientation, double dataMinValue, - double dataMaxValue, boolean zeroYes, int numberOfGraphs, - Unit fallbackUnits) throws VizException { - NumberAxis axis = null; - String units = ""; - if (preferences.getDisplayUnits() != null) { - units = preferences.getDisplayUnits().toString(); - } else if (fallbackUnits != null) { - units = fallbackUnits.toString(); - } - - DataAxisInfo info = GraphUtilPorted.initDataAxisInfo( - (float) dataMinValue, zeroYes, ABS_MIN, (float) dataMaxValue, - units, preferences); - - AxisLabeling labeling = AxisUtil.makeYaxis(info, numberOfGraphs, false); - - axis = new NumberAxis(orientation, units); - axis.setLabeling(labeling); - axis.setRange((double) info.getDivMin(), (double) info.getDivMax()); - if (preferences.getAxisScale().getScaleType() == AxisScale.Type.LOG) { - axis.setLogarithmic(true); - } - axis.setInfo(info); - - return axis; - } - /** * Builds a linear number axis * @@ -149,143 +79,4 @@ public class AxisFactory { return axis; } - public static boolean axisIsCompatible(DataAxisInfo firstInfo, - boolean dataAtZero, String units, DataAxisInfo secondInfo) { - boolean compatible = false; - if (firstInfo == null && secondInfo == null) { - // primarily axes that hold images (e.g. wind barbs) - compatible = true; - } else if (firstInfo == null || secondInfo == null) { - compatible = false; - } else { - compatible = GraphUtilPorted.verifyDataAxisInfo( - firstInfo.getDataMin(), dataAtZero, ABS_MIN, - firstInfo.getDataMax(), units, firstInfo.getStyle(), - secondInfo, true); - } - - return compatible; - } - - /** - * Builds a date axis - * - * @param orientation - * the orientation - * @param times - * the times to label - * @param minTime - * the start time in milliseconds - * @param maxTime - * the end time in milliseconds - * @return the date axis - */ - public static DateAxis buildDateAxis(IAxis.Orientation orientation, - Object[] times, double minTime, double maxTime) { - DateAxis axis = new DateAxis(orientation); - AxisLabeling labeling = new AxisLabeling(); - HashMap labels = new HashMap(); - if (times[0] instanceof Calendar) { - for (Object time : times) { - Calendar cTime = (Calendar) time; - double millis = cTime.getTimeInMillis(); - String label = TIME_FORMAT.format(cTime.getTime()); - if (millis == minTime || millis == maxTime) { - label += DateAxis.LABEL_LINEBREAK - + DAY_OF_WEEK_FORMAT.format(cTime.getTime()); - label += DateAxis.LABEL_LINEBREAK - + DATE_FORMAT.format(cTime.getTime()); - } - labels.put(millis, label); - } - } else if (times[0] instanceof DataTime) { - for (Object time : times) { - DataTime dTime = (DataTime) time; - double millis = GraphUtil.getNumberRepresentation(dTime); - String label = REF_TIME_FORMAT.format(dTime.getRefTime() - .getTime()); - label += DateAxis.LABEL_LINEBREAK - + (dTime.getFcstTime() / 3600) + "HR"; - label += DateAxis.LABEL_LINEBREAK - + FCST_TIME_FORMAT.format(dTime.getValidTime() - .getTime()); - if (millis == minTime || millis == maxTime) { - label += DateAxis.LABEL_LINEBREAK - + DATE_FORMAT - .format(dTime.getValidTime().getTime()); - } - labels.put(millis, label); - } - } - labeling.setLabels(labels); - axis.setLabeling(labeling); - axis.setRange(minTime, maxTime); - return axis; - } - - public static NumberAxis buildVerticalHeightAxis(RGB color, - SingleLevel[] levels, HeightScale scale) { - if (color == null) { - color = ColorUtil.DEFAULT_ITEM_COLOR; - } - - // TODO support more level types - NumberAxis rangeAxis = new NumberAxis(IAxis.Orientation.VERTICAL, "mb"); - rangeAxis.addTitle("Millibars", color); - rangeAxis.setShowTitle(true); - Arrays.sort(levels); - double minLevel = levels[0].getValue(); - double maxLevel = levels[levels.length - 1].getValue(); - - rangeAxis.setRange(minLevel, maxLevel); - - // TODO should be configurable - GraphPreferences style = GraphPrefsFactory.buildSimplePreferences( - scale.getScale() == ScaleType.LOG, minLevel, maxLevel); - style.getAxisScale().setMaxValue(maxLevel); - style.getAxisScale().setMinValue(minLevel); - DataAxisInfo info = GraphUtilPorted.initDataAxisInfo((float) minLevel, - false, (float) minLevel, (float) maxLevel, "mb", style); - rangeAxis.setInfo(info); - rangeAxis.setLogarithmic(scale.getScale() == ScaleType.LOG); - rangeAxis.setLabeling(generateVerticalLabels(levels, scale)); - rangeAxis.setDrawLinesAtLabels(true); - rangeAxis.setLabelLineStyle(IGraphicsTarget.LineStyle.SOLID); - - return rangeAxis; - } - - private static AxisLabeling generateVerticalLabels(SingleLevel[] levels, - HeightScale scale) { - AxisLabeling labeling = new AxisLabeling(); - HashMap labelMap = new HashMap(); - if (levels.length < 11) { - for (SingleLevel level : levels) { - double val = level.getValue(); - labelMap.put(val, Double.toString(val)); - } - } else { - if (scale.getScale() == ScaleType.LOG && levels.length > 20) { - for (int i = 0; i < levels.length / 2; i += 4) { - double val = levels[i].getValue(); - labelMap.put(val, Double.toString(val)); - } - for (int i = levels.length / 2; i < levels.length; i += 2) { - double val = levels[i].getValue(); - labelMap.put(val, Double.toString(val)); - } - double val = levels[levels.length - 1].getValue(); - labelMap.put(val, Double.toString(val)); - } else { - for (int i = 0; i < levels.length; i += 2) { - double val = levels[i].getValue(); - labelMap.put(val, Double.toString(val)); - } - } - } - labeling.setLabels(labelMap); - - return labeling; - } - } diff --git a/cave/com.raytheon.viz.core.graphing/src/com/raytheon/viz/core/graphing/axis/DateAxis.java b/cave/com.raytheon.viz.core.graphing/src/com/raytheon/viz/core/graphing/axis/DateAxis.java deleted file mode 100644 index d429bd8b83..0000000000 --- a/cave/com.raytheon.viz.core.graphing/src/com/raytheon/viz/core/graphing/axis/DateAxis.java +++ /dev/null @@ -1,256 +0,0 @@ -/** - * This software was developed and / or modified by Raytheon Company, - * pursuant to Contract DG133W-05-CQ-1067 with the US Government. - * - * U.S. EXPORT CONTROLLED TECHNICAL DATA - * This software product contains export-restricted data whose - * export/transfer/disclosure is restricted by U.S. law. Dissemination - * to non-U.S. persons whether in the United States or abroad requires - * an export license or other authorization. - * - * Contractor Name: Raytheon Company - * Contractor Address: 6825 Pine Street, Suite 340 - * Mail Stop B8 - * Omaha, NE 68106 - * 402.291.0100 - * - * See the AWIPS II Master Rights File ("Master Rights File.pdf") for - * further licensing information. - **/ -package com.raytheon.viz.core.graphing.axis; - -import java.util.Arrays; -import java.util.GregorianCalendar; -import java.util.Set; -import java.util.Stack; - -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.graphics.Rectangle; - -import com.raytheon.uf.viz.core.IExtent; -import com.raytheon.uf.viz.core.IGraphicsTarget; -import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment; -import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle; -import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment; -import com.raytheon.uf.viz.core.drawables.PaintProperties; -import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.viz.core.graphing.GraphProperties; -import com.raytheon.viz.core.graphing.GraphUtil; -import com.vividsolutions.jts.geom.Coordinate; - -/** - * Graph axis which uses dates. - * - *
- * 
- *     SOFTWARE HISTORY
- *    
- *     Date       	Ticket#		Engineer	Description
- *     ------------	----------	-----------	--------------------------
- *     Oct 2006                 Phillipe    Initial creation
- *     Oct 2007                 njensen     Major refactor
- * 
- * 
- * - * @author bphillip - * @version 1 - */ - -public class DateAxis extends Axis { - - protected static final String LABEL_LINEBREAK = "\n"; - - protected static final int LABEL_SEPARATION = 100; - - protected static double MARK_LENGTH = 5.0; - - protected Stack zoomedAxes = new Stack(); - - public DateAxis(IAxis.Orientation orientation) { - this.orientation = orientation; - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.viz.core.graphing.IGraphRenderable#paint() - */ - public void paint(IGraphicsTarget target, PaintProperties paintProps) - throws VizException { - IExtent extent = ((GraphProperties) paintProps).getGraph() - .getWorldExtent(); - Rectangle bounds = GraphUtil.getBounds(extent); - graphArea = GraphUtil.getDrawingArea(extent); - - // Draws the axes - // target.drawRect(new PixelExtent(graphArea), DEFAULT_AXIS_COLOR, 1.0f, - // 1.0); - - if (orientation == IAxis.Orientation.VERTICAL) { - - // TODO not up to date with latest changes - - } else { - double boundsGraphDiff = bounds.y + bounds.height - graphArea.y - - graphArea.height; - double y = graphArea.y + graphArea.height + boundsGraphDiff * THIRD; - - Set keys = labeling.getLabels().keySet(); - RGB[] colors = new RGB[4]; - for (int i = 0; i < colors.length; i++) { - colors[i] = color; - } - - // we need to draw the labels in order so we can remove drawing - // some if there's too many too close together - double[] times = new double[keys.size()]; - int i = 0; - for (double time : keys) { - times[i] = time; - i++; - } - Arrays.sort(times); - - double previousLabelX = 0; - double startLabelX = valueToCoordinate(times[0]); - double endLabelX = valueToCoordinate(times[times.length - 1]); - - for (double time : times) { - double x = valueToCoordinate(time); - y = graphArea.y + graphArea.height; - target.drawLine(x - MARK_LENGTH, y + MARK_LENGTH, 0.0, x, y, - 0.0, color, lineWeight); - target.drawLine(x, y, 0.0, x + MARK_LENGTH, y + MARK_LENGTH, - 0.0, color, lineWeight); - if (x == startLabelX - || x == endLabelX - || (Math.abs(x - previousLabelX) > LABEL_SEPARATION - && Math.abs(x - startLabelX) > LABEL_SEPARATION && Math - .abs(x - endLabelX) > LABEL_SEPARATION)) { - String label = labeling.getLabel(time); - String[] split = label.split(LABEL_LINEBREAK); - target.drawStrings(null, split, x, y, 0.0, - TextStyle.NORMAL, colors, - HorizontalAlignment.CENTER, VerticalAlignment.TOP); - previousLabelX = x; - } - } - } - } - - @Override - public double valueToCoordinate(Object aValue) { - double val = GraphUtil.getNumberRepresentation(aValue); - return doubleValueToCoordinate(val); - } - - /** - * Gets the minimum value of the axis - * - * @return The minimum value of the axis - */ - public GregorianCalendar getBeginDate() { - - GregorianCalendar retVal = new GregorianCalendar(); - retVal.setTimeInMillis(minVal.longValue()); - return retVal; - } - - /** - * Gets the maximum value of the axis - * - * @return The maximum value of the axis - */ - public GregorianCalendar getEndDate() { - GregorianCalendar retVal = new GregorianCalendar(); - retVal.setTimeInMillis(maxVal.longValue()); - return retVal; - } - - public double coordinateToValue(Coordinate aCoordinate) { - double retVal = Double.NaN; - double range = getMaxVal() - getMinVal(); - if (orientation == IAxis.Orientation.HORIZONTAL) { - retVal = getMinVal() - + ((range * (aCoordinate.x - graphArea.x) / graphArea.width)); - } else { - - retVal = getMaxVal() - - ((range * (aCoordinate.y - graphArea.y) / graphArea.height)); - } - - return retVal; - } - - @Override - public boolean zoom(double x, double y, double zoom) { - // this may not be a good solution, let's ensure there's always - // two points on the axis - - if (zoom > 1) { - if (labeling.getLabels().size() > 2) { - zoomedAxes.push(this.labeling); - - // if you're closer one end, drop the time on that end - double val = coordinateToValue(new Coordinate(x, y)); - - double maxDiff = getMaxVal() - val; - double minDiff = val - getMinVal(); - - AxisLabeling zoomedLabeling = new AxisLabeling(); - zoomedLabeling.setSampleFormat(labeling.getSampleFormat()); - - boolean removeFirst = false; - boolean removeLast = false; - if (minDiff < maxDiff) { - // zoom towards the min - removeLast = true; - } else { - // zoom towards the max - removeFirst = true; - } - - Set keys = this.labeling.getLabels().keySet(); - for (Double key : keys) { - zoomedLabeling.getLabels().put(key, labeling.getLabel(key)); - } - double[] minMax = getLabelRanges(zoomedLabeling); - if (removeFirst) { - zoomedLabeling.getLabels().remove(minMax[0]); - } else if (removeLast) { - zoomedLabeling.getLabels().remove(minMax[1]); - } - - minMax = getLabelRanges(zoomedLabeling); - this.setRange(minMax[0], minMax[1]); - labeling = zoomedLabeling; - } - } else if (zoom < 0) { - if (zoomedAxes.size() > 0) { - labeling = zoomedAxes.pop(); - double[] minMax = getLabelRanges(labeling); - this.setRange(minMax[0], minMax[1]); - } - } - - return true; - } - - private static double[] getLabelRanges(AxisLabeling labels) { - Set keys = labels.getLabels().keySet(); - double min = Double.MAX_VALUE; - double max = Double.MIN_VALUE; - for (Double key : keys) { - min = Math.min(min, key); - max = Math.max(max, key); - } - - return new double[] { min, max }; - } - - @Override - public void updateLabeling(int numberOfGraphs) { - // currently not necessary - } - -} diff --git a/cave/com.raytheon.viz.core.graphing/src/com/raytheon/viz/core/graphing/axis/NumberAxis.java b/cave/com.raytheon.viz.core.graphing/src/com/raytheon/viz/core/graphing/axis/NumberAxis.java index db8c2d1193..fb81bff144 100644 --- a/cave/com.raytheon.viz.core.graphing/src/com/raytheon/viz/core/graphing/axis/NumberAxis.java +++ b/cave/com.raytheon.viz.core.graphing/src/com/raytheon/viz/core/graphing/axis/NumberAxis.java @@ -20,13 +20,16 @@ package com.raytheon.viz.core.graphing.axis; +import java.util.ArrayList; +import java.util.List; import java.util.Set; import java.util.Stack; +import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.IGraphicsTarget; -import com.raytheon.uf.viz.core.PixelExtent; import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment; +import com.raytheon.uf.viz.core.PixelExtent; import com.raytheon.uf.viz.core.drawables.IFont; import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.exception.VizException; @@ -47,6 +50,7 @@ import com.vividsolutions.jts.geom.Coordinate; * ------------ ---------- ----------- -------------------------- * 24Oct2006 Phillippe Initial Creation * Oct 2007 njensen Major refactor + * 24Jul2014 3429 mapeters Updated deprecated drawLine() calls. * * * @@ -119,7 +123,8 @@ public class NumberAxis extends Axis { // Draws the axes target.drawRect(new PixelExtent(graphArea), DEFAULT_AXIS_COLOR, 1.0f, 1.0); - + + List lines = new ArrayList(); if (orientation == IAxis.Orientation.VERTICAL) { double maxLabelWidth = 0.0; @@ -154,9 +159,13 @@ public class NumberAxis extends Axis { double x = graphArea.x; double x2 = graphArea.x + graphArea.width; - target.drawLine(x, y, 0.0, x2, y, 0.0, - DEFAULT_AXIS_COLOR, lineWeight, - labelLineStyle); + DrawableLine line = new DrawableLine(); + line.setCoordinates(x, y); + line.addPoint(x2, y); + line.basics.color = DEFAULT_AXIS_COLOR; + line.width = lineWeight; + line.lineStyle = labelLineStyle; + lines.add(line); } yPos = y @@ -169,9 +178,13 @@ public class NumberAxis extends Axis { labeling.getLabel(labelVal)) .getWidth(); - target.drawLine(x, y, 0.0, x2, y, 0.0, - DEFAULT_AXIS_COLOR, lineWeight, - labelLineStyle); + DrawableLine line = new DrawableLine(); + line.setCoordinates(x, y); + line.addPoint(x2, y); + line.basics.color = DEFAULT_AXIS_COLOR; + line.width = lineWeight; + line.lineStyle = labelLineStyle; + lines.add(line); } target.drawString(font, labeling.getLabel(labelVal), @@ -221,17 +234,27 @@ public class NumberAxis extends Axis { if (drawLinesAtLabels) { double y = graphArea.y; - target.drawLine(x, y, 0.0, x, yEnd, 0.0, - DEFAULT_AXIS_COLOR, lineWeight, labelLineStyle); + DrawableLine line = new DrawableLine(); + line.setCoordinates(x, y); + line.addPoint(x, yEnd); + line.basics.color = DEFAULT_AXIS_COLOR; + line.width = lineWeight; + line.lineStyle = labelLineStyle; + lines.add(line); } if (drawTickmarksAtLabels) { double y = yPos - target.getStringBounds(null, labeling.getLabel(labelVal)) .getHeight(); - - target.drawLine(x, y, 0.0, x, yEnd, 0.0, - DEFAULT_AXIS_COLOR, lineWeight, labelLineStyle); + + DrawableLine line = new DrawableLine(); + line.setCoordinates(x, y); + line.addPoint(x, yEnd); + line.basics.color = DEFAULT_AXIS_COLOR; + line.width = lineWeight; + line.lineStyle = labelLineStyle; + lines.add(line); } target.drawString(font, labeling.getLabel(labelVal), xPos, @@ -241,7 +264,8 @@ public class NumberAxis extends Axis { } } - + target.drawLine(lines.toArray(new DrawableLine[0])); + if (font != target.getDefaultFont()) { font.dispose(); } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/FreeformRenderable.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/FreeformRenderable.java index 82461eff05..fc71ce79fa 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/FreeformRenderable.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/FreeformRenderable.java @@ -25,6 +25,7 @@ import java.util.List; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.swt.graphics.RGB; +import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.RGBColors; import com.raytheon.uf.viz.core.drawables.IDescriptor; @@ -44,6 +45,7 @@ import com.vividsolutions.jts.geom.Coordinate; * ------------ ---------- ----------- -------------------------- * 04/10/2008 chammack Initial Creation. * 04/14/2009 #2058 rjpeter Ensured nulls couldn't be added to polyLineVis. + * 07/23/2014 #3429 mapeters Updated deprecated drawLine() call. * * * @author chammack @@ -107,16 +109,21 @@ public class FreeformRenderable implements IRenderable { if (descriptor != null) { double[] last = null; double[] nextCoord = new double[2]; + List lines = new ArrayList(); for (Coordinate coord : polyLineVis) { nextCoord[0] = coord.x; nextCoord[1] = coord.y; double[] out = descriptor.worldToPixel(nextCoord); if ((last != null) && (out != null)) { - target.drawLine(last[0], last[1], 0.0, out[0], out[1], 0.0, - drawingColor, 1.0f); + DrawableLine line = new DrawableLine(); + line.setCoordinates(last[0], last[1]); + line.addPoint(out[0], out[1]); + line.basics.color = drawingColor; + lines.add(line); } last = out; } + target.drawLine(lines.toArray(new DrawableLine[0])); } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/sample/SamplePainter.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/sample/SamplePainter.java index 6f87d88013..ac154dab32 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/sample/SamplePainter.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/sample/SamplePainter.java @@ -37,6 +37,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.SimulatedTime; +import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.DrawableString; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment; @@ -71,6 +72,7 @@ import com.vividsolutions.jts.geom.Coordinate; * calcGridLabels(). * 11/05/2012 #14566 jzeng Paint the sample points with the order of grids * in calcGridLabels () + * 07/24/2014 #3429 mapeters Updated deprecated drawLine() calls. * * * @author chammack @@ -205,12 +207,19 @@ public class SamplePainter { if (showDataValues) { double tickMarkExtent = ratio * 3; - target.drawLine(screenloc[0] - tickMarkExtent, screenloc[1], - 0.0, screenloc[0] + tickMarkExtent, screenloc[1], 0.0, - llPlusColor, 2.0f); - target.drawLine(screenloc[0], screenloc[1] - tickMarkExtent, - 0.0, screenloc[0], screenloc[1] + tickMarkExtent, 0.0, - llPlusColor, 2.0f); + DrawableLine[] lines = new DrawableLine[2]; + lines[0] = new DrawableLine(); + lines[0].setCoordinates(screenloc[0] - tickMarkExtent, screenloc[1]); + lines[0].addPoint(screenloc[0] + tickMarkExtent, screenloc[1]); + lines[0].basics.color = llPlusColor; + lines[0].width = 2.0f; + lines[1] = new DrawableLine(); + lines[1].setCoordinates(screenloc[0], screenloc[1] - tickMarkExtent); + lines[1].addPoint(screenloc[0], screenloc[1] + tickMarkExtent); + lines[1].basics.color = llPlusColor; + lines[1].width = 2.0f; + + target.drawLine(lines); } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/DiscreteColorbar.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/DiscreteColorbar.java index 746544627d..eb36328566 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/DiscreteColorbar.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/DiscreteColorbar.java @@ -48,6 +48,7 @@ import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.common.time.TimeRange; +import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.DrawableString; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment; @@ -97,6 +98,7 @@ import com.vividsolutions.jts.geom.Coordinate; * on discrete color bar when no grid exists * Feb 12, 2013 15719 jdynina Fixed out of bounds error in calcGridColorTable * Oct 31, 2013 #2508 randerso Change to use DiscreteGridSlice.getKeys() + * Jul 23, 2014 #3429 mapeters Updated deprecated drawLine() calls * * * @@ -529,11 +531,14 @@ public class DiscreteColorbar implements IColorBarDisplay, dstring.horizontalAlignment = HorizontalAlignment.CENTER; dstring.verticallAlignment = VerticalAlignment.MIDDLE; + DrawableLine[] lines = new DrawableLine[colorTable.size()]; i = 0; for (ColorEntry colorEntry : colorTable) { double ikeywidth = i * keywidth; - target.drawLine(minX + ikeywidth, minY, 0.0, minX + ikeywidth, - maxY, 0.0, seColorBarTickColor, 1.0f); + lines[i] = new DrawableLine(); + lines[i].setCoordinates(minX + ikeywidth, minY); + lines[i].addPoint(minX + ikeywidth, maxY); + lines[i].basics.color = seColorBarTickColor; String keyName = colorEntry.getValue().toString(); labelLoc = (float) (minX + ikeywidth) + ((float) keywidth / 2); @@ -556,6 +561,7 @@ public class DiscreteColorbar implements IColorBarDisplay, } i++; } + target.drawLine(lines); } /** diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/HydroPointResource.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/HydroPointResource.java index a805ee9875..577ca263ed 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/HydroPointResource.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/HydroPointResource.java @@ -22,6 +22,7 @@ package com.raytheon.viz.mpe.ui.rsc; import org.eclipse.swt.graphics.RGB; import com.raytheon.uf.viz.core.DrawableCircle; +import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.exception.VizException; @@ -42,6 +43,7 @@ import com.vividsolutions.jts.geom.Coordinate; * ------------ ---------- ----------- -------------------------- * Sep 22, 2009 snaples Initial creation * Jul 22, 2014 #3422 mapeters Updated deprecated drawFilledCircle() call. + * Jul 24, 2014 #3429 mapeters Updated deprecated drawLine() calls. * * * @author snaples @@ -98,15 +100,20 @@ public abstract class HydroPointResource > e if (pixels != null) { RGB color = getCapability(ColorableCapability.class).getColor(); if (getStyle() == Style.STAR) { - target.drawLine(pixels[0], pixels[1] - LINE_LENGTH, 0.0, - pixels[0], pixels[1] + LINE_LENGTH, 0.0, color, - getLineWidth()); - target.drawLine(pixels[0] - LINE_LENGTH, pixels[1] - + LINE_LENGTH, 0.0, pixels[0] + LINE_LENGTH, pixels[1] - - LINE_LENGTH, 0.0, color, getLineWidth()); - target.drawLine(pixels[0] - LINE_LENGTH, pixels[1] - - LINE_LENGTH, 0.0, pixels[0] + LINE_LENGTH, pixels[1] - + LINE_LENGTH, 0.0, color, getLineWidth()); + DrawableLine[] lines = new DrawableLine[3]; + lines[0] = new DrawableLine(); + lines[0].setCoordinates(pixels[0], pixels[1] - LINE_LENGTH); + lines[0].addPoint(pixels[0], pixels[1] + LINE_LENGTH); + lines[0].basics.color = color; + lines[1] = new DrawableLine(); + lines[1].setCoordinates(pixels[0] - LINE_LENGTH, pixels[1] + LINE_LENGTH); + lines[1].addPoint(pixels[0] + LINE_LENGTH, pixels[1] - LINE_LENGTH); + lines[1].basics.color = color; + lines[2] = new DrawableLine(); + lines[2].setCoordinates(pixels[0] - LINE_LENGTH, pixels[1] - LINE_LENGTH); + lines[2].addPoint(pixels[0] + LINE_LENGTH, pixels[1] + LINE_LENGTH); + lines[2].basics.color = color; + target.drawLine(lines); } else if (getStyle() == Style.RECTANGLE) { target.drawShadedRect(paintProps.getView().getExtent(), color, 1.0, null); diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEPolygonResource.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEPolygonResource.java index fa3bdb82a7..a189811656 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEPolygonResource.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEPolygonResource.java @@ -41,6 +41,7 @@ import com.raytheon.uf.common.hydro.spatial.HRAPSubGrid; import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.IDisplayPaneContainer; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.drawables.IDescriptor; @@ -72,7 +73,7 @@ import com.vividsolutions.jts.geom.Polygon; * Jun 30, 2009 2685 mpduff Initial creation. * Sep 23, 2009 3069 mpduff Changed the parent class to HydroPointResource. * Feb 07, 2011 5535 mschenke Rewrote resource to fix numerous issues and follow viz standards - * + * Jul 24, 2014 3429 mapeters Updated deprecated drawLine() calls. * * * @author mpduff @@ -229,21 +230,18 @@ public class MPEPolygonResource extends private void paintCoordinates(IGraphicsTarget target, PaintProperties paintProps, Coordinate[] coords) throws VizException { - Coordinate prev = coords[0]; - double[] prevPixels = descriptor.worldToPixel(new double[] { prev.x, - prev.y }); + double[] startPixels = descriptor.worldToPixel(new double[] { + coords[0].x, coords[0].y }); + DrawableLine line = new DrawableLine(); + line.basics.color = getCapability(ColorableCapability.class).getColor(); + line.setCoordinates(startPixels[0], startPixels[1]); for (int i = 1; i < coords.length; ++i) { Coordinate curr = coords[i]; double[] currPixels = descriptor.worldToPixel(new double[] { curr.x, curr.y }); - - target.drawLine(prevPixels[0], prevPixels[1], 0.0, currPixels[0], - currPixels[1], 0.0, - getCapability(ColorableCapability.class).getColor(), 1.0f); - - prev = curr; - prevPixels = currPixels; + line.addPoint(currPixels[0], currPixels[1]); } + target.drawLine(line); } /* diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PointFreezePlotResource.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PointFreezePlotResource.java index fae4e1efe4..fe72f43eec 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PointFreezePlotResource.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PointFreezePlotResource.java @@ -48,6 +48,7 @@ import com.raytheon.uf.common.colormap.prefs.DataMappingPreferences; import com.raytheon.uf.common.colormap.prefs.DataMappingPreferences.DataMappingEntry; import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue; import com.raytheon.uf.common.geospatial.ReferencedCoordinate; +import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.DrawableString; import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.IGraphicsTarget; @@ -86,7 +87,7 @@ import com.vividsolutions.jts.index.strtree.STRtree; * ------------ ---------- ----------- -------------------------- * Jul 8, 2009 2589 snaples Initial creation * Mar 3, 2014 2804 mschenke Set back up clipping pane - * + * Jul 24, 2014 3429 mapeters Updated deprecated drawLine() calls. * * * @author snaples @@ -532,7 +533,7 @@ public class PointFreezePlotResource extends } } - private void drawQCLegend() { + private void drawQCLegend() throws VizException { // TODO this screen location code is borrowed from MPELegendResource... // should it be put into a shared class, possibly a paint // properties method? @@ -553,30 +554,29 @@ public class PointFreezePlotResource extends int[] funct = DailyQcUtils.funct; int temp = 0; + DrawableLine[] lines = new DrawableLine[4]; for (int i = 0; i < typename.length; i++) { if (i != 0 && i != 6 && i != 7 && i != 3) { continue; } - try { - color = RGBColors.getRGBColor(color_map_a[funct[i]]); - target.drawLine(x1, y1 + temp * textSpace, 0.0, x1 - + (2.5 * padding), y1 + temp * textSpace, 0.0, color, - 35); - label = typename[i]; - color = RGBColors.getRGBColor(color_map_n[15]); - double xLoc = x1 + (4 * padding); - double yLoc = y1 + (temp + .5) * textSpace; - string.setText(label, color); - string.setCoordinates(xLoc, yLoc); - string.horizontalAlignment = HorizontalAlignment.LEFT; - string.verticallAlignment = VerticalAlignment.BOTTOM; - target.drawStrings(string); - temp++; - } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + color = RGBColors.getRGBColor(color_map_a[funct[i]]); + lines[temp] = new DrawableLine(); + lines[temp].setCoordinates(x1, y1 + temp * textSpace); + lines[temp].addPoint(x1 + (2.5 * padding), y1 + temp * textSpace); + lines[temp].basics.color = color; + lines[temp].width = 35; + label = typename[i]; + color = RGBColors.getRGBColor(color_map_n[15]); + double xLoc = x1 + (4 * padding); + double yLoc = y1 + (temp + .5) * textSpace; + string.setText(label, color); + string.setCoordinates(xLoc, yLoc); + string.horizontalAlignment = HorizontalAlignment.LEFT; + string.verticallAlignment = VerticalAlignment.BOTTOM; + target.drawStrings(string); + temp++; } + target.drawLine(lines); } /** diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PointPrecipPlotResource.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PointPrecipPlotResource.java index 533ba697fb..a3a1a3af8d 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PointPrecipPlotResource.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PointPrecipPlotResource.java @@ -48,6 +48,7 @@ import com.raytheon.uf.common.colormap.prefs.DataMappingPreferences; import com.raytheon.uf.common.colormap.prefs.DataMappingPreferences.DataMappingEntry; import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue; import com.raytheon.uf.common.geospatial.ReferencedCoordinate; +import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.DrawableString; import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.IGraphicsTarget; @@ -88,7 +89,7 @@ import com.vividsolutions.jts.index.strtree.STRtree; * ------------ ---------- ----------- -------------------------- * Nov 24, 2008 1748 snaples Initial creation * Mar 3, 2014 2804 mschenke Set back up clipping pane - * + * Jul 24, 2014 3429 mapeters Updated deprecated drawLine() calls. * * * @author snaples @@ -765,7 +766,7 @@ public class PointPrecipPlotResource extends } } - private void drawQCLegend() { + private void drawQCLegend() throws VizException { // TODO this screen location code is borrowed from MPELegendResource... // should it be put into a shared class, possibly a paint // properties method? @@ -784,26 +785,25 @@ public class PointPrecipPlotResource extends RGB color = null; String label = ""; int[] funct = DailyQcUtils.funct; + DrawableLine[] lines = new DrawableLine[typename.length]; for (int i = 0; i < typename.length; i++) { - - try { - color = RGBColors.getRGBColor(color_map_a[funct[i]]); - target.drawLine(x1, y1 + i * textSpace, 0.0, x1 - + (2.5 * padding), y1 + i * textSpace, 0.0, color, 35); - label = typename[i]; - color = RGBColors.getRGBColor(color_map_n[15]); - double xLoc = x1 + (4 * padding); - double yLoc = y1 + (i + .45) * textSpace; - string.setText(label, color); - string.setCoordinates(xLoc, yLoc); - string.horizontalAlignment = HorizontalAlignment.LEFT; - string.verticallAlignment = VerticalAlignment.BOTTOM; - target.drawStrings(string); - } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + color = RGBColors.getRGBColor(color_map_a[funct[i]]); + lines[i] = new DrawableLine(); + lines[i].setCoordinates(x1, y1 + i * textSpace); + lines[i].addPoint(x1 + (2.5 * padding), y1 + i * textSpace); + lines[i].basics.color = color; + lines[i].width = 35; + label = typename[i]; + color = RGBColors.getRGBColor(color_map_n[15]); + double xLoc = x1 + (4 * padding); + double yLoc = y1 + (i + .45) * textSpace; + string.setText(label, color); + string.setCoordinates(xLoc, yLoc); + string.horizontalAlignment = HorizontalAlignment.LEFT; + string.verticallAlignment = VerticalAlignment.BOTTOM; + target.drawStrings(string); } + target.drawLine(lines); } diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PointTempPlotResource.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PointTempPlotResource.java index 922cef4572..163047eb7f 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PointTempPlotResource.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/PointTempPlotResource.java @@ -48,6 +48,7 @@ import com.raytheon.uf.common.colormap.prefs.DataMappingPreferences; import com.raytheon.uf.common.colormap.prefs.DataMappingPreferences.DataMappingEntry; import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue; import com.raytheon.uf.common.geospatial.ReferencedCoordinate; +import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.DrawableString; import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.IGraphicsTarget; @@ -87,6 +88,7 @@ import com.vividsolutions.jts.index.strtree.STRtree; * ------------ ---------- ----------- -------------------------- * Jun 24, 2009 2524 snaples Initial creation * Mar 3, 2014 2804 mschenke Set back up clipping pane + * Jul 24, 2014 3429 mapeters Updated deprecated drawLine() calls. * * * @@ -606,7 +608,7 @@ public class PointTempPlotResource extends } } - private void drawQCLegend() { + private void drawQCLegend() throws VizException { // TODO this screen location code is borrowed from MPELegendResource... // should it be put into a shared class, possibly a paint // properties method? @@ -626,33 +628,30 @@ public class PointTempPlotResource extends String label = ""; int[] funct = DailyQcUtils.funct; int temp = 0; - + int x = 0; + DrawableLine[] lines = new DrawableLine[typename.length - 1]; for (int i = 0; i < typename.length; i++) { if (i == 5) { continue; } - - try { - color = RGBColors.getRGBColor(color_map_a[funct[i]]); - target.drawLine(x1, y1 + temp * textSpace, 0.0, x1 - + (2.5 * padding), y1 + temp * textSpace, 0.0, color, - 35); - label = typename[i]; - color = RGBColors.getRGBColor(color_map_n[15]); - double xLoc = x1 + (4 * padding); - double yLoc = y1 + (temp + .5) * textSpace; - string.setText(label, color); - string.setCoordinates(xLoc, yLoc); - string.horizontalAlignment = HorizontalAlignment.LEFT; - string.verticallAlignment = VerticalAlignment.BOTTOM; - target.drawStrings(string); - temp++; - } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + color = RGBColors.getRGBColor(color_map_a[funct[i]]); + lines[x] = new DrawableLine(); + lines[x].setCoordinates(x1, y1 + temp * textSpace); + lines[x].addPoint(x1 + (2.5 * padding), y1 + temp * textSpace); + lines[x].basics.color = color; + lines[x++].width = 35; + label = typename[i]; + color = RGBColors.getRGBColor(color_map_n[15]); + double xLoc = x1 + (4 * padding); + double yLoc = y1 + (temp + .5) * textSpace; + string.setText(label, color); + string.setCoordinates(xLoc, yLoc); + string.horizontalAlignment = HorizontalAlignment.LEFT; + string.verticallAlignment = VerticalAlignment.BOTTOM; + target.drawStrings(string); + temp++; } - + target.drawLine(lines); } /** diff --git a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/xy/CellTrendGraph.java b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/xy/CellTrendGraph.java index 26e558175c..781a0371bb 100644 --- a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/xy/CellTrendGraph.java +++ b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/xy/CellTrendGraph.java @@ -26,7 +26,9 @@ import java.util.List; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; +import com.raytheon.uf.viz.core.AbstractDrawableObject; import com.raytheon.uf.viz.core.DrawableCircle; +import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment; @@ -58,6 +60,8 @@ import com.raytheon.viz.radar.ui.xy.RadarGraphResource.GraphPosition; * ------------ ---------- ----------- -------------------------- * Apr 8, 2009 askripsk Initial creation * 07-21-14 #3412 mapeters Updated deprecated drawCircle call. + * 07-24-14 #3429 mapeters Updated deprecated drawLine() calls. + * * * * @author askripsk @@ -111,15 +115,17 @@ public class CellTrendGraph extends XYGraph { double previousScreenY = 0.0; // Paint each series in the xyData - boolean first = true; + boolean first; int i = 0; LineStyle currLineStyle; PointType currPointType; + List circles = new ArrayList(); + List lines = new ArrayList(); for (XYDataList currSeries : dataSeries) { currLineStyle = dataSeriesLineTypes.get(i); currPointType = dataSeriesPointTypes.get(i++); - + first = true; for (XYData currPoint : currSeries.getData()) { double x = ((Number) currPoint.getX()).doubleValue(); @@ -132,53 +138,75 @@ public class CellTrendGraph extends XYGraph { double screenX = domainAxis.valueToCoordinate(x); double screenY = rangeAxis.valueToCoordinate(y); - // Draw the cooresponding type of point - drawPoint(target, screenX, screenY, currPointType); + AbstractDrawableObject object = drawPoint(target, + screenX, screenY, currPointType); + // Add the point to its corresponding list + if (object instanceof DrawableCircle) { + circles.add((DrawableCircle) object); + } else if (object instanceof DrawableLine) { + lines.add((DrawableLine) object); + } - // Don't draw a line for the first if (first) { first = false; - previousScreenX = screenX; - previousScreenY = screenY; } else { - target.drawLine(screenX, screenY, 0, - previousScreenX, previousScreenY, 0, - colorCap.getColor(), outlineCap - .getOutlineWidth(), currLineStyle); + DrawableLine line = new DrawableLine(); + line.setCoordinates(screenX, screenY); + line.addPoint(previousScreenX, previousScreenY); + line.basics.color = colorCap.getColor(); + line.width = outlineCap.getOutlineWidth(); + line.lineStyle = currLineStyle; + lines.add(line); } previousScreenX = screenX; previousScreenY = screenY; } } + target.drawLine(lines.toArray(new DrawableLine[0])); + target.drawCircle(circles.toArray(new DrawableCircle[0])); target.clearClippingPlane(); } } } - - private void drawPoint(IGraphicsTarget target, double x, double y, + + private AbstractDrawableObject drawPoint(IGraphicsTarget target, double x, double y, PointType currPointType) throws VizException { if (currPointType.equals(PointType.CIRCLE)) { DrawableCircle circle = new DrawableCircle(); + circle = new DrawableCircle(); circle.setCoordinates(x, y); circle.radius = 3.0; circle.basics.color = colorCap.getColor(); - target.drawCircle(circle); + return circle; } else if (currPointType.equals(PointType.X)) { - target.drawLine(x - 3, y - 3, 0.0, x + 3, y + 3, 0.0, colorCap - .getColor(), 1.0f); - target.drawLine(x - 3, y + 3, 0.0, x + 3, y - 3, 0.0, colorCap - .getColor(), 1.0f); + DrawableLine line = new DrawableLine(); + line = new DrawableLine(); + line.setCoordinates(x - 3, y - 3); + line.addPoint(x + 3, y + 3); + line.addPoint(x, y); + line.addPoint(x - 3, y + 3); + line.addPoint(x + 3, y - 3); + line.basics.color = colorCap.getColor(); + return line; } else if (currPointType.equals(PointType.UP_ARROW)) { - target.drawLine(x - 3, y + 3, 0.0, x, y - 3, 0.0, colorCap - .getColor(), 1.0f); - target.drawLine(x, y - 3, 0.0, x + 3, y + 3, 0.0, colorCap - .getColor(), 1.0f); + DrawableLine line = new DrawableLine(); + line = new DrawableLine(); + line.setCoordinates(x - 3, y + 3); + line.addPoint(x, y - 3); + line.addPoint(x + 3, y + 3); + line.basics.color = colorCap.getColor(); + return line; } else if (currPointType.equals(PointType.DOWN_ARROW)) { - target.drawLine(x - 3, y - 3, 0.0, x, y + 3, 0.0, colorCap - .getColor(), 1.0f); - target.drawLine(x, y + 3, 0.0, x + 3, y - 3, 0.0, colorCap - .getColor(), 1.0f); + DrawableLine line = new DrawableLine(); + line = new DrawableLine(); + line.setCoordinates(x - 3, y - 3); + line.addPoint(x, y + 3); + line.addPoint(x + 3, y - 3); + line.basics.color = colorCap.getColor(); + return line; + } else { + return null; } } @@ -205,15 +233,28 @@ public class CellTrendGraph extends XYGraph { double offset = (labelX1 - labelX0) * 1 / 4; + List circles = new ArrayList(); + List lines = new ArrayList(); // Write legend from left to right and top to bottom for (int i = 0; i < dataSeriesLabels.size(); i++) { // Point type - drawPoint(target, labelx[i], labely[i], dataSeriesPointTypes.get(i)); + PointType pt = dataSeriesPointTypes.get(i); + AbstractDrawableObject object = drawPoint(target, labelx[i], + labely[i], pt); + //Add the point to its corresponding list + if (object instanceof DrawableCircle) { + circles.add((DrawableCircle) object); + } else if (object instanceof DrawableLine) { + lines.add((DrawableLine) object); + } // Draw line sample - target.drawLine(labelx[i], labely[i], 0, labelx[i] - + (offset * 3 / 4), labely[i], 0, colorCap.getColor(), 1, - dataSeriesLineTypes.get(i)); + DrawableLine line = new DrawableLine(); + line.setCoordinates(labelx[i], labely[i]); + line.addPoint(labelx[i] + (offset * 3 / 4), labely[i]); + line.basics.color = colorCap.getColor(); + line.lineStyle = dataSeriesLineTypes.get(i); + lines.add(line); // Label Text target.drawString(null, dataSeriesLabels.get(i), @@ -221,6 +262,9 @@ public class CellTrendGraph extends XYGraph { colorCap.getColor(), HorizontalAlignment.LEFT, VerticalAlignment.MIDDLE, 0.0); } + + target.drawLine(lines.toArray(new DrawableLine[0])); + target.drawCircle(circles.toArray(new DrawableCircle[0])); } private void createAxes() { diff --git a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/xy/RadarGSMResource.java b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/xy/RadarGSMResource.java index f36e4ca821..92fa6d343a 100644 --- a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/xy/RadarGSMResource.java +++ b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/xy/RadarGSMResource.java @@ -29,6 +29,7 @@ import org.eclipse.swt.graphics.RGB; import com.raytheon.uf.common.dataplugin.radar.RadarRecord; import com.raytheon.uf.common.dataplugin.radar.level3.GSMBlock.GSMMessage; +import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment; import com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle; @@ -54,7 +55,8 @@ import com.raytheon.viz.radar.rsc.RadarResourceData; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * May 13, 2010 mnash Initial creation - * 03/01/2013 DR 15496 zwang Handled expanded GSM, display more status + * 03/01/2013 DR 15496 zwang Handled expanded GSM, display more status + * 07/24/2014 #3429 mapeters Updated deprecated drawLine() calls. * * * @@ -328,9 +330,14 @@ public class RadarGSMResource extends AbstractRadarResource { } int height = 780; + List lines = new ArrayList( + theTemp.size() + 8); for (int i = 0; i < theTemp.size(); i++) { - target.drawLine(xOffset + 50, height, 0, 800, height - i - * lineSpace, 0, color, 1); + DrawableLine line = new DrawableLine(); + line.setCoordinates(xOffset + 50, height); + line.addPoint(800, height - i * lineSpace); + line.basics.color = color; + lines.add(line); drawNexradString( String.valueOf(theTemp.get(theTemp.size() - 1 - i)), 800, height - i * lineSpace - 10, target, color); @@ -340,14 +347,14 @@ public class RadarGSMResource extends AbstractRadarResource { yOffset = height + lineSpace; // first box - target.drawLine(xOffset, yOffset, 0, xOffset + 200, yOffset, 0, - color, 1); - target.drawLine(xOffset, yOffset, 0, xOffset, yOffset + boxHeight, - 0, color, 1); - target.drawLine(xOffset + 200, yOffset, 0, xOffset + 200, yOffset - + boxHeight, 0, color, 1); - target.drawLine(xOffset, yOffset + boxHeight, 0, xOffset + 200, - yOffset + boxHeight, 0, color, 1); + DrawableLine box1 = new DrawableLine(); + box1.setCoordinates(xOffset, yOffset); + box1.addPoint(xOffset + 200, yOffset); + box1.addPoint(xOffset + 200, yOffset + boxHeight); + box1.addPoint(xOffset, yOffset + boxHeight); + box1.addPoint(xOffset, yOffset); + box1.basics.color = color;; + lines.add(box1); drawNexradString(rda_tdwr, xOffset + 85, yOffset + halfHeight, target, color); @@ -361,24 +368,29 @@ public class RadarGSMResource extends AbstractRadarResource { || (message.getRdaStatus() & RDA_STATUS_OFFLINE) != 0) rdaDown = true; if (!rdaDown) { - target.drawLine(xOffset + 200, yOffset + halfHeight, 0, - xOffset + 300, yOffset + halfHeight, 0, color, 1); - target.drawLine(xOffset + 300, yOffset + halfHeight, 0, - xOffset + 280, yOffset + halfHeight - 10, 0, color, 1); - target.drawLine(xOffset + 300, yOffset + halfHeight, 0, - xOffset + 280, yOffset + halfHeight + 10, 0, color, 1); + DrawableLine arrow1line = new DrawableLine(); + arrow1line.setCoordinates(xOffset + 200, yOffset + halfHeight); + arrow1line.addPoint(xOffset + 300, yOffset + halfHeight); + arrow1line.basics.color = color; + DrawableLine arrow1head = new DrawableLine(); + arrow1head.setCoordinates(xOffset + 280, yOffset + halfHeight - 10); + arrow1head.addPoint(xOffset + 300, yOffset + halfHeight); + arrow1head.addPoint(xOffset + 280, yOffset + halfHeight + 10); + arrow1head.basics.color = color; + lines.add(arrow1line); + lines.add(arrow1head); } - xOffset += 300; // second box - target.drawLine(xOffset, yOffset, 0, xOffset + 200, yOffset, 0, - color, 1); - target.drawLine(xOffset, yOffset, 0, xOffset, yOffset + boxHeight, - 0, color, 1); - target.drawLine(xOffset + 200, yOffset, 0, xOffset + 200, yOffset - + boxHeight, 0, color, 1); - target.drawLine(xOffset, yOffset + boxHeight, 0, xOffset + 200, - yOffset + boxHeight, 0, color, 1); + DrawableLine box2 = new DrawableLine(); + box2.setCoordinates(xOffset, yOffset); + box2.addPoint(xOffset + 200, yOffset); + box2.addPoint(xOffset + 200, yOffset + boxHeight); + box2.addPoint(xOffset, yOffset + boxHeight); + box2.addPoint(xOffset, yOffset); + box2.basics.color = color;; + lines.add(box2); + drawNexradString(rpg_spg, xOffset + 85, yOffset + halfHeight, target, color); @@ -386,29 +398,37 @@ public class RadarGSMResource extends AbstractRadarResource { || dedicatedComms.equals("Disconnected")) rpgDown = true; if (!rpgDown) { - target.drawLine(xOffset + 200, yOffset + halfHeight, 0, - xOffset + 300, yOffset + halfHeight, 0, color, 1); - target.drawLine(xOffset + 300, yOffset + halfHeight, 0, - xOffset + 280, yOffset + halfHeight - 10, 0, color, 1); - target.drawLine(xOffset + 300, yOffset + halfHeight, 0, - xOffset + 280, yOffset + halfHeight + 10, 0, color, 1); - - target.drawLine(xOffset + 200, yOffset + halfHeight, 0, - xOffset + 220, yOffset + halfHeight - 10, 0, color, 1); - target.drawLine(xOffset + 200, yOffset + halfHeight, 0, - xOffset + 220, yOffset + halfHeight + 10, 0, color, 1); + DrawableLine arrow2line = new DrawableLine(); + arrow2line.setCoordinates(xOffset + 200, yOffset + halfHeight); + arrow2line.addPoint(xOffset + 300, yOffset + halfHeight); + arrow2line.basics.color = color; + DrawableLine arrow2head1 = new DrawableLine(); + arrow2head1.setCoordinates(xOffset + 280, yOffset + halfHeight - 10); + arrow2head1.addPoint(xOffset + 300, yOffset + halfHeight); + arrow2head1.addPoint(xOffset + 280, yOffset + halfHeight + 10); + arrow2head1.basics.color = color; + DrawableLine arrow2head2 = new DrawableLine(); + arrow2head2.setCoordinates(xOffset + 220, yOffset + halfHeight - 10); + arrow2head2.addPoint(xOffset + 200, yOffset + halfHeight); + arrow2head2.addPoint(xOffset + 220, yOffset + halfHeight + 10); + arrow2head2.basics.color = color; + lines.add(arrow2line); + lines.add(arrow2head1); + lines.add(arrow2head2); } - xOffset += 300; // third box - target.drawLine(xOffset, yOffset, 0, xOffset + 200, yOffset, 0, - color, 1); - target.drawLine(xOffset, yOffset, 0, xOffset, yOffset + boxHeight, - 0, color, 1); - target.drawLine(xOffset + 200, yOffset, 0, xOffset + 200, yOffset - + boxHeight, 0, color, 1); - target.drawLine(xOffset, yOffset + boxHeight, 0, xOffset + 200, - yOffset + boxHeight, 0, color, 1); + DrawableLine box3 = new DrawableLine(); + box3.setCoordinates(xOffset, yOffset); + box3.addPoint(xOffset + 200, yOffset); + box3.addPoint(xOffset + 200, yOffset + boxHeight); + box3.addPoint(xOffset, yOffset + boxHeight); + box3.addPoint(xOffset, yOffset); + box3.basics.color = color;; + lines.add(box3); + + target.drawLine(lines.toArray(new DrawableLine[0])); + drawNexradString("WFO", xOffset + 85, yOffset + 58, target, color); } } diff --git a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/xy/RadarXYResource.java b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/xy/RadarXYResource.java index d140d6d768..1a4816f1a8 100644 --- a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/xy/RadarXYResource.java +++ b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/ui/xy/RadarXYResource.java @@ -44,6 +44,7 @@ import com.raytheon.uf.common.dataplugin.radar.level3.UnlinkedVectorPacket; import com.raytheon.uf.common.dataplugin.radar.level3.WindBarbPacket; import com.raytheon.uf.common.dataplugin.radar.level3.WindBarbPacket.WindBarbPoint; import com.raytheon.uf.common.time.DataTime; +import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.DrawableString; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment; @@ -83,7 +84,7 @@ import com.vividsolutions.jts.geom.Coordinate; * Mar 19, 2013 1804 bsteffen Remove empty data structures from radar * hdf5. * Sep 23, 2013 2363 bsteffen Add more vector configuration options. - * + * Jul 23, 2014 3429 mapeters Updated deprecated drawLine() calls. * * * @author askripsk @@ -220,22 +221,29 @@ public class RadarXYResource extends RadarImageResource { .getMagnification().floatValue(); // Paint unlinked lines + DrawableLine[] lines = new DrawableLine[this.unlinkedLines.size() + this.linkedLines.size()]; + int i = 0; for (UnlinkedVector currVec : this.unlinkedLines) { - target.drawLine((currVec.i1 + X_OFFSET_NWP) * SCALAR, - (currVec.j1 + Y_OFFSET_NWP) * SCALAR, 0, - (currVec.i2 + X_OFFSET_NWP) * SCALAR, - (currVec.j2 + Y_OFFSET_NWP) * SCALAR, 0, - getVectorColor(currVec), 1 * magnification); + lines[i] = new DrawableLine(); + lines[i].setCoordinates((currVec.i1 + X_OFFSET_NWP) * SCALAR, + (currVec.j1 + Y_OFFSET_NWP) * SCALAR); + lines[i].addPoint((currVec.i2 + X_OFFSET_NWP) * SCALAR, + (currVec.j2 + Y_OFFSET_NWP) * SCALAR); + lines[i].basics.color = getVectorColor(currVec); + lines[i++].width = 1 * magnification; } // Paint linked lines for (LinkedVector currVec : this.linkedLines) { - target.drawLine((currVec.i1 + X_OFFSET_NWP) * SCALAR, - (currVec.j1 + Y_OFFSET_NWP) * SCALAR, 0, - (currVec.i2 + X_OFFSET_NWP) * SCALAR, - (currVec.j2 + Y_OFFSET_NWP) * SCALAR, 0, - getVectorColor(currVec), 1 * magnification); + lines[i] = new DrawableLine(); + lines[i].setCoordinates((currVec.i1 + X_OFFSET_NWP) * SCALAR, + (currVec.j1 + Y_OFFSET_NWP) * SCALAR); + lines[i].addPoint((currVec.i2 + X_OFFSET_NWP) * SCALAR, + (currVec.j2 + Y_OFFSET_NWP) * SCALAR); + lines[i].basics.color = getVectorColor(currVec); + lines[i++].width = 1 * magnification; } + target.drawLine(lines); } private void paintPoints(IGraphicsTarget target, PaintProperties paintProps) diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java index 2682829ff3..aa8b42266a 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java @@ -79,6 +79,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.DataTime; import com.raytheon.uf.common.time.SimulatedTime; import com.raytheon.uf.common.time.util.TimeUtil; +import com.raytheon.uf.viz.core.DrawableLine; import com.raytheon.uf.viz.core.DrawableString; import com.raytheon.uf.viz.core.IDisplayPane; import com.raytheon.uf.viz.core.IDisplayPaneContainer; @@ -212,6 +213,7 @@ import com.vividsolutions.jts.io.WKTReader; * 04/23/2014 DR 16356 Qinglu Lin Updated initializeState() and added reset(). * 04/28,2014 3033 jsanchez Properly handled back up configuration (*.xml) files. Set backupSite to null when backup site is not selected. * 05/16/2014 DR 17365 D. Friedman Check if moved vertex results in polygon valid in both lat/lon and local coordinates. + * 07/24/2014 3429 mapeters Updated deprecated drawLine() calls. * * * @author mschenke @@ -1017,6 +1019,8 @@ public class WarngenLayer extends AbstractStormTrackResource { double[] in1 = new double[2]; double[] in2 = new double[2]; + List lines = new ArrayList( + (c.length - 1) * 2); for (int i = 0; i < (c.length - 1); i++) { in1[0] = c[i].x; in1[1] = c[i].y; @@ -1025,8 +1029,13 @@ public class WarngenLayer extends AbstractStormTrackResource { double[] out1 = this.descriptor.worldToPixel(in1); double[] out2 = this.descriptor.worldToPixel(in2); - target.drawLine(out1[0], out1[1], 0.0, out2[0], out2[1], 0.0, - color, LINE_WIDTH); + + DrawableLine line = new DrawableLine(); + line.setCoordinates(out1[0], out1[1]); + line.addPoint(out2[0], out2[1]); + line.basics.color = color; + line.width = LINE_WIDTH; + lines.add(line); double delta; @@ -1043,15 +1052,16 @@ public class WarngenLayer extends AbstractStormTrackResource { double[] triRight = new double[] { out1[0] + delta, out1[1] + delta }; - target.drawLine(triTop[0], triTop[1], 0.0, triLeft[0], - triLeft[1], 0.0, color, LINE_WIDTH); - target.drawLine(triTop[0], triTop[1], 0.0, triRight[0], - triRight[1], 0.0, color, LINE_WIDTH); - target.drawLine(triLeft[0], triLeft[1], 0.0, triRight[0], - triRight[1], 0.0, color, LINE_WIDTH); - + DrawableLine line2 = new DrawableLine(); + line2.setCoordinates(triLeft[0], triLeft[1]); + line2.addPoint(triTop[0], triTop[1]); + line2.addPoint(triRight[0], triRight[1]); + line2.addPoint(triLeft[0], triLeft[1]); + line2.basics.color = color; + line2.width = LINE_WIDTH; + lines.add(line2); } - + target.drawLine(lines.toArray(new DrawableLine[0])); } }