Issue #704 fixes to plots/MPE to work better in KML

Former-commit-id: 2b6e1fa5b6 [formerly 32627cf132] [formerly 2b6e1fa5b6 [formerly 32627cf132] [formerly b01be5085f [formerly f1d440729b4e436e879219abaaaf7fa0e04d4ef6]]]
Former-commit-id: b01be5085f
Former-commit-id: 8517eafdf4 [formerly 67ba3ee6f6]
Former-commit-id: 6a9c9a47e2
This commit is contained in:
Ben Steffensmeier 2012-06-22 17:54:31 -05:00
parent 5ea6c7da61
commit 2c6b6269fd
3 changed files with 31 additions and 24 deletions

View file

@ -82,7 +82,8 @@ import com.vividsolutions.jts.geom.Polygon;
public class MPEPolygonResource extends public class MPEPolygonResource extends
AbstractVizResource<GenericResourceData, IDescriptor> implements AbstractVizResource<GenericResourceData, IDescriptor> implements
IResourceDataChanged { 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 */ /** Input handler for polygon creation and dialog opening */
private IInputHandler polygonInputHandler = new InputAdapter() { private IInputHandler polygonInputHandler = new InputAdapter() {
@ -252,7 +253,10 @@ public class MPEPolygonResource extends
*/ */
@Override @Override
protected void disposeInternal() { 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(); polyPoints.clear();
} }
} }
private List<Point> constructPolyPoints() { private List<Point> constructPolyPoints() {
List<Point> points = new ArrayList<Point>(); List<Point> points = new ArrayList<Point>();
List<Coordinate> hrapList = new ArrayList<Coordinate>(); List<Coordinate> hrapList = new ArrayList<Coordinate>();
@ -272,24 +276,25 @@ public class MPEPolygonResource extends
Envelope env; Envelope env;
GeometryFactory gf = new GeometryFactory(); GeometryFactory gf = new GeometryFactory();
try { try {
for (Coordinate coord: polyPoints) { for (Coordinate coord : polyPoints) {
Coordinate cell = hrap.latLonToGridCoordinate(coord, PixelOrientation.UPPER_LEFT); Coordinate cell = hrap.latLonToGridCoordinate(coord,
PixelOrientation.UPPER_LEFT);
hrapList.add(cell); hrapList.add(cell);
} }
Polygon drawnPolygon; Polygon drawnPolygon;
drawnPolygon = gf.createPolygon(gf drawnPolygon = gf.createPolygon(gf.createLinearRing(hrapList
.createLinearRing(hrapList.toArray(new Coordinate[hrapList.size()])), null); .toArray(new Coordinate[hrapList.size()])), null);
env = drawnPolygon.getEnvelopeInternal(); env = drawnPolygon.getEnvelopeInternal();
for (int i = (int) env.getMinX(); i < env.getMaxX(); ++i) { for (int i = (int) env.getMinX(); i < env.getMaxX(); ++i) {
for (int j = (int) env.getMinY(); j < env.getMaxY(); ++j) { for (int j = (int) env.getMinY(); j < env.getMaxY(); ++j) {
Coordinate ul = new Coordinate(i, j); Coordinate ul = new Coordinate(i, j);
if (drawnPolygon.contains(gf.createPoint(ul))) { 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 (drawnPolygon.contains(gf.createPoint(lr))) {
if (env.contains(i+1, j)) { if (env.contains(i + 1, j)) {
if (env.contains(i, j+1)) { if (env.contains(i, j + 1)) {
points.add(new Point(i, j)); points.add(new Point(i, j));
} }
} }
@ -298,7 +303,8 @@ public class MPEPolygonResource extends
} }
} }
} catch (Exception e1) { } catch (Exception e1) {
statusHandler.handle(Priority.PROBLEM, e1.getLocalizedMessage(), e1); statusHandler
.handle(Priority.PROBLEM, e1.getLocalizedMessage(), e1);
} }
synchronized (polyPoints) { synchronized (polyPoints) {
@ -360,8 +366,7 @@ public class MPEPolygonResource extends
try { try {
llToGrid.transform(in, 0, out, 0, 1); llToGrid.transform(in, 0, out, 0, 1);
} catch (TransformException e) { } catch (TransformException e) {
statusHandler.handle(Priority.PROBLEM, statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
e.getLocalizedMessage(), e);
return false; return false;
} }
@ -383,8 +388,7 @@ public class MPEPolygonResource extends
try { try {
llToGrid.transform(new double[] { c1.x, c1.y }, 0, out, 0, 1); llToGrid.transform(new double[] { c1.x, c1.y }, 0, out, 0, 1);
} catch (TransformException e) { } catch (TransformException e) {
statusHandler.handle(Priority.PROBLEM, statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
e.getLocalizedMessage(), e);
return false; return false;
} }
Coordinate p1 = new Coordinate(out[0], out[1]); Coordinate p1 = new Coordinate(out[0], out[1]);
@ -393,8 +397,7 @@ public class MPEPolygonResource extends
try { try {
llToGrid.transform(new double[] { c2.x, c2.y }, 0, out, 0, 1); llToGrid.transform(new double[] { c2.x, c2.y }, 0, out, 0, 1);
} catch (TransformException e) { } catch (TransformException e) {
statusHandler.handle(Priority.PROBLEM, statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
e.getLocalizedMessage(), e);
return false; return false;
} }
Coordinate p2 = new Coordinate(out[0], out[1]); Coordinate p2 = new Coordinate(out[0], out[1]);
@ -451,8 +454,7 @@ public class MPEPolygonResource extends
try { try {
gridToLL.transform(new double[] { used.x, used.y }, 0, out, 0, 1); gridToLL.transform(new double[] { used.x, used.y }, 0, out, 0, 1);
} catch (TransformException e) { } catch (TransformException e) {
statusHandler.handle(Priority.PROBLEM, statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
e.getLocalizedMessage(), e);
return false; return false;
} }
polyPoints.add(new Coordinate(out[0], out[1])); polyPoints.add(new Coordinate(out[0], out[1]));

View file

@ -24,6 +24,7 @@ import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate; import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.drawables.PaintProperties; 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.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.MapDescriptor; import com.raytheon.uf.viz.core.map.MapDescriptor;
@ -142,8 +143,13 @@ public class PlotBlendedResource extends
AbstractVizResource<?, ?> rsc = null; AbstractVizResource<?, ?> rsc = null;
for (int i = 0; i < resourceData.getResourceList().size(); i++) { for (int i = 0; i < resourceData.getResourceList().size(); i++) {
rsc = resourceData.getResourceList().get(i).getResource(); rsc = resourceData.getResourceList().get(i).getResource();
newProps.setDataTime(descriptor.getTimeForResource(rsc)); if (rsc.getProperties().isVisible()) {
rsc.paint(target, newProps); newProps.setDataTime(descriptor.getTimeForResource(rsc));
PaintStatus paintStatus = rsc.paint(target, newProps);
if (paintStatus != PaintStatus.PAINTED) {
updatePaintStatus(paintStatus);
}
}
} }
} }

View file

@ -48,7 +48,6 @@ import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.PixelExtent; import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.core.drawables.IImage; import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.PaintProperties; 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.drawables.ext.ISingleColorImageExtension.ISingleColorImage;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.jobs.JobPool; import com.raytheon.uf.viz.core.jobs.JobPool;
@ -211,7 +210,7 @@ public class PlotResource2 extends
if (!progressiveDisclosure.isDone() || !generator.isDone() if (!progressiveDisclosure.isDone() || !generator.isDone()
|| frameRetrievalPool.isActive()) { || frameRetrievalPool.isActive()) {
updatePaintStatus(PaintStatus.INCOMPLETE); issueRefresh();
} }
this.updateRecords(); this.updateRecords();