Merge "Omaha #3397 resource cleanup related to wireframe shape api changes" into omaha_14.4.1

Former-commit-id: 0467df2764 [formerly 994afa5de9cc99489193f265652c4a27f16ca82b]
Former-commit-id: c1f24417e4
This commit is contained in:
Nate Jensen 2014-07-28 15:59:45 -05:00 committed by Gerrit Code Review
commit 83fa679203
2 changed files with 17 additions and 44 deletions

View file

@ -40,7 +40,6 @@ import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
import com.raytheon.uf.viz.core.IView;
import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.datastructure.WireframeCache;
import com.raytheon.uf.viz.core.drawables.IFont;
@ -71,6 +70,8 @@ import com.vividsolutions.jts.geom.Coordinate;
* 1/10/08 562 bphillip Modified to handle .bcx files
* 02/11/09 njensen Refactored to new rsc architecture
* 07/31/12 DR 14935 D. Friedman Handle little-endian files
* Jul 28, 2014 3397 bclement switched to non deprecated version of createWireframeShape()
* now closes on FileInputStream instead of FileChannel in initInternal()
*
* </pre>
*
@ -153,7 +154,7 @@ public class BCDResource extends
@Override
protected void initInternal(IGraphicsTarget target) throws VizException {
super.initInternal(target);
FileChannel fc = null;
FileInputStream fis = null;
try {
if (this.resourceData.getFilename().endsWith("bcx")) {
@ -167,14 +168,7 @@ public class BCDResource extends
this.gridGeometry = descriptor.getGridGeometry();
wireframeShape = target.createWireframeShape(true, descriptor,
0.0f, true, new PixelExtent(descriptor
.getGridGeometry().getGridRange().getLow(0),
descriptor.getGridGeometry().getGridRange()
.getHigh(0), descriptor
.getGridGeometry().getGridRange()
.getLow(1), descriptor
.getGridGeometry().getGridRange()
.getHigh(1)));
0.0f);
// wireframeShape = target.createWireframeShape(true,
// mapDescriptor);
File file = new File(resourceData.getFilename());
@ -187,8 +181,8 @@ public class BCDResource extends
throw new VizException("Could not find bcd file",
new FileNotFoundException(String.valueOf(file)));
}
FileInputStream fis = new FileInputStream(file);
fc = fis.getChannel();
fis = new FileInputStream(file);
FileChannel fc = fis.getChannel();
ByteBuffer buffer = fc.map(MapMode.READ_ONLY, 0, file.length());
@ -200,8 +194,6 @@ public class BCDResource extends
buffer.order(ByteOrder.LITTLE_ENDIAN);
}
int i = 0;
double minLat = Double.MAX_VALUE;
double minLon = Double.MAX_VALUE;
double maxLat = Double.MIN_VALUE;
@ -254,7 +246,6 @@ public class BCDResource extends
labels.add(new BcxLabel(label, pts[0], descriptor));
wireframeShape.addLabel(label, labelPixel);
}
i++;
}
if (isBCX) {
@ -285,8 +276,8 @@ public class BCDResource extends
} finally {
try {
if (fc != null) {
fc.close();
if (fis != null) {
fis.close();
}
} catch (IOException e) {
// ignore

View file

@ -1,25 +1,23 @@
package gov.noaa.nws.ncep.viz.overlays.resources;
import gov.noaa.nws.ncep.viz.resources.INatlCntrsResource;
import java.util.ArrayList;
import java.util.List;
import gov.noaa.nws.ncep.viz.resources.INatlCntrsResource;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapDescriptor;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.vividsolutions.jts.geom.Coordinate;
/**
* Implements a drawing layer to draw lat/lon lines
* Implements a drawing layer to draw lat/lon lines
*
* <pre>
* SOFTWARE HISTORY
@ -31,6 +29,8 @@ import com.vividsolutions.jts.geom.Coordinate;
* 11/18/09 Greg Hull Incorporate to11d6 changes
* 11/04/13 #880 Xiaochuan set one wireframeShape for one lat or Lon lines.
* Set spatialChopFlag to be false.
* Jul 28, 2014 3397 bclement switched to non deprecated version of createWireframeShape()
* removed unneeded clearCoodrinatePointArrayList() method
* </pre>
*
* @author mgao
@ -38,9 +38,6 @@ import com.vividsolutions.jts.geom.Coordinate;
*/
public class LatLonOverlayResource extends AbstractVizResource<LatLonOverlayResourceData, IMapDescriptor>
implements INatlCntrsResource {
private final static org.apache.log4j.Logger log =
org.apache.log4j.Logger.getLogger(LatLonOverlayResource.class);
private LatLonOverlayResourceData latLonOverlayResourceData;
@ -54,8 +51,6 @@ public class LatLonOverlayResource extends AbstractVizResource<LatLonOverlayReso
private List<Coordinate[]> longitudeCoordinatePointArrayList;
private double offset = 0; //50000;
private double mapMinX;
private double mapMaxY;
private double mapMinY;
@ -118,15 +113,12 @@ public class LatLonOverlayResource extends AbstractVizResource<LatLonOverlayReso
*/
clearWireFrameShapeArray(wireframeShapeForLatLineArray);
clearWireFrameShapeArray(wireframeShapeForLonLineArray);
clearCoordinatePointArrayList(latitudeCoordinatePointArrayList);
clearCoordinatePointArrayList(longitudeCoordinatePointArrayList);
latitudeCoordinatePointArrayList = new ArrayList<Coordinate[]>(latitudeDrawingLineNumber);
longitudeCoordinatePointArrayList = new ArrayList<Coordinate[]>(longitudeDrawingLineNumber);
wireframeShapeForLatLineArray = target.createWireframeShape(false,
descriptor, 4.0f, false, new PixelExtent(
getViewMinX()+offset, getViewMaxX()-offset, getViewMinY()+offset, getViewMaxY()-offset));
descriptor, 4.0f);
double latitudeValue = -90;
for(int i=0; i<latitudeDrawingLineNumber && latitudeValue <= 90; i++) {
@ -143,8 +135,7 @@ public class LatLonOverlayResource extends AbstractVizResource<LatLonOverlayReso
wireframeShapeForLatLineArray.compile();
wireframeShapeForLonLineArray = target.createWireframeShape(false,
descriptor, 4.0f, false, new PixelExtent(
getViewMinX()+offset, getViewMaxX()-offset, getViewMinY()+offset, getViewMaxY()-offset));
descriptor, 4.0f);
double longitudeValue = -180;
for(int i=0; i<longitudeDrawingLineNumber && longitudeValue <= 180; i++) {
@ -379,15 +370,6 @@ public class LatLonOverlayResource extends AbstractVizResource<LatLonOverlayReso
wireframeShapeArray = null;
}
}
private void clearCoordinatePointArrayList(List<Coordinate[]> coordinatePointArrayList) {
if(coordinatePointArrayList != null) {
for(Coordinate[] eachCoordinateArray : coordinatePointArrayList) {
eachCoordinateArray = null;
}
coordinatePointArrayList = null;
}
}
/*
* the getters for Map's Min and Max X and Y, View's Min and Max X and Y