Issue #2819 Removed more unnecessary .clone() calls

Change-Id: I6924801040b238354527edfd57b4a3999f844617

Former-commit-id: 419e9d0b8d [formerly ce896b573fcef99e30e3bda5f53b0941cd1b2e36]
Former-commit-id: 5258aecf45
This commit is contained in:
Ron Anderson 2014-02-19 11:21:26 -06:00
parent fc5aa71b86
commit 663cb4cb62
13 changed files with 252 additions and 242 deletions

View file

@ -94,6 +94,7 @@ import com.vividsolutions.jts.io.WKBReader;
* polygons in map resource.
* Nov 06, 2013 2361 njensen Prepopulate fields in initInternal
* instead of constructor for speed
* Feb 18, 2014 2819 randerso Removed unnecessary clones of geometries
*
* </pre>
*
@ -279,11 +280,11 @@ public class DbMapResource extends
}
List<String> fields = new ArrayList<String>();
fields.add(GID);
if (req.labelField != null
if ((req.labelField != null)
&& !fields.contains(req.labelField)) {
fields.add(req.labelField);
}
if (req.shadingField != null
if ((req.shadingField != null)
&& !fields.contains(req.shadingField)) {
fields.add(req.shadingField);
}
@ -318,7 +319,7 @@ public class DbMapResource extends
Geometry geom = GeometryCache.getGeometry(table, ""
+ gid, req.geomField);
if (geom != null) {
gidMap.put(gid, (Geometry) geom.clone());
gidMap.put(gid, geom);
} else {
toRequest.add(gid);
}
@ -371,7 +372,7 @@ public class DbMapResource extends
}
gidMap.put(gid, g);
GeometryCache.putGeometry(table, "" + gid,
req.geomField, (Geometry) g.clone());
req.geomField, g);
}
}
@ -411,7 +412,7 @@ public class DbMapResource extends
req.labelField.toLowerCase());
}
if (obj != null && g != null) {
if ((obj != null) && (g != null)) {
String label;
if (obj instanceof BigDecimal) {
label = Double.toString(((Number) obj)
@ -447,8 +448,7 @@ public class DbMapResource extends
} catch (TopologyException e) {
statusHandler.handle(Priority.VERBOSE,
"Invalid geometry cannot be labeled: "
+ label,
e);
+ label, e);
unlabelablePoints.add(label);
}
}
@ -645,12 +645,12 @@ public class DbMapResource extends
String shadingField = getCapability(ShadeableCapability.class)
.getShadingField();
// System.out.println("shadingField: " + shadingField);
boolean isShaded = isPolygonal() && shadingField != null;
boolean isShaded = isPolygonal() && (shadingField != null);
if (simpLev < lastSimpLev
if ((simpLev < lastSimpLev)
|| (isLabeled && !labelField.equals(lastLabelField))
|| (isShaded && !shadingField.equals(lastShadingField))
|| lastExtent == null
|| (lastExtent == null)
|| !lastExtent.getEnvelope().contains(
clipToProjExtent(screenExtent).getEnvelope())) {
if (!paintProps.isZooming()) {
@ -688,20 +688,20 @@ public class DbMapResource extends
float alpha = paintProps.getAlpha();
if (shadedShape != null && shadedShape.isDrawable() && isShaded) {
if ((shadedShape != null) && shadedShape.isDrawable() && isShaded) {
float opacity = getCapability(ShadeableCapability.class)
.getOpacity();
aTarget.drawShadedShape(shadedShape, alpha * opacity);
}
if (outlineShape != null && outlineShape.isDrawable()
if ((outlineShape != null) && outlineShape.isDrawable()
&& getCapability(OutlineCapability.class).isOutlineOn()) {
aTarget.drawWireframeShape(outlineShape,
getCapability(ColorableCapability.class).getColor(),
getCapability(OutlineCapability.class).getOutlineWidth(),
getCapability(OutlineCapability.class).getLineStyle(),
alpha);
} else if (outlineShape == null
} else if ((outlineShape == null)
&& getCapability(OutlineCapability.class).isOutlineOn()) {
issueRefresh();
}
@ -709,7 +709,7 @@ public class DbMapResource extends
double labelMagnification = getCapability(MagnificationCapability.class)
.getMagnification();
if (labels != null && isLabeled && labelMagnification != 0) {
if ((labels != null) && isLabeled && (labelMagnification != 0)) {
if (font == null) {
font = aTarget
.initializeFont(aTarget.getDefaultFont().getFontName(),
@ -737,7 +737,7 @@ public class DbMapResource extends
.getDensity();
double minScreenDistance = Double.MAX_VALUE;
if (density > 0) {
minScreenDistance = screenToWorldRatio * BASE_DENSITY_MULT
minScreenDistance = (screenToWorldRatio * BASE_DENSITY_MULT)
/ density;
}
@ -768,7 +768,7 @@ public class DbMapResource extends
node.location[1]
+ ((node.rect.getHeight() - node.rect.getY()) * screenToWorldRatio));
if (lastLabel != null && lastLabel.equals(node.label)) {
if ((lastLabel != null) && lastLabel.equals(node.label)) {
// check intersection of extents
for (IExtent ext : extents) {
if (ext.intersects(strExtent)) {

View file

@ -113,6 +113,7 @@ import com.vividsolutions.jts.geom.Point;
* Feb 22, 2013 #1641 randerso Moved ID_ATTRIBUTE_NAME to package scope
* Jul 24, 2013 #1907 randerso Fixed sampling when cropped
* Jul 24, 2013 #1908 randerso Update attributes when cropped
* Feb 18, 2014 #2819 randerso Removed unnecessary clones of geometries
*
* </pre>
*

View file

@ -56,6 +56,7 @@ import com.vividsolutions.jts.geom.Point;
* Oct 31, 2012 #1326 randerso Initial creation
* Feb 22, 2013 #1641 randerso Added checks for using ID as label or shading attribute
* Jul 24, 2014 #1908 randerso Removed debug sysouts
* Feb 18, 2014 #2819 randerso Removed unnecessary clones of geometries
*
* </pre>
*
@ -314,7 +315,7 @@ class ReloadJob extends Job {
Geometry g = (Geometry) f.getAttribute(req.geomField);
if (da.isHighlighted()) {
highlightGeoms.add((Geometry) g.clone());
highlightGeoms.add(g);
}
if (req.highlightsOnly) {

View file

@ -173,8 +173,10 @@ import com.vividsolutions.jts.geom.Point;
* Jul 15, 2013 2184 dhladky Remove all HUC's for storage except ALL
* Jul 17, 2013 2197 njensen Improved speed of getName()
* Oct 18, 2013 DR 16151 gzhang Used getAverageValue() for QPF Graph.
* Feb 19, 2014 2819 randerso Removed unnecessary .clone() call
*
* </pre>
*
* @author dhladky
* @version 1.0
*/
@ -1203,8 +1205,8 @@ public class FFMPResource extends
@Override
protected void paintInternal(IGraphicsTarget aTarget,
PaintProperties paintProps) throws VizException {
if (getTimeOrderedKeys() == null || getTimeOrderedKeys().isEmpty()
|| getDomains() == null) {
if ((getTimeOrderedKeys() == null) || getTimeOrderedKeys().isEmpty()
|| (getDomains() == null)) {
return;
}
@ -1252,12 +1254,12 @@ public class FFMPResource extends
if ((drawable != null) && drawable.isDirty()) {
// only need to do the query if extent changed, pfafs may be
// fine
if (!isFirst || queryJob.getState() == Job.NONE) {
if (!isFirst || (queryJob.getState() == Job.NONE)) {
queryJob.request(aTarget, drawable, paintTime);
}
}
if (drawable != null && isFfmpDataToggle()) {
if ((drawable != null) && isFfmpDataToggle()) {
IColormapShadedShapeExtension ext = aTarget
.getExtension(IColormapShadedShapeExtension.class);
ImagingCapability imageCap = getCapability(ImagingCapability.class);
@ -1268,7 +1270,7 @@ public class FFMPResource extends
IColormapShadedShape shape = shadedShapes.getDrawableShape(cwa,
drawable.getShadedHuc());
Map<Object, RGB> colorMap = drawable.getColorMap(cwa);
if (shape != null && colorMap != null) {
if ((shape != null) && (colorMap != null)) {
ext.drawColormapShadedShape(shape, colorMap, alpha,
brightness);
}
@ -1319,7 +1321,7 @@ public class FFMPResource extends
}
// the product string
if (isFfmpDataToggle() && fieldDescString != null) {
if (isFfmpDataToggle() && (fieldDescString != null)) {
paintProductString(aTarget, paintProps);
}
}
@ -1558,7 +1560,7 @@ public class FFMPResource extends
FFMPBasinMetaData metaBasin = monitor.getTemplates(getSiteKey())
.findBasinByLatLon(getSiteKey(), coord.asLatLon());
if (getHuc().equals(FFMPRecord.ALL)
|| centeredAggregationKey != null) {
|| (centeredAggregationKey != null)) {
pfaf = metaBasin.getPfaf();
if (isMaintainLayer) {
pfaf = monitor.getTemplates(getSiteKey())
@ -1826,13 +1828,11 @@ public class FFMPResource extends
List<Float> guids = null;
if ((getQpeRecord() != null)
&& (getGuidanceRecord() != null)) {
qpes = getQpeRecord().getBasinData()
.getAccumValues(pfafs, getTableTime(),
recentTime, getQpeSourceExpiration(),
isRate());
qpes = getQpeRecord().getBasinData().getAccumValues(
pfafs, getTableTime(), recentTime,
getQpeSourceExpiration(), isRate());
guids = getGuidanceRecord()
.getBasinData()
guids = getGuidanceRecord().getBasinData()
.getGuidanceValues(pfafs,
getGuidanceInterpolation(ffgType),
getGuidSourceExpiration(ffgType));
@ -1870,8 +1870,8 @@ public class FFMPResource extends
guid = getGuidanceValue(
(FFMPGuidanceBasin) getGuidanceRecord()
.getBasinData().get(key),
recentTime, ffgType);
.getBasinData().get(key), recentTime,
ffgType);
guid = forceValue(pfafs,
getBasin(key, getField(), recentTime, aggregate),
guid);
@ -1905,14 +1905,12 @@ public class FFMPResource extends
List<Float> qpes = null;
List<Float> guids = null;
if (getQpeRecord() != null) {
qpes = getQpeRecord().getBasinData()
.getAccumValues(pfafs, getTableTime(),
recentTime, getQpeSourceExpiration(),
isRate());
qpes = getQpeRecord().getBasinData().getAccumValues(
pfafs, getTableTime(), recentTime,
getQpeSourceExpiration(), isRate());
}
if (getGuidanceRecord() != null) {
guids = getGuidanceRecord()
.getBasinData()
guids = getGuidanceRecord().getBasinData()
.getGuidanceValues(pfafs,
getGuidanceInterpolation(ffgType),
getGuidSourceExpiration(ffgType));
@ -1947,8 +1945,8 @@ public class FFMPResource extends
getQpeSourceExpiration(), isRate());
guid = getGuidanceValue(
(FFMPGuidanceBasin) getGuidanceRecord()
.getBasinData().get(key),
recentTime, ffgType);
.getBasinData().get(key), recentTime,
ffgType);
ratio = FFMPUtils.getRatioValue(qpe, guid);
}
}
@ -2236,7 +2234,7 @@ public class FFMPResource extends
*/
private void addWorstCase(Long aggPfaf, Date recentTime, Float value) {
FFMPDrawable drawable = drawables.get(new DataTime(recentTime));
if (drawable != null && drawable.worstCaseHash != null) {
if ((drawable != null) && (drawable.worstCaseHash != null)) {
drawable.worstCaseHash.put(aggPfaf, value);
}
}
@ -2761,8 +2759,7 @@ public class FFMPResource extends
try {
Geometry g = geomMap.get(pfaf);
if (g != null) {
jtsCompiler2.handle((Geometry) g.clone(),
basinTraceColor);
jtsCompiler2.handle(g, basinTraceColor);
}
} catch (Exception e) {
@ -2817,8 +2814,7 @@ public class FFMPResource extends
for (Long pfaf : geomMap.keySet()) {
Geometry g = geomMap.get(pfaf);
if (g != null) {
jtsCompiler3
.handle((Geometry) g.clone(), color);
jtsCompiler3.handle(g, color);
}
}
}
@ -2897,7 +2893,7 @@ public class FFMPResource extends
FFMPTime ffmpTime = (FFMPTime) fhce.getSource();
if (ffmpTime.getTime() != time || isSplit != ffmpTime.isSplit()) {
if ((ffmpTime.getTime() != time) || (isSplit != ffmpTime.isSplit())) {
isSplit = ffmpTime.isSplit();
setTime(ffmpTime.getTime());
@ -3157,9 +3153,11 @@ public class FFMPResource extends
getDataKey(), null, oldestRefTime, FFMPRecord.ALL,
basinPfaf);
//Float qpfFloat = qpfBasin.getValue(monitor.getQpfWindow()
//.getBeforeTime(), monitor.getQpfWindow().getAfterTime());
Float qpfFloat = qpfBasin.getAverageValue(monitor.getQpfWindow().getAfterTime(),monitor.getQpfWindow().getBeforeTime() ); // DR 16151
// Float qpfFloat = qpfBasin.getValue(monitor.getQpfWindow()
// .getBeforeTime(), monitor.getQpfWindow().getAfterTime());
Float qpfFloat = qpfBasin.getAverageValue(monitor.getQpfWindow()
.getAfterTime(), monitor.getQpfWindow().getBeforeTime()); // DR
// 16151
fgd.setQpfValue(qpfFloat);
ArrayList<Double> qpfTimes = new ArrayList<Double>();
@ -3407,7 +3405,7 @@ public class FFMPResource extends
synchronized (tableTime) {
Date recentTime = getMostRecentTime();
long time = new Double(recentTime.getTime()
- (TimeUtil.MILLIS_PER_HOUR) * getTime()).longValue();
- ((TimeUtil.MILLIS_PER_HOUR) * getTime())).longValue();
Date date = new Date();
date.setTime(time);
this.tableTime = date;
@ -3570,7 +3568,7 @@ public class FFMPResource extends
* @return ordered dates
*/
public synchronized List<Date> getTimeOrderedKeys() {
if (timeOrderedKeys == null || !toKeysInitialized) {
if ((timeOrderedKeys == null) || !toKeysInitialized) {
toKeysInitialized = true;
// stand alone displays use this
@ -3623,7 +3621,7 @@ public class FFMPResource extends
- getTableTime().getTime();
sliderTime = Math
.floor(4 * (offset.doubleValue() / (TimeUtil.MILLIS_PER_HOUR)) + .25) / 4;
.floor((4 * (offset.doubleValue() / (TimeUtil.MILLIS_PER_HOUR))) + .25) / 4;
// sliderTime = Math.floor(((offset.doubleValue() / (1000 * 3600)) +
// .005) * 100) / 100;
setTime(sliderTime);
@ -4018,7 +4016,7 @@ public class FFMPResource extends
*/
public FFMPDrawable getDrawable(DataTime time) {
FFMPDrawable drawable = null;
if (drawables != null && time != null) {
if ((drawables != null) && (time != null)) {
drawable = drawables.get(time);
}
return drawable;

View file

@ -93,6 +93,7 @@ import com.vividsolutions.jts.geom.LineString;
* Dec 4, 2007 njensen Initial creation
* 02/17/09 njensen Refactored to new rsc architecture
* 02/27/12 14490 kshresth Fixed cross sections not loading as images
* 02/19/2014 2819 randerso Removed unnecessary .clone() call
*
* </pre>
*
@ -179,7 +180,7 @@ public abstract class AbstractCrossSectionResource extends
DataTime time = dataTimes.get(numTimes - 1);
sliceMap.put(time, null);
dataRetrievalJob.times.add(time);
for (int i = 0; i < numTimes - 1; i++) {
for (int i = 0; i < (numTimes - 1); i++) {
time = dataTimes.get(i);
sliceMap.put(time, null);
dataRetrievalJob.times.add(time);
@ -205,7 +206,7 @@ public abstract class AbstractCrossSectionResource extends
IExtent extent = descriptor.getGraph(this).getExtent().clone();
// To be numerically accurate the grid geometry should be 1 grid
// cell larger than the graph
extent.scale(1.0 + 1.0 / GRID_SIZE);
extent.scale(1.0 + (1.0 / GRID_SIZE));
GeneralEnvelope env = new GeneralEnvelope(new double[] {
extent.getMinX(), extent.getMinY() }, new double[] {
extent.getMaxX(), extent.getMaxY() });
@ -283,12 +284,11 @@ public abstract class AbstractCrossSectionResource extends
GRID_SIZE);
// filter below topo
for (int i = 0; i < GRID_SIZE; i++) {
double height = GRID_SIZE
* (graph.getExtent().getMaxY() - topoData[i])
double height = (GRID_SIZE * (graph.getExtent().getMaxY() - topoData[i]))
/ graph.getExtent().getHeight();
for (int j = 0; j < height; j++) {
for (float[] floatArr : floatData) {
floatArr[j * GRID_SIZE + i] = -999999;
floatArr[(j * GRID_SIZE) + i] = -999999;
}
}
}
@ -324,7 +324,7 @@ public abstract class AbstractCrossSectionResource extends
pdoTime = resourceData.getBinOffset().getNormalizedTime(pdoTime);
}
if (dataTimes == null || dataTimes.isEmpty()) {
if ((dataTimes == null) || dataTimes.isEmpty()) {
dataTimes = new ArrayList<DataTime>();
}
adapter.addRecord(pdo);
@ -415,7 +415,7 @@ public abstract class AbstractCrossSectionResource extends
shape = target.createWireframeShape(false, insetMapDescriptor);
JTSCompiler compiler = new JTSCompiler(null, shape,
insetMapDescriptor);
compiler.handle((LineString) line.clone());
compiler.handle(line);
shape.compile();
lines.put(line, shape);
}
@ -437,18 +437,20 @@ public abstract class AbstractCrossSectionResource extends
stnID = resourceData.getMetadataMap().get("location.stationId")
.getConstraintValue();
if (stnID == null)
if (stnID == null) {
stnID = "";
}
}
if (stnID != "") {
if (stnID.contains(",")) { // ID may be formatted point1,point2 to
// define a line
String stn = stnID.replace(",", "-"); // For display, need
// point1-point2
completeName += " " + stn;
} else
} else {
completeName += " " + stnID;
}
}
String parameterName = resourceData.getParameterName();
completeName += " " + parameterName;
if (getCapability(DisplayTypeCapability.class).getDisplayType() == DisplayType.IMAGE) {
@ -464,7 +466,7 @@ public abstract class AbstractCrossSectionResource extends
public String getUnitString() {
String unitString = "?";
if (prefs != null && prefs.getDisplayUnitLabel() != null) {
if ((prefs != null) && (prefs.getDisplayUnitLabel() != null)) {
unitString = prefs.getDisplayUnitLabel();
} else if (adapter.getUnit() == Unit.ONE) {
return "";
@ -477,11 +479,11 @@ public abstract class AbstractCrossSectionResource extends
public Unit<?> getUnit() {
Unit<?> xPrefUnit = prefs == null ? null : prefs.getDisplayUnits();
if (xPrefUnit != null && xPrefUnit != Unit.ONE) {
if ((xPrefUnit != null) && (xPrefUnit != Unit.ONE)) {
return xPrefUnit;
}
Unit<?> xDataUnit = adapter.getUnit();
if (xDataUnit != null && xDataUnit != Unit.ONE) {
if ((xDataUnit != null) && (xDataUnit != Unit.ONE)) {
return xDataUnit;
}
return Unit.ONE;
@ -501,7 +503,7 @@ public abstract class AbstractCrossSectionResource extends
Coordinate[] coords = descriptor.getLine(myTime).getCoordinates();
double totalDistance = 0.0;
for (int j = 0; j < coords.length - 1; j++) {
for (int j = 0; j < (coords.length - 1); j++) {
try {
totalDistance += JTS.orthodromicDistance(coords[j],
coords[j + 1], MapUtil.getLatLonProjection());
@ -550,7 +552,7 @@ public abstract class AbstractCrossSectionResource extends
protected IStatus run(IProgressMonitor monitor) {
DataTime time = null;
while (run && (time = times.poll()) != null) {
while (run && ((time = times.poll()) != null)) {
try {
AbstractCrossSectionResource.this.loadSlice(time);
AbstractCrossSectionResource.this.issueRefresh();

View file

@ -144,7 +144,7 @@ public class GenericGeometryResource extends
OutlineCapability outlineCapability = getCapability(OutlineCapability.class);
// Finally, draw the shape
if (frameData.shape != null && outlineCapability.isOutlineOn()) {
if ((frameData.shape != null) && outlineCapability.isOutlineOn()) {
target.drawWireframeShape(frameData.shape,
getCapability(ColorableCapability.class).getColor(),
outlineCapability.getOutlineWidth(),
@ -215,8 +215,7 @@ public class GenericGeometryResource extends
// add the geometries
for (IGeometryData geometryData : this.resourceData.getData(time)) {
try {
jtsCompiler.handle((Geometry) geometryData.getGeometry()
.clone());
jtsCompiler.handle(geometryData.getGeometry());
} catch (VizException e1) {
statusHandler.handle(UFStatus.Priority.ERROR,
"Failed to handle Geometry "

View file

@ -62,6 +62,7 @@ import com.vividsolutions.jts.geom.MultiPolygon;
* Mar 27, 2008 #1053 randerso Initial creation
* 02/14/2013 #1506 mnash Use the new Python concurrency for QueryScript
* 02/26/2013 #1708 randerso Changed to not evaluate the ref set
* 02/19/2014 #2819 randerso Removed unnecessary .clone() call
*
* </pre>
*
@ -162,8 +163,7 @@ public class GFEReferenceSetResource extends
refData.setGrid(refData.getGrid());
MultiPolygon mp = (MultiPolygon) refData.getPolygons(
CoordinateType.GRID).clone();
MultiPolygon mp = refData.getPolygons(CoordinateType.GRID);
ReferencedGeometry rc = new ReferencedGeometry(mp,
MapUtil.getGridGeometry(refData.getGloc()), Type.GRID_CENTER);
@ -196,12 +196,12 @@ public class GFEReferenceSetResource extends
float alpha = paintProps.getAlpha();
if (shadedShape != null && shadedShape.isDrawable()) {
if ((shadedShape != null) && shadedShape.isDrawable()) {
aTarget.drawShadedShape(shadedShape, alpha);
}
OutlineCapability outlineCapability = getCapability(OutlineCapability.class);
if (outlineCapability.isOutlineOn() && outlineShape != null
if (outlineCapability.isOutlineOn() && (outlineShape != null)
&& outlineShape.isDrawable()) {
aTarget.drawWireframeShape(outlineShape,
getCapability(ColorableCapability.class).getColor(),

View file

@ -102,6 +102,7 @@ import com.vividsolutions.jts.io.WKBReader;
* Apr 10, 2013 #1854 randerso Fix for compatibility with PostGIS 2.0
* May 30, 2013 #2028 randerso Fixed date line issue with map display
* Jul 31, 2013 #2239 randerso Fixed scaling of maps that cross the date line
* Feb 18, 2014 #2819 randerso Removed unnecessary clones of geometries
*
* </pre>
*
@ -277,7 +278,7 @@ public class ZoneSelectorResource extends DbMapResource {
wfoPoints -= existingGeom.getNumPoints();
}
wfoPoints += g.getNumPoints();
wfoGeoms.add((Geometry) g.clone());
wfoGeoms.add(g);
}
ZoneInfo info = req.rsc.getZoneInfo(zoneName);
@ -326,7 +327,7 @@ public class ZoneSelectorResource extends DbMapResource {
ZoneInfo info = req.rsc.getZoneInfo(zoneName);
try {
outlineCompiler.handle((Geometry) g.clone());
outlineCompiler.handle(g);
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
"Error reprojecting map outline", e);
@ -905,7 +906,7 @@ public class ZoneSelectorResource extends DbMapResource {
JTSCompiler shapeCompiler = new JTSCompiler(newShadedShape, null,
descriptor, PointStyle.CROSS);
try {
shapeCompiler.handle((Geometry) g.clone(), color);
shapeCompiler.handle(g, color);
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
"Error computing shaded shape", e);

View file

@ -195,6 +195,7 @@ import com.vividsolutions.jts.io.WKTReader;
* Use A1 hatching behavior when no county passes the inclusion filter.
* 10/29/2013 DR 16734 D. Friedman If redraw-from-hatched-area fails, don't allow the pollygon the be used.
* 12/04/2013 2604 jsanchez Refactored GisUtil.
* 02/19/2014 2819 randerso Removed unnecessary .clone() call
* </pre>
*
* @author mschenke
@ -233,7 +234,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
public GeospatialDataAccessor(GeospatialDataList geoData,
AreaSourceConfiguration areaConfig) {
if (geoData == null || areaConfig == null) {
if ((geoData == null) || (areaConfig == null)) {
throw new IllegalArgumentException(
"GeospatialDataAccessor must not be null");
}
@ -309,11 +310,12 @@ public class WarngenLayer extends AbstractStormTrackResource {
Geometry g2 = g.getGeometryN(n);
if (g != g2) {
String fips = getFips(g2);
if (fips != null)
if (fips != null) {
return fips;
}
}
}
}
return null;
}
@ -413,7 +415,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
*/
@Override
protected IStatus run(IProgressMonitor monitor) {
while (this.warningArea != null && this.warningPolygon != null) {
while ((this.warningArea != null) && (this.warningPolygon != null)) {
Geometry warningArea;
Polygon warningPolygon;
synchronized (polygonUtil) {
@ -443,7 +445,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
hatchedArea = gf.createPolygon(lr, null);
int adjustPolygon_counter = 0;
while (!hatchedArea.isValid()
&& adjustPolygon_counter < 1) {
&& (adjustPolygon_counter < 1)) {
System.out.println("Calling adjustPolygon #"
+ adjustPolygon_counter);
PolygonUtil.adjustPolygon(coords);
@ -457,7 +459,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
adjustPolygon_counter += 1;
}
int counter = 0;
if (!hatchedArea.isValid() && counter < 2) {
if (!hatchedArea.isValid() && (counter < 2)) {
System.out
.println("calling adjustVertex & alterVertexes: loop #"
+ counter);
@ -465,7 +467,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
lr = gf.createLinearRing(coords);
hatchedArea = gf.createPolygon(lr, null);
while (!hatchedArea.isValid()
&& adjustVertex_counter < 5) {
&& (adjustVertex_counter < 5)) {
System.out.println(" Calling adjustVertex #"
+ adjustVertex_counter);
coords = PolygonUtil.adjustVertex(coords);
@ -479,7 +481,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
}
int inner_counter = 0;
System.out.println("");
while (!hatchedArea.isValid() && inner_counter < 5) {
while (!hatchedArea.isValid()
&& (inner_counter < 5)) {
System.out
.println(" Calling alterVertexes #"
+ inner_counter);
@ -531,8 +534,9 @@ public class WarngenLayer extends AbstractStormTrackResource {
break;
}
}
if (!this.haveInput)
if (!this.haveInput) {
return null;
}
hatchedArea = this.hatchedArea;
hatchedWarningArea = this.hatchedWarningArea;
return new Geometry[] { hatchedArea, hatchedWarningArea };
@ -605,13 +609,13 @@ public class WarngenLayer extends AbstractStormTrackResource {
static {
for (int i = 0; i < 128; i++) {
if (i % 32 == 0) {
if ((i % 32) == 0) {
fillPattern[i] = 0x11;
} else if (i % 32 == 1) {
} else if ((i % 32) == 1) {
fillPattern[i] = 0x11;
} else if (i % 32 == 2) {
} else if ((i % 32) == 2) {
fillPattern[i] = 0x11;
} else if (i % 32 == 3) {
} else if ((i % 32) == 3) {
fillPattern[i] = 0x11;
}
}
@ -653,8 +657,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
}
private void setDuration() {
if (getConfiguration() != null
&& getConfiguration().getDefaultDuration() != 0) {
if ((getConfiguration() != null)
&& (getConfiguration().getDefaultDuration() != 0)) {
displayState.duration = getConfiguration().getDefaultDuration();
} else {
displayState.duration = 30;
@ -737,14 +741,14 @@ public class WarngenLayer extends AbstractStormTrackResource {
}
Date now = SimulatedTime.getSystemTime().getTime();
Date then = data.getDate();
if (then == null
|| ((now.getTime() - then.getTime()) / (60 * 1000) > 10)) {
if ((then == null)
|| (((now.getTime() - then.getTime()) / (60 * 1000)) > 10)) {
return false;
}
if (Double.isNaN(data.getMotionDirection())
|| Double.isNaN(data.getMotionSpeed())
|| data.getMotionSpeed() == 0) {
|| (data.getMotionSpeed() == 0)) {
return false;
}
@ -775,7 +779,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
@Override
protected void initInternal(IGraphicsTarget target) throws VizException {
WarngenLayer theOne = getLayerForContainer();
if (theOne != null && theOne != this) {
if ((theOne != null) && (theOne != this)) {
/**
* For multipane containers, warngen should only have a single
* resource shared by all panes, when deserializing you end up with
@ -824,8 +828,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
for (WarngenLayer other : otherwarngens) {
// grab the first layer, unless another layer exists and is
// already intialized
if (layer == null
|| other.getStatus() == ResourceStatus.INITIALIZED) {
if ((layer == null)
|| (other.getStatus() == ResourceStatus.INITIALIZED)) {
layer = other;
}
}
@ -848,13 +852,13 @@ public class WarngenLayer extends AbstractStormTrackResource {
// TODO: Issues with frameCount == 1? Could happen if we update on all
// tilts where we had multiple frames then they went away.
if (displayState.mode == Mode.TRACK && lastMode == Mode.DRAG_ME) {
if (warningAction == null || warningAction == WarningAction.NEW) {
if ((displayState.mode == Mode.TRACK) && (lastMode == Mode.DRAG_ME)) {
if ((warningAction == null) || (warningAction == WarningAction.NEW)) {
// Initialize box
redrawBoxFromTrack();
if (((configuration.isTrackEnabled() == false || configuration
.getPathcastConfig() == null) && this.displayState.displayType != DisplayType.POLY)
|| frameCount == 1) {
if ((((configuration.isTrackEnabled() == false) || (configuration
.getPathcastConfig() == null)) && (this.displayState.displayType != DisplayType.POLY))
|| (frameCount == 1)) {
resetInitialFrame();
}
} else {
@ -863,7 +867,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
}
if (configuration.getEnableDamBreakThreat()
&& displayState.mode == Mode.NONE && lastMode == Mode.NONE) {
&& (displayState.mode == Mode.NONE) && (lastMode == Mode.NONE)) {
resetInitialFrame();
}
@ -910,7 +914,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
double[] in1 = new double[2];
double[] in2 = new double[2];
for (int i = 0; i < c.length - 1; i++) {
for (int i = 0; i < (c.length - 1); i++) {
in1[0] = c[i].x;
in1[1] = c[i].y;
in2[0] = c[i + 1].x;
@ -966,7 +970,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
double minY = paintProps.getView().getExtent().getMinY() + boundary;
double maxY = paintProps.getView().getExtent().getMaxY() - boundary;
List<DrawableString> strings = new ArrayList<DrawableString>();
if (state.strings != null && state.strings.size() > 0) {
if ((state.strings != null) && (state.strings.size() > 0)) {
Iterator<Coordinate> coords = state.strings.keySet().iterator();
double[] in = new double[3];
while (coords.hasNext()) {
@ -996,7 +1000,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
if (false) {
// set to true for debug and drawing coordinate order
Coordinate[] coords = state.getWarningPolygon().getCoordinates();
for (int i = 0; i < coords.length - 1; ++i) {
for (int i = 0; i < (coords.length - 1); ++i) {
double[] out = descriptor.worldToPixel(new double[] {
coords[i].x, coords[i].y });
DrawableString string = new DrawableString("" + i, textColor);
@ -1025,9 +1029,9 @@ public class WarngenLayer extends AbstractStormTrackResource {
}
if (config != null) {
init(config);
displayState.setInitiallyMotionless(this.configuration
.isTrackEnabled() == false
|| this.configuration.getPathcastConfig() == null);
displayState.setInitiallyMotionless((this.configuration
.isTrackEnabled() == false)
|| (this.configuration.getPathcastConfig() == null));
}
}
@ -1147,8 +1151,9 @@ public class WarngenLayer extends AbstractStormTrackResource {
GridSpacing gridSpacing = dialogConfig.getGridSpacing();
if (gridSpacing != null && gridSpacing.getNx() != null
&& gridSpacing != null) {
if ((gridSpacing != null)
&& (gridSpacing.getNx() != null)
&& (gridSpacing != null)) {
nx = gridSpacing.getNx();
ny = gridSpacing.getNy();
keepAspectRatio = gridSpacing.isKeepAspectRatio();
@ -1268,7 +1273,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
public String getLocalizedSite() {
String site = "";
if (backupSite == null || "".equals(backupSite)) {
if ((backupSite == null) || "".equals(backupSite)) {
site = LocalizationManager.getInstance().getCurrentSite();
} else {
site = backupSite;
@ -1306,8 +1311,9 @@ public class WarngenLayer extends AbstractStormTrackResource {
state.setOldWarningPolygon((Polygon) record.getGeometry().clone());
Geometry oldArea = getWarningAreaFromPolygon(
state.getOldWarningPolygon(), record);
if (oldArea.getUserData() instanceof Set)
if (oldArea.getUserData() instanceof Set) {
state.setFipsOutsidePolygon((Set<String>) oldArea.getUserData());
}
state.setOldWarningArea(oldArea);
} else {
state.setOldWarningArea(null);
@ -1399,7 +1405,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
for (Map.Entry<String, GeospatialDataList> entry : siteMap
.entrySet()) {
String[] keyParts = entry.getKey().split("\\.");
if (keyParts.length == 2
if ((keyParts.length == 2)
&& "county".equalsIgnoreCase(keyParts[0])
&& getLocalizedSite().equals(keyParts[1])) {
return entry.getValue();
@ -1519,8 +1525,9 @@ public class WarngenLayer extends AbstractStormTrackResource {
Geometry result = area.getFactory().createGeometryCollection(
newList.toArray(new Geometry[newList.size()]));
if (fipsOutsidePolygon != null)
if (fipsOutsidePolygon != null) {
result.setUserData(fipsOutsidePolygon);
}
return result;
}
@ -1541,7 +1548,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
* Create the WarnGen dialog if it has not been created.
*/
public void createDialog() {
if (dialog == null || dialog.isDisposed() == true) {
if ((dialog == null) || (dialog.isDisposed() == true)) {
dialog = new WarngenDialog(PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getShell(), this);
dialog.open();
@ -1560,7 +1567,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
* Show the WarnGen dialog and move it to the front.
*/
public void showDialog(boolean show) {
if (dialog != null && dialog.isDisposed() == false) {
if ((dialog != null) && (dialog.isDisposed() == false)) {
dialog.showDialog(show);
}
}
@ -1588,9 +1595,9 @@ public class WarngenLayer extends AbstractStormTrackResource {
Geometry warningArea = state.getWarningArea();
Geometry warningPolygon = state.getWarningPolygon();
Geometry newWarningArea = createWarnedArea(
latLonToLocal((snapHatchedAreaToPolygon || warningArea == null) ? warningPolygon
latLonToLocal((snapHatchedAreaToPolygon || (warningArea == null)) ? warningPolygon
: warningArea), preservedSelection
&& warningArea != null ? latLonToLocal(warningArea)
&& (warningArea != null) ? latLonToLocal(warningArea)
: null);
updateWarnedAreaState(newWarningArea, snapHatchedAreaToPolygon);
@ -1647,8 +1654,9 @@ public class WarngenLayer extends AbstractStormTrackResource {
Set<String> selectedFips = null;
List<Geometry> selectedGeoms = null;
if (preservedSelection != null)
if (preservedSelection != null) {
selectedFips = getAllFipsInArea(preservedSelection);
}
// Loop through each of our counties returned from the query
for (GeospatialData f : geoData.features) {
@ -1665,7 +1673,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
oldWarningArea);
}
if (intersection.isEmpty()) {
if (selectedFips == null
if ((selectedFips == null)
|| !selectedFips.contains(getFips(f))) {
continue;
} else if (!selectedFips.isEmpty()) {
@ -1713,7 +1721,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
useFilteredArea = useFilteredArea || passed;
include = (passed || filterAreaSecondChance(f,
intersection, true))
&& (oldWarningPolygon == null
&& ((oldWarningPolygon == null)
|| prepGeom.intersects(oldWarningPolygon) || isOldAreaOutsidePolygon(f));
newUnfilteredArea = union(newUnfilteredArea, intersection);
}
@ -1730,18 +1738,19 @@ public class WarngenLayer extends AbstractStormTrackResource {
}
}
newHatchedArea = useFilteredArea && newHatchedArea != null ? newHatchedArea
newHatchedArea = useFilteredArea && (newHatchedArea != null) ? newHatchedArea
: useFallback ? newUnfilteredArea : null;
return newHatchedArea != null ? newHatchedArea : new GeometryFactory()
.createGeometryCollection(new Geometry[0]);
}
private static Geometry union(Geometry a, Geometry b) {
if (a != null && b != null)
if ((a != null) && (b != null)) {
return GeometryUtil.union(a, b);
else
} else {
return a != null ? a : b;
}
}
private void updateWarnedAreaState(Geometry newHatchedArea,
boolean snapToHatchedArea) throws VizException {
@ -1763,7 +1772,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
dialog.setInstructions();
}
});
if (!state.isMarked() || oldWarningArea == null) {
if (!state.isMarked() || (oldWarningArea == null)) {
return;
}
}
@ -1783,13 +1792,13 @@ public class WarngenLayer extends AbstractStormTrackResource {
e);
areaPercent = 100;
}
if (oldWarningPolygon.intersects(warningPolygon) == false
if ((oldWarningPolygon.intersects(warningPolygon) == false)
&& !state.isMarked()) {
// Snap back to polygon
state.setWarningPolygon(localToLatLon((Polygon) oldWarningPolygon));
newHatchedArea = (Geometry) oldWarningArea.clone();
} else if (oldWarningPolygon.intersects(warningPolygon) == false
&& areaPercent < 10 && state.isMarked()) {
} else if ((oldWarningPolygon.intersects(warningPolygon) == false)
&& (areaPercent < 10) && state.isMarked()) {
// snap back to last valid user selected area
state.setWarningPolygon((Polygon) state
.getMarkedWarningPolygon().clone());
@ -1836,31 +1845,33 @@ public class WarngenLayer extends AbstractStormTrackResource {
break;
}
}
if (flag)
if (flag) {
areas.add(area);
}
}
}
newHatchedArea = GeometryUtil.union(areas
.toArray(new Geometry[0]));
}
}
}
if (newHatchedArea == null || newHatchedArea.isEmpty()) {
if ((newHatchedArea == null) || newHatchedArea.isEmpty()) {
boolean initialWarning = false;
String[] followUps = this.getConfiguration().getFollowUps();
if (followUps.length == 0)
if (followUps.length == 0) {
initialWarning = true;
else
} else {
for (String followup : followUps) {
if (followup.equals("NEW")) {
initialWarning = true;
break;
}
}
if (initialWarning)
}
if (initialWarning) {
state.clear2(); // not to hatch polygon for initial warning
else {
} else {
// Snap back for follow-ups
state.setWarningPolygon((Polygon) state
.getMarkedWarningPolygon().clone());
@ -1954,8 +1965,9 @@ public class WarngenLayer extends AbstractStormTrackResource {
* more permissive, this test is not really necessary.
*/
Geometry oldWarningArea = state.getOldWarningArea();
if (localCRS)
if (localCRS) {
oldWarningArea = latLonToLocal(oldWarningArea);
}
List<Geometry> geoms = new ArrayList<Geometry>();
GeometryUtil.buildGeometryList(geoms, oldWarningArea);
Geometry oldSelectedArea = null;
@ -1977,7 +1989,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
* possible loss of precision in all of the calculations, we
* allow >= 0.999.
*/
return ratioOfOldArea >= .999
return (ratioOfOldArea >= .999)
&& !filterCheck(oldSelectedArea, geom, areaOfGeom);
}
}
@ -1986,8 +1998,9 @@ public class WarngenLayer extends AbstractStormTrackResource {
private boolean isOldAreaOutsidePolygon(GeospatialData f) {
Set<String> fipsOutsidePolygon = state.getFipsOutsidePolygon();
if (fipsOutsidePolygon != null)
if (fipsOutsidePolygon != null) {
return fipsOutsidePolygon.contains(getFips(f));
}
return false;
}
@ -2003,7 +2016,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
if (poly != null) {
JTSCompiler comp = new JTSCompiler(shadedCoveredArea, null,
descriptor);
comp.handle((Geometry) state.getWarningArea().clone(),
comp.handle(state.getWarningArea(),
getCapability(ColorableCapability.class).getColor());
hasDrawnShaded = true;
} else {
@ -2048,11 +2061,11 @@ public class WarngenLayer extends AbstractStormTrackResource {
if (displayState.mode == Mode.DRAG_ME) {
return;
}
if (warningAction == null || warningAction == WarningAction.NEW) {
if ((configuration.isTrackEnabled() == false || configuration
.getPathcastConfig() == null)
if ((warningAction == null) || (warningAction == WarningAction.NEW)) {
if (((configuration.isTrackEnabled() == false) || (configuration
.getPathcastConfig() == null))
&& !this.displayState.isNonstationary()
&& this.displayState.displayType != DisplayType.POLY) {
&& (this.displayState.displayType != DisplayType.POLY)) {
createSquare();
return;
} else if (descriptor.getFramesInfo().getFrameCount() == 1) {
@ -2118,7 +2131,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
end = new Coordinate(point.getX(), point.getY());
}
if (start == null || end == null) {
if ((start == null) || (end == null)) {
return;
}
@ -2132,7 +2145,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
gc.setStartingGeographicPoint(start.x, start.y);
gc.setDestinationGeographicPoint(end.x, end.y);
double farDistance = displayState.futurePoints != null ? gc
.getOrthodromicDistance() + shortDistance * 1.8
.getOrthodromicDistance() + (shortDistance * 1.8)
: shortDistance;
double angle = displayState.angle;
Point2D startPoint = null;
@ -2156,7 +2169,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
.getDestinationGeographicPoint());
gc.setDirection(adjustAngle(gc2.getAzimuth() - 180),
shortDistance * factor);
} else if (i == size - 1) {
} else if (i == (size - 1)) {
gc2.setStartingGeographicPoint(coord.x, coord.y);
gc2.setDestinationGeographicPoint(coords[i - 1].x,
coords[i - 1].y);
@ -2188,7 +2201,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
.getDestinationGeographicPoint());
gc.setDirection(adjustAngle(gc2.getAzimuth() - 180),
shortDistance);
} else if (i == size - 1) {
} else if (i == (size - 1)) {
gc2.setStartingGeographicPoint(coord.x, coord.y);
gc2.setDestinationGeographicPoint(coords[i - 1].x,
coords[i - 1].y);
@ -2227,8 +2240,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
double dist2 = 11000;
final double hyp1 = Math.sqrt(d1 * d1 + dist1 * dist1);
final double hyp2 = Math.sqrt(d2 * d2 + dist2 * dist2);
final double hyp1 = Math.sqrt((d1 * d1) + (dist1 * dist1));
final double hyp2 = Math.sqrt((d2 * d2) + (dist2 * dist2));
double ang1 = 90 + Math.toDegrees(Math.atan(dist1 / d1));
double ang2 = Math.toDegrees(Math.atan(d2 / dist2));
@ -2271,7 +2284,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
public boolean redrawBoxFromHatched() {
boolean result = true;
if (state.snappedToArea == false) {
if (state.getWarningArea() == null
if ((state.getWarningArea() == null)
|| state.getWarningArea().isEmpty()) {
return true;
}
@ -2287,9 +2300,10 @@ public class WarngenLayer extends AbstractStormTrackResource {
warningAreaChanged();
areas = areaHatcher.getHatchedAreas();
// If still null, give up.
if (areas == null)
if (areas == null) {
return false;
}
}
hatched = (Polygon) areas[0];
hatchedArea = areas[1];
}
@ -2421,8 +2435,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
}
Point point = displayState.dragMePoint;
if (motdir != null && motspd != null
&& (motspd != 0 || configuration.isTrackEnabled())) {
if ((motdir != null) && (motspd != null)
&& ((motspd != 0) || configuration.isTrackEnabled())) {
displayState.setInitiallyMotionless(false);
displayState.angle = adjustAngle(motdir);
displayState.speed = knotToMeterPerSec.convert(motspd);
@ -2475,9 +2489,10 @@ public class WarngenLayer extends AbstractStormTrackResource {
if (m.find()) {
int hour = Integer.parseInt(m.group(1));
int minute = Integer.parseInt(m.group(2));
frameTime = TimeUtil.timeOfDayToAbsoluteTime(hour
* TimeUtil.SECONDS_PER_HOUR + minute
* TimeUtil.SECONDS_PER_MINUTE, warnRecord.getIssueTime());
frameTime = TimeUtil.timeOfDayToAbsoluteTime(
(hour * TimeUtil.SECONDS_PER_HOUR)
+ (minute * TimeUtil.SECONDS_PER_MINUTE),
warnRecord.getIssueTime());
} else {
frameTime = warnRecord.getIssueTime();
}
@ -2525,7 +2540,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
FramesInfo info = descriptor.getFramesInfo();
int currentFrame = trackUtil.getCurrentFrame(info);
int frameCount = trackUtil.getFrameCount(info);
if (currentFrame == frameCount - 1 || !displayState.isNonstationary()) {
if ((currentFrame == (frameCount - 1))
|| !displayState.isNonstationary()) {
return coordinate;
}
DataTime[] datatimes = trackUtil.getDataTimes(info);
@ -2549,17 +2565,18 @@ public class WarngenLayer extends AbstractStormTrackResource {
case POINT:
cc = new Coordinate[] { stormTrackState.futurePoints == null ? stormTrackState.dragMePoint
.getCoordinate() : stormTrackState.futurePoints[0].coord };
if (warningAction == null || warningAction == WarningAction.NEW
|| warningAction == WarningAction.CON
|| warningAction == WarningAction.CAN) {
if ((warningAction == null) || (warningAction == WarningAction.NEW)
|| (warningAction == WarningAction.CON)
|| (warningAction == WarningAction.CAN)) {
Coordinate coord = new Coordinate(
stormTrackState.dragMePoint.getCoordinate());
DataTime currentDataTime = new DataTime(SimulatedTime
.getSystemTime().getTime());
if (stormTrackState.compuateCurrentStormCenter(coord,
currentDataTime))
currentDataTime)) {
cc = new Coordinate[] { coord };
}
}
break;
case POLY:
Coordinate[] polyPoints = stormTrackState.dragMeLine
@ -2616,7 +2633,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
IDisplayPaneContainer container = getResourceContainer();
Coordinate[] coords = warningPolygon.getExteriorRing().getCoordinates();
if (vertexId >= coords.length || vertexId < 0) {
if ((vertexId >= coords.length) || (vertexId < 0)) {
return vertexId;
}
int rval = vertexId;
@ -2635,8 +2652,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
}
double[] a = container.translateInverseClick(coords[i]);
double distance = new Coordinate(a[0], a[1]).distance(vc);
if (distance < 5
&& !((i == coords.length - 1 && vertexId == 0) || (i == 0 && vertexId == coords.length - 1))) {
if ((distance < 5)
&& !(((i == (coords.length - 1)) && (vertexId == 0)) || ((i == 0) && (vertexId == (coords.length - 1))))) {
delete = i;
}
}
@ -2644,20 +2661,20 @@ public class WarngenLayer extends AbstractStormTrackResource {
coords[vertexId] = newCoord;
if (vertexId == 0) {
coords[coords.length - 1] = newCoord;
} else if (vertexId == coords.length - 1) {
} else if (vertexId == (coords.length - 1)) {
coords[0] = newCoord;
}
if (deleteSameVertex && delete != -1 && coords.length > 4) {
if (deleteSameVertex && (delete != -1) && (coords.length > 4)) {
setModifiedVertexNeedsToBeUpdated(true);
Coordinate[] newCoords = new Coordinate[coords.length - 1];
int ctr = 0;
if (delete == 0 || delete == coords.length - 1) {
for (int i = 1; i < coords.length - 1; i++) {
if ((delete == 0) || (delete == (coords.length - 1))) {
for (int i = 1; i < (coords.length - 1); i++) {
newCoords[ctr++] = coords[i];
}
newCoords[newCoords.length - 1] = newCoords[0];
} else {
for (int i = 0; i < coords.length - 1; i++) {
for (int i = 0; i < (coords.length - 1); i++) {
if (i != delete) {
newCoords[ctr++] = coords[i];
}
@ -2681,18 +2698,18 @@ public class WarngenLayer extends AbstractStormTrackResource {
LineSegment[] ls = new LineSegment[coords.length - 1];
for (int i = 0; i < coords.length - 1; i++) {
for (int i = 0; i < (coords.length - 1); i++) {
ls[i] = new LineSegment(coords[i], coords[i + 1]);
}
boolean intersectFlag = false;
for (int i = 0; i < ls.length; i++) {
for (int j = 0; j < ls.length; j++) {
if (i != j
&& ls[i].intersection(ls[j]) != null
&& ls[i].intersection(ls[j]).equals(
ls[i].getCoordinate(0)) == false
&& ls[i].intersection(ls[j]).equals(
ls[i].getCoordinate(1)) == false) {
if ((i != j)
&& (ls[i].intersection(ls[j]) != null)
&& (ls[i].intersection(ls[j]).equals(
ls[i].getCoordinate(0)) == false)
&& (ls[i].intersection(ls[j]).equals(
ls[i].getCoordinate(1)) == false)) {
intersectFlag = true;
}
}
@ -2713,9 +2730,9 @@ public class WarngenLayer extends AbstractStormTrackResource {
AbstractWarningRecord warnRec = cw.getNewestByTracking(data.getEtn(),
data.getPhen() + "." + data.getSig());
if (warnRec == null
|| GisUtil.equivalent(warnRec.getGeometry(),
state.getWarningPolygon()) == false) {
if ((warnRec == null)
|| (GisUtil.equivalent(warnRec.getGeometry(),
state.getWarningPolygon()) == false)) {
return true;
}
@ -2762,7 +2779,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
coords = (Coordinate[]) newArray;
coords[coords.length - 1] = coords[0];
}
for (int i = 0; i < coords.length - 1; i++) {
for (int i = 0; i < (coords.length - 1); i++) {
coords[i].x += delta.x;
coords[i].y += delta.y;
coords[i].z += delta.z;
@ -2787,7 +2804,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
super.addContextMenuItems(menuManager, x, y);
menuManager.add(manager.getSelectLocationAction());
if (displayState.mode == Mode.DRAG_ME || !boxEditable) {
if ((displayState.mode == Mode.DRAG_ME) || !boxEditable) {
return;
}
@ -2840,7 +2857,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
Geometry tmp = removeCounty(warningArea, getFips(f));
if (tmp.isEmpty()) {
String fip = getFips(f);
if (fip != null && uniqueFip != null
if ((fip != null) && (uniqueFip != null)
&& fip.equals(uniqueFip)) {
updateWarnedAreas(true);
}
@ -2855,8 +2872,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
if (oldWarningArea != null) {
// for a CON, prevents extra areas to be added
Set<String> fipsIds = getAllFipsInArea(oldWarningArea);
if (fipsIds.contains(featureFips) == false
|| !(oldWarningPolygon.contains(point) == true || isOldAreaOutsidePolygon(f))) {
if ((fipsIds.contains(featureFips) == false)
|| !((oldWarningPolygon.contains(point) == true) || isOldAreaOutsidePolygon(f))) {
break;
}
}
@ -2900,8 +2917,9 @@ public class WarngenLayer extends AbstractStormTrackResource {
private Geometry filterWarningArea(Geometry warningArea) {
// TODO: Duplicates logic in createWarnedArea
if (warningArea == null)
if (warningArea == null) {
return null;
}
/*
* Note: Currently does not determine if warningArea is valid (i.e., in
* contained in CWA, old warning area, etc.) or has overlapping
@ -2920,12 +2938,13 @@ public class WarngenLayer extends AbstractStormTrackResource {
boolean passed = filterArea(f, warningAreaForFeature, false);
useFilteredArea = useFilteredArea || passed;
if (passed
|| filterAreaSecondChance(f, warningAreaForFeature, false))
|| filterAreaSecondChance(f, warningAreaForFeature, false)) {
newHatchedArea = union(newHatchedArea, warningAreaForFeature);
}
newUnfilteredArea = union(newUnfilteredArea, warningAreaForFeature);
}
newHatchedArea = useFilteredArea && newHatchedArea != null ? newHatchedArea
newHatchedArea = useFilteredArea && (newHatchedArea != null) ? newHatchedArea
: useFallback ? newUnfilteredArea : null;
return newHatchedArea != null ? newHatchedArea : new GeometryFactory()
@ -2964,12 +2983,12 @@ public class WarngenLayer extends AbstractStormTrackResource {
Polygon newPolygon = null;
if (g instanceof Polygon) {
newPolygon = (Polygon) g;
} else if (g instanceof GeometryCollection
&& g.getNumGeometries() == 1
&& g.getGeometryN(0) instanceof Polygon) {
} else if ((g instanceof GeometryCollection)
&& (g.getNumGeometries() == 1)
&& (g.getGeometryN(0) instanceof Polygon)) {
newPolygon = (Polygon) g.getGeometryN(0);
}
if (newPolygon != null && newPolygon.isValid()) {
if ((newPolygon != null) && newPolygon.isValid()) {
polygon = newPolygon;
}
} catch (TopologyException e) {
@ -3001,8 +3020,9 @@ public class WarngenLayer extends AbstractStormTrackResource {
private Geometry removeCounties(Geometry warningArea,
Set<String> fipsToRemove) {
if (fipsToRemove == null || fipsToRemove.isEmpty())
if ((fipsToRemove == null) || fipsToRemove.isEmpty()) {
return warningArea;
}
List<Geometry> toKeep = new ArrayList<Geometry>(
warningArea.getNumGeometries());
for (int n = 0; n < warningArea.getNumGeometries(); ++n) {
@ -3057,10 +3077,10 @@ public class WarngenLayer extends AbstractStormTrackResource {
if (s == null) {
// invalid follow up selection
continue;
} else if (f != null && f.equals(s)) {
} else if ((f != null) && f.equals(s)) {
// follow up already featured
continue;
} else if (prev != null && s.equals(prev)) {
} else if ((prev != null) && s.equals(prev)) {
// geometry for this warning has already been tested
continue;
}
@ -3069,7 +3089,7 @@ public class WarngenLayer extends AbstractStormTrackResource {
getLocalizedSite()).getNewestByTracking(s.getEtn(),
s.getPhen() + "." + s.getSig());
GeometryFactory gf = new GeometryFactory();
if (featuredWarning != null
if ((featuredWarning != null)
&& featuredWarning.getGeometry().contains(
gf.createPoint(c))) {
if (isPolygonLocked()) {
@ -3083,13 +3103,13 @@ public class WarngenLayer extends AbstractStormTrackResource {
}
}
if (w == null || w.getGeometry() == null) {
if ((w == null) || (w.getGeometry() == null)) {
continue;
}
// check if mouse click is near the polygon
Coordinate[] coords = w.getGeometry().getCoordinates();
for (int i = 0; i < coords.length - 1; i++) {
for (int i = 0; i < (coords.length - 1); i++) {
LineSegment segment = new LineSegment(coords[i],
coords[i + 1]);
double dist = segment.distance(c);
@ -3134,8 +3154,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
@Override
public void resourceChanged(ChangeType type, Object object) {
super.resourceChanged(type, object);
if (type == ChangeType.CAPABILITY
&& object instanceof EditableCapability) {
if ((type == ChangeType.CAPABILITY)
&& (object instanceof EditableCapability)) {
if (dialog != null) {
final boolean editable = isEditable();
boxEditable = editable;
@ -3145,8 +3165,8 @@ public class WarngenLayer extends AbstractStormTrackResource {
dialog.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (dlg.isDisposed() == false
&& dlg.getShell().isVisible() != editable) {
if ((dlg.isDisposed() == false)
&& (dlg.getShell().isVisible() != editable)) {
dlg.showDialog(editable);
}
}
@ -3219,8 +3239,9 @@ public class WarngenLayer extends AbstractStormTrackResource {
*/
private Set<String> removeDuplicateGid(Set<String> prefixes) {
if (prefixes.size() < 2)
if (prefixes.size() < 2) {
return prefixes;
}
Map<String, Double> fipsSize = new HashMap<String, Double>();
Map<String, String> namePrefix = new HashMap<String, String>();

View file

@ -62,6 +62,7 @@ import com.vividsolutions.jts.geom.Geometry;
* Removed no longer needed frameAltered. Do not set wire frame for a CAN.
* Jul 24, 2013 DR16350 mgamazaychikov Fix the problem with plotting EXP warning
* Sep 5, 2013 2176 jsanchez Disposed the emergency font.
* Feb 19, 2014 2819 randerso Removed unnecessary .clone() call
* </pre>
*
* @author jsanchez
@ -116,7 +117,7 @@ public class WarningsResource extends AbstractWWAResource {
protected void initInternal(IGraphicsTarget target) throws VizException {
FramesInfo info = descriptor.getFramesInfo();
DataTime[] times = info.getFrameTimes();
if (times != null && times.length > 0) {
if ((times != null) && (times.length > 0)) {
// Request data for "earliest" time
requestData(times[0]);
}
@ -165,9 +166,9 @@ public class WarningsResource extends AbstractWWAResource {
}
}
} else if (type == ChangeType.CAPABILITY) {
if (color != null
&& color.equals(getCapability((ColorableCapability.class))
.getColor()) == false) {
if ((color != null)
&& (color.equals(getCapability((ColorableCapability.class))
.getColor()) == false)) {
color = getCapability((ColorableCapability.class)).getColor();
// TODO this needs to be fixed to work with watches which are
@ -212,7 +213,7 @@ public class WarningsResource extends AbstractWWAResource {
// Do not paint a wire frame shape for a CAN
if (act != WarningAction.CAN) {
wfs = target.createWireframeShape(false, descriptor);
geo = (Geometry) record.getGeometry().clone();
geo = record.getGeometry();
JTSCompiler jtsCompiler = new JTSCompiler(null, wfs,
descriptor);
@ -238,8 +239,8 @@ public class WarningsResource extends AbstractWWAResource {
DataTime[] frames = info.getFrameTimes();
for (AbstractWarningRecord warnrec : recordsToLoad) {
WarningAction act = WarningAction.valueOf(warnrec.getAct());
if (act == WarningAction.CON || act == WarningAction.CAN
|| act == WarningAction.EXT) {
if ((act == WarningAction.CON) || (act == WarningAction.CAN)
|| (act == WarningAction.EXT)) {
AbstractWarningRecord createShape = null;
for (String key : entryMap.keySet()) {
WarningEntry entry = entryMap.get(key);
@ -274,8 +275,8 @@ public class WarningsResource extends AbstractWWAResource {
// if it's a con, need to have a new entry for a
// new
// polygon
if (act == WarningAction.CON
|| act == WarningAction.EXT) {
if ((act == WarningAction.CON)
|| (act == WarningAction.EXT)) {
createShape = warnrec;
}
} else if ((entry.altered && entry.partialCancel)) {

View file

@ -52,6 +52,7 @@ import com.vividsolutions.jts.geom.GeometryFactory;
* Sep 5, 2013 2176 jsanchez Disposed the emergency font.
* Nov 8, 2013 16758 mgamazaychikov Changed access modifier of mergeWatches to protected
* so a child class can override the implementation.
* Feb 19, 2014 2819 randerso Removed unnecessary .clone() call
* </pre>
*
* @author jsanchez
@ -196,7 +197,7 @@ public class WatchesResource extends AbstractWWAResource {
if ((record.getGeometry() != null) && (record.getPhen() != null)) {
IShadedShape ss = target.createShadedShape(false,
descriptor.getGridGeometry(), false);
geo = (Geometry) record.getGeometry().clone();
geo = record.getGeometry();
JTSCompiler jtsCompiler = new JTSCompiler(ss, null,
this.descriptor, PointStyle.CROSS);
jtsCompiler.handle(geo, color);

View file

@ -20,11 +20,14 @@
package com.raytheon.uf.common.geospatial;
import org.geotools.coverage.grid.GeneralGridGeometry;
import org.geotools.geometry.jts.CoordinateSequenceTransformer;
import org.geotools.geometry.jts.DefaultCoordinateSequenceTransformer;
import org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.impl.PackedCoordinateSequenceFactory;
/**
* Represents a coordinate in any reference system
@ -35,6 +38,7 @@ import com.vividsolutions.jts.geom.Geometry;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 29, 2008 chammack Initial creation
* Feb 18, 2014 #2819 randerso Made transform non-destructive
*
* </pre>
*
@ -94,33 +98,13 @@ public class ReferencedGeometry extends ReferencedObject<Geometry> {
*/
@Override
protected Geometry transform(MathTransform mt) throws TransformException {
// The following appears to be very slow due to object creation:
// return JTS.transform(this.internalCoordinate, mt);
CoordinateSequenceTransformer t1 = new DefaultCoordinateSequenceTransformer(
PackedCoordinateSequenceFactory.DOUBLE_FACTORY);
final GeometryCoordinateSequenceTransformer transformer = new GeometryCoordinateSequenceTransformer(
t1);
transformer.setMathTransform(mt);
// Faster, but destructive version:
Coordinate[] coords = this.internalObject.getCoordinates();
int size = coords.length * 2;
double[] out = new double[size];
double[] in = new double[size];
int index = 0;
for (int i = 0; i < coords.length; i++) {
in[index++] = coords[i].x;
in[index++] = coords[i].y;
}
try {
mt.transform(in, 0, out, 0, coords.length);
index = 0;
for (int i = 0; i < coords.length; i++) {
coords[i].x = out[index++];
coords[i].y = out[index++];
}
} catch (Exception e) {
e.printStackTrace();
}
return this.internalObject;
return transformer.transform(this.internalObject);
}
}

View file

@ -140,6 +140,7 @@ import com.vividsolutions.jts.operation.distance.DistanceOp;
* this class
* 11/13 TTR 752 J. Wu added methods to compute an element's range record.
* 12/13 #1089 B. Yin Modify watch to display county list
* 02/14 #2819 R. Anderson Removed unnecessary .clone() call
* </pre>
*
* @author sgilbert
@ -697,7 +698,7 @@ public class DisplayElementFactory {
null, iDescriptor, PointStyle.CROSS);
try {
compiler.handle((Geometry) cntyUnion.clone(),
compiler.handle(cntyUnion,
new RGB(colors[1].getRed(), colors[1].getGreen(), colors[1].getBlue()));
if ( elem.getFillPattern() != FillPattern.TRANSPARENCY &&