Issue #239 Refactored Collaboration rendering so it looks up renderes by

extension point so radar renderer can be injected by a radar
collaboration project

Former-commit-id: 7d2a7d987d [formerly 9b018ea151 [formerly 79f4d46bf18fc03c79df0c80c8dde025fe954f0c]]
Former-commit-id: 9b018ea151
Former-commit-id: 490c75f684
This commit is contained in:
Max Schenkelberg 2012-04-16 17:29:59 -05:00
parent a75e5d6773
commit a9864fa590
19 changed files with 1104 additions and 642 deletions

View file

@ -20,6 +20,8 @@
-->
<?eclipse version="3.2"?>
<plugin>
<extension-point id="renderingExtension" name="renderingExtension" schema="schema/renderingExtension.exsd"/>
<!-- Collaboration groups -->
<extension
point="org.eclipse.ui.views">
@ -156,4 +158,22 @@
icon="icons/add_correction.gif">
</editorMenuAddition>
</extension>
<extension
point="com.raytheon.uf.viz.collaboration.ui.renderingExtension">
<renderingExtension
class="com.raytheon.uf.viz.collaboration.ui.rsc.rendering.GeneralRenderingHandler">
</renderingExtension>
<renderingExtension
class="com.raytheon.uf.viz.collaboration.ui.rsc.rendering.FontRenderingHandler">
</renderingExtension>
<renderingExtension
class="com.raytheon.uf.viz.collaboration.ui.rsc.rendering.ImagingRenderingHandler">
</renderingExtension>
<renderingExtension
class="com.raytheon.uf.viz.collaboration.ui.rsc.rendering.OffscreenRenderingHandler">
</renderingExtension>
<renderingExtension
class="com.raytheon.uf.viz.collaboration.ui.rsc.rendering.WireframeShapeRenderingHandler">
</renderingExtension>
</extension>
</plugin>

View file

@ -0,0 +1,102 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="com.raytheon.uf.viz.collaboration" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="com.raytheon.uf.viz.collaboration" id="renderingExtension" name="renderingExtension"/>
</appinfo>
<documentation>
Defines rendering handler objects that use @Subscribe tags to handle render events
</documentation>
</annotation>
<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<sequence minOccurs="1" maxOccurs="unbounded">
<element ref="renderingExtension"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="renderingExtension">
<complexType>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn="com.raytheon.uf.viz.collaboration.ui.rsc.rendering.CollaborationRenderingHandler:"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="examples"/>
</appinfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="apiinfo"/>
</appinfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="implementation"/>
</appinfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>

View file

