Issue #1146 clone DrawableImages so they are impossible to dispose.

Former-commit-id: 1109ee5694 [formerly 1109ee5694 [formerly d2f1051380ce995126c31031dc1bbd85f31e0eb0]]
Former-commit-id: ef6b9b0014
Former-commit-id: 60891f4e02
This commit is contained in:
Ben Steffensmeier 2012-10-03 18:12:41 -05:00
parent b498ca1a65
commit 949d6017fe
4 changed files with 20 additions and 15 deletions

View file

@ -99,11 +99,8 @@ public class KmlColormappedImageExtension extends
private static class Generator extends KmlGroundOverlayGenerator {
private final DrawableImage[] images;
public Generator(float alpha, DrawableImage[] images) {
super(alpha);
this.images = images;
super(alpha, images);
}
@Override

View file

@ -40,6 +40,8 @@ import com.raytheon.uf.common.geospatial.interpolation.Interpolation;
import com.raytheon.uf.common.geospatial.interpolation.NearestNeighborInterpolation;
import com.raytheon.uf.common.geospatial.interpolation.data.DataSource;
import com.raytheon.uf.common.geospatial.interpolation.data.FloatArrayWrapper;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback.ColorMapData;
import com.raytheon.uf.viz.core.data.prep.Colormapper;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
@ -74,7 +76,21 @@ public abstract class KmlGroundOverlayGenerator extends KmlFeatureGenerator {
protected final double alpha;
public KmlGroundOverlayGenerator(double alpha) {
protected final DrawableImage[] images;
public KmlGroundOverlayGenerator(double alpha, DrawableImage[] images) {
this.images = new DrawableImage[images.length];
for (int i = 0; i < images.length; i += 1) {
// Clone the DrawableImage so that if whatever is drawing modifies
// or disposes of it then when the generator runs it will still draw
// what was rendered.
PixelCoverage oldCov = images[i].getCoverage();
PixelCoverage newCov = new PixelCoverage(oldCov.getUl(),
oldCov.getUr(), oldCov.getLr(), oldCov.getLl());
newCov.setMesh(oldCov.getMesh());
this.images[i] = new DrawableImage(images[i].getImage(), newCov,
images[i].getMode());
}
this.alpha = alpha;
}

View file

@ -19,7 +19,6 @@
**/
package com.raytheon.uf.viz.kml.export.graphics.ext;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Comparator;
@ -34,7 +33,6 @@ import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.geospatial.interpolation.Interpolation;
import com.raytheon.uf.common.geospatial.interpolation.NearestNeighborInterpolation;
import com.raytheon.uf.common.geospatial.interpolation.data.AbstractDataWrapper;
import com.raytheon.uf.common.geospatial.interpolation.data.ByteBufferWrapper;
import com.raytheon.uf.common.geospatial.interpolation.data.DataDestination;
import com.raytheon.uf.common.geospatial.interpolation.data.DataSource;
import com.raytheon.uf.common.geospatial.interpolation.data.FloatArrayWrapper;
@ -121,11 +119,8 @@ public class KmlMosaicImageExtension extends
private final ColorMapParameters parameters;
private final DrawableImage[] images;
public Generator(float alpha, KmlMosaicImage image) {
super(alpha);
this.images = image.getImagesToMosaic();
super(alpha, image.getImagesToMosaic());
this.parameters = image.getColorMapParameters();
this.mosaicComparator = image.getMosaicComparator();
}

View file

@ -77,11 +77,8 @@ public class KmlRasterImageExtension extends
private static class Generator extends KmlGroundOverlayGenerator {
private final DrawableImage[] images;
public Generator(float alpha, DrawableImage[] images) {
super(alpha);
this.images = images;
super(alpha, images);
}
@Override