Issue #239 Got IColormapShadedShapeExtension implemented

Change-Id: Idb2b5a894530b739cd8b00f8f3b294f186d5143f

Former-commit-id: 6ddfe51e93d62145678d87ed3db208e90d3146e3
This commit is contained in:
Max Schenkelberg 2012-05-23 09:14:21 -05:00
parent e81a9ee935
commit ae8236aa21
13 changed files with 819 additions and 105 deletions

View file

@ -19,6 +19,10 @@
**/
package com.raytheon.uf.viz.collaboration.ui.rsc.rendering;
import java.util.HashMap;
import org.eclipse.swt.graphics.RGB;
import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.collaboration.ui.Activator;
@ -27,20 +31,28 @@ import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.IShadedShape;
import com.raytheon.uf.viz.core.drawables.IShape;
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.ext.colormap.IColormapShadedShapeExtension;
import com.raytheon.uf.viz.core.drawables.ext.colormap.IColormapShadedShapeExtension.IColormapShadedShape;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.remote.graphics.events.shapes.AbstractShadedShapeData.DataSpace;
import com.raytheon.uf.viz.remote.graphics.events.shapes.AllocatePointsEvent;
import com.raytheon.uf.viz.remote.graphics.events.shapes.ColormappedShadedShapeDataEvent;
import com.raytheon.uf.viz.remote.graphics.events.shapes.ColormappedShadedShapeDataEvent.ColormappedShadedGeometryData;
import com.raytheon.uf.viz.remote.graphics.events.shapes.ColormappedShadedShapeDataEvent.ColormappedShadedShapeData;
import com.raytheon.uf.viz.remote.graphics.events.shapes.CreateColormappedShadedShape;
import com.raytheon.uf.viz.remote.graphics.events.shapes.CreateShadedShapeEvent;
import com.raytheon.uf.viz.remote.graphics.events.shapes.CreateWireframeShapeEvent;
import com.raytheon.uf.viz.remote.graphics.events.shapes.DrawShadedShapeEvent;
import com.raytheon.uf.viz.remote.graphics.events.shapes.DrawShadedShapesEvent;
import com.raytheon.uf.viz.remote.graphics.events.shapes.RenderColormappedShadedShape;
import com.raytheon.uf.viz.remote.graphics.events.shapes.RenderWireframeShapeEvent;
import com.raytheon.uf.viz.remote.graphics.events.shapes.SetShadedShapeFillPattern;
import com.raytheon.uf.viz.remote.graphics.events.shapes.ShadedShapeDataEvent;
import com.raytheon.uf.viz.remote.graphics.events.shapes.ShadedShapeDataEvent.DataSpace;
import com.raytheon.uf.viz.remote.graphics.events.shapes.ShadedShapeDataEvent.ShadedShapeData;
import com.raytheon.uf.viz.remote.graphics.events.shapes.WireframeShapeDataEvent;
import com.raytheon.uf.viz.remote.graphics.events.shapes.WireframeShapeDataEvent.Label;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.LineString;
/**
* Handles render events for IShapes
@ -94,6 +106,21 @@ public class ShapeRenderingHandler extends CollaborationRenderingHandler {
dataManager.putRenderableObject(shapeId, shape);
}
@Subscribe
public void createColormapShadedShape(CreateColormappedShadedShape event) {
IGraphicsTarget target = getGraphicsTarget();
try {
IColormapShadedShapeExtension ext = target
.getExtension(IColormapShadedShapeExtension.class);
IColormapShadedShape shape = ext.createColormapShadedShape(
event.getTargetGeometry(), event.isTesselate());
dataManager.putRenderableObject(event.getObjectId(), shape);
} catch (VizException e) {
Activator.statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
}
@Subscribe
public void allocatePointsForShape(AllocatePointsEvent event) {
IWireframeShape shape = dataManager.getRenderableObject(
@ -132,10 +159,10 @@ public class ShapeRenderingHandler extends CollaborationRenderingHandler {
shape.reset();
for (ShadedShapeData data : event.getShapeData()) {
if (data.getDataSpace() == DataSpace.PIXEL) {
shape.addPolygonPixelSpace(data.getData(),
data.getDataColor());
shape.addPolygonPixelSpace(data.getContour(),
data.getInfo());
} else if (data.getDataSpace() == DataSpace.WORLD) {
shape.addPolygon(data.getData(), data.getDataColor());
shape.addPolygon(data.getContour(), data.getInfo());
}
}
if (event.isCompile()) {
@ -144,6 +171,31 @@ public class ShapeRenderingHandler extends CollaborationRenderingHandler {
}
}
@Subscribe
public void colormapShadedShapeDataArrived(
ColormappedShadedShapeDataEvent event) {
IColormapShadedShape shape = dataManager.getRenderableObject(
event.getObjectId(), IColormapShadedShape.class);
if (shape != null) {
shape.reset();
for (ColormappedShadedShapeData data : event.getShapeData()) {
LineString[] contour = data.getContour();
Integer key = data.getInfo();
if (data.getDataSpace() == DataSpace.WORLD) {
shape.addPolygon(contour, key);
} else {
shape.addPolygonPixelSpace(contour, key);
}
}
for (ColormappedShadedGeometryData data : event.getGeometryData()) {
shape.addGeometry(data.getGeometry(), data.getColorKey());
}
if (event.isCompile()) {
shape.compile();
}
}
}
@Subscribe
public void setShadedShapeFillPattern(SetShadedShapeFillPattern event) {
int shapeId = event.getObjectId();
@ -199,6 +251,25 @@ public class ShapeRenderingHandler extends CollaborationRenderingHandler {
}
}
@Subscribe
public void renderColormapShadedShape(RenderColormappedShadedShape event) {
IColormapShadedShape shape = dataManager.getRenderableObject(
event.getObjectId(), IColormapShadedShape.class);
if (shape != null) {
try {
IGraphicsTarget target = getGraphicsTarget();
IColormapShadedShapeExtension extension = target
.getExtension(IColormapShadedShapeExtension.class);
extension.drawColormapShadedShape(shape,
new HashMap<Object, RGB>(event.getColorMap()),
event.getAlpha(), event.getBrightness());
} catch (VizException e) {
Activator.statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
}
}
@Subscribe
public void disposeShape(IShape shape) {
shape.dispose();

View file

@ -26,6 +26,7 @@ import org.eclipse.swt.graphics.RGB;
import org.geotools.coverage.grid.GeneralGridGeometry;
import com.raytheon.uf.viz.core.drawables.IShadedShape;
import com.raytheon.uf.viz.core.drawables.IShape;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
import com.raytheon.uf.viz.core.exception.VizException;
import com.vividsolutions.jts.geom.Geometry;
@ -57,7 +58,7 @@ import com.vividsolutions.jts.geom.LineString;
public interface IColormapShadedShapeExtension extends
IGraphicsExtensionInterface {
public interface IColormapShadedShape {
public interface IColormapShadedShape extends IShape {
/**
* get the colormap keys
@ -97,8 +98,6 @@ public interface IColormapShadedShapeExtension extends
*/
public void addGeometry(Geometry geometry, Object colorKey);
public void dispose();
}
/**

View file

@ -37,5 +37,8 @@
<graphicsExtension
class="com.raytheon.uf.viz.remote.graphics.extensions.DispatchingSingleColorImageExtension">
</graphicsExtension>
<graphicsExtension
class="com.raytheon.uf.viz.remote.graphics.extensions.DispatchingColormappedShadedShapeExtension">
</graphicsExtension>
</extension>
</plugin>

View file

@ -0,0 +1,104 @@
/**
* 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.events.shapes;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.vividsolutions.jts.geom.LineString;
/**
* Abstract class for shaded shape data. Accommodates colormapped shaded shapes
* and regular shaded shapes
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 22, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
@DynamicSerialize
public abstract class AbstractShadedShapeData<T> {
public static enum DataSpace {
PIXEL, WORLD;
}
@DynamicSerializeElement
private T info;
@DynamicSerializeElement
private LineString[] contour;
@DynamicSerializeElement
private DataSpace dataSpace;
/**
* @return the info
*/
public T getInfo() {
return info;
}
/**
* @param info
* the info to set
*/
public void setInfo(T info) {
this.info = info;
}
/**
* @return the contour
*/
public LineString[] getContour() {
return contour;
}
/**
* @param contour
* the contour to set
*/
public void setContour(LineString[] contour) {
this.contour = contour;
}
/**
* @return the dataSpace
*/
public DataSpace getDataSpace() {
return dataSpace;
}
/**
* @param dataSpace
* the dataSpace to set
*/
public void setDataSpace(DataSpace dataSpace) {
this.dataSpace = dataSpace;
}
}