@ -23,6 +23,9 @@ package com.raytheon.uf.viz.collaboration.ui;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* The activator class controls the plug-in life cycle
*
@ -41,6 +44,9 @@ import org.osgi.framework.BundleContext;
*/
public class Activator extends AbstractUIPlugin {
public static final IUFStatusHandler statusHandler = UFStatus
.getHandler(Activator.class);
// The plug-in ID
public static final String PLUGIN_ID = "com.raytheon.uf.viz.collaboration"; //$NON-NLS-1$

View file

@ -1,72 +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.collaboration.ui.rsc;
import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.viz.collaboration.ui.rsc.CollaborationRenderingHandler.ColorMapDataCallback;
import com.raytheon.uf.viz.core.IMesh;
import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
/**
* Collaboration class responsible for disposing renderable objects
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 11, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class CollaborationDisposingHandler {
@Subscribe
public void disposeImage(IImage image) {
image.dispose();
}
@Subscribe
public void disposeMesh(IMesh mesh) {
mesh.dispose();
}
@Subscribe
public void disposeColorMapCallback(ColorMapDataCallback callback) {
callback.setData(null);
}
@Subscribe
public void disposeWireframeShape(IWireframeShape shape) {
shape.dispose();
}
@Subscribe
public void disposeFont(IFont font) {
font.dispose();
}
}

View file

@ -1,545 +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.collaboration.ui.rsc;
import java.io.File;
import java.io.IOException;
import java.nio.Buffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IMesh;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IColormappedImage;
import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.IOffscreenRenderingExtension;
import com.raytheon.uf.viz.core.drawables.ext.ISingleColorImageExtension;
import com.raytheon.uf.viz.core.drawables.ext.ISingleColorImageExtension.ISingleColorImage;
import com.raytheon.uf.viz.core.drawables.ext.colormap.IColormappedImageExtension;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapMeshExtension;
import com.raytheon.uf.viz.remote.graphics.events.BeginFrameEvent;
import com.raytheon.uf.viz.remote.graphics.events.DisposeObjectEvent;
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.events.colormap.UpdateColorMapParametersEvent;
import com.raytheon.uf.viz.remote.graphics.events.fonts.CreateFontEvent;
import com.raytheon.uf.viz.remote.graphics.events.fonts.UpdateFontDataEvent;
import com.raytheon.uf.viz.remote.graphics.events.imagery.CreateSingleColorImage;
import com.raytheon.uf.viz.remote.graphics.events.imagery.PaintImageEvent;
import com.raytheon.uf.viz.remote.graphics.events.imagery.PaintImagesEvent;
import com.raytheon.uf.viz.remote.graphics.events.imagery.UpdateImageDataEvent;
import com.raytheon.uf.viz.remote.graphics.events.imagery.UpdateSingleColorImage;
import com.raytheon.uf.viz.remote.graphics.events.mesh.CreateMeshEvent;
import com.raytheon.uf.viz.remote.graphics.events.mesh.ReprojectMeshEvent;
import com.raytheon.uf.viz.remote.graphics.events.offscreen.CreateOffscreenImageEvent;
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.events.wireframe.AllocatePointsEvent;
import com.raytheon.uf.viz.remote.graphics.events.wireframe.CreateWireframeShapeEvent;
import com.raytheon.uf.viz.remote.graphics.events.wireframe.RenderWireframeShapeEvent;
import com.raytheon.uf.viz.remote.graphics.events.wireframe.SimpleWireframeShapeEvent;
import com.raytheon.uf.viz.remote.graphics.events.wireframe.UpdateWireframeShapeEvent;
import com.raytheon.uf.viz.remote.graphics.events.wireframe.WireframeShapeData;
import com.raytheon.uf.viz.remote.graphics.events.wireframe.WireframeShapeData.Label;
/**
* Class that handles rendering events for collaboration resource
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 9, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class CollaborationRenderingHandler {
private Map<Integer, Object[]> renderableObjectMap = new HashMap<Integer, Object[]>();
private IGraphicsTarget target;
private PaintProperties paintProps;
private EventBus disposerRouter;
public CollaborationRenderingHandler() {
this.disposerRouter = new EventBus();
this.disposerRouter.register(new CollaborationDisposingHandler());
}
/**
* @param target
* @param paintProps
*/
public void beginRender(IGraphicsTarget target, PaintProperties paintProps) {
this.target = target;
this.paintProps = paintProps;
}
/**
* Put a renderable object in the object map. If an object already exists
* for that id, it will be sent to the disposer
*
* @param objectId
* @param obj
*/
private void putRenderableObject(int objectId, Object obj) {
if (obj != null) {
Object[] objects = null;
if (obj.getClass().isArray()) {
objects = (Object[]) obj;
} else {
objects = new Object[] { obj };
}
Object[] oldValue = renderableObjectMap.put(objectId, objects);
if (oldValue != null) {
dispose(oldValue);
}
}
}
/**
* Get a renderable object out of the object map as the objectType, if no
* object exists or the object is not of type objectType, null is returned.
* If the Object in the map is an Object[], the first object in the array
* that is of type objectType will be returned
*
* @param <T>
* @param objectId
* @param objectType
* @return
*/
private <T> T getRenderableObject(int objectId, Class<T> objectType) {
T obj = null;
Object[] toCheck = renderableObjectMap.get(objectId);
if (toCheck != null) {
for (Object check : toCheck) {
if (objectType.isInstance(check)) {
obj = objectType.cast(check);
break;
}
}
}
return obj;
}
/**
* Dispose all renderable object data
*/
public void dispose() {
for (Object[] obj : renderableObjectMap.values()) {
dispose(obj);
}
renderableObjectMap.clear();
}
/**
* Disposes a single renderable object by sending it to the disposer
* EventBus
*
* @param obj
*/
private void dispose(Object[] objects) {
for (Object toDispose : objects) {
disposerRouter.post(toDispose);
}
}
/**
* General dispose of a renderable object event
*
* @param event
*/
@Subscribe
public void disposeRenderable(DisposeObjectEvent event) {
Object[] toDispose = renderableObjectMap.remove(event.getObjectId());
if (toDispose != null) {
dispose(toDispose);
}
}
/**
* Begin frame event, modifies the target extent
*
* @param event
*/
@Subscribe
public void handleBeginFrame(BeginFrameEvent event) {
double[] center = event.getExtentCenter();
IExtent copy = paintProps.getView().getExtent().clone();
if (center != null) {
double[] currCenter = copy.getCenter();
copy.shift(center[0] - currCenter[0], center[1] - currCenter[1]);
copy.scaleAndBias(event.getExtentFactor() / copy.getScale(),
center[0], center[1]);
target.updateExtent(copy);
event.setExtentCenter(null);
target.setNeedsRefresh(true);
}
}
// ================== Common IImage events ==================
@Subscribe
public void renderImages(PaintImagesEvent event) throws VizException {
PaintImageEvent[] events = event.getImageEvents();
List<DrawableImage> images = new ArrayList<DrawableImage>(events.length);
for (PaintImageEvent pie : events) {
IImage image = getRenderableObject(pie.getObjectId(), IImage.class);
if (image != null) {
PixelCoverage coverage = new PixelCoverage(pie.getUl(),
pie.getUr(), pie.getLr(), pie.getLl());
IMesh mesh = getRenderableObject(pie.getMeshId(), IMesh.class);
if (mesh != null) {
coverage.setMesh(mesh);
}
images.add(new DrawableImage(image, coverage));
} else {
// TODO: Log?
}
}
if (images.size() > 0) {
PaintProperties imageProps = new PaintProperties(paintProps);
imageProps.setAlpha(event.getAlpha());
target.drawRasters(imageProps,
images.toArray(new DrawableImage[images.size()]));
}
}
@Subscribe
public void updateImageData(UpdateImageDataEvent event) {
IImage image = getRenderableObject(event.getObjectId(), IImage.class);
if (image != null) {
image.setBrightness(event.getBrightness());
image.setContrast(event.getContrast());
image.setInterpolated(event.isInterpolated());
}
}
// ================== IColormappedImage events ==================
/**
* TODO: Manage ColorMaps better! (sharing and updating)
*
* Creates an IColormappedImage object from the event
*
* @param event
* @throws VizException
*/
@Subscribe
public void createColormappedImage(CreateColormappedImageEvent event)
throws VizException {
int imageId = event.getObjectId();
IColorMapDataRetrievalCallback callback = new ColorMapDataCallback();
UpdateColorMapParametersEvent cmapEvent = event.getColorMapParameters();
ColorMapParameters params = null;
if (cmapEvent != null) {
params = cmapEvent.asColorMapParameters();
}
IColormappedImage image = target.getExtension(
IColormappedImageExtension.class).initializeRaster(callback,
params);
putRenderableObject(imageId, new Object[] { image, callback });
}
@Subscribe
public void dataArrived(ColorMapDataEvent event) {
ColorMapDataCallback callback = getRenderableObject(
event.getObjectId(), ColorMapDataCallback.class);
if (callback != null) {
callback.setData(event.getColorMapData());
}
}
// TODO: Put utility classes in same package
public class ColorMapDataCallback implements IColorMapDataRetrievalCallback {
private ColorMapData data;
@Override
public ColorMapData getColorMapData() throws VizException {
ColorMapData rval = data;
if (data != null) {
data = null;
}
return rval;
}
public void setData(ColorMapData data) {
this.data = data;
}
}
// ================== IMesh events ==================
@Subscribe
public void createMesh(CreateMeshEvent event) throws VizException {
// TODO: Should we cache or should we expect data provider or even
// internal to the target?
int meshId = event.getObjectId();
IMesh mesh = target.getExtension(IMapMeshExtension.class)
.constructMesh(event.getImageGeometry(),
event.getTargetGeometry());
putRenderableObject(meshId, mesh);
}
@Subscribe
public void reprojectMesh(ReprojectMeshEvent event) throws VizException {
IMesh mesh = getRenderableObject(event.getObjectId(), IMesh.class);
if (mesh != null) {
mesh.reproject(event.getTargetGeometry());
}
}
// ================== Offscreen image events ==================
@Subscribe
public void createOffscreenImage(CreateOffscreenImageEvent event)
throws VizException {
try {
IImage offscreenImage = null;
IOffscreenRenderingExtension ext = target
.getExtension(IOffscreenRenderingExtension.class);
int[] dims = event.getDimensions();
if (event.getBufferType() != null) {
Class<? extends Buffer> bufferType = Class.forName(
event.getBufferType()).asSubclass(Buffer.class);
if (event.getColorMapParamters() != null) {
offscreenImage = ext.constructOffscreenImage(bufferType,
dims, event.getColorMapParamters()
.asColorMapParameters());
} else {
offscreenImage = ext.constructOffscreenImage(bufferType,
dims);
}
} else {
offscreenImage = ext.constructOffscreenImage(dims);
}
if (offscreenImage != null) {
putRenderableObject(event.getObjectId(), offscreenImage);
}
} catch (ClassNotFoundException e) {
throw new VizException("Could not find class for buffer type: "
+ event.getBufferType(), e);
}
}
@Subscribe
public void renderOffscreen(RenderOffscreenEvent event) throws VizException {
IImage offscreenImage = getRenderableObject(event.getObjectId(),
IImage.class);
if (offscreenImage != null) {
if (event.getExtent() != null) {
target.getExtension(IOffscreenRenderingExtension.class)
.renderOffscreen(offscreenImage, event.getIExtent());
} else {
target.getExtension(IOffscreenRenderingExtension.class)
.renderOffscreen(offscreenImage);
}
}
}
@Subscribe
public void renderOnscreen(RenderOnscreenEvent event) throws VizException {
target.getExtension(IOffscreenRenderingExtension.class)
.renderOnscreen();
}
// ================== Wireframe shape events ==================
@Subscribe
public void createWireframeShape(CreateWireframeShapeEvent event) {
int shapeId = event.getObjectId();
IWireframeShape shape = null;
if (event.getSimplificationLevel() != null) {
if (event.isSpatialChopFlag() != null) {
shape = target.createWireframeShape(event.isMutable(),
event.getGridGeometry(),
event.getSimplificationLevel(),
event.isSpatialChopFlag(), event.getIExtent());
} else {
shape = target
.createWireframeShape(event.isMutable(),
event.getGridGeometry(),
event.getSimplificationLevel());
}
} else {
shape = target.createWireframeShape(event.isMutable(),
event.getGridGeometry());
}
putRenderableObject(shapeId, shape);
}
@Subscribe
public void allocatePointsForShape(AllocatePointsEvent event) {
IWireframeShape shape = getRenderableObject(event.getObjectId(),
IWireframeShape.class);
if (shape != null) {
shape.allocate(event.getNumberOfPoints());
}
}
@Subscribe
public void updateWireframeShapeData(UpdateWireframeShapeEvent event) {
IWireframeShape shape = getRenderableObject(event.getObjectId(),
IWireframeShape.class);
if (shape != null) {
WireframeShapeData data = event.getWireframeData();
for (Label label : data.getLabels()) {
shape.addLabel(label.getText(), label.getPoint());
}
for (double[][] coords : data.getCoordinates()) {
shape.addLineSegment(coords);
}
}
}
@Subscribe
public void handleSimpleWireframeShapeEvent(SimpleWireframeShapeEvent event) {
IWireframeShape shape = getRenderableObject(event.getObjectId(),
IWireframeShape.class);
if (shape != null) {
switch (event.getAction()) {
case CLEAR_LABELS:
shape.clearLabels();
break;
case COMPILE:
shape.compile();
break;
case RESET:
shape.reset();
break;
}
}
}
@Subscribe
public void renderWireframeShape(RenderWireframeShapeEvent event)
throws VizException {
IWireframeShape shape = getRenderableObject(event.getObjectId(),
IWireframeShape.class);
if (shape != null) {
IFont font = null;
if (event.getFontId() != null) {
font = getRenderableObject(event.getFontId(), IFont.class);
}
if (event.getAlpha() == null) {
target.drawWireframeShape(shape, event.getColor(),
event.getLineWidth(), event.getLineStyle(), font);
} else {
target.drawWireframeShape(shape, event.getColor(),
event.getLineWidth(), event.getLineStyle(), font,
event.getAlpha());
}
}
}
// ================== Font events ==================
@Subscribe
public void createFont(CreateFontEvent event) throws VizException {
int fontId = event.getObjectId();
IFont font = null;
if (event.getFontData() != null) {
try {
File fontFile = File.createTempFile(event.getFontName(), null);
FileUtil.bytes2File(event.getFontData(), fontFile);
font = target.initializeFont(fontFile, event.getFontSize(),
event.getFontStyle());
} catch (IOException e) {
throw new VizException("Unable to write font file: "
+ e.getLocalizedMessage());
}
} else {
font = target.initializeFont(event.getFontName(),
event.getFontSize(), event.getFontStyle());
}
font.setMagnification(event.getMagnification());
font.setSmoothing(event.isSmoothing());
font.setScaleFont(event.isScaleFont());
putRenderableObject(fontId, font);
}
@Subscribe
public void updateFont(UpdateFontDataEvent event) {
IFont font = getRenderableObject(event.getObjectId(), IFont.class);
if (font != null) {
if (event.getMagnification() != null) {
if (event.getScaleFont() != null) {
font.setMagnification(event.getMagnification(),
event.getScaleFont());
} else {
font.setMagnification(event.getMagnification());
}
} else {
if (event.getScaleFont() != null) {
font.setScaleFont(event.getScaleFont());
} else if (event.getSmoothing() != null) {
font.setSmoothing(event.getSmoothing());
}
}
font.setMagnification(event.getMagnification());
font.setSmoothing(event.getSmoothing());
font.setScaleFont(event.getScaleFont());
}
}
// ================== ISingleColorImage events ==================
@Subscribe
public void createSingleColorImage(CreateSingleColorImage event)
throws VizException {
int imageId = event.getObjectId();
ISingleColorImage image = target.getExtension(
ISingleColorImageExtension.class).constructImage(
event.getRenderedImage(), event.getColor());
putRenderableObject(imageId, image);
}
@Subscribe
public void updateSingleColorImage(UpdateSingleColorImage event) {
ISingleColorImage image = getRenderableObject(event.getObjectId(),
ISingleColorImage.class);
if (image != null) {
image.setColor(event.getColor());
}
}
}

