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 d041485994..3504c84349 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 @@ -22,6 +22,7 @@ package com.raytheon.uf.viz.ncwf.rsc; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.eclipse.swt.graphics.RGB; @@ -102,6 +103,10 @@ public class NcwfMovementResource extends return; } + List lines = new ArrayList( + curRecords.size() * 2); + List strings = new ArrayList( + curRecords.size() * 2); for (BUFRncwf record : curRecords) { RGB color = getCapability(ColorableCapability.class).getColor(); // This should adjust the direction so 0 is north @@ -117,7 +122,9 @@ public class NcwfMovementResource extends double[] or_centerPixel = descriptor.worldToPixel(new double[] { or_centerll.x, or_centerll.y, or_centerll.z }); // 90 are added to dir so that 0 is now on the right - paintArrowHead(target, centerPixel, spd, dir + 90, color); + DrawableLine arrowhead = createArrowHead(target, centerPixel, spd, + dir + 90, color); + lines.add(arrowhead); // Get the string objects. DrawableString topStr = new DrawableString(String.format("%.0f", @@ -156,22 +163,25 @@ public class NcwfMovementResource extends spdStr.horizontalAlignment = HorizontalAlignment.LEFT; } // Draw the tops string - target.drawStrings(topStr); + strings.add(topStr); + // Draw the body of the arrow 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); + lines.add(line); // Draw the wind speed string - target.drawStrings(spdStr); - + strings.add(spdStr); } + target.drawLine(lines.toArray(new DrawableLine[0])); + target.drawStrings(strings); } - private void paintArrowHead(IGraphicsTarget target, double[] center, + private DrawableLine createArrowHead(IGraphicsTarget target, + double[] center, Double length, Double dir, RGB color) throws VizException { double[] pointPixel = target.getPointOnCircle(center[0], center[1], center[2], length, dir + 210); @@ -180,12 +190,13 @@ public class NcwfMovementResource extends 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], + double[] pointPixel2 = target.getPointOnCircle(center[0], center[1], + center[2], length, dir + 150); - line.addPoint(pointPixel[0], pointPixel[1], pointPixel[2]); + line.addPoint(pointPixel2[0], pointPixel2[1], pointPixel2[2]); line.basics.color = color; line.width = 1.5f; - target.drawLine(line); + return line; } private void updateRecords(DataTime displayedDataTime) throws VizException { 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 e3af64bf63..241caf89d3 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 @@ -110,22 +110,24 @@ public class CellTrendGraph extends XYGraph { * Paint the data series */ target.setupClippingPlane(this.worldExtent); - double previousScreenX = 0.0; - double previousScreenY = 0.0; // Paint each series in the xyData - 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; + DrawableLine line = new DrawableLine(); + line.basics.color = colorCap.getColor(); + line.width = outlineCap.getOutlineWidth(); + line.lineStyle = currLineStyle; + for (XYData currPoint : currSeries.getData()) { double x = ((Number) currPoint.getX()).doubleValue(); double y = ((Number) currPoint.getY()).doubleValue(); @@ -137,7 +139,7 @@ public class CellTrendGraph extends XYGraph { double screenX = domainAxis.valueToCoordinate(x); double screenY = rangeAxis.valueToCoordinate(y); - AbstractDrawableObject object = drawPoint(target, + AbstractDrawableObject object = createPoint(target, screenX, screenY, currPointType); // Add the point to its corresponding list if (object instanceof DrawableCircle) { @@ -146,19 +148,10 @@ public class CellTrendGraph extends XYGraph { lines.add((DrawableLine) object); } - if (first) { - first = false; - } else { - 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; + line.addPoint(screenX, screenY); + } + if (line.points.size() > 0) { + lines.add(line); } } target.drawLine(lines.toArray(new DrawableLine[0])); @@ -169,7 +162,8 @@ public class CellTrendGraph extends XYGraph { } } - private AbstractDrawableObject drawPoint(IGraphicsTarget target, double x, double y, + private AbstractDrawableObject createPoint(IGraphicsTarget target, + double x, double y, PointType currPointType) throws VizException { if (currPointType.equals(PointType.CIRCLE)) { DrawableCircle circle = new DrawableCircle(); @@ -239,7 +233,7 @@ public class CellTrendGraph extends XYGraph { for (int i = 0; i < dataSeriesLabels.size(); i++) { // Point type PointType pt = dataSeriesPointTypes.get(i); - AbstractDrawableObject object = drawPoint(target, labelx[i], + AbstractDrawableObject object = createPoint(target, labelx[i], labely[i], pt); //Add the point to its corresponding list if (object instanceof DrawableCircle) {