View file

@ -0,0 +1,168 @@
/**
* 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.events.shapes;
import java.util.LinkedList;
import java.util.List;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent;
import com.raytheon.uf.viz.remote.graphics.events.shapes.AbstractShadedShapeData.DataSpace;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.LineString;
/**
* Event for colormapped shaded shape data for display
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 15, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
@DynamicSerialize
public class ColormappedShadedShapeDataEvent extends
AbstractDispatchingObjectEvent {
@DynamicSerialize
public static class ColormappedShadedShapeData extends
AbstractShadedShapeData<Integer> {
}
@DynamicSerialize
public static class ColormappedShadedGeometryData {
@DynamicSerializeElement
private Geometry geometry;
@DynamicSerializeElement
private Integer colorKey;
/**
* @return the geometry
*/
public Geometry getGeometry() {
return geometry;
}
/**
* @param geometry
* the geometry to set
*/
public void setGeometry(Geometry geometry) {
this.geometry = geometry;
}
/**
* @return the colorKey
*/
public Integer getColorKey() {
return colorKey;
}
/**
* @param colorKey
* the colorKey to set
*/
public void setColorKey(Integer colorKey) {
this.colorKey = colorKey;
}
}
@DynamicSerializeElement
private boolean compile = false;
@DynamicSerializeElement
private List<ColormappedShadedShapeData> shapeData = new LinkedList<ColormappedShadedShapeData>();
@DynamicSerializeElement
private List<ColormappedShadedGeometryData> geometryData = new LinkedList<ColormappedShadedShapeDataEvent.ColormappedShadedGeometryData>();
/**
* @return the compile
*/
public boolean isCompile() {
return compile;
}
/**
* @param compile
* the compile to set
*/
public void setCompile(boolean compile) {
this.compile = compile;
}
/**
* @return the shapeData
*/
public List<ColormappedShadedShapeData> getShapeData() {
return shapeData;
}
/**
* @param shapeData
* the shapeData to set
*/
public void setShapeData(List<ColormappedShadedShapeData> shapeData) {
this.shapeData = shapeData;
}
/**
* @return the geometryData
*/
public List<ColormappedShadedGeometryData> getGeometryData() {
return geometryData;
}
/**
* @param geometryData
* the geometryData to set
*/
public void setGeometryData(List<ColormappedShadedGeometryData> geometryData) {
this.geometryData = geometryData;
}
public void addShapeData(DataSpace dataSpace, LineString[] contours,
Integer colorKey) {
ColormappedShadedShapeData shapeDataItem = new ColormappedShadedShapeData();
shapeDataItem.setDataSpace(dataSpace);
shapeDataItem.setInfo(colorKey);
shapeDataItem.setContour(contours);
shapeData.add(shapeDataItem);
}
public void addGeometryData(Geometry data, Integer colorKey) {
ColormappedShadedGeometryData shapeDataItem = new ColormappedShadedGeometryData();
shapeDataItem.setColorKey(colorKey);
shapeDataItem.setGeometry(data);
geometryData.add(shapeDataItem);
}
}

View file

@ -0,0 +1,85 @@
/**
* 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.events.shapes;
import org.geotools.coverage.grid.GeneralGridGeometry;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent;
import com.raytheon.uf.viz.remote.graphics.events.ICreationEvent;
/**
* Event to create a new colormapped shaded shape
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 22, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
@DynamicSerialize
public class CreateColormappedShadedShape extends
AbstractDispatchingObjectEvent implements ICreationEvent {
@DynamicSerializeElement
private GeneralGridGeometry targetGeometry;
@DynamicSerializeElement
private boolean tesselate;
/**
* @return the targetGeometry
*/
public GeneralGridGeometry getTargetGeometry() {
return targetGeometry;
}
/**
* @param targetGeometry
* the targetGeometry to set
*/
public void setTargetGeometry(GeneralGridGeometry targetGeometry) {
this.targetGeometry = targetGeometry;
}
/**
* @return the tesselate
*/
public boolean isTesselate() {
return tesselate;
}
/**
* @param tesselate
* the tesselate to set
*/
public void setTesselate(boolean tesselate) {
this.tesselate = tesselate;
}
}

View file

@ -0,0 +1,190 @@
/**
* 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.events.shapes;
import java.util.Map;
import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent;
import com.raytheon.uf.viz.remote.graphics.events.rendering.IRenderEvent;
/**
* Event for rendering a colormapped shaded shape
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 22, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
@DynamicSerialize
public class RenderColormappedShadedShape extends
AbstractDispatchingObjectEvent implements IRenderEvent {
@DynamicSerializeElement
private Map<Integer, RGB> colorMap;
@DynamicSerializeElement
private Float alpha;
@DynamicSerializeElement
private Float brightness;
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.remote.graphics.events.rendering.
* AbstractRemoteGraphicsRenderEvent
* #createDiffObject(com.raytheon.uf.viz.remote
* .graphics.events.rendering.IRenderEvent)
*/
@Override
public IRenderEvent createDiffObject(IRenderEvent event) {
RenderColormappedShadedShape e = (RenderColormappedShadedShape) event;
RenderColormappedShadedShape diffObject = new RenderColormappedShadedShape();
diffObject.setObjectId(e.getObjectId());
if (alpha.equals(e.alpha) == false)
diffObject.alpha = e.alpha;
if (brightness.equals(e.brightness) == false)
diffObject.brightness = e.brightness;
if (colorMap.equals(e.colorMap) == false)
diffObject.colorMap = e.colorMap;
return diffObject;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.remote.graphics.events.rendering.IRenderEvent#
* applyDiffObject
* (com.raytheon.uf.viz.remote.graphics.events.rendering.IRenderEvent)
*/
@Override
public void applyDiffObject(IRenderEvent diffEvent) {
RenderColormappedShadedShape diffObject = (RenderColormappedShadedShape) diffEvent;
setObjectId(diffObject.getObjectId());
if (diffObject.alpha != null)
alpha = diffObject.alpha;
if (diffObject.brightness != null)
brightness = diffObject.brightness;
if (diffObject.colorMap != null)
colorMap = diffObject.colorMap;
}
/**
* @return the colorMap
*/
public Map<Integer, RGB> getColorMap() {
return colorMap;
}
/**
* @param colorMap
* the colorMap to set
*/
public void setColorMap(Map<Integer, RGB> colorMap) {
this.colorMap = colorMap;
}
/**
* @return the alpha
*/
public Float getAlpha() {
return alpha;
}
/**
* @param alpha
* the alpha to set
*/
public void setAlpha(Float alpha) {
this.alpha = alpha;
}
/**
* @return the brightness
*/
public Float getBrightness() {
return brightness;
}
/**
* @param brightness
* the brightness to set
*/
public void setBrightness(Float brightness) {
this.brightness = brightness;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#clone()
*/
@Override
public Object clone() {
RenderColormappedShadedShape newInstance = new RenderColormappedShadedShape();
newInstance.applyDiffObject(this);
return newInstance;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
RenderColormappedShadedShape other = (RenderColormappedShadedShape) obj;
if (alpha == null) {
if (other.alpha != null)
return false;
} else if (!alpha.equals(other.alpha))
return false;
if (brightness == null) {
if (other.brightness != null)
return false;
} else if (!brightness.equals(other.brightness))
return false;
if (colorMap == null) {
if (other.colorMap != null)
return false;
} else if (!colorMap.equals(other.colorMap))
return false;
return true;
}
}

View file

@ -27,6 +27,7 @@ import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent;
import com.raytheon.uf.viz.remote.graphics.events.shapes.AbstractShadedShapeData.DataSpace;
import com.vividsolutions.jts.geom.LineString;
/**
@ -48,66 +49,9 @@ import com.vividsolutions.jts.geom.LineString;
@DynamicSerialize
public class ShadedShapeDataEvent extends AbstractDispatchingObjectEvent {
public static enum DataSpace {
WORLD, PIXEL;
}
@DynamicSerialize
public static class ShadedShapeData {
public static class ShadedShapeData extends AbstractShadedShapeData<RGB> {
@DynamicSerializeElement
private DataSpace dataSpace;
@DynamicSerializeElement
private RGB dataColor;
@DynamicSerializeElement
private LineString[] data;
/**
* @return the dataSpace
*/
public DataSpace getDataSpace() {
return dataSpace;
}
/**
* @param dataSpace
* the dataSpace to set
*/
public void setDataSpace(DataSpace dataSpace) {
this.dataSpace = dataSpace;
}
/**
* @return the dataColor
*/
public RGB getDataColor() {
return dataColor;
}
/**
* @param dataColor
* the dataColor to set
*/
public void setDataColor(RGB dataColor) {
this.dataColor = dataColor;
}
/**
* @return the data
*/
public LineString[] getData() {
return data;
}
/**
* @param data
* the data to set
*/
public void setData(LineString[] data) {
this.data = data;
}
}
@DynamicSerializeElement
@ -149,8 +93,8 @@ public class ShadedShapeDataEvent extends AbstractDispatchingObjectEvent {
public void addShapeData(DataSpace dataSpace, LineString[] data, RGB color) {
ShadedShapeData shapeDataItem = new ShadedShapeData();
shapeDataItem.setDataSpace(dataSpace);
shapeDataItem.setData(data);
shapeDataItem.setDataColor(color);
shapeDataItem.setContour(data);
shapeDataItem.setInfo(color);
shapeData.add(shapeDataItem);
}
}

