Issue #358 Merging core drawing API improvements from Collaboration
Former-commit-id:d43b0456d8
[formerlyd43b0456d8
[formerly a266a93ec2dca3ffbd7d2fd1f9dc47d7e18e6904]] Former-commit-id:89f603f448
Former-commit-id:4662ece060
This commit is contained in:
parent
b1a521b17e
commit
1303289d12
20 changed files with 257 additions and 141 deletions
|
@ -89,6 +89,7 @@ public abstract class AbstractDbMapResource<T extends AbstractDbMapResourceData,
|
|||
|
||||
if (font != null) {
|
||||
font.dispose();
|
||||
font = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -514,7 +514,7 @@ public class DbMapResource extends
|
|||
if (shadedShape != null) {
|
||||
shadedShape.dispose();
|
||||
}
|
||||
|
||||
lastExtent = null;
|
||||
super.disposeInternal();
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
|||
import com.raytheon.uf.viz.core.drawables.IFont;
|
||||
import com.raytheon.uf.viz.core.drawables.IImage;
|
||||
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
|
||||
import com.raytheon.uf.viz.core.drawables.IRenderedImage;
|
||||
import com.raytheon.uf.viz.core.drawables.IShadedShape;
|
||||
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
|
@ -126,15 +127,16 @@ public interface IGraphicsTarget extends IImagingExtension {
|
|||
ColorMapParameters optionalParams);
|
||||
|
||||
/**
|
||||
* This method will create an IImage object from a RenderedImage callback.
|
||||
* The callback is used to construct the RenderableImage when it is needed.
|
||||
* All targets need to support IImage creation for RenderedImage. Other
|
||||
* IImage construction methods should be done through extensions
|
||||
* This method will create an IRenderedImage object from a RenderedImage
|
||||
* callback. The callback is used to construct the RenderableImage when it
|
||||
* is needed. All targets need to support IImage creation for RenderedImage.
|
||||
* Other IImage construction methods should be done through extensions
|
||||
*
|
||||
* @param imageCallback
|
||||
* @return
|
||||
*/
|
||||
public abstract IImage initializeRaster(IRenderedImageCallback imageCallback);
|
||||
public abstract IRenderedImage initializeRaster(
|
||||
IRenderedImageCallback imageCallback);
|
||||
|
||||
/**
|
||||
* Given the font, construct it with default values for the font
|
||||
|
@ -1026,4 +1028,5 @@ public interface IGraphicsTarget extends IImagingExtension {
|
|||
*/
|
||||
public abstract <T extends IGraphicsExtensionInterface> T getExtension(
|
||||
Class<T> extensionClass) throws VizException;
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package com.raytheon.uf.viz.core.drawables;
|
||||
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
||||
|
@ -71,6 +72,16 @@ public interface IImage {
|
|||
*/
|
||||
public abstract void stage() throws VizException;
|
||||
|
||||
/**
|
||||
* Load the staged data into something that can be used by the target.
|
||||
* Errors may be thrown if image is not in correct state when called, see
|
||||
* getStatus() to check image state
|
||||
*
|
||||
* @param target
|
||||
* @throws VizException
|
||||
*/
|
||||
public abstract void target(IGraphicsTarget target) throws VizException;
|
||||
|
||||
/**
|
||||
* @return the status
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.core.drawables;
|
||||
|
||||
import java.awt.image.RenderedImage;
|
||||
|
||||
/**
|
||||
* IImage object represents java RenderedImage
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 5, 2012 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IRenderedImage extends IImage {
|
||||
|
||||
/**
|
||||
* Get the RenderedImage associated with this object
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RenderedImage getImage();
|
||||
|
||||
}
|
|
@ -76,12 +76,18 @@ public abstract class GraphicsExtension<T extends IGraphicsTarget> {
|
|||
public final int setTarget(IGraphicsTarget target) {
|
||||
try {
|
||||
this.target = (T) target;
|
||||
return getCompatibilityValue(this.target);
|
||||
} catch (ClassCastException e) {
|
||||
return Compatibilty.INCOMPATIBLE;
|
||||
}
|
||||
return getCompatibilityValue(this.target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the target compability value.
|
||||
*
|
||||
* @param target
|
||||
* @return
|
||||
*/
|
||||
public abstract int getCompatibilityValue(T target);
|
||||
|
||||
/**
|
||||
|
|
|
@ -81,6 +81,11 @@ public class GraphicsExtensionManager {
|
|||
try {
|
||||
graphicsExt = GraphicsExtension.class.cast(eClass
|
||||
.newInstance());
|
||||
int val = graphicsExt.setTarget(target);
|
||||
if (val > bestVal) {
|
||||
bestVal = val;
|
||||
bestExt = extensionClass.cast(graphicsExt);
|
||||
}
|
||||
} catch (InstantiationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
e.getLocalizedMessage(), e);
|
||||
|
@ -90,11 +95,6 @@ public class GraphicsExtensionManager {
|
|||
e.getLocalizedMessage(), e);
|
||||
continue;
|
||||
}
|
||||
int val = graphicsExt.setTarget(target);
|
||||
if (val > bestVal) {
|
||||
bestVal = val;
|
||||
bestExt = extensionClass.cast(graphicsExt);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bestExt != null) {
|
||||
|
|
|
@ -19,7 +19,14 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.core.drawables.ext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.viz.core.DrawableImage;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.RasterMode;
|
||||
import com.raytheon.uf.viz.core.drawables.IImage;
|
||||
import com.raytheon.uf.viz.core.drawables.IImage.Status;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
|
@ -54,4 +61,100 @@ public interface IImagingExtension extends IGraphicsExtensionInterface {
|
|||
public boolean drawRasters(PaintProperties paintProps,
|
||||
DrawableImage... images) throws VizException;
|
||||
|
||||
public static class ImagingSupport {
|
||||
|
||||
protected static final TextureLoader textureLoader = TextureLoader
|
||||
.getInstance();
|
||||
|
||||
/**
|
||||
* Prepares images for painting by staging and/or targeting the image
|
||||
*
|
||||
* @param target
|
||||
* @param images
|
||||
* @throws VizException
|
||||
*/
|
||||
public static void prepareImages(IGraphicsTarget target,
|
||||
DrawableImage... images) throws VizException {
|
||||
for (DrawableImage di : images) {
|
||||
IImage image = di.getImage();
|
||||
RasterMode mode = di.getMode();
|
||||
|
||||
if (image.getStatus() != Status.LOADED) {
|
||||
if (image.getStatus() != Status.STAGED) {
|
||||
if (mode == RasterMode.ASYNCHRONOUS) {
|
||||
textureLoader.requestLoad(image);
|
||||
target.setNeedsRefresh(true);
|
||||
} else if (mode == RasterMode.SYNCHRONOUS) {
|
||||
image.stage();
|
||||
}
|
||||
}
|
||||
|
||||
if (image.getStatus() == Status.STAGED) {
|
||||
image.target(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Routes the images to be rendered by their proper extensions
|
||||
*
|
||||
* @param target
|
||||
* @param paintProps
|
||||
* @param images
|
||||
* @return
|
||||
* @throws VizException
|
||||
*/
|
||||
public static boolean routeImages(IGraphicsTarget target,
|
||||
PaintProperties paintProps, DrawableImage[] images)
|
||||
throws VizException {
|
||||
boolean rval = true;
|
||||
boolean skipped = false;
|
||||
List<DrawableImage> bulk = new ArrayList<DrawableImage>();
|
||||
Class<? extends IImagingExtension> lastExt = null;
|
||||
for (DrawableImage di : images) {
|
||||
IImage image = di.getImage();
|
||||
if (image.getStatus() == IImage.Status.LOADED) {
|
||||
Class<? extends IImagingExtension> imageExt = image
|
||||
.getExtensionClass();
|
||||
if (imageExt.equals(lastExt) == false && bulk.size() > 0) {
|
||||
DrawableImage[] extImages = bulk
|
||||
.toArray(new DrawableImage[bulk.size()]);
|
||||
// Render what we have
|
||||
IImagingExtension impl = target.getExtension(lastExt);
|
||||
rval &= impl.drawRasters(paintProps, extImages);
|
||||
bulk.clear();
|
||||
}
|
||||
|
||||
bulk.add(di);
|
||||
lastExt = imageExt;
|
||||
} else {
|
||||
skipped = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (bulk.size() > 0) {
|
||||
// Render what is left
|
||||
IImagingExtension impl = target.getExtension(lastExt);
|
||||
rval &= impl.drawRasters(paintProps,
|
||||
bulk.toArray(new DrawableImage[bulk.size()]));
|
||||
}
|
||||
|
||||
return rval & skipped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the images, then routes them for rendering
|
||||
*
|
||||
* @param paintProps
|
||||
* @param images
|
||||
* @return
|
||||
*/
|
||||
public static boolean drawRasters(IGraphicsTarget target,
|
||||
PaintProperties paintProps, DrawableImage[] images)
|
||||
throws VizException {
|
||||
prepareImages(target, images);
|
||||
return routeImages(target, paintProps, images);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,17 +18,19 @@
|
|||
* further licensing information.
|
||||
**/
|
||||
|
||||
package com.raytheon.viz.core.gl;
|
||||
package com.raytheon.uf.viz.core.drawables.ext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.ui.services.IDisposable;
|
||||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.core.drawables.IImage.Status;
|
||||
import com.raytheon.uf.viz.core.Activator;
|
||||
import com.raytheon.uf.viz.core.drawables.IImage;
|
||||
import com.raytheon.uf.viz.core.jobs.JobPool;
|
||||
import com.raytheon.viz.core.gl.images.AbstractGLImage;
|
||||
|
||||
/**
|
||||
* Class that loads data for AbstractGLImages asynchronously
|
||||
|
@ -56,7 +58,7 @@ public class TextureLoader {
|
|||
|
||||
private JobPool loaderPool;
|
||||
|
||||
private List<AbstractGLImage> texturesToLoad;
|
||||
private List<IImage> texturesToLoad;
|
||||
|
||||
/**
|
||||
* Get the currently running instance of the texture loader
|
||||
|
@ -75,9 +77,16 @@ public class TextureLoader {
|
|||
*
|
||||
*/
|
||||
private TextureLoader() {
|
||||
this.texturesToLoad = new ArrayList<AbstractGLImage>();
|
||||
this.texturesToLoad = new ArrayList<IImage>();
|
||||
this.loaderPool = new JobPool("Texture Loader", Runtime.getRuntime()
|
||||
.availableProcessors(), true);
|
||||
// Make sure we get shutdown properly
|
||||
Activator.getDefault().registerDisposable(new IDisposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
shutdown();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,7 +95,7 @@ public class TextureLoader {
|
|||
* @param img
|
||||
* the image
|
||||
*/
|
||||
public void requestLoad(final AbstractGLImage img) {
|
||||
public void requestLoad(final IImage img) {
|
||||
if (!texturesToLoad.contains(img)) {
|
||||
texturesToLoad.add(img);
|
||||
loaderPool.schedule(new Runnable() {
|
||||
|
@ -96,7 +105,6 @@ public class TextureLoader {
|
|||
try {
|
||||
img.stage();
|
||||
} catch (Throwable t) {
|
||||
img.setStatus(Status.FAILED);
|
||||
statusHandler.handle(
|
||||
Priority.PROBLEM,
|
||||
"Error staging texture: "
|
|
@ -237,4 +237,16 @@ public class ColormappedImage implements IColormappedImage,
|
|||
image.stage();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.viz.core.drawables.IImage#target(com.raytheon.uf.viz.
|
||||
* core.IGraphicsTarget)
|
||||
*/
|
||||
@Override
|
||||
public void target(IGraphicsTarget target) throws VizException {
|
||||
image.target(target);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -717,7 +717,7 @@ public abstract class AbstractVizResource<T extends AbstractResourceData, D exte
|
|||
*/
|
||||
public final void recycle() {
|
||||
if (status == ResourceStatus.INITIALIZED) {
|
||||
dispose();
|
||||
disposeInternal();
|
||||
}
|
||||
status = ResourceStatus.NEW;
|
||||
initJob = null;
|
||||
|
|
|
@ -96,7 +96,10 @@ public class GLRadarMosaicImageExtension extends AbstractGLSLImagingExtension
|
|||
.getExtension(IOffscreenRenderingExtension.class);
|
||||
try {
|
||||
extension.renderOffscreen(mosaicImage);
|
||||
drawRasters(paintProps, mosaicImage.getImagesToMosaic());
|
||||
DrawableImage[] imagesToMosaic = mosaicImage
|
||||
.getImagesToMosaic();
|
||||
ImagingSupport.prepareImages(target, imagesToMosaic);
|
||||
drawRasters(paintProps, imagesToMosaic);
|
||||
} finally {
|
||||
extension.renderOnscreen();
|
||||
}
|
||||
|
|
|
@ -73,8 +73,6 @@ public class Activator extends AbstractUIPlugin {
|
|||
public void stop(BundleContext context) throws Exception {
|
||||
plugin = null;
|
||||
super.stop(context);
|
||||
// Start the texture loader job
|
||||
TextureLoader.getInstance().shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -31,20 +31,16 @@ import javax.media.opengl.GL;
|
|||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.core.DrawableImage;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.RasterMode;
|
||||
import com.raytheon.uf.viz.core.IMesh;
|
||||
import com.raytheon.uf.viz.core.PixelCoverage;
|
||||
import com.raytheon.uf.viz.core.drawables.IImage;
|
||||
import com.raytheon.uf.viz.core.drawables.IImage.Status;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension;
|
||||
import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.core.gl.GLCapabilities;
|
||||
import com.raytheon.viz.core.gl.IGLTarget;
|
||||
import com.raytheon.viz.core.gl.TextureLoader;
|
||||
import com.raytheon.viz.core.gl.glsl.GLSLFactory;
|
||||
import com.raytheon.viz.core.gl.glsl.GLShaderProgram;
|
||||
import com.raytheon.viz.core.gl.images.AbstractGLImage;
|
||||
|
@ -74,9 +70,6 @@ public abstract class AbstractGLImagingExtension extends
|
|||
protected static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(AbstractGLImagingExtension.class);
|
||||
|
||||
protected static final TextureLoader textureLoader = TextureLoader
|
||||
.getInstance();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -95,44 +88,7 @@ public abstract class AbstractGLImagingExtension extends
|
|||
target.pushGLState();
|
||||
try {
|
||||
gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
|
||||
List<DrawableImage> renderable = new ArrayList<DrawableImage>(
|
||||
images.length);
|
||||
|
||||
for (DrawableImage di : images) {
|
||||
IImage image = di.getImage();
|
||||
if (image instanceof AbstractGLImage) {
|
||||
AbstractGLImage glImage = (AbstractGLImage) image;
|
||||
RasterMode mode = di.getMode();
|
||||
|
||||
if (glImage.getStatus() != Status.LOADED) {
|
||||
if (glImage.getStatus() != Status.STAGED) {
|
||||
if (mode == RasterMode.ASYNCHRONOUS) {
|
||||
textureLoader.requestLoad(glImage);
|
||||
target.setNeedsRefresh(true);
|
||||
} else if (mode == RasterMode.SYNCHRONOUS) {
|
||||
glImage.stage();
|
||||
}
|
||||
}
|
||||
|
||||
if (glImage.getStatus() == Status.STAGED) {
|
||||
glImage.target(target);
|
||||
}
|
||||
}
|
||||
|
||||
if (glImage.getStatus() == IImage.Status.LOADED) {
|
||||
renderable.add(di);
|
||||
}
|
||||
} else {
|
||||
statusHandler
|
||||
.handle(Priority.PROBLEM,
|
||||
"Can only draw AbstractGLImages on AbstractGLImagingExtension");
|
||||
}
|
||||
}
|
||||
|
||||
rval = drawRastersInternal(paintProps,
|
||||
renderable.toArray(new DrawableImage[renderable.size()]))
|
||||
&& (renderable.size() == images.length);
|
||||
|
||||
rval = drawRastersInternal(paintProps, images);
|
||||
gl.glPolygonMode(GL.GL_BACK, GL.GL_LINE);
|
||||
gl.glDisable(GL.GL_BLEND);
|
||||
} finally {
|
||||
|
|
|
@ -30,6 +30,7 @@ import javax.media.jai.PlanarImage;
|
|||
import javax.media.opengl.GL;
|
||||
|
||||
import com.raytheon.uf.viz.core.data.IRenderedImageCallback;
|
||||
import com.raytheon.uf.viz.core.drawables.IRenderedImage;
|
||||
import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.core.gl.internal.cache.IImageCacheable;
|
||||
|
@ -56,7 +57,8 @@ import com.sun.opengl.util.texture.TextureIO;
|
|||
* @author chammack
|
||||
*
|
||||
*/
|
||||
public class GLImage extends AbstractGLImage implements IImageCacheable {
|
||||
public class GLImage extends AbstractGLImage implements IRenderedImage,
|
||||
IImageCacheable {
|
||||
|
||||
/** The memory resident texture */
|
||||
private TextureData theStagedData;
|
||||
|
@ -71,7 +73,8 @@ public class GLImage extends AbstractGLImage implements IImageCacheable {
|
|||
|
||||
protected int size;
|
||||
|
||||
public GLImage(IRenderedImageCallback preparer, Class<? extends IImagingExtension> extensionClass) {
|
||||
public GLImage(IRenderedImageCallback preparer,
|
||||
Class<? extends IImagingExtension> extensionClass) {
|
||||
super(extensionClass);
|
||||
theTexture = null;
|
||||
this.imagePreparer = preparer;
|
||||
|
@ -80,7 +83,7 @@ public class GLImage extends AbstractGLImage implements IImageCacheable {
|
|||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.drawables.IImage#getImage()
|
||||
* @see com.raytheon.viz.core.drawables.IRenderedImage#getImage()
|
||||
*/
|
||||
public RenderedImage getImage() {
|
||||
return theImage;
|
||||
|
|
|
@ -82,6 +82,7 @@ import com.raytheon.uf.viz.core.drawables.IFont;
|
|||
import com.raytheon.uf.viz.core.drawables.IFont.Style;
|
||||
import com.raytheon.uf.viz.core.drawables.IImage;
|
||||
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
|
||||
import com.raytheon.uf.viz.core.drawables.IRenderedImage;
|
||||
import com.raytheon.uf.viz.core.drawables.IShadedShape;
|
||||
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
|
@ -99,7 +100,6 @@ import com.raytheon.viz.core.gl.IGLFont;
|
|||
import com.raytheon.viz.core.gl.IGLTarget;
|
||||
import com.raytheon.viz.core.gl.glsl.GLSLFactory;
|
||||
import com.raytheon.viz.core.gl.glsl.GLShaderProgram;
|
||||
import com.raytheon.viz.core.gl.images.AbstractGLImage;
|
||||
import com.raytheon.viz.core.gl.images.GLColormappedImage;
|
||||
import com.raytheon.viz.core.gl.images.GLImage;
|
||||
import com.raytheon.viz.core.gl.internal.ext.GLColormappedImageExtension;
|
||||
|
@ -1044,34 +1044,7 @@ public class GLTarget implements IGLTarget {
|
|||
@Override
|
||||
public boolean drawRasters(PaintProperties paintProps,
|
||||
DrawableImage... images) throws VizException {
|
||||
boolean rval = true;
|
||||
List<DrawableImage> bulk = new ArrayList<DrawableImage>();
|
||||
Class<? extends IImagingExtension> lastExt = null;
|
||||
for (DrawableImage di : images) {
|
||||
IImage image = di.getImage();
|
||||
Class<? extends IImagingExtension> imageExt = image
|
||||
.getExtensionClass();
|
||||
if (imageExt.equals(lastExt) == false && bulk.size() > 0) {
|
||||
DrawableImage[] extImages = bulk.toArray(new DrawableImage[bulk
|
||||
.size()]);
|
||||
// Render what we have
|
||||
IImagingExtension impl = getExtension(lastExt);
|
||||
rval &= impl.drawRasters(paintProps, extImages);
|
||||
bulk.clear();
|
||||
}
|
||||
|
||||
bulk.add(di);
|
||||
lastExt = imageExt;
|
||||
}
|
||||
|
||||
if (bulk.size() > 0) {
|
||||
// Render what is left
|
||||
IImagingExtension impl = getExtension(lastExt);
|
||||
rval &= impl.drawRasters(paintProps,
|
||||
bulk.toArray(new DrawableImage[bulk.size()]));
|
||||
}
|
||||
|
||||
return rval;
|
||||
return ImagingSupport.drawRasters(this, paintProps, images);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1814,15 +1787,8 @@ public class GLTarget implements IGLTarget {
|
|||
* .uf.viz.core.data.IRenderedImageCallback)
|
||||
*/
|
||||
@Override
|
||||
public AbstractGLImage initializeRaster(IRenderedImageCallback imageCallback) {
|
||||
GLImage image = new GLImage(imageCallback,
|
||||
GLDefaultImagingExtension.class);
|
||||
try {
|
||||
image.stage();
|
||||
} catch (VizException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, "Error staging texture", e);
|
||||
}
|
||||
return image;
|
||||
public IRenderedImage initializeRaster(IRenderedImageCallback imageCallback) {
|
||||
return new GLImage(imageCallback, GLDefaultImagingExtension.class);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -51,7 +51,6 @@ import com.raytheon.uf.common.status.UFStatus;
|
|||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.core.AbstractGraphicsFactoryAdapter;
|
||||
import com.raytheon.uf.viz.core.DrawableImage;
|
||||
import com.raytheon.uf.viz.core.GraphicsFactory;
|
||||
import com.raytheon.uf.viz.core.IExtent;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.RasterMode;
|
||||
|
@ -192,7 +191,6 @@ public abstract class AbstractTileSet implements IRenderable, IMeshCallback {
|
|||
this.tileSize = tileSize;
|
||||
this.rsc = rsc;
|
||||
this.cellOrientation = pixelOrientation;
|
||||
graphicsAdapter = GraphicsFactory.getGraphicsAdapter(viewType);
|
||||
setup(levels, tileSize, gridGeometry);
|
||||
}
|
||||
|
||||
|
@ -216,7 +214,6 @@ public abstract class AbstractTileSet implements IRenderable, IMeshCallback {
|
|||
this.rsc = rsc;
|
||||
}
|
||||
setSharedGeometryTileSet(sharedGeometryTileset);
|
||||
disposed = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -261,7 +258,6 @@ public abstract class AbstractTileSet implements IRenderable, IMeshCallback {
|
|||
|
||||
protected void setup(int levels, int tileSize, GridGeometry2D gridGeometry)
|
||||
throws VizException {
|
||||
disposed = false;
|
||||
this.levels = levels;
|
||||
try {
|
||||
|
||||
|
@ -677,6 +673,7 @@ public abstract class AbstractTileSet implements IRenderable, IMeshCallback {
|
|||
}
|
||||
|
||||
public void init(IGraphicsTarget target) throws VizException {
|
||||
disposed = false;
|
||||
this.lastPaintedTarget = target;
|
||||
|
||||
if (this.sharedGeometryTileSet == null) {
|
||||
|
@ -722,7 +719,6 @@ public abstract class AbstractTileSet implements IRenderable, IMeshCallback {
|
|||
this.originalGridGeometry = sharedGeometryTileset.originalGridGeometry;
|
||||
this.originalMathTransform = sharedGeometryTileset.originalMathTransform;
|
||||
this.cellOrientation = sharedGeometryTileset.cellOrientation;
|
||||
this.graphicsAdapter = sharedGeometryTileset.graphicsAdapter;
|
||||
}
|
||||
|
||||
public void reproject() throws VizException {
|
||||
|
|
|
@ -182,7 +182,6 @@ public class AbstractRadarResource<D extends IDescriptor> extends
|
|||
*/
|
||||
@Override
|
||||
protected void disposeInternal() {
|
||||
radarRecords.clear();
|
||||
upperTextMap.clear();
|
||||
|
||||
RadarTextResourceData.removeRadarTextResource(descriptor);
|
||||
|
|
|
@ -149,10 +149,10 @@ public class SatBlendedResource extends
|
|||
@Override
|
||||
protected void paintInternal(IGraphicsTarget target,
|
||||
PaintProperties paintProps) throws VizException {
|
||||
if (Arrays.equals(
|
||||
imageBounds,
|
||||
new int[] { paintProps.getCanvasBounds().width,
|
||||
paintProps.getCanvasBounds().height }) == false) {
|
||||
if (offscreenImage == null
|
||||
|| Arrays.equals(imageBounds,
|
||||
new int[] { paintProps.getCanvasBounds().width,
|
||||
paintProps.getCanvasBounds().height }) == false) {
|
||||
disposeImage();
|
||||
initImage(target, paintProps);
|
||||
}
|
||||
|
|
|
@ -120,8 +120,11 @@ public class VizDisplayPane implements IDisplayPane {
|
|||
|
||||
protected static final double ZOOM_ANIMATION_FACTOR = 2.0;
|
||||
|
||||
/** The canvas composite */
|
||||
private final Composite canvasComp;
|
||||
|
||||
/** The canvas */
|
||||
protected final Canvas canvas;
|
||||
private final Canvas canvas;
|
||||
|
||||
/** The graphics target */
|
||||
protected IGraphicsTarget target;
|
||||
|
@ -196,9 +199,17 @@ public class VizDisplayPane implements IDisplayPane {
|
|||
Composite canvasComp, IRenderableDisplay display,
|
||||
boolean enableContextualMenus) throws VizException {
|
||||
this.container = container;
|
||||
this.canvasComp = canvasComp;
|
||||
this.canvasComp.addDisposeListener(new DisposeListener() {
|
||||
@Override
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
VizDisplayPane.this.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
// create the graphics adapter
|
||||
graphicsAdapter = getGraphicsAdapter(display);
|
||||
graphicsAdapter = GraphicsFactory.getGraphicsAdapter(display
|
||||
.getDisplayType());
|
||||
// create the canvas
|
||||
this.canvas = graphicsAdapter.constrcutCanvas(canvasComp);
|
||||
// set the renderable display
|
||||
|
@ -236,7 +247,7 @@ public class VizDisplayPane implements IDisplayPane {
|
|||
});
|
||||
Menu menu = menuMgr.createContextMenu(canvas);
|
||||
menu.setVisible(false);
|
||||
canvas.getParent().setMenu(menu);
|
||||
canvasComp.setMenu(menu);
|
||||
}
|
||||
|
||||
// Register ourselves with the DrawCoordinatorJob
|
||||
|
@ -263,15 +274,6 @@ public class VizDisplayPane implements IDisplayPane {
|
|||
}
|
||||
});
|
||||
|
||||
canvas.addDisposeListener(new DisposeListener() {
|
||||
|
||||
@Override
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
VizDisplayPane.this.dispose();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
canvas.addListener(SWT.MouseMove, new Listener() {
|
||||
@Override
|
||||
public void handleEvent(Event event) {
|
||||
|
@ -294,9 +296,8 @@ public class VizDisplayPane implements IDisplayPane {
|
|||
* @param display
|
||||
* @return
|
||||
*/
|
||||
protected AbstractGraphicsFactoryAdapter getGraphicsAdapter(
|
||||
IRenderableDisplay display) throws VizException {
|
||||
return GraphicsFactory.getGraphicsAdapter(display.getDisplayType());
|
||||
public AbstractGraphicsFactoryAdapter getGraphicsAdapter() {
|
||||
return graphicsAdapter;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -404,7 +405,7 @@ public class VizDisplayPane implements IDisplayPane {
|
|||
}
|
||||
|
||||
if (canvas.isDisposed() == false) {
|
||||
canvas.getParent().dispose();
|
||||
canvasComp.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -942,7 +943,7 @@ public class VizDisplayPane implements IDisplayPane {
|
|||
*/
|
||||
@Override
|
||||
public void setVisible(boolean visible) {
|
||||
canvas.getParent().setVisible(visible);
|
||||
canvasComp.setVisible(visible);
|
||||
canvas.setVisible(visible);
|
||||
}
|
||||
|
||||
|
@ -965,7 +966,7 @@ public class VizDisplayPane implements IDisplayPane {
|
|||
lastClickX = lastMouseX = e.x;
|
||||
lastClickY = lastMouseY = e.y;
|
||||
if (prefManager.handleLongClick(CONTEXT_MENU_PREF, e.button)) {
|
||||
canvas.getParent().getMenu().setVisible(false);
|
||||
canvasComp.getMenu().setVisible(false);
|
||||
synchronized (menuLock) {
|
||||
if (menuJob != null) {
|
||||
menuJob.cancel();
|
||||
|
@ -978,7 +979,7 @@ public class VizDisplayPane implements IDisplayPane {
|
|||
@Override
|
||||
public void run() {
|
||||
if (canvas.isDisposed() == false
|
||||
&& canvas.getParent().getMenu() != null) {
|
||||
&& canvasComp.getMenu() != null) {
|
||||
showMenu();
|
||||
}
|
||||
}
|
||||
|
@ -991,7 +992,7 @@ public class VizDisplayPane implements IDisplayPane {
|
|||
};
|
||||
menuJob.schedule(275);
|
||||
} else if (prefManager.handleClick(CONTEXT_MENU_PREF, e.button)) {
|
||||
canvas.getParent().getMenu().setVisible(false);
|
||||
canvasComp.getMenu().setVisible(false);
|
||||
showMenu();
|
||||
}
|
||||
}
|
||||
|
@ -1002,8 +1003,8 @@ public class VizDisplayPane implements IDisplayPane {
|
|||
protected void showMenu() {
|
||||
Point canvasLoc = canvas.getDisplay().map(canvas, null, lastClickX,
|
||||
lastClickY);
|
||||
canvas.getParent().getMenu().setLocation(canvasLoc);
|
||||
canvas.getParent().getMenu().setVisible(true);
|
||||
canvasComp.getMenu().setLocation(canvasLoc);
|
||||
canvasComp.getMenu().setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue