diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/ext/IOffscreenRenderingExtension.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/ext/IOffscreenRenderingExtension.java index a195967b63..e8a69947d8 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/ext/IOffscreenRenderingExtension.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/drawables/ext/IOffscreenRenderingExtension.java @@ -4,6 +4,7 @@ import java.nio.Buffer; import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.drawables.ColorMapParameters; +import com.raytheon.uf.viz.core.drawables.IColormappedImage; import com.raytheon.uf.viz.core.drawables.IImage; import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface; import com.raytheon.uf.viz.core.exception.VizException; @@ -61,8 +62,9 @@ public interface IOffscreenRenderingExtension extends * @return * @throws VizException */ - public IImage constructOffscreenImage(Class dataType, - int[] dimensions) throws VizException; + public IColormappedImage constructOffscreenImage( + Class dataType, int[] dimensions) + throws VizException; /** * Construct an offscreen image for given Buffer type and size, applying @@ -74,7 +76,7 @@ public interface IOffscreenRenderingExtension extends * @return * @throws VizException */ - public IImage constructOffscreenImage(Class dataType, - int[] dimensions, ColorMapParameters parameters) - throws VizException; + public IColormappedImage constructOffscreenImage( + Class dataType, int[] dimensions, + ColorMapParameters parameters) throws VizException; } diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/ResourceList.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/ResourceList.java index bbaa8f64f6..359958e9e0 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/ResourceList.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/rsc/ResourceList.java @@ -23,8 +23,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; -import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; @@ -98,10 +98,10 @@ public class ResourceList extends CopyOnWriteArrayList implements }; public ResourceList() { - preAddListeners = new HashSet(); - postAddListeners = new HashSet(); - preRemoveListeners = new HashSet(); - postRemoveListeners = new HashSet(); + preAddListeners = new LinkedHashSet(); + postAddListeners = new LinkedHashSet(); + preRemoveListeners = new LinkedHashSet(); + postRemoveListeners = new LinkedHashSet(); addPostAddListener(new AddListener() { @Override diff --git a/cave/com.raytheon.uf.viz.radar.gl/src/com/raytheon/uf/viz/radar/gl/mosaic/GLMosaicImage.java b/cave/com.raytheon.uf.viz.radar.gl/src/com/raytheon/uf/viz/radar/gl/mosaic/GLMosaicImage.java index de4808393f..7f1b5114f2 100644 --- a/cave/com.raytheon.uf.viz.radar.gl/src/com/raytheon/uf/viz/radar/gl/mosaic/GLMosaicImage.java +++ b/cave/com.raytheon.uf.viz.radar.gl/src/com/raytheon/uf/viz/radar/gl/mosaic/GLMosaicImage.java @@ -20,7 +20,9 @@ package com.raytheon.uf.viz.radar.gl.mosaic; import com.raytheon.uf.viz.core.DrawableImage; -import com.raytheon.viz.core.gl.images.AbstractGLImage; +import com.raytheon.uf.viz.core.IExtent; +import com.raytheon.uf.viz.core.drawables.ColorMapParameters; +import com.raytheon.viz.core.gl.images.GLColormappedImage; import com.raytheon.viz.core.gl.images.GLDelegateImage; import com.raytheon.viz.radar.rsc.mosaic.ext.IRadarMosaicImageExtension.IMosaicImage; @@ -42,8 +44,8 @@ import com.raytheon.viz.radar.rsc.mosaic.ext.IRadarMosaicImageExtension.IMosaicI * @version 1.0 */ -public class GLMosaicImage extends GLDelegateImage implements - IMosaicImage { +public class GLMosaicImage extends GLDelegateImage + implements IMosaicImage { private DrawableImage[] images; @@ -51,14 +53,18 @@ public class GLMosaicImage extends GLDelegateImage implements private int[] bounds; + private IExtent extent; + /** * @param target * @param image * @param extensionClass */ - public GLMosaicImage(AbstractGLImage image, int[] bounds) { + public GLMosaicImage(GLColormappedImage image, int[] bounds, + IExtent imageExtent) { super(image, GLRadarMosaicImageExtension.class); this.bounds = bounds; + this.extent = imageExtent; } /* @@ -104,4 +110,56 @@ public class GLMosaicImage extends GLDelegateImage implements this.images = images; repaint = true; } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.viz.radar.rsc.mosaic.ext.IRadarMosaicImageExtension.IMosaicImage + * #setImageExtent(com.raytheon.uf.viz.core.IExtent) + */ + @Override + public void setImageExtent(IExtent imageExtent) { + this.extent = imageExtent; + } + + public IExtent getImageExtent() { + return extent; + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.core.drawables.IColormappedImage#getColorMapParameters + * () + */ + @Override + public ColorMapParameters getColorMapParameters() { + return image.getColorMapParameters(); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.core.drawables.IColormappedImage#setColorMapParameters + * (com.raytheon.uf.viz.core.drawables.ColorMapParameters) + */ + @Override + public void setColorMapParameters(ColorMapParameters params) { + image.setColorMapParameters(params); + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.core.drawables.IColormappedImage#getValue(int, + * int) + */ + @Override + public double getValue(int x, int y) { + return image.getValue(x, y); + } + } diff --git a/cave/com.raytheon.uf.viz.radar.gl/src/com/raytheon/uf/viz/radar/gl/mosaic/GLRadarMosaicImageExtension.java b/cave/com.raytheon.uf.viz.radar.gl/src/com/raytheon/uf/viz/radar/gl/mosaic/GLRadarMosaicImageExtension.java index 30a0fce788..3fbd1ff9ea 100644 --- a/cave/com.raytheon.uf.viz.radar.gl/src/com/raytheon/uf/viz/radar/gl/mosaic/GLRadarMosaicImageExtension.java +++ b/cave/com.raytheon.uf.viz.radar.gl/src/com/raytheon/uf/viz/radar/gl/mosaic/GLRadarMosaicImageExtension.java @@ -24,6 +24,7 @@ import java.nio.ByteBuffer; import javax.media.opengl.GL; import com.raytheon.uf.viz.core.DrawableImage; +import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.PixelCoverage; import com.raytheon.uf.viz.core.drawables.ColorMapParameters; import com.raytheon.uf.viz.core.drawables.IImage; @@ -60,10 +61,11 @@ public class GLRadarMosaicImageExtension extends AbstractGLSLImagingExtension private AbstractGLImage writeToImage; public GLMosaicImage initializeRaster(int[] imageBounds, - ColorMapParameters params) throws VizException { + IExtent imageExtent, ColorMapParameters params) throws VizException { return new GLMosaicImage(target.getExtension( GLOffscreenRenderingExtension.class).constructOffscreenImage( - ByteBuffer.class, imageBounds, params), imageBounds); + ByteBuffer.class, imageBounds, params), imageBounds, + imageExtent); } /* @@ -96,14 +98,23 @@ public class GLRadarMosaicImageExtension extends AbstractGLSLImagingExtension IOffscreenRenderingExtension extension = target .getExtension(IOffscreenRenderingExtension.class); try { - extension.renderOffscreen(mosaicImage); + extension.renderOffscreen(mosaicImage, + mosaicImage.getImageExtent()); DrawableImage[] imagesToMosaic = mosaicImage .getImagesToMosaic(); // Make sure images are staged before we mosaic them ImagingSupport.prepareImages(target, imagesToMosaic); - // Need to set repaint based on if drawing completed - mosaicImage.setRepaint(drawRasters(paintProps, - imagesToMosaic) == false); + + boolean allPainted = true; + // Each image needs to draw separately due to gl issues when + // zoomed in very far, rendered parts near the corners don't + // show all the pixels for each image. Pushing and popping + // GL_TEXTURE_BIT before/after each render fixes this issue + for (DrawableImage di : imagesToMosaic) { + allPainted &= drawRasters(paintProps, di); + } + // Need to set repaint based on if drawing completed. + mosaicImage.setRepaint(allPainted == false); } finally { extension.renderOnscreen(); } @@ -117,7 +128,7 @@ public class GLRadarMosaicImageExtension extends AbstractGLSLImagingExtension } else { GL gl = target.getGl(); // activate on texture2 as 0 is radar image and 1 is colormap - gl.glActiveTexture(GL.GL_TEXTURE2); + gl.glActiveTexture(GL.GL_TEXTURE1); gl.glBindTexture(writeToImage.getTextureStorageType(), writeToImage.getTextureid()); return image; @@ -136,8 +147,8 @@ public class GLRadarMosaicImageExtension extends AbstractGLSLImagingExtension public void postImageRender(PaintProperties paintProps, AbstractGLImage image, Object data) throws VizException { GL gl = target.getGl(); - // activate on texture2 as 0 is radar image and 1 is colormap - gl.glActiveTexture(GL.GL_TEXTURE2); + // activate on texture2 as 0 is radar image + gl.glActiveTexture(GL.GL_TEXTURE1); gl.glBindTexture(writeToImage.getTextureStorageType(), 0); } @@ -154,7 +165,7 @@ public class GLRadarMosaicImageExtension extends AbstractGLSLImagingExtension public void loadShaderData(GLShaderProgram program, IImage image, PaintProperties paintProps) throws VizException { program.setUniform("radarData", 0); - program.setUniform("mosaicTexture", 2); + program.setUniform("mosaicTexture", 1); // pass in width and height program.setUniform("height", (paintProps.getCanvasBounds().height)); diff --git a/cave/com.raytheon.uf.viz.remote.graphics/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.remote.graphics/META-INF/MANIFEST.MF index 483c0e5b80..a6f32bc5f8 100644 --- a/cave/com.raytheon.uf.viz.remote.graphics/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.uf.viz.remote.graphics/META-INF/MANIFEST.MF @@ -25,4 +25,5 @@ Export-Package: com.raytheon.uf.viz.remote.graphics, com.raytheon.uf.viz.remote.graphics.events.mesh, com.raytheon.uf.viz.remote.graphics.events.offscreen, com.raytheon.uf.viz.remote.graphics.events.wireframe, - com.raytheon.uf.viz.remote.graphics.extensions + com.raytheon.uf.viz.remote.graphics.extensions, + com.raytheon.uf.viz.remote.graphics.objects diff --git a/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/extensions/DispatchColormappedImageExtension.java b/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/extensions/DispatchColormappedImageExtension.java index 3fecdd9616..29906d0a93 100644 --- a/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/extensions/DispatchColormappedImageExtension.java +++ b/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/extensions/DispatchColormappedImageExtension.java @@ -24,8 +24,10 @@ import com.raytheon.uf.viz.core.drawables.ColorMapParameters; import com.raytheon.uf.viz.core.drawables.IColormappedImage; import com.raytheon.uf.viz.core.drawables.ext.colormap.IColormappedImageExtension; import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.remote.graphics.events.RemoteGraphicsEventFactory; +import com.raytheon.uf.viz.remote.graphics.events.colormap.ColorMapDataEvent; +import com.raytheon.uf.viz.remote.graphics.events.colormap.CreateColormappedImageEvent; import com.raytheon.uf.viz.remote.graphics.objects.DispatchingColormappedImage; -import com.raytheon.uf.viz.remote.graphics.objects.DispatchingColormappedImage.DispatchingColormappedCallback; /** * TODO Add Description @@ -47,6 +49,35 @@ import com.raytheon.uf.viz.remote.graphics.objects.DispatchingColormappedImage.D public class DispatchColormappedImageExtension extends AbstractDispatchingImageExtension implements IColormappedImageExtension { + public class DispatchingColormappedCallback implements + IColorMapDataRetrievalCallback { + + private IColorMapDataRetrievalCallback callback; + + private DispatchingColormappedImage image; + + public DispatchingColormappedCallback( + IColorMapDataRetrievalCallback callback) { + this.callback = callback; + } + + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback# + * getColorMapData() + */ + @Override + public ColorMapData getColorMapData() throws VizException { + ColorMapData data = callback.getColorMapData(); + ColorMapDataEvent event = RemoteGraphicsEventFactory.createEvent( + ColorMapDataEvent.class, image); + event.setColorMapData(data); + image.dispatch(event); + return data; + } + } + /* * (non-Javadoc) * @@ -73,8 +104,22 @@ public class DispatchColormappedImageExtension extends dataCallback); IColormappedImage actualImage = targetExt.initializeRaster(wrapper, colorMapParameters); - return new DispatchingColormappedImage(actualImage, wrapper, - target.getDispatcher()); + DispatchingColormappedImage image = new DispatchingColormappedImage( + actualImage, DispatchColormappedImageExtension.class, + target.getDispatcher(), colorMapParameters); + wrapper.image = image; + + // Send creation event + CreateColormappedImageEvent creation = RemoteGraphicsEventFactory + .createEvent(CreateColormappedImageEvent.class, image); + if (colorMapParameters != null) { + creation.setColorMapParameters(DispatchingColormappedImage + .createColorMapParametersUpdateEvent(image)); + } + target.dispatch(creation); + + // Return image + return image; } } diff --git a/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/extensions/DispatchingOffscreenRenderingExtension.java b/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/extensions/DispatchingOffscreenRenderingExtension.java index b8eaf1c49e..0f22b4d758 100644 --- a/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/extensions/DispatchingOffscreenRenderingExtension.java +++ b/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/extensions/DispatchingOffscreenRenderingExtension.java @@ -23,6 +23,7 @@ import java.nio.Buffer; import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.drawables.ColorMapParameters; +import com.raytheon.uf.viz.core.drawables.IColormappedImage; import com.raytheon.uf.viz.core.drawables.IImage; import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension; import com.raytheon.uf.viz.core.drawables.ext.IOffscreenRenderingExtension; @@ -34,7 +35,8 @@ import com.raytheon.uf.viz.remote.graphics.events.offscreen.CreateOffscreenImage import com.raytheon.uf.viz.remote.graphics.events.offscreen.RenderOffscreenEvent; import com.raytheon.uf.viz.remote.graphics.events.offscreen.RenderOnscreenEvent; import com.raytheon.uf.viz.remote.graphics.objects.AbstractDispatchingImage; -import com.raytheon.uf.viz.remote.graphics.objects.DispatchingOffscreenImage; +import com.raytheon.uf.viz.remote.graphics.objects.DispatchingColormappedImage; +import com.raytheon.uf.viz.remote.graphics.objects.DispatchingImage; /** * Offscreen rendering extension that creates remote images for offscreen @@ -127,8 +129,9 @@ public class DispatchingOffscreenRenderingExtension extends * constructOffscreenImage(java.lang.Class, int[]) */ @Override - public IImage constructOffscreenImage(Class dataType, - int[] dimensions) throws VizException { + public IColormappedImage constructOffscreenImage( + Class dataType, int[] dimensions) + throws VizException { return constructOffscreenImage(dataType, dimensions, null); } @@ -140,21 +143,30 @@ public class DispatchingOffscreenRenderingExtension extends * com.raytheon.uf.viz.core.drawables.ColorMapParameters) */ @Override - public IImage constructOffscreenImage(Class dataType, - int[] dimensions, ColorMapParameters parameters) - throws VizException { - IImage offscreenImage = target.getWrappedObject() + public IColormappedImage constructOffscreenImage( + Class dataType, int[] dimensions, + ColorMapParameters parameters) throws VizException { + IColormappedImage offscreenImage = target.getWrappedObject() .getExtension(IOffscreenRenderingExtension.class) .constructOffscreenImage(dataType, dimensions, parameters); - return createOffscreenImage(offscreenImage, dataType, dimensions, - parameters); + return (IColormappedImage) createOffscreenImage(offscreenImage, + dataType, dimensions, parameters); } - private DispatchingOffscreenImage createOffscreenImage(IImage wrapped, + private IImage createOffscreenImage(IImage wrapped, Class dataType, int[] dimensions, ColorMapParameters parameters) { - DispatchingOffscreenImage wrapper = new DispatchingOffscreenImage( - wrapped, target.getDispatcher(), parameters); + AbstractDispatchingImage wrapper = null; + if (dataType == null) { + wrapper = new DispatchingImage(wrapped, + DispatchingImagingExtension.class, null, + target.getDispatcher()); + } else { + wrapper = new DispatchingColormappedImage( + (IColormappedImage) wrapped, + DispatchColormappedImageExtension.class, + target.getDispatcher(), parameters); + } // Send event of offscreen image creation CreateOffscreenImageEvent event = RemoteGraphicsEventFactory .createEvent(CreateOffscreenImageEvent.class, wrapper); diff --git a/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/objects/AbstractDispatchingColormappedImage.java b/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/objects/AbstractDispatchingColormappedImage.java deleted file mode 100644 index dd21ba5dd4..0000000000 --- a/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/objects/AbstractDispatchingColormappedImage.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * 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.remote.graphics.objects; - -import com.raytheon.uf.common.colormap.IColorMap; -import com.raytheon.uf.viz.core.drawables.ColorMapParameters; -import com.raytheon.uf.viz.core.drawables.IColorMapParametersListener; -import com.raytheon.uf.viz.core.drawables.IImage; -import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension; -import com.raytheon.uf.viz.remote.graphics.Dispatcher; -import com.raytheon.uf.viz.remote.graphics.events.colormap.UpdateColorMapParametersEvent; - -/** - * TODO Add Description - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Mar 29, 2012            mschenke     Initial creation
- * 
- * 
- * - * @author mschenke - * @version 1.0 - */ - -public abstract class AbstractDispatchingColormappedImage - extends AbstractDispatchingImage implements - IColorMapParametersListener { - - private IColorMap colorMap; - - /** - * @param targetObject - * @param extensionClass - * @param dispatcher - */ - public AbstractDispatchingColormappedImage(T targetObject, - Class extensionClass, - Dispatcher dispatcher, ColorMapParameters parameters) { - super(targetObject, extensionClass, dispatcher); - if (parameters != null) { - parameters.addListener(this); - } - } - - public abstract ColorMapParameters getColorMapParameters(); - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.viz.core.drawables.IColorMapParametersListener# - * colorMapChanged() - */ - @Override - public void colorMapChanged() { - ColorMapParameters parameters = getColorMapParameters(); - if (parameters != null) { - dispatch(createColorMapParametersUpdateEvent(parameters)); - } - } - - protected UpdateColorMapParametersEvent createColorMapParametersUpdateEvent( - ColorMapParameters parameters) { - UpdateColorMapParametersEvent event = UpdateColorMapParametersEvent - .createEvent(this, parameters); - if (parameters.getColorMap() == colorMap && colorMap != null) { - // Same colormap, discard cm data - event.setRed(null); - event.setBlue(null); - event.setGreen(null); - event.setAlpha(null); - } else { - colorMap = parameters.getColorMap(); - } - return event; - } - -} diff --git a/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/objects/DispatchingColormappedImage.java b/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/objects/DispatchingColormappedImage.java index e867932a70..e39e46458d 100644 --- a/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/objects/DispatchingColormappedImage.java +++ b/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/objects/DispatchingColormappedImage.java @@ -19,15 +19,13 @@ **/ package com.raytheon.uf.viz.remote.graphics.objects; -import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback; +import com.raytheon.uf.common.colormap.IColorMap; import com.raytheon.uf.viz.core.drawables.ColorMapParameters; +import com.raytheon.uf.viz.core.drawables.IColorMapParametersListener; import com.raytheon.uf.viz.core.drawables.IColormappedImage; -import com.raytheon.uf.viz.core.exception.VizException; +import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension; import com.raytheon.uf.viz.remote.graphics.Dispatcher; -import com.raytheon.uf.viz.remote.graphics.events.RemoteGraphicsEventFactory; -import com.raytheon.uf.viz.remote.graphics.events.colormap.ColorMapDataEvent; -import com.raytheon.uf.viz.remote.graphics.events.colormap.CreateColormappedImageEvent; -import com.raytheon.uf.viz.remote.graphics.extensions.DispatchColormappedImageExtension; +import com.raytheon.uf.viz.remote.graphics.events.colormap.UpdateColorMapParametersEvent; /** * Dispatching colormapped image object created from graphics image and forwards @@ -47,58 +45,24 @@ import com.raytheon.uf.viz.remote.graphics.extensions.DispatchColormappedImageEx * @version 1.0 */ -public class DispatchingColormappedImage extends - AbstractDispatchingColormappedImage implements +public class DispatchingColormappedImage extends + AbstractDispatchingImage implements IColorMapParametersListener, IColormappedImage { - public static class DispatchingColormappedCallback implements - IColorMapDataRetrievalCallback { - - private IColorMapDataRetrievalCallback callback; - - private DispatchingColormappedImage image; - - public DispatchingColormappedCallback( - IColorMapDataRetrievalCallback callback) { - this.callback = callback; - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback# - * getColorMapData() - */ - @Override - public ColorMapData getColorMapData() throws VizException { - ColorMapData data = callback.getColorMapData(); - ColorMapDataEvent event = RemoteGraphicsEventFactory.createEvent( - ColorMapDataEvent.class, image); - event.setColorMapData(data); - image.dispatch(event); - return data; - } - } + private IColorMap colorMap; /** * @param targetObject + * @param extensionClass * @param dispatcher */ - public DispatchingColormappedImage(IColormappedImage targetObject, - DispatchingColormappedCallback callback, Dispatcher dispatcher) { - super(targetObject, DispatchColormappedImageExtension.class, - dispatcher, targetObject.getColorMapParameters()); - callback.image = this; - ColorMapParameters parameters = targetObject.getColorMapParameters(); - - // Send creation event - CreateColormappedImageEvent creation = RemoteGraphicsEventFactory - .createEvent(CreateColormappedImageEvent.class, this); + public DispatchingColormappedImage(T targetObject, + Class extensionClass, + Dispatcher dispatcher, ColorMapParameters parameters) { + super(targetObject, extensionClass, dispatcher); if (parameters != null) { - creation.setColorMapParameters(createColorMapParametersUpdateEvent(parameters)); + parameters.addListener(this); } - - dispatch(creation); } /* @@ -130,7 +94,7 @@ public class DispatchingColormappedImage extends wrappedObject.setColorMapParameters(params); if (params != null) { params.addListener(this); - dispatch(createColorMapParametersUpdateEvent(params)); + dispatch(createColorMapParametersUpdateEvent(this)); } } } @@ -146,4 +110,52 @@ public class DispatchingColormappedImage extends return wrappedObject.getValue(x, y); } + /* + * (non-Javadoc) + * + * @see com.raytheon.uf.viz.core.drawables.IColorMapParametersListener# + * colorMapChanged() + */ + @Override + public void colorMapChanged() { + ColorMapParameters parameters = getColorMapParameters(); + if (parameters != null) { + dispatch(createColorMapParametersUpdateEvent(this)); + } + } + + public static UpdateColorMapParametersEvent createColorMapParametersUpdateEvent( + DispatchingColormappedImage image) { + ColorMapParameters parameters = image.getColorMapParameters(); + UpdateColorMapParametersEvent event = UpdateColorMapParametersEvent + .createEvent(image, parameters); + if (parameters.getColorMap() == image.colorMap + && image.colorMap != null) { + // Same colormap, discard cm data + event.setRed(null); + event.setBlue(null); + event.setGreen(null); + event.setAlpha(null); + } else { + image.colorMap = parameters.getColorMap(); + } + return event; + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.viz.remote.graphics.objects.AbstractDispatchingImage# + * dispose() + */ + @Override + public void dispose() { + super.dispose(); + ColorMapParameters params = getColorMapParameters(); + if (params != null) { + params.removeListener(this); + } + } + } diff --git a/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/objects/DispatchingImage.java b/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/objects/DispatchingImage.java index 9da6de1b59..d756910f6e 100644 --- a/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/objects/DispatchingImage.java +++ b/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/objects/DispatchingImage.java @@ -84,7 +84,9 @@ public class DispatchingImage extends AbstractDispatchingImage { Class extension, DispatchingRenderedImageCallback callback, Dispatcher dispatcher) { super(targetObject, extension, dispatcher); - callback.image = this; + if (callback != null) { + callback.image = this; + } } } diff --git a/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/objects/DispatchingOffscreenImage.java b/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/objects/DispatchingOffscreenImage.java deleted file mode 100644 index 592cb184a0..0000000000 --- a/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/objects/DispatchingOffscreenImage.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * 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.remote.graphics.objects; - -import com.raytheon.uf.viz.core.drawables.ColorMapParameters; -import com.raytheon.uf.viz.core.drawables.IImage; -import com.raytheon.uf.viz.remote.graphics.Dispatcher; -import com.raytheon.uf.viz.remote.graphics.extensions.DispatchingImagingExtension; - -/** - * TODO Add Description - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Mar 29, 2012            mschenke     Initial creation
- * 
- * 
- * - * @author mschenke - * @version 1.0 - */ - -public class DispatchingOffscreenImage extends - AbstractDispatchingColormappedImage { - - private ColorMapParameters parameters; - - /** - * @param targetObject - * @param extensionClass - * @param dispatcher - */ - public DispatchingOffscreenImage(IImage targetObject, - Dispatcher dispatcher, ColorMapParameters parameters) { - super(targetObject, DispatchingImagingExtension.class, dispatcher, - parameters); - this.parameters = parameters; - } - - /* - * (non-Javadoc) - * - * @see com.raytheon.uf.viz.remote.graphics.objects. - * AbstractDispatchingColormappedImage#getColorMapParameters() - */ - @Override - public ColorMapParameters getColorMapParameters() { - return parameters; - } - - /* - * (non-Javadoc) - * - * @see - * com.raytheon.uf.viz.remote.graphics.objects.AbstractDispatchingImage# - * dispose() - */ - @Override - public void dispose() { - super.dispose(); - if (parameters != null) { - parameters.removeListener(this); - } - } - -} diff --git a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/ext/GLOffscreenRenderingExtension.java b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/ext/GLOffscreenRenderingExtension.java index 777568eeb8..ef20f7d020 100644 --- a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/ext/GLOffscreenRenderingExtension.java +++ b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/ext/GLOffscreenRenderingExtension.java @@ -23,6 +23,7 @@ import com.raytheon.viz.core.gl.dataformat.AbstractGLColorMapDataFormat; import com.raytheon.viz.core.gl.dataformat.GLByteDataFormat; import com.raytheon.viz.core.gl.dataformat.IGLColorMapDataFormatProvider; import com.raytheon.viz.core.gl.images.AbstractGLImage; +import com.raytheon.viz.core.gl.images.GLColormappedImage; import com.raytheon.viz.core.gl.internal.GLView2D; import com.raytheon.viz.core.gl.internal.ext.GLColormappedImageExtension; @@ -163,7 +164,7 @@ public class GLOffscreenRenderingExtension extends GraphicsExtension * constructOffscreenImage(java.lang.Class, java.awt.Rectangle) */ @Override - public AbstractGLImage constructOffscreenImage( + public GLColormappedImage constructOffscreenImage( Class dataType, int[] dimensions) throws VizException { return constructOffscreenImage(dataType, dimensions, null); @@ -176,7 +177,7 @@ public class GLOffscreenRenderingExtension extends GraphicsExtension * constructOffscreenImage(java.lang.Class, java.awt.Rectangle) */ @Override - public AbstractGLImage constructOffscreenImage( + public GLColormappedImage constructOffscreenImage( Class dataType, final int[] dimensions, ColorMapParameters parameters) throws VizException { int width = dimensions[0]; @@ -193,7 +194,7 @@ public class GLOffscreenRenderingExtension extends GraphicsExtension } if (imageBuffer != null) { - AbstractGLImage image = null; + GLColormappedImage image = null; final Buffer buffer = imageBuffer; GLColormappedImageExtension cmapExt = target .getExtension(GLColormappedImageExtension.class); diff --git a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/mosaic/RadarMosaicRenderer.java b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/mosaic/RadarMosaicRenderer.java index e44bb780f5..e1f58c89e1 100644 --- a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/mosaic/RadarMosaicRenderer.java +++ b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/mosaic/RadarMosaicRenderer.java @@ -149,6 +149,7 @@ public class RadarMosaicRenderer implements IRadarMosaicRenderer, writeTo.setImagesToMosaic(images .toArray(new DrawableImage[images.size()])); lastExtent = paintProps.getView().getExtent().clone(); + writeTo.setImageExtent(lastExtent); Coordinate ul = new Coordinate(lastExtent.getMinX(), lastExtent.getMaxY()); @@ -180,7 +181,8 @@ public class RadarMosaicRenderer implements IRadarMosaicRenderer, writeTo = target.getExtension(IRadarMosaicImageExtension.class) .initializeRaster( new int[] { paintProps.getCanvasBounds().width, - paintProps.getCanvasBounds().height }, params); + paintProps.getCanvasBounds().height }, + paintProps.getView().getExtent(), params); } @Override diff --git a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/mosaic/ext/IRadarMosaicImageExtension.java b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/mosaic/ext/IRadarMosaicImageExtension.java index fe0ef14d81..c0d3a883f7 100644 --- a/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/mosaic/ext/IRadarMosaicImageExtension.java +++ b/cave/com.raytheon.viz.radar/src/com/raytheon/viz/radar/rsc/mosaic/ext/IRadarMosaicImageExtension.java @@ -20,8 +20,9 @@ package com.raytheon.viz.radar.rsc.mosaic.ext; import com.raytheon.uf.viz.core.DrawableImage; +import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.drawables.ColorMapParameters; -import com.raytheon.uf.viz.core.drawables.IImage; +import com.raytheon.uf.viz.core.drawables.IColormappedImage; import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension; import com.raytheon.uf.viz.core.exception.VizException; @@ -44,13 +45,24 @@ import com.raytheon.uf.viz.core.exception.VizException; public interface IRadarMosaicImageExtension extends IImagingExtension { - public static interface IMosaicImage extends IImage { + public static interface IMosaicImage extends IColormappedImage { public void setImagesToMosaic(DrawableImage... images); + public void setImageExtent(IExtent imageExtent); + } + /** + * Creates a mosaic image with the given imageBounds and imageExtent + * + * @param imageBounds + * @param imageExtent + * @param params + * @return + * @throws VizException + */ public IMosaicImage initializeRaster(int[] imageBounds, - ColorMapParameters params) throws VizException; + IExtent imageExtent, ColorMapParameters params) throws VizException; }