From 2c6b6269fda9863acfce323f793c8eab43d9890c Mon Sep 17 00:00:00 2001 From: Ben Steffensmeier Date: Fri, 22 Jun 2012 17:54:31 -0500 Subject: [PATCH] Issue #704 fixes to plots/MPE to work better in KML Former-commit-id: 2b6e1fa5b6c015743a67b9b18e127e84e225a492 [formerly 32627cf132cfc6e358543a53dd5b9e9e44d4e081] [formerly 2b6e1fa5b6c015743a67b9b18e127e84e225a492 [formerly 32627cf132cfc6e358543a53dd5b9e9e44d4e081] [formerly b01be5085fe20b9cb020b09ebc402a7de0598e78 [formerly f1d440729b4e436e879219abaaaf7fa0e04d4ef6]]] Former-commit-id: b01be5085fe20b9cb020b09ebc402a7de0598e78 Former-commit-id: 8517eafdf49d79b7470ea22c1d34000e42aa7277 [formerly 67ba3ee6f689518c5e4967c67f361381b1767f5a] Former-commit-id: 6a9c9a47e220aaede38e1576fe994456f6335733 --- .../viz/mpe/ui/rsc/MPEPolygonResource.java | 42 ++++++++++--------- .../pointdata/rsc/PlotBlendedResource.java | 10 ++++- .../viz/pointdata/rsc/PlotResource2.java | 3 +- 3 files changed, 31 insertions(+), 24 deletions(-) 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 b65b92b875..fa3bdb82a7 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 @@ -82,7 +82,8 @@ import com.vividsolutions.jts.geom.Polygon; public class MPEPolygonResource extends AbstractVizResource implements IResourceDataChanged { - private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(MPEPolygonResource.class); + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(MPEPolygonResource.class); /** Input handler for polygon creation and dialog opening */ private IInputHandler polygonInputHandler = new InputAdapter() { @@ -252,7 +253,10 @@ public class MPEPolygonResource extends */ @Override protected void disposeInternal() { - getResourceContainer().unregisterMouseHandler(polygonInputHandler); + IDisplayPaneContainer container = getResourceContainer(); + if (container != null) { + container.unregisterMouseHandler(polygonInputHandler); + } } /** @@ -264,7 +268,7 @@ public class MPEPolygonResource extends polyPoints.clear(); } } - + private List constructPolyPoints() { List points = new ArrayList(); List hrapList = new ArrayList(); @@ -272,24 +276,25 @@ public class MPEPolygonResource extends Envelope env; GeometryFactory gf = new GeometryFactory(); try { - for (Coordinate coord: polyPoints) { - Coordinate cell = hrap.latLonToGridCoordinate(coord, PixelOrientation.UPPER_LEFT); + for (Coordinate coord : polyPoints) { + Coordinate cell = hrap.latLonToGridCoordinate(coord, + PixelOrientation.UPPER_LEFT); hrapList.add(cell); } - + Polygon drawnPolygon; - drawnPolygon = gf.createPolygon(gf - .createLinearRing(hrapList.toArray(new Coordinate[hrapList.size()])), null); + drawnPolygon = gf.createPolygon(gf.createLinearRing(hrapList + .toArray(new Coordinate[hrapList.size()])), null); env = drawnPolygon.getEnvelopeInternal(); for (int i = (int) env.getMinX(); i < env.getMaxX(); ++i) { for (int j = (int) env.getMinY(); j < env.getMaxY(); ++j) { Coordinate ul = new Coordinate(i, j); if (drawnPolygon.contains(gf.createPoint(ul))) { - Coordinate lr = new Coordinate(i+1, j+1); + Coordinate lr = new Coordinate(i + 1, j + 1); if (drawnPolygon.contains(gf.createPoint(lr))) { - if (env.contains(i+1, j)) { - if (env.contains(i, j+1)) { + if (env.contains(i + 1, j)) { + if (env.contains(i, j + 1)) { points.add(new Point(i, j)); } } @@ -298,7 +303,8 @@ public class MPEPolygonResource extends } } } catch (Exception e1) { - statusHandler.handle(Priority.PROBLEM, e1.getLocalizedMessage(), e1); + statusHandler + .handle(Priority.PROBLEM, e1.getLocalizedMessage(), e1); } synchronized (polyPoints) { @@ -360,8 +366,7 @@ public class MPEPolygonResource extends try { llToGrid.transform(in, 0, out, 0, 1); } catch (TransformException e) { - statusHandler.handle(Priority.PROBLEM, - e.getLocalizedMessage(), e); + statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); return false; } @@ -383,8 +388,7 @@ public class MPEPolygonResource extends try { llToGrid.transform(new double[] { c1.x, c1.y }, 0, out, 0, 1); } catch (TransformException e) { - statusHandler.handle(Priority.PROBLEM, - e.getLocalizedMessage(), e); + statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); return false; } Coordinate p1 = new Coordinate(out[0], out[1]); @@ -393,8 +397,7 @@ public class MPEPolygonResource extends try { llToGrid.transform(new double[] { c2.x, c2.y }, 0, out, 0, 1); } catch (TransformException e) { - statusHandler.handle(Priority.PROBLEM, - e.getLocalizedMessage(), e); + statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); return false; } Coordinate p2 = new Coordinate(out[0], out[1]); @@ -451,8 +454,7 @@ public class MPEPolygonResource extends try { gridToLL.transform(new double[] { used.x, used.y }, 0, out, 0, 1); } catch (TransformException e) { - statusHandler.handle(Priority.PROBLEM, - e.getLocalizedMessage(), e); + statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); return false; } polyPoints.add(new Coordinate(out[0], out[1])); diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotBlendedResource.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotBlendedResource.java index 783a19a138..c1928f7da5 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotBlendedResource.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotBlendedResource.java @@ -24,6 +24,7 @@ import org.opengis.referencing.crs.CoordinateReferenceSystem; import com.raytheon.uf.common.geospatial.ReferencedCoordinate; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.drawables.PaintProperties; +import com.raytheon.uf.viz.core.drawables.PaintStatus; import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.map.MapDescriptor; @@ -142,8 +143,13 @@ public class PlotBlendedResource extends AbstractVizResource rsc = null; for (int i = 0; i < resourceData.getResourceList().size(); i++) { rsc = resourceData.getResourceList().get(i).getResource(); - newProps.setDataTime(descriptor.getTimeForResource(rsc)); - rsc.paint(target, newProps); + if (rsc.getProperties().isVisible()) { + newProps.setDataTime(descriptor.getTimeForResource(rsc)); + PaintStatus paintStatus = rsc.paint(target, newProps); + if (paintStatus != PaintStatus.PAINTED) { + updatePaintStatus(paintStatus); + } + } } } diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource2.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource2.java index 9d9fa9d580..ed79eeb323 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource2.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource2.java @@ -48,7 +48,6 @@ import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.PixelExtent; import com.raytheon.uf.viz.core.drawables.IImage; import com.raytheon.uf.viz.core.drawables.PaintProperties; -import com.raytheon.uf.viz.core.drawables.PaintStatus; import com.raytheon.uf.viz.core.drawables.ext.ISingleColorImageExtension.ISingleColorImage; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.jobs.JobPool; @@ -211,7 +210,7 @@ public class PlotResource2 extends if (!progressiveDisclosure.isDone() || !generator.isDone() || frameRetrievalPool.isActive()) { - updatePaintStatus(PaintStatus.INCOMPLETE); + issueRefresh(); } this.updateRecords();