View file

@ -27,6 +27,8 @@ import org.eclipse.jface.action.IMenuManager;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.viz.collaboration.ui.rsc.rendering.CollaborationRenderingDataManager;
import com.raytheon.uf.viz.collaboration.ui.rsc.rendering.CollaborationRenderingHandler;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
@ -74,25 +76,22 @@ public class CollaborationResource extends
/** Internal rendering event object router */
private EventBus renderingRouter;
private CollaborationRenderingHandler renderingHandler;
private CollaborationRenderingDataManager dataManager;
private BeginFrameEvent latestBeginFrameEvent;
protected CollaborationResource(CollaborationResourceData resourceData,
public CollaborationResource(CollaborationResourceData resourceData,
LoadProperties loadProperties) {
super(resourceData, loadProperties);
dataChangeEvents = new LinkedList<AbstractRemoteGraphicsEvent>();
currentRenderables = new LinkedList<IRenderEvent>();
activeRenderables = new LinkedList<IRenderEvent>();
renderingRouter = new EventBus();
renderingHandler = new CollaborationRenderingHandler();
renderingRouter.register(renderingHandler);
}
@Override
protected void disposeInternal() {
renderingHandler.dispose();
renderingRouter.unregister(renderingHandler);
dataManager.dispose();
renderingRouter = null;
}
@Override
@ -109,7 +108,7 @@ public class CollaborationResource extends
dataChangeEvents.clear();
}
renderingHandler.beginRender(target, paintProps);
dataManager.beginRender(target, paintProps);
// Handle begin frame
if (latestBeginFrameEvent != null) {
@ -127,7 +126,12 @@ public class CollaborationResource extends
@Override
protected void initInternal(IGraphicsTarget target) throws VizException {
// Nothing to do
renderingRouter = new EventBus();
dataManager = new CollaborationRenderingDataManager();
for (CollaborationRenderingHandler handler : CollaborationRenderingDataManager
.createRenderingHandlers(dataManager)) {
renderingRouter.register(handler);
}
}
@Subscribe

View file

@ -0,0 +1,214 @@
/**
* 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.collaboration.ui.rsc.rendering;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import com.google.common.eventbus.EventBus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.collaboration.ui.Activator;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
/**
* Collaboration rendering data manager, manages render data and render handlers
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 16, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class CollaborationRenderingDataManager {
private static final String RENDERING_EXTENSION = "com.raytheon.uf.viz.collaboration.ui.renderingExtension";
private static Collection<IConfigurationElement> handlerElements = new LinkedList<IConfigurationElement>();
static {
IExtensionRegistry registry = Platform.getExtensionRegistry();
if (registry != null) {
IExtensionPoint point = registry
.getExtensionPoint(RENDERING_EXTENSION);
if (point != null) {
IExtension[] extensions = point.getExtensions();
for (IExtension ext : extensions) {
IConfigurationElement[] config = ext
.getConfigurationElements();
handlerElements.addAll(Arrays.asList(config));
}
}
}
}
private Map<Integer, Object[]> renderableObjectMap = new HashMap<Integer, Object[]>();
private IGraphicsTarget target;
private PaintProperties paintProps;
private EventBus disposerRouter;
public CollaborationRenderingDataManager() {
this.disposerRouter = new EventBus();
}
/**
* @param target
* @param paintProps
*/
public void beginRender(IGraphicsTarget target, PaintProperties paintProps) {
this.target = target;
this.paintProps = paintProps;
}
/**
* @return the target
*/
public IGraphicsTarget getTarget() {
return target;
}
/**
* @return the paintProperties
*/
public PaintProperties getPaintProperties() {
return paintProps;
}
/**
* Put a renderable object in the object map. If an object already exists
* for that id, it will be sent to the disposer
*
* @param objectId
* @param obj
*/
public void putRenderableObject(int objectId, Object obj) {
if (obj != null) {
Object[] objects = null;
if (obj.getClass().isArray()) {
objects = (Object[]) obj;
} else {
objects = new Object[] { obj };
}
Object[] oldValue = renderableObjectMap.put(objectId, objects);
if (oldValue != null) {
dispose(oldValue);
}
}
}
/**
* Get a renderable object out of the object map as the objectType, if no
* object exists or the object is not of type objectType, null is returned.
* Use Object[].class as the objectType if you want all objects bound to the
* id. The first object in the array that is of type objectType will be
* returned otherwise
*
* @param <T>
* @param objectId
* @param objectType
* @return
*/
public <T> T getRenderableObject(int objectId, Class<T> objectType) {
T obj = null;
Object[] toCheck = renderableObjectMap.get(objectId);
if (toCheck != null) {
if (objectType == Object[].class) {
obj = objectType.cast(toCheck);
} else {
for (Object check : toCheck) {
if (objectType.isInstance(check)) {
obj = objectType.cast(check);
break;
}
}
}
}
return obj;
}
/**
* Dispose all renderable object data
*/
public void dispose() {
for (Object[] obj : renderableObjectMap.values()) {
dispose(obj);
}
renderableObjectMap.clear();
}
/**
* Disposes a single renderable object by sending it to the disposer
* EventBus
*
* @param obj
*/
public void dispose(Object[] objects) {
for (Object toDispose : objects) {
disposerRouter.post(toDispose);
}
}
/**
* @param dataManager
* @return
*/
public static synchronized Collection<CollaborationRenderingHandler> createRenderingHandlers(
CollaborationRenderingDataManager dataManager) {
List<CollaborationRenderingHandler> handlers = new ArrayList<CollaborationRenderingHandler>(
handlerElements.size());
for (IConfigurationElement element : handlerElements) {
try {
CollaborationRenderingHandler handler = (CollaborationRenderingHandler) element
.createExecutableExtension("class");
handler.setDataManager(dataManager);
handlers.add(handler);
dataManager.disposerRouter.register(handler);
} catch (CoreException e) {
Activator.statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
}
return handlers;
}
}

View file

@ -0,0 +1,59 @@
/**
* 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.collaboration.ui.rsc.rendering;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
/**
* An abstract class which contains a reference to the dataManager the
* subclasses will use for data access, also has convenience methods for
* accessing current target and paint properties
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 16, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public abstract class CollaborationRenderingHandler {
protected CollaborationRenderingDataManager dataManager;
final void setDataManager(CollaborationRenderingDataManager dataManager) {
this.dataManager = dataManager;
}
protected final IGraphicsTarget getTarget() {
return dataManager.getTarget();
}
protected final PaintProperties getPaintProperties() {
return dataManager.getPaintProperties();
}
}

View file

@ -0,0 +1,106 @@
/**
* 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.collaboration.ui.rsc.rendering;
import java.io.File;
import java.io.IOException;
import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.remote.graphics.events.fonts.CreateFontEvent;
import com.raytheon.uf.viz.remote.graphics.events.fonts.UpdateFontDataEvent;
/**
* Handles render events for Font objects
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 16, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class FontRenderingHandler extends CollaborationRenderingHandler {
@Subscribe
public void createFont(CreateFontEvent event) throws VizException {
IGraphicsTarget target = getTarget();
int fontId = event.getObjectId();
IFont font = null;
if (event.getFontData() != null) {
try {
File fontFile = File.createTempFile(event.getFontName(), null);
FileUtil.bytes2File(event.getFontData(), fontFile);
font = target.initializeFont(fontFile, event.getFontSize(),
event.getFontStyle());
} catch (IOException e) {
throw new VizException("Unable to write font file: "
+ e.getLocalizedMessage());
}
} else {
font = target.initializeFont(event.getFontName(),
event.getFontSize(), event.getFontStyle());
}
font.setMagnification(event.getMagnification());
font.setSmoothing(event.isSmoothing());
font.setScaleFont(event.isScaleFont());
dataManager.putRenderableObject(fontId, font);
}
@Subscribe
public void updateFont(UpdateFontDataEvent event) {
IFont font = dataManager.getRenderableObject(event.getObjectId(),
IFont.class);
if (font != null) {
if (event.getMagnification() != null) {
if (event.getScaleFont() != null) {
font.setMagnification(event.getMagnification(),
event.getScaleFont());
} else {
font.setMagnification(event.getMagnification());
}
} else {
if (event.getScaleFont() != null) {
font.setScaleFont(event.getScaleFont());
} else if (event.getSmoothing() != null) {
font.setSmoothing(event.getSmoothing());
}
}
font.setMagnification(event.getMagnification());
font.setSmoothing(event.getSmoothing());
font.setScaleFont(event.getScaleFont());
}
}
@Subscribe
public void disposeFont(IFont font) {
font.dispose();
}
}

View file

@ -0,0 +1,84 @@
/**
* 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.collaboration.ui.rsc.rendering;
import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.remote.graphics.events.BeginFrameEvent;
import com.raytheon.uf.viz.remote.graphics.events.DisposeObjectEvent;
/**
* Handles general rendering events, begin frame and dispose
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 16, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class GeneralRenderingHandler extends CollaborationRenderingHandler {
/**
* General dispose of a renderable object event
*
* @param event
*/
@Subscribe
public void disposeRenderable(DisposeObjectEvent event) {
Object[] toDispose = dataManager.getRenderableObject(
event.getObjectId(), Object[].class);
if (toDispose != null) {
dataManager.dispose(toDispose);
}
}
/**
* Begin frame event, modifies the target extent
*
* @param event
*/
@Subscribe
public void handleBeginFrame(BeginFrameEvent event) {
PaintProperties paintProps = getPaintProperties();
IGraphicsTarget target = getTarget();
double[] center = event.getExtentCenter();
IExtent copy = paintProps.getView().getExtent().clone();
if (center != null) {
double[] currCenter = copy.getCenter();
copy.shift(center[0] - currCenter[0], center[1] - currCenter[1]);
copy.scaleAndBias(event.getExtentFactor() / copy.getScale(),
center[0], center[1]);
target.updateExtent(copy);
event.setExtentCenter(null);
target.setNeedsRefresh(true);
}
}
}

View file

@ -0,0 +1,226 @@
/**
* 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.collaboration.ui.rsc.rendering;
import java.util.ArrayList;
import java.util.List;
import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IMesh;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback;
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.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.ISingleColorImageExtension;
import com.raytheon.uf.viz.core.drawables.ext.ISingleColorImageExtension.ISingleColorImage;
import com.raytheon.uf.viz.core.drawables.ext.colormap.IColormappedImageExtension;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapMeshExtension;
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.events.colormap.UpdateColorMapParametersEvent;
import com.raytheon.uf.viz.remote.graphics.events.imagery.CreateSingleColorImage;
import com.raytheon.uf.viz.remote.graphics.events.imagery.PaintImageEvent;
import com.raytheon.uf.viz.remote.graphics.events.imagery.PaintImagesEvent;
import com.raytheon.uf.viz.remote.graphics.events.imagery.UpdateImageDataEvent;
import com.raytheon.uf.viz.remote.graphics.events.imagery.UpdateSingleColorImage;
import com.raytheon.uf.viz.remote.graphics.events.mesh.CreateMeshEvent;
import com.raytheon.uf.viz.remote.graphics.events.mesh.ReprojectMeshEvent;
/**
* Handles render events for imagery/mesh objects
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 16, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class ImagingRenderingHandler extends CollaborationRenderingHandler {
@Subscribe
public void renderImages(PaintImagesEvent event) throws VizException {
PaintProperties paintProps = getPaintProperties();
IGraphicsTarget target = getTarget();
PaintImageEvent[] events = event.getImageEvents();
List<DrawableImage> images = new ArrayList<DrawableImage>(events.length);
for (PaintImageEvent pie : events) {
IImage image = dataManager.getRenderableObject(pie.getObjectId(),
IImage.class);
if (image != null) {
PixelCoverage coverage = new PixelCoverage(pie.getUl(),
pie.getUr(), pie.getLr(), pie.getLl());
IMesh mesh = dataManager.getRenderableObject(pie.getMeshId(),
IMesh.class);
if (mesh != null) {
coverage.setMesh(mesh);
}
images.add(new DrawableImage(image, coverage));
} else {
// TODO: Log?
}
}
if (images.size() > 0) {
PaintProperties imageProps = new PaintProperties(paintProps);
imageProps.setAlpha(event.getAlpha());
target.drawRasters(imageProps,
images.toArray(new DrawableImage[images.size()]));
}
}
@Subscribe
public void updateImageData(UpdateImageDataEvent event) {
IImage image = dataManager.getRenderableObject(event.getObjectId(),
IImage.class);
if (image != null) {
image.setBrightness(event.getBrightness());
image.setContrast(event.getContrast());
image.setInterpolated(event.isInterpolated());
}
}
@Subscribe
public void disposeImage(IImage image) {
image.dispose();
}
// ================== IColormappedImage events ==================
/**
* TODO: Manage ColorMaps better! (sharing and updating)
*
* Creates an IColormappedImage object from the event
*
* @param event
* @throws VizException
*/
@Subscribe
public void createColormappedImage(CreateColormappedImageEvent event)
throws VizException {
IGraphicsTarget target = getTarget();
int imageId = event.getObjectId();
IColorMapDataRetrievalCallback callback = new ColorMapDataCallback();
UpdateColorMapParametersEvent cmapEvent = event.getColorMapParameters();
ColorMapParameters params = null;
if (cmapEvent != null) {
params = cmapEvent.asColorMapParameters();
}
IColormappedImage image = target.getExtension(
IColormappedImageExtension.class).initializeRaster(callback,
params);
dataManager.putRenderableObject(imageId,
new Object[] { image, callback });
}
@Subscribe
public void dataArrived(ColorMapDataEvent event) {
ColorMapDataCallback callback = dataManager.getRenderableObject(
event.getObjectId(), ColorMapDataCallback.class);
if (callback != null) {
callback.setData(event.getColorMapData());
}
}
@Subscribe
public void disposeColorMapCallback(ColorMapDataCallback callback) {
callback.setData(null);
}
// TODO: Put utility classes in same package
public class ColorMapDataCallback implements IColorMapDataRetrievalCallback {
private ColorMapData data;
@Override
public ColorMapData getColorMapData() throws VizException {
ColorMapData rval = data;
if (data != null) {
data = null;
}
return rval;
}
public void setData(ColorMapData data) {
this.data = data;
}
}
// ================== IMesh events ==================
@Subscribe
public void createMesh(CreateMeshEvent event) throws VizException {
IGraphicsTarget target = getTarget();
// TODO: Should we cache or should we expect data provider or even
// internal to the target?
int meshId = event.getObjectId();
IMesh mesh = target.getExtension(IMapMeshExtension.class)
.constructMesh(event.getImageGeometry(),
event.getTargetGeometry());
dataManager.putRenderableObject(meshId, mesh);
}
@Subscribe
public void reprojectMesh(ReprojectMeshEvent event) throws VizException {
IMesh mesh = dataManager.getRenderableObject(event.getObjectId(),
IMesh.class);
if (mesh != null) {
mesh.reproject(event.getTargetGeometry());
}
}
@Subscribe
public void disposeMesh(IMesh mesh) {
mesh.dispose();
}
// ================== ISingleColorImage events ==================
@Subscribe
public void createSingleColorImage(CreateSingleColorImage event)
throws VizException {
IGraphicsTarget target = getTarget();
int imageId = event.getObjectId();
ISingleColorImage image = target.getExtension(
ISingleColorImageExtension.class).constructImage(
event.getRenderedImage(), event.getColor());
dataManager.putRenderableObject(imageId, image);
}
@Subscribe
public void updateSingleColorImage(UpdateSingleColorImage event) {
ISingleColorImage image = dataManager.getRenderableObject(
event.getObjectId(), ISingleColorImage.class);
if (image != null) {
image.setColor(event.getColor());
}
}
}