View file

@ -19,6 +19,7 @@
**/
package com.raytheon.uf.viz.remote.graphics.extensions;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.swt.graphics.RGB;
@ -29,9 +30,13 @@ import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension;
import com.raytheon.uf.viz.core.drawables.ext.colormap.IColormapShadedShapeExtension;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.remote.graphics.DispatchGraphicsTarget;
import com.raytheon.uf.viz.remote.graphics.events.RemoteGraphicsEventFactory;
import com.raytheon.uf.viz.remote.graphics.events.shapes.CreateColormappedShadedShape;
import com.raytheon.uf.viz.remote.graphics.events.shapes.RenderColormappedShadedShape;
import com.raytheon.uf.viz.remote.graphics.objects.DispatchingColormappedShadedShape;
/**
* TODO Add Description
* Dispatching implementation of IColormapShadedShapeExtension
*
* <pre>
*
@ -51,6 +56,8 @@ public class DispatchingColormappedShadedShapeExtension extends
GraphicsExtension<DispatchGraphicsTarget> implements
IColormapShadedShapeExtension {
private IColormapShadedShapeExtension wrappedExt;
/*
* (non-Javadoc)
*
@ -63,8 +70,16 @@ public class DispatchingColormappedShadedShapeExtension extends
@Override
public IColormapShadedShape createColormapShadedShape(
GeneralGridGeometry targetGeometry, boolean tesselate) {
// TODO Auto-generated method stub
return null;
DispatchingColormappedShadedShape wrapper = new DispatchingColormappedShadedShape(
wrappedExt.createColormapShadedShape(targetGeometry, tesselate),
target.getDispatcher());
// Send creation event
CreateColormappedShadedShape event = RemoteGraphicsEventFactory
.createEvent(CreateColormappedShadedShape.class, wrapper);
event.setTargetGeometry(targetGeometry);
event.setTesselate(tesselate);
target.dispatch(event);
return wrapper;
}
/*
@ -78,7 +93,7 @@ public class DispatchingColormappedShadedShapeExtension extends
@Override
public IShadedShape createShadedShape(IColormapShadedShape baseShape,
Map<Object, RGB> colors) {
// TODO Auto-generated method stub
// TODO Implement this
return null;
}
@ -95,8 +110,24 @@ public class DispatchingColormappedShadedShapeExtension extends
public void drawColormapShadedShape(IColormapShadedShape shape,
Map<Object, RGB> colors, float alpha, float brightness)
throws VizException {
// TODO Auto-generated method stub
DispatchingColormappedShadedShape wrapper = (DispatchingColormappedShadedShape) shape;
IColormapShadedShape wrapped = wrapper.getWrappedObject();
// Draw to screen
wrappedExt.drawColormapShadedShape(wrapped, colors, alpha, brightness);
// Draw remote
wrapper.flushState();
Map<Object, Integer> keyMap = wrapper.getKeyMap();
Map<Integer, RGB> colorMap = new HashMap<Integer, RGB>();
for (Object key : colors.keySet()) {
Integer keyId = keyMap.get(key);
colorMap.put(keyId, colors.get(key));
}
RenderColormappedShadedShape event = RemoteGraphicsEventFactory
.createEvent(RenderColormappedShadedShape.class, wrapper);
event.setColorMap(colorMap);
event.setAlpha(alpha);
event.setBrightness(brightness);
target.dispatch(event);
}
/*
@ -107,7 +138,13 @@ public class DispatchingColormappedShadedShapeExtension extends
*/
@Override
public int getCompatibilityValue(DispatchGraphicsTarget target) {
return Compatibilty.TARGET_COMPATIBLE;
try {
wrappedExt = target.getWrappedObject().getExtension(
IColormapShadedShapeExtension.class);
return Compatibilty.TARGET_COMPATIBLE;
} catch (VizException e) {
return Compatibilty.INCOMPATIBLE;
}
}
}

