Merge "Omaha #3418 Fixed NPE for cell trends. Fixed possible NPE in PointsDataManager catch block." into omaha_14.4.1

Former-commit-id: 579f38dc62 [formerly 26c8400ac1 [formerly abd0db67d4525476a55be5c07ca8c50228c54258]]
Former-commit-id: 26c8400ac1
Former-commit-id: 332fb931c6
This commit is contained in:
Nate Jensen 2014-10-20 15:32:17 -05:00 committed by Gerrit Code Review
commit a0a300082a
2 changed files with 43 additions and 26 deletions

View file

@ -88,6 +88,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* Jul 10, 2012 #875 rferrel Initial creation * Jul 10, 2012 #875 rferrel Initial creation
* Dec 05, 2012 #1364 rferrel Replace File.Separator with IPathManager.SEPARATOR * Dec 05, 2012 #1364 rferrel Replace File.Separator with IPathManager.SEPARATOR
* to work correctly on all platforms. * to work correctly on all platforms.
* Oct 20, 2014 #3418 dlovely Fixed a possible NPE in loadPoint.
* *
* </pre> * </pre>
* *
@ -658,12 +659,6 @@ public class PointsDataManager implements ILocalizationFileObserver {
try { try {
point = unmarshalPointFromXmlFile(lFile); point = unmarshalPointFromXmlFile(lFile);
} catch (IOException ex) { } catch (IOException ex) {
StringBuffer sb = new StringBuffer(lFile.toString());
sb.replace(0, pointsDir.toString().length(), "");
int index = sb.lastIndexOf(IPathManager.SEPARATOR);
sb.setLength(index);
point.setGroup(sb.toString());
statusHandler.handle(Priority.PROBLEM, statusHandler.handle(Priority.PROBLEM,
"Unable to open localized file: " + lFile, ex); "Unable to open localized file: " + lFile, ex);
} catch (LocalizationException e) { } catch (LocalizationException e) {

View file

@ -21,6 +21,7 @@ package com.raytheon.viz.radar.ui.xy;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -49,6 +50,7 @@ import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.ImagingCapability; import com.raytheon.uf.viz.core.rsc.capabilities.ImagingCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability; import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability;
import com.raytheon.uf.viz.points.PointsDataManager; import com.raytheon.uf.viz.points.PointsDataManager;
import com.raytheon.uf.viz.points.data.Point;
import com.raytheon.uf.viz.xy.map.rsc.IInsetMapResource; import com.raytheon.uf.viz.xy.map.rsc.IInsetMapResource;
import com.raytheon.viz.awipstools.capabilities.RangeRingsOverlayCapability; import com.raytheon.viz.awipstools.capabilities.RangeRingsOverlayCapability;
import com.raytheon.viz.core.graphing.GraphProperties; import com.raytheon.viz.core.graphing.GraphProperties;
@ -68,9 +70,9 @@ import com.vividsolutions.jts.geom.Geometry;
* SOFTWARE HISTORY * SOFTWARE HISTORY
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Mar 16, 2009 askripsk Initial creation * Mar 16, 2009 askripsk Initial creation
* 10-21-09 #1711 bsteffen Updated Baseline and Points to use new ToolsDataManager * 10-21-09 #1711 bsteffen Updated Baseline and Points to use new ToolsDataManager
* * Oct 20, 2014 #3418 dlovely Fixed an NPE with the Points now showing on the inset map.
* *
* </pre> * </pre>
* *
@ -274,16 +276,9 @@ public class RadarGraphResource extends
} }
} }
String selectedPoint = this.resourceData.getPointID();
// Default to Point A if somehow the point wasn't set
if ("".equals(selectedPoint)) {
selectedPoint = "A";
}
// Find the packet that is closest to the selected point // Find the packet that is closest to the selected point
CellTrendDataPacket packet = getNearestCell(selectedPoint, CellTrendDataPacket packet = getNearestCell(
radarRecord.getSymbologyData()); getResourcePointID(), radarRecord.getSymbologyData());
// get the data for each trend code // get the data for each trend code
for (Integer trendCode : packet.getLatestScans().keySet()) { for (Integer trendCode : packet.getLatestScans().keySet()) {
@ -484,27 +479,54 @@ public class RadarGraphResource extends
return sortedTimes; return sortedTimes;
} }
/** This should happen on initialization and cache it maybe */ /**
private Coordinate getMapCoordinate() { * Returns the Point ID for the local Radar Resource Data. The Point ID is
RadarRecord record = getRadarRecord(displayedDate); * verified and if not found a default Point is used.
if (record == null) { *
return null; * @return String Point ID
*/
private String getResourcePointID() {
String selectedPoint = this.resourceData.getPointID();
PointsDataManager manager = PointsDataManager.getInstance();
Collection<String> names = manager.getPointNames();
if (!names.contains(selectedPoint)) {
if (names.contains("A")) {
selectedPoint = "A";
} else {
selectedPoint = (String) names.toArray()[0];
}
} }
return new Coordinate(record.getLongitude(), record.getLatitude(), 0.0);
return selectedPoint;
} }
// This should happen on initialization and cache it maybe
/**
* Returns the coordinate for the currently referenced {@link Point}.
*
* @return Coordinate
*/
private Coordinate getMapCoordinate() {
Point pt = PointsDataManager.getInstance().getPoint(
getResourcePointID());
return new Coordinate(pt.getLongitude(), pt.getLatitude(), 0.0);
}
/** {@inheritDoc} */
@Override @Override
public Geometry getInsetMapLocation() { public Geometry getInsetMapLocation() {
return IInsetMapResource.factory.createPoint(getMapCoordinate()); return IInsetMapResource.factory.createPoint(getMapCoordinate());
} }
/** {@inheritDoc} */
@Override @Override
public void paintInsetMap(IGraphicsTarget target, public void paintInsetMap(IGraphicsTarget target,
PaintProperties paintProps, MapDescriptor insetMapDescriptor) PaintProperties paintProps, MapDescriptor insetMapDescriptor)
throws VizException { throws VizException {
Coordinate latLon = getMapCoordinate(); Coordinate latLon = getMapCoordinate();
double[] pixels = descriptor.worldToPixel(new double[] { latLon.x, double[] pixels = insetMapDescriptor.worldToPixel(new double[] {
latLon.y }); latLon.x, latLon.y });
target.drawPoint(pixels[0], pixels[1], 0.0, target.drawPoint(pixels[0], pixels[1], 0.0,
getCapability(ColorableCapability.class).getColor(), style); getCapability(ColorableCapability.class).getColor(), style);
} }