View file

@ -0,0 +1,108 @@
/**
* 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.collaboration.ui.rsc.rendering;
import java.nio.Buffer;
import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.ext.IOffscreenRenderingExtension;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.remote.graphics.events.offscreen.CreateOffscreenImageEvent;
import com.raytheon.uf.viz.remote.graphics.events.offscreen.RenderOffscreenEvent;
import com.raytheon.uf.viz.remote.graphics.events.offscreen.RenderOnscreenEvent;
/**
* Handles render events for offscreen rendering
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 16, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class OffscreenRenderingHandler extends CollaborationRenderingHandler {
@Subscribe
public void createOffscreenImage(CreateOffscreenImageEvent event)
throws VizException {
IGraphicsTarget target = getTarget();
try {
IImage offscreenImage = null;
IOffscreenRenderingExtension ext = target
.getExtension(IOffscreenRenderingExtension.class);
int[] dims = event.getDimensions();
if (event.getBufferType() != null) {
Class<? extends Buffer> bufferType = Class.forName(
event.getBufferType()).asSubclass(Buffer.class);
if (event.getColorMapParamters() != null) {
offscreenImage = ext.constructOffscreenImage(bufferType,
dims, event.getColorMapParamters()
.asColorMapParameters());
} else {
offscreenImage = ext.constructOffscreenImage(bufferType,
dims);
}
} else {
offscreenImage = ext.constructOffscreenImage(dims);
}
if (offscreenImage != null) {
dataManager.putRenderableObject(event.getObjectId(),
offscreenImage);
}
} catch (ClassNotFoundException e) {
throw new VizException("Could not find class for buffer type: "
+ event.getBufferType(), e);
}
}
@Subscribe
public void renderOffscreen(RenderOffscreenEvent event) throws VizException {
IGraphicsTarget target = getTarget();
IImage offscreenImage = dataManager.getRenderableObject(
event.getObjectId(), IImage.class);
if (offscreenImage != null) {
if (event.getExtent() != null) {
target.getExtension(IOffscreenRenderingExtension.class)
.renderOffscreen(offscreenImage, event.getIExtent());
} else {
target.getExtension(IOffscreenRenderingExtension.class)
.renderOffscreen(offscreenImage);
}
}
}
@Subscribe
public void renderOnscreen(RenderOnscreenEvent event) throws VizException {
IGraphicsTarget target = getTarget();
target.getExtension(IOffscreenRenderingExtension.class)
.renderOnscreen();
}
}

View file

@ -0,0 +1,150 @@
/**
* 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.collaboration.ui.rsc.rendering;
import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.remote.graphics.events.wireframe.AllocatePointsEvent;
import com.raytheon.uf.viz.remote.graphics.events.wireframe.CreateWireframeShapeEvent;
import com.raytheon.uf.viz.remote.graphics.events.wireframe.RenderWireframeShapeEvent;
import com.raytheon.uf.viz.remote.graphics.events.wireframe.SimpleWireframeShapeEvent;
import com.raytheon.uf.viz.remote.graphics.events.wireframe.UpdateWireframeShapeEvent;
import com.raytheon.uf.viz.remote.graphics.events.wireframe.WireframeShapeData;
import com.raytheon.uf.viz.remote.graphics.events.wireframe.WireframeShapeData.Label;
/**
* Handles render events for wireframe shapes
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 16, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class WireframeShapeRenderingHandler extends
CollaborationRenderingHandler {
@Subscribe
public void createWireframeShape(CreateWireframeShapeEvent event) {
IGraphicsTarget target = getTarget();
int shapeId = event.getObjectId();
IWireframeShape shape = null;
if (event.getSimplificationLevel() != null) {
if (event.isSpatialChopFlag() != null) {
shape = target.createWireframeShape(event.isMutable(),
event.getGridGeometry(),
event.getSimplificationLevel(),
event.isSpatialChopFlag(), event.getIExtent());
} else {
shape = target
.createWireframeShape(event.isMutable(),
event.getGridGeometry(),
event.getSimplificationLevel());
}
} else {
shape = target.createWireframeShape(event.isMutable(),
event.getGridGeometry());
}
dataManager.putRenderableObject(shapeId, shape);
}
@Subscribe
public void allocatePointsForShape(AllocatePointsEvent event) {
IWireframeShape shape = dataManager.getRenderableObject(
event.getObjectId(), IWireframeShape.class);
if (shape != null) {
shape.allocate(event.getNumberOfPoints());
}
}
@Subscribe
public void updateWireframeShapeData(UpdateWireframeShapeEvent event) {
IWireframeShape shape = dataManager.getRenderableObject(
event.getObjectId(), IWireframeShape.class);
if (shape != null) {
WireframeShapeData data = event.getWireframeData();
for (Label label : data.getLabels()) {
shape.addLabel(label.getText(), label.getPoint());
}
for (double[][] coords : data.getCoordinates()) {
shape.addLineSegment(coords);
}
}
}
@Subscribe
public void handleSimpleWireframeShapeEvent(SimpleWireframeShapeEvent event) {
IWireframeShape shape = dataManager.getRenderableObject(
event.getObjectId(), IWireframeShape.class);
if (shape != null) {
switch (event.getAction()) {
case CLEAR_LABELS:
shape.clearLabels();
break;
case COMPILE:
shape.compile();
break;
case RESET:
shape.reset();
break;
}
}
}
@Subscribe
public void renderWireframeShape(RenderWireframeShapeEvent event)
throws VizException {
IGraphicsTarget target = getTarget();
IWireframeShape shape = dataManager.getRenderableObject(
event.getObjectId(), IWireframeShape.class);
if (shape != null) {
IFont font = null;
if (event.getFontId() != null) {
font = dataManager.getRenderableObject(event.getFontId(),
IFont.class);
}
if (event.getAlpha() == null) {
target.drawWireframeShape(shape, event.getColor(),
event.getLineWidth(), event.getLineStyle(), font);
} else {
target.drawWireframeShape(shape, event.getColor(),
event.getLineWidth(), event.getLineStyle(), font,
event.getAlpha());
}
}
}
@Subscribe
public void disposeWireframeShape(IWireframeShape shape) {
shape.dispose();
}
}

View file

@ -19,11 +19,12 @@
**/
package com.raytheon.uf.viz.radar.gl;
import org.geotools.coverage.grid.GeneralGridGeometry;
import com.raytheon.uf.common.dataplugin.radar.RadarRecord;
import com.raytheon.uf.viz.core.IMesh;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapDescriptor;
import com.raytheon.viz.core.gl.IGLTarget;
import com.raytheon.viz.radar.rsc.image.IRadialMeshExtension;
@ -55,11 +56,11 @@ public class GLRadialMeshExtension extends GraphicsExtension<IGLTarget>
* com.raytheon.uf.viz.core.drawables.IDescriptor)
*/
@Override
public IMesh constructMesh(RadarRecord radarData, IMapDescriptor descriptor)
throws VizException {
public IMesh constructMesh(RadarRecord radarData,
GeneralGridGeometry targetGeometry) throws VizException {
String format = radarData.getFormat();
if ("Radial".equals(format)) {
return RadarRadialMesh.getMesh(radarData, descriptor);
return RadarRadialMesh.getMesh(radarData, targetGeometry);
} else {
throw new VizException(
"Cannot construct radial meshes for non radial RadarRecords");

View file

@ -35,7 +35,6 @@ import com.raytheon.uf.common.dataplugin.radar.util.RadarUtil;
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.IDescriptor;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.core.gl.AbstractGLMesh;
import com.raytheon.viz.core.gl.SharedCoordMap.SharedCoordinateKey;
@ -406,7 +405,7 @@ public class RadarRadialMesh extends AbstractGLMesh {
}
public static RadarRadialMesh getMesh(RadarRecord radarData,
IDescriptor descriptor) throws VizException {
GeneralGridGeometry targetGeometry) throws VizException {
float latitude = radarData.getLatitude();
float longitude = radarData.getLongitude();
int numBins = radarData.getNumBins();
@ -420,13 +419,12 @@ public class RadarRadialMesh extends AbstractGLMesh {
float[] angleData = radarData.getAngleData();
CacheKey key = new CacheKey(latitude, longitude, numBins, numRadials,
gateResolution, trueElevationAngle, jStart, angleData,
descriptor.getGridGeometry());
targetGeometry);
synchronized (cache) {
RadarRadialMesh mesh = cache.get(key);
if (mesh == null) {
// System.out.println("Mesh Cache miss");
mesh = new RadarRadialMesh(radarData,
descriptor.getGridGeometry(), key);
mesh = new RadarRadialMesh(radarData, targetGeometry, key);
cache.put(key, mesh);
} else {
// System.out.println("Mesh Cache hit");

View file

@ -19,11 +19,12 @@
**/
package com.raytheon.viz.radar.rsc.image;
import org.geotools.coverage.grid.GeneralGridGeometry;
import com.raytheon.uf.common.dataplugin.radar.RadarRecord;
import com.raytheon.uf.viz.core.IMesh;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapDescriptor;
/**
* Interface for constructing radial meshes for radar records
@ -52,7 +53,7 @@ public interface IRadialMeshExtension extends IGraphicsExtensionInterface {
* @return
* @throws VizException
*/
public IMesh constructMesh(RadarRecord radarData, IMapDescriptor descriptor)
throws VizException;
public IMesh constructMesh(RadarRecord radarData,
GeneralGridGeometry targetGeometry) throws VizException;
}

View file

@ -37,7 +37,6 @@ import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.ext.colormap.IColormappedImageExtension;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapDescriptor;
import com.raytheon.uf.viz.core.map.MapDescriptor;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.viz.awipstools.capabilities.EAVCapability;
@ -212,7 +211,7 @@ public class RadarRadialResource extends RadarImageResource<MapDescriptor> {
public IMesh buildMesh(IGraphicsTarget target, VizRadarRecord radarRecord)
throws VizException {
return target.getExtension(IRadialMeshExtension.class).constructMesh(
radarRecord, (IMapDescriptor) descriptor);
radarRecord, descriptor.getGridGeometry());
}
}

View file

@ -591,7 +591,8 @@ params = /*new ColorMapParameters();//*/ColorMapParameterFactory.build((Object)
public IMesh buildMesh(IGraphicsTarget target, RadarTimeRecord timeRecord)
throws VizException {
return target.getExtension(IRadialMeshExtension.class).constructMesh(
timeRecord.radarCacheObject.getObjectSync(), descriptor);
timeRecord.radarCacheObject.getObjectSync(),
descriptor.getGridGeometry());
}
public PixelCoverage buildCoverage(IGraphicsTarget target,

View file

@ -203,7 +203,7 @@ public class RadarRadialResource extends RadarImageResource<MapDescriptor> {
public IMesh buildMesh(IGraphicsTarget target, VizRadarRecord radarRecord)
throws VizException {
return target.getExtension(IRadialMeshExtension.class).constructMesh(
radarRecord, (IMapDescriptor) descriptor);
radarRecord, descriptor.getGridGeometry());
}
@Override