View file

@ -19,13 +19,18 @@
**/
package com.raytheon.uf.viz.remote.graphics.objects;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import com.raytheon.uf.viz.core.drawables.ext.colormap.IColormapShadedShapeExtension.IColormapShadedShape;
import com.raytheon.uf.viz.remote.graphics.Dispatcher;
import com.raytheon.uf.viz.remote.graphics.DispatchingObject;
import com.raytheon.uf.viz.remote.graphics.events.DisposeObjectEvent;
import com.raytheon.uf.viz.remote.graphics.events.RemoteGraphicsEventFactory;
import com.raytheon.uf.viz.remote.graphics.events.shapes.AbstractShadedShapeData.DataSpace;
import com.raytheon.uf.viz.remote.graphics.events.shapes.ColormappedShadedShapeDataEvent;
import com.raytheon.uf.viz.remote.graphics.events.shapes.ColormappedShadedShapeDataEvent.ColormappedShadedGeometryData;
import com.raytheon.uf.viz.remote.graphics.events.shapes.ColormappedShadedShapeDataEvent.ColormappedShadedShapeData;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.LineString;
@ -47,9 +52,14 @@ import com.vividsolutions.jts.geom.LineString;
*/
public class DispatchingColormappedShadedShape extends
DispatchingObject<IColormapShadedShape> implements IColormapShadedShape {
AbstractDispatchingShape<IColormapShadedShape> implements
IColormapShadedShape {
private boolean dirty = true;
private int currentId = 0;
private Map<Object, Integer> keyMap = new HashMap<Object, Integer>();
private ColormappedShadedShapeDataEvent updateEvent;
/**
* @param targetObject
@ -59,6 +69,7 @@ public class DispatchingColormappedShadedShape extends
public DispatchingColormappedShadedShape(IColormapShadedShape targetObject,
Dispatcher dispatcher) {
super(targetObject, dispatcher);
updateEvent = createNewUpdateEvent();
}
/**
@ -77,6 +88,11 @@ public class DispatchingColormappedShadedShape extends
*/
public void addPolygon(LineString[] lineString, Object colorKey) {
wrappedObject.addPolygon(lineString, colorKey);
if (updateEvent != null) {
updateEvent.addShapeData(DataSpace.WORLD, lineString,
getKey(colorKey));
markDirty();
}
}
/**
@ -87,6 +103,11 @@ public class DispatchingColormappedShadedShape extends
*/
public void addPolygonPixelSpace(LineString[] contours, Object colorKey) {
wrappedObject.addPolygonPixelSpace(contours, colorKey);
if (updateEvent != null) {
updateEvent.addShapeData(DataSpace.PIXEL, contours,
getKey(colorKey));
markDirty();
}
}
/**
@ -97,16 +118,96 @@ public class DispatchingColormappedShadedShape extends
*/
public void addGeometry(Geometry geometry, Object colorKey) {
wrappedObject.addGeometry(geometry, colorKey);
if (updateEvent != null) {
updateEvent.addGeometryData(geometry, getKey(colorKey));
markDirty();
}
}
/**
private Integer getKey(Object colorKey) {
synchronized (keyMap) {
Integer keyId = keyMap.get(colorKey);
if (keyId == null) {
keyId = currentId++;
keyMap.put(colorKey, keyId);
}
return keyId;
}
}
public Map<Object, Integer> getKeyMap() {
synchronized (keyMap) {
return new HashMap<Object, Integer>(keyMap);
}
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.ext.colormap.IColormapShadedShapeExtension.IColormapShadedShape#dispose()
* @see
* com.raytheon.uf.viz.remote.graphics.objects.AbstractDispatchingShape#
* compile()
*/
@Override
public void compile() {
updateEvent.setCompile(true);
// super.compile() will flush the state
super.compile();
// Event if original shape was mutable, once compiled we should not
// accept more data
updateEvent = null;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.remote.graphics.objects.AbstractDispatchingShape#
* reset()
*/
@Override
public void reset() {
super.reset();
updateEvent = createNewUpdateEvent();
markDirty();
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.remote.graphics.objects.AbstractDispatchingShape#
* dispose()
*/
@Override
public void dispose() {
wrappedObject.dispose();
dispatch(RemoteGraphicsEventFactory.createEvent(
DisposeObjectEvent.class, this));
super.dispose();
keyMap.clear();
updateEvent = null;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.remote.graphics.objects.AbstractDispatchingShape#
* flushInternalState()
*/
@Override
protected void flushInternalState() {
if (updateEvent != null) {
ColormappedShadedShapeDataEvent toSend = createNewUpdateEvent();
toSend.setShapeData(new ArrayList<ColormappedShadedShapeData>(
updateEvent.getShapeData()));
toSend.setGeometryData(new ArrayList<ColormappedShadedGeometryData>(
updateEvent.getGeometryData()));
dispatch(toSend);
}
}
private ColormappedShadedShapeDataEvent createNewUpdateEvent() {
return RemoteGraphicsEventFactory.createEvent(
ColormappedShadedShapeDataEvent.class, this);
}
}

View file

@ -26,9 +26,9 @@ import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.viz.core.drawables.IShadedShape;
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.shapes.AbstractShadedShapeData.DataSpace;
import com.raytheon.uf.viz.remote.graphics.events.shapes.SetShadedShapeFillPattern;
import com.raytheon.uf.viz.remote.graphics.events.shapes.ShadedShapeDataEvent;
import com.raytheon.uf.viz.remote.graphics.events.shapes.ShadedShapeDataEvent.DataSpace;
import com.raytheon.uf.viz.remote.graphics.events.shapes.ShadedShapeDataEvent.ShadedShapeData;
import com.vividsolutions.jts.geom.LineString;

View file

@ -72,21 +72,6 @@ public class GLShadedShape extends GLShadedShapeBase implements IShadedShape {
return mutable;
}
@Override
public boolean isDrawable() {
return true;
}
@Override
public void dispose() {
super.dispose();
}
@Override
public void reset() {
super.dispose();
}
@Override
public void addPolygon(LineString[] lineString, RGB color) {
colors.add(color);

View file

@ -41,11 +41,8 @@ import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.geospatial.TransformFactory;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.drawables.IShape;
import com.raytheon.viz.core.gl.Activator;
import com.raytheon.viz.core.gl.GLCapabilities;
import com.raytheon.viz.core.gl.glsl.GLSLFactory;
import com.raytheon.viz.core.gl.glsl.GLShaderProgram;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.LineString;
@ -66,7 +63,7 @@ import com.vividsolutions.jts.geom.LineString;
* @author bsteffen
* @version 1.0
*/
public class GLShadedShapeBase {
public class GLShadedShapeBase implements IShape {
public boolean tessellate;
@ -379,7 +376,7 @@ public class GLShadedShapeBase {
}
}
protected synchronized void dispose() {
public synchronized void dispose() {
polygons = new ArrayList<FloatBuffer[]>();
vertexBuffer = null;
polygonLengthBuffer = null;
@ -464,4 +461,34 @@ public class GLShadedShapeBase {
}
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.IShape#isMutable()
*/
@Override
public boolean isMutable() {
return true;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.IShape#isDrawable()
*/
@Override
public boolean isDrawable() {
return true;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.IShape#reset()
*/
@Override
public void reset() {
dispose();
}
}