Issue #588 Added serialization adapter registration to better support serializing DrawableString objects

Change-Id: I2833b345fbef4674083dcad3561444ec4e6a0056

Former-commit-id: 6c456c0bad00aaa1fea67f90a4633b3e14a78495
This commit is contained in:
Max Schenkelberg 2012-05-09 15:02:30 -05:00
parent 58037cb5d1
commit 1f5abc6e20
41 changed files with 803 additions and 929 deletions

View file

@ -101,7 +101,7 @@ class VizPainter():
# requires multiple passes to paint everything # requires multiple passes to paint everything
paint = True paint = True
while paint: while paint:
self.target.beginFrame(self.display, True) self.target.beginFrame(self.display.getView(), True)
if backgroundColor is not None: if backgroundColor is not None:
self.target.setBackgroundColor(backgroundColor) self.target.setBackgroundColor(backgroundColor)
self.display.paint(self.target, props) self.display.paint(self.target, props)

View file

@ -106,7 +106,7 @@ public class DispatchingMosaicImage extends
this.imageExtent = imageExtent; this.imageExtent = imageExtent;
UpdateMosaicExtent extentUpdate = RemoteGraphicsEventFactory UpdateMosaicExtent extentUpdate = RemoteGraphicsEventFactory
.createEvent(UpdateMosaicExtent.class, this); .createEvent(UpdateMosaicExtent.class, this);
extentUpdate.setIExtent(imageExtent); extentUpdate.setExtent(imageExtent.clone());
dispatch(extentUpdate); dispatch(extentUpdate);
} }
} }

View file

@ -78,7 +78,7 @@ public class DispatchingRadarMosaicExtension extends
if (imageExtent != null) { if (imageExtent != null) {
UpdateMosaicExtent extentUpdate = RemoteGraphicsEventFactory UpdateMosaicExtent extentUpdate = RemoteGraphicsEventFactory
.createEvent(UpdateMosaicExtent.class, image); .createEvent(UpdateMosaicExtent.class, image);
extentUpdate.setIExtent(imageExtent); extentUpdate.setExtent(imageExtent.clone());
creation.setExtent(extentUpdate); creation.setExtent(extentUpdate);
} }
target.dispatch(creation); target.dispatch(creation);

View file

@ -22,7 +22,6 @@ package com.raytheon.uf.viz.collaboration.radar.mosaic;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent; import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent;
/** /**
@ -45,12 +44,12 @@ import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent
public class UpdateMosaicExtent extends AbstractDispatchingObjectEvent { public class UpdateMosaicExtent extends AbstractDispatchingObjectEvent {
@DynamicSerializeElement @DynamicSerializeElement
private double[] extent; private IExtent extent;
/** /**
* @return the extent * @return the extent
*/ */
public double[] getExtent() { public IExtent getExtent() {
return extent; return extent;
} }
@ -58,22 +57,8 @@ public class UpdateMosaicExtent extends AbstractDispatchingObjectEvent {
* @param extent * @param extent
* the extent to set * the extent to set
*/ */
public void setExtent(double[] extent) { public void setExtent(IExtent extent) {
this.extent = extent; this.extent = extent;
} }
public void setIExtent(IExtent extent) {
if (extent != null) {
setExtent(new double[] { extent.getMinX(), extent.getMaxX(),
extent.getMinY(), extent.getMaxY() });
}
}
public IExtent getIExtent() {
if (extent != null) {
return new PixelExtent(extent[0], extent[1], extent[2], extent[3]);
}
return null;
}
} }

View file

@ -79,7 +79,7 @@ public class RadarGraphicsExtRenderingHandler extends
IExtent imageExtent = null; IExtent imageExtent = null;
ColorMapParameters parameters = null; ColorMapParameters parameters = null;
if (event.getExtent() != null) { if (event.getExtent() != null) {
imageExtent = event.getExtent().getIExtent(); imageExtent = event.getExtent().getExtent();
} }
if (event.getColorMapParameters() != null) { if (event.getColorMapParameters() != null) {
parameters = event.getColorMapParameters().getColorMapParameters(); parameters = event.getColorMapParameters().getColorMapParameters();
@ -114,7 +114,7 @@ public class RadarGraphicsExtRenderingHandler extends
IMosaicImage image = dataManager.getRenderableObject( IMosaicImage image = dataManager.getRenderableObject(
event.getObjectId(), IMosaicImage.class); event.getObjectId(), IMosaicImage.class);
if (image != null) { if (image != null) {
image.setImageExtent(event.getIExtent()); image.setImageExtent(event.getExtent());
} }
} }
} }

View file

@ -180,7 +180,10 @@ public class CollaborationObjectEventStorage implements
throws CollaborationException { throws CollaborationException {
if (event instanceof CollaborationHttpPersistedEvent) { if (event instanceof CollaborationHttpPersistedEvent) {
CollaborationHttpPersistedObject object = retreiveStoredObject((CollaborationHttpPersistedEvent) event); CollaborationHttpPersistedObject object = retreiveStoredObject((CollaborationHttpPersistedEvent) event);
if (object != null && object.event != null) { if (object == null) {
// No object available
return null;
} else if (object.event != null) {
stats.log(object.event.getClass().getSimpleName(), 0, stats.log(object.event.getClass().getSimpleName(), 0,
object.dataSize); object.dataSize);
return object.event; return object.event;
@ -213,6 +216,9 @@ public class CollaborationObjectEventStorage implements
} catch (SerializationException e) { } catch (SerializationException e) {
throw new CollaborationException(e); throw new CollaborationException(e);
} }
} else if (isNotExists(response.code)) {
// Object was deleted
return null;
} else { } else {
throw new CollaborationException("Error retrieving object from " throw new CollaborationException("Error retrieving object from "
+ objectPath + " : " + new String(response.data)); + objectPath + " : " + new String(response.data));
@ -236,9 +242,8 @@ public class CollaborationObjectEventStorage implements
if (isNotExists(response.code)) { if (isNotExists(response.code)) {
return new AbstractDispatchingObjectEvent[0]; return new AbstractDispatchingObjectEvent[0];
} }
throw new CollaborationException( throw new CollaborationException("Error retrieving object ("
"Error retrieving object events, received code: " + objectId + ") events, received code: " + response.code);
+ response.code);
} }
CollaborationHttpPersistedEvent event = new CollaborationHttpPersistedEvent(); CollaborationHttpPersistedEvent event = new CollaborationHttpPersistedEvent();
List<CollaborationHttpPersistedObject> objectEvents = new ArrayList<CollaborationHttpPersistedObject>(); List<CollaborationHttpPersistedObject> objectEvents = new ArrayList<CollaborationHttpPersistedObject>();
@ -264,6 +269,9 @@ public class CollaborationObjectEventStorage implements
CollaborationHttpPersistedObject eventObject = retreiveStoredObject(event); CollaborationHttpPersistedObject eventObject = retreiveStoredObject(event);
if (eventObject != null) { if (eventObject != null) {
objectEvents.add(eventObject); objectEvents.add(eventObject);
} else {
// Object was deleted, abort
return new AbstractDispatchingObjectEvent[0];
} }
} }
searchIdx = endsAt + 1; searchIdx = endsAt + 1;

View file

@ -299,7 +299,11 @@ public class CollaborationResource extends
@Override @Override
public void run() { public void run() {
try { try {
renderableArrived(dataManager.retrieveEvent(event)); AbstractDispatchingObjectEvent objectEvent = dataManager
.retrieveEvent(event);
if (objectEvent != null) {
renderableArrived(objectEvent);
}
} catch (CollaborationException e) { } catch (CollaborationException e) {
Activator.statusHandler.handle(Priority.PROBLEM, Activator.statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e); e.getLocalizedMessage(), e);
@ -340,7 +344,7 @@ public class CollaborationResource extends
IRenderableDisplay display = descriptor IRenderableDisplay display = descriptor
.getRenderableDisplay(); .getRenderableDisplay();
BeginFrameEvent bfe = (BeginFrameEvent) renderable; BeginFrameEvent bfe = (BeginFrameEvent) renderable;
IExtent frameExtent = bfe.getIExtent(); IExtent frameExtent = bfe.getExtent();
providerWindow = frameExtent; providerWindow = frameExtent;
Rectangle bounds = display.getBounds(); Rectangle bounds = display.getBounds();
double width = frameExtent.getWidth(); double width = frameExtent.getWidth();

View file

@ -137,6 +137,6 @@ public class GeneralRenderingHandler extends CollaborationRenderingHandler {
@Subscribe @Subscribe
public void setupClippingPane(SetupClippingPane event) { public void setupClippingPane(SetupClippingPane event) {
getGraphicsTarget().setupClippingPlane(event.getIExtent()); getGraphicsTarget().setupClippingPlane(event.getExtent());
} }
} }

View file

@ -374,7 +374,7 @@ public class ImagingRenderingHandler extends CollaborationRenderingHandler {
cmap.brightness = event.getBrightness(); cmap.brightness = event.getBrightness();
cmap.contrast = event.getContrast(); cmap.contrast = event.getContrast();
cmap.interpolate = event.isInterpolate(); cmap.interpolate = event.isInterpolate();
cmap.extent = event.getIExtent(); cmap.extent = event.getExtent();
try { try {
target.drawColorRamp(cmap); target.drawColorRamp(cmap);
} catch (VizException e) { } catch (VizException e) {

View file

@ -96,7 +96,7 @@ public class OffscreenRenderingHandler extends CollaborationRenderingHandler {
try { try {
if (event.getExtent() != null) { if (event.getExtent() != null) {
target.getExtension(IOffscreenRenderingExtension.class) target.getExtension(IOffscreenRenderingExtension.class)
.renderOffscreen(offscreenImage, event.getIExtent()); .renderOffscreen(offscreenImage, event.getExtent());
} else { } else {
target.getExtension(IOffscreenRenderingExtension.class) target.getExtension(IOffscreenRenderingExtension.class)
.renderOffscreen(offscreenImage); .renderOffscreen(offscreenImage);

View file

@ -35,7 +35,6 @@ import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IDescriptor; import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IFont; import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.IImage; import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.drawables.IShadedShape; import com.raytheon.uf.viz.core.drawables.IShadedShape;
import com.raytheon.uf.viz.core.drawables.IWireframeShape; import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.drawables.PaintProperties;
@ -594,13 +593,12 @@ public interface IGraphicsTarget extends IImagingExtension {
* Start a frame with a given extent. Must call endFrame after drawing is * Start a frame with a given extent. Must call endFrame after drawing is
* complete. * complete.
* *
* @param display * @param view
* the display area that the frame covers * viewable area of the frame
* @param isClearBackground * @param isClearBackground
* whether background should be cleared prior to drawing * whether background should be cleared prior to drawing
*/ */
public abstract void beginFrame(IRenderableDisplay display, public abstract void beginFrame(IView view, boolean isClearBackground);
boolean isClearBackground);
/** /**
* End a frame * End a frame
@ -775,14 +773,6 @@ public interface IGraphicsTarget extends IImagingExtension {
*/ */
public IView getView(); public IView getView();
/**
* Notify the Graphics Target that there are updated extents that need to be
* set.
*
* @param updatedExtent
*/
public void updateExtent(IExtent updatedExtent);
/** /**
* Use getExtension(IOffscreenRenderingExtension.class).renderOffscreen( * Use getExtension(IOffscreenRenderingExtension.class).renderOffscreen(
* offscreenImage) instead; * offscreenImage) instead;

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?>
<pydev_project>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
</pydev_project>

View file

@ -6,6 +6,7 @@ Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.raytheon.uf.viz.remote.graphics.Activator Bundle-Activator: com.raytheon.uf.viz.remote.graphics.Activator
Bundle-Vendor: RAYTHEON Bundle-Vendor: RAYTHEON
Eclipse-RegisterBuddy: com.raytheon.uf.viz.core Eclipse-RegisterBuddy: com.raytheon.uf.viz.core
Eclipse-BuddyPolicy: dependent
Require-Bundle: org.eclipse.ui, Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime, org.eclipse.core.runtime,
com.raytheon.uf.viz.core;bundle-version="1.12.1174", com.raytheon.uf.viz.core;bundle-version="1.12.1174",

View file

@ -1,10 +1,18 @@
package com.raytheon.uf.viz.remote.graphics; package com.raytheon.uf.viz.remote.graphics;
import java.awt.image.BufferedImage;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
import com.raytheon.uf.common.serialization.DynamicSerializationManager;
import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.remote.graphics.adapters.PixelExtentSerializationAdapter;
import com.raytheon.uf.viz.remote.graphics.adapters.RGBSerializationAdapter;
import com.raytheon.uf.viz.remote.graphics.adapters.RenderedImageAdapter;
/** /**
* The activator class controls the plug-in life cycle * The activator class controls the plug-in life cycle
@ -36,6 +44,12 @@ public class Activator extends AbstractUIPlugin {
public void start(BundleContext context) throws Exception { public void start(BundleContext context) throws Exception {
super.start(context); super.start(context);
plugin = this; plugin = this;
DynamicSerializationManager.registerAdapter(PixelExtent.class,
new PixelExtentSerializationAdapter());
DynamicSerializationManager.registerAdapter(RGB.class,
new RGBSerializationAdapter());
DynamicSerializationManager.registerAdapter(BufferedImage.class,
new RenderedImageAdapter());
} }
/* /*

View file

@ -55,7 +55,6 @@ import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IFont; import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.IFont.Style; import com.raytheon.uf.viz.core.drawables.IFont.Style;
import com.raytheon.uf.viz.core.drawables.IImage; import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.drawables.IShadedShape; import com.raytheon.uf.viz.core.drawables.IShadedShape;
import com.raytheon.uf.viz.core.drawables.IWireframeShape; import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.ImagingSupport; import com.raytheon.uf.viz.core.drawables.ImagingSupport;
@ -110,6 +109,8 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
private IFont defaultFont; private IFont defaultFont;
private RGB backgroundColor = new RGB(0, 0, 0);
private GraphicsExtensionManager extensionManager; private GraphicsExtensionManager extensionManager;
public DispatchGraphicsTarget(IGraphicsTarget target, Dispatcher dispatcher) { public DispatchGraphicsTarget(IGraphicsTarget target, Dispatcher dispatcher) {
@ -291,6 +292,8 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
for (int i = 0; i < parameters.length; ++i) { for (int i = 0; i < parameters.length; ++i) {
parameters[i].font = originalFonts[i]; parameters[i].font = originalFonts[i];
} }
// TODO: Send rendering event for String drawing
} }
/** /**
@ -787,15 +790,15 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
/** /**
* @param display * @param display
* @param isClearBackground * @param isClearBackground
* @see com.raytheon.uf.viz.core.IGraphicsTarget#beginFrame(com.raytheon.uf.viz.core.drawables.IRenderableDisplay, * @see com.raytheon.uf.viz.core.IGraphicsTarget#beginFrame(com.raytheon.uf.viz.core.IView,
* boolean) * boolean)
*/ */
public void beginFrame(IRenderableDisplay display, boolean isClearBackground) { public void beginFrame(IView view, boolean isClearBackground) {
wrappedObject.beginFrame(display, isClearBackground); wrappedObject.beginFrame(view, isClearBackground);
BeginFrameEvent beginFrame = RemoteGraphicsEventFactory.createEvent( BeginFrameEvent beginFrame = RemoteGraphicsEventFactory.createEvent(
BeginFrameEvent.class, this); BeginFrameEvent.class, this);
beginFrame.setIExtent(display.getExtent()); beginFrame.setExtent(view.getExtent().clone());
beginFrame.setColor(display.getBackgroundColor()); beginFrame.setColor(backgroundColor);
dispatch(beginFrame); dispatch(beginFrame);
} }
@ -841,7 +844,7 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
wrappedObject.setupClippingPlane(extent); wrappedObject.setupClippingPlane(extent);
SetupClippingPane event = RemoteGraphicsEventFactory.createEvent( SetupClippingPane event = RemoteGraphicsEventFactory.createEvent(
SetupClippingPane.class, this); SetupClippingPane.class, this);
event.setIExtent(extent); event.setExtent(extent);
dispatch(event); dispatch(event);
} }
@ -876,6 +879,7 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
* @see com.raytheon.uf.viz.core.IGraphicsTarget#setBackgroundColor(org.eclipse.swt.graphics.RGB) * @see com.raytheon.uf.viz.core.IGraphicsTarget#setBackgroundColor(org.eclipse.swt.graphics.RGB)
*/ */
public void setBackgroundColor(RGB backgroundColor) { public void setBackgroundColor(RGB backgroundColor) {
this.backgroundColor = backgroundColor;
wrappedObject.setBackgroundColor(backgroundColor); wrappedObject.setBackgroundColor(backgroundColor);
} }
@ -902,7 +906,7 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
event.setBrightness(colorMap.brightness); event.setBrightness(colorMap.brightness);
event.setContrast(colorMap.contrast); event.setContrast(colorMap.contrast);
event.setInterpolate(colorMap.interpolate); event.setInterpolate(colorMap.interpolate);
event.setIExtent(colorMap.extent); event.setExtent(colorMap.extent);
dispatch(event); dispatch(event);
} }
@ -1017,14 +1021,6 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
dispatch(event); dispatch(event);
} }
/**
* @param updatedExtent
* @see com.raytheon.uf.viz.core.IGraphicsTarget#updateExtent(com.raytheon.uf.viz.core.IExtent)
*/
public void updateExtent(IExtent updatedExtent) {
wrappedObject.updateExtent(updatedExtent);
}
/** /**
* @param offscreenImage * @param offscreenImage
* @throws VizException * @throws VizException
@ -1072,11 +1068,14 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
HorizontalAlignment horizontalAlignment, HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment, Double rotation) VerticalAlignment verticalAlignment, Double rotation)
throws VizException { throws VizException {
if (font instanceof DispatchingFont) { DrawableString string = new DrawableString(text, color);
font = ((DispatchingFont) font).getWrappedObject(); string.setCoordinates(x, y, z);
} string.font = font;
wrappedObject.drawString(font, text, x, y, z, textStyle, color, string.textStyle = textStyle;
horizontalAlignment, verticalAlignment, rotation); string.horizontalAlignment = horizontalAlignment;
string.verticallAlignment = verticalAlignment;
string.rotation = rotation;
drawStrings(string);
} }
/** /**
@ -1102,11 +1101,13 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
double z, TextStyle textStyle, RGB color, double z, TextStyle textStyle, RGB color,
HorizontalAlignment horizontalAlignment, Double rotation) HorizontalAlignment horizontalAlignment, Double rotation)
throws VizException { throws VizException {
if (font instanceof DispatchingFont) { DrawableString string = new DrawableString(text, color);
font = ((DispatchingFont) font).getWrappedObject(); string.setCoordinates(x, y, z);
} string.font = font;
wrappedObject.drawString(font, text, x, y, z, textStyle, color, string.textStyle = textStyle;
horizontalAlignment, rotation); string.horizontalAlignment = horizontalAlignment;
string.rotation = rotation;
drawStrings(string);
} }
/** /**
@ -1132,11 +1133,13 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
double z, TextStyle textStyle, RGB[] colors, double z, TextStyle textStyle, RGB[] colors,
HorizontalAlignment horizontalAlignment, HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment) throws VizException { VerticalAlignment verticalAlignment) throws VizException {
if (font instanceof DispatchingFont) { DrawableString string = new DrawableString(text, colors);
font = ((DispatchingFont) font).getWrappedObject(); string.setCoordinates(x, y, z);
} string.font = font;
wrappedObject.drawStrings(font, text, x, y, z, textStyle, colors, string.textStyle = textStyle;
horizontalAlignment, verticalAlignment); string.horizontalAlignment = horizontalAlignment;
string.verticallAlignment = verticalAlignment;
drawStrings(string);
} }
/** /**
@ -1162,17 +1165,21 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
* com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment, * com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment,
* java.lang.Double, float, double) * java.lang.Double, float, double)
*/ */
public void drawString(IFont font, String string, double xPos, double yPos, public void drawString(IFont font, String text, double x, double y,
double zPos, TextStyle textStyle, RGB color, double z, TextStyle textStyle, RGB color,
HorizontalAlignment horizontalAlignment, HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment, Double rotation, float alpha, VerticalAlignment verticalAlignment, Double rotation, float alpha,
double magnification) throws VizException { double magnification) throws VizException {
if (font instanceof DispatchingFont) { DrawableString string = new DrawableString(text, color);
font = ((DispatchingFont) font).getWrappedObject(); string.setCoordinates(x, y, z);
} string.font = font;
wrappedObject.drawString(font, string, xPos, yPos, zPos, textStyle, string.textStyle = textStyle;
color, horizontalAlignment, verticalAlignment, rotation, alpha, string.horizontalAlignment = horizontalAlignment;
magnification); string.verticallAlignment = verticalAlignment;
string.rotation = rotation;
string.basics.alpha = alpha;
string.magnification = magnification;
drawStrings(string);
} }
/** /**

View file

@ -0,0 +1,77 @@
/**
* 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.adapters;
import com.raytheon.uf.common.serialization.IDeserializationContext;
import com.raytheon.uf.common.serialization.ISerializationContext;
import com.raytheon.uf.common.serialization.ISerializationTypeAdapter;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.viz.core.PixelExtent;
/**
* Serialization adapter for PixelExtent
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 3, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class PixelExtentSerializationAdapter implements
ISerializationTypeAdapter<PixelExtent> {
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.serialization.ISerializationTypeAdapter#serialize
* (com.raytheon.uf.common.serialization.ISerializationContext,
* java.lang.Object)
*/
@Override
public void serialize(ISerializationContext serializer, PixelExtent object)
throws SerializationException {
serializer.writeDoubleArray(new double[] { object.getMinX(),
object.getMaxX(), object.getMinY(), object.getMaxY() });
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.serialization.ISerializationTypeAdapter#deserialize
* (com.raytheon.uf.common.serialization.IDeserializationContext)
*/
@Override
public PixelExtent deserialize(IDeserializationContext deserializer)
throws SerializationException {
double[] extent = deserializer.readDoubleArray();
return new PixelExtent(extent[0], extent[1], extent[2], extent[3]);
}
}

View file

@ -0,0 +1,78 @@
/**
* 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.adapters;
import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.serialization.IDeserializationContext;
import com.raytheon.uf.common.serialization.ISerializationContext;
import com.raytheon.uf.common.serialization.ISerializationTypeAdapter;
import com.raytheon.uf.common.serialization.SerializationException;
/**
* Serialization adapter for RGB
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 3, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class RGBSerializationAdapter implements ISerializationTypeAdapter<RGB> {
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.serialization.ISerializationTypeAdapter#serialize
* (com.raytheon.uf.common.serialization.ISerializationContext,
* java.lang.Object)
*/
@Override
public void serialize(ISerializationContext serializer, RGB object)
throws SerializationException {
serializer.writeI32(object.red);
serializer.writeI32(object.green);
serializer.writeI32(object.blue);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.serialization.ISerializationTypeAdapter#deserialize
* (com.raytheon.uf.common.serialization.IDeserializationContext)
*/
@Override
public RGB deserialize(IDeserializationContext deserializer)
throws SerializationException {
return new RGB(deserializer.readI32(), deserializer.readI32(),
deserializer.readI32());
}
}

View file

@ -0,0 +1,97 @@
/**
* 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.adapters;
import java.awt.image.RenderedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.raytheon.uf.common.serialization.IDeserializationContext;
import com.raytheon.uf.common.serialization.ISerializationContext;
import com.raytheon.uf.common.serialization.ISerializationTypeAdapter;
import com.raytheon.uf.common.serialization.SerializationException;
/**
* Serialization adapter for RenderedImages
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 3, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class RenderedImageAdapter implements
ISerializationTypeAdapter<RenderedImage> {
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.serialization.ISerializationTypeAdapter#serialize
* (com.raytheon.uf.common.serialization.ISerializationContext,
* java.lang.Object)
*/
@Override
public void serialize(ISerializationContext serializer, RenderedImage image)
throws SerializationException {
// serialize rendered image into bytes
try {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
ImageIO.write(image, "png", bytes);
serializer.writeBinary(bytes.toByteArray());
} catch (IOException e) {
throw new SerializationException(
"Error serializing rendered image", e);
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.serialization.ISerializationTypeAdapter#deserialize
* (com.raytheon.uf.common.serialization.IDeserializationContext)
*/
@Override
public RenderedImage deserialize(IDeserializationContext deserializer)
throws SerializationException {
byte[] data = deserializer.readBinary();
// deserialize bytes into rendered image
try {
return ImageIO.read(new ByteArrayInputStream(data));
} catch (Exception e) {
throw new SerializationException(
"Error deserializing rendered image: "
+ e.getLocalizedMessage(), e);
}
}
}

View file

@ -19,12 +19,9 @@
**/ **/
package com.raytheon.uf.viz.remote.graphics.events.clipping; package com.raytheon.uf.viz.remote.graphics.events.clipping;
import java.util.Arrays;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.remote.graphics.events.rendering.AbstractRemoteGraphicsRenderEvent; import com.raytheon.uf.viz.remote.graphics.events.rendering.AbstractRemoteGraphicsRenderEvent;
import com.raytheon.uf.viz.remote.graphics.events.rendering.IRenderEvent; import com.raytheon.uf.viz.remote.graphics.events.rendering.IRenderEvent;
@ -48,7 +45,7 @@ import com.raytheon.uf.viz.remote.graphics.events.rendering.IRenderEvent;
public class SetupClippingPane extends AbstractRemoteGraphicsRenderEvent { public class SetupClippingPane extends AbstractRemoteGraphicsRenderEvent {
@DynamicSerializeElement @DynamicSerializeElement
private double[] extent; private IExtent extent;
/* /*
* (non-Javadoc) * (non-Javadoc)
@ -62,7 +59,7 @@ public class SetupClippingPane extends AbstractRemoteGraphicsRenderEvent {
public IRenderEvent createDiffObject(IRenderEvent event) { public IRenderEvent createDiffObject(IRenderEvent event) {
SetupClippingPane diffEvent = (SetupClippingPane) event; SetupClippingPane diffEvent = (SetupClippingPane) event;
SetupClippingPane diffObject = new SetupClippingPane(); SetupClippingPane diffObject = new SetupClippingPane();
if (Arrays.equals(extent, diffEvent.extent) == false) { if (extent.equals(diffEvent.extent) == false) {
diffObject.extent = diffEvent.extent; diffObject.extent = diffEvent.extent;
} }
return diffObject; return diffObject;
@ -86,7 +83,7 @@ public class SetupClippingPane extends AbstractRemoteGraphicsRenderEvent {
/** /**
* @return the extent * @return the extent
*/ */
public double[] getExtent() { public IExtent getExtent() {
return extent; return extent;
} }
@ -94,24 +91,10 @@ public class SetupClippingPane extends AbstractRemoteGraphicsRenderEvent {
* @param extent * @param extent
* the extent to set * the extent to set
*/ */
public void setExtent(double[] extent) { public void setExtent(IExtent extent) {
this.extent = extent; this.extent = extent;
} }
public void setIExtent(IExtent extent) {
if (extent != null) {
setExtent(new double[] { extent.getMinX(), extent.getMaxX(),
extent.getMinY(), extent.getMaxY() });
}
}
public IExtent getIExtent() {
if (extent != null) {
return new PixelExtent(extent[0], extent[1], extent[2], extent[3]);
}
return null;
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -126,7 +109,10 @@ public class SetupClippingPane extends AbstractRemoteGraphicsRenderEvent {
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
SetupClippingPane other = (SetupClippingPane) obj; SetupClippingPane other = (SetupClippingPane) obj;
if (!Arrays.equals(extent, other.extent)) if (extent == null) {
if (other.extent != null)
return false;
} else if (!extent.equals(other.extent))
return false; return false;
return true; return true;
} }

View file

@ -19,13 +19,14 @@
**/ **/
package com.raytheon.uf.viz.remote.graphics.events.colormap; package com.raytheon.uf.viz.remote.graphics.events.colormap;
import java.nio.Buffer;
import com.raytheon.uf.common.serialization.SerializationException; import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.SerializationUtil; import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback.ColorMapData; import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback.ColorMapData;
import com.raytheon.uf.viz.remote.graphics.Activator; import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback.ColorMapDataType;
import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent; import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent;
/** /**
@ -49,38 +50,19 @@ import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent
public class ColorMapDataEvent extends AbstractDispatchingObjectEvent { public class ColorMapDataEvent extends AbstractDispatchingObjectEvent {
@DynamicSerializeElement @DynamicSerializeElement
private byte[] serializedColorMapData; private int[] dimensions;
/** @DynamicSerializeElement
* @return the serializedColorMapData private ColorMapDataType dataType;
*/
public byte[] getSerializedColorMapData() {
return serializedColorMapData;
}
/** @DynamicSerializeElement
* @param serializedColorMapData private Buffer buffer;
* the serializedColorMapData to set
*/
public void setSerializedColorMapData(byte[] serializedColorMapData) {
this.serializedColorMapData = serializedColorMapData;
}
/** /**
* @return the colorMapData * @return the colorMapData
*/ */
public ColorMapData getColorMapData() { public ColorMapData getColorMapData() {
if (serializedColorMapData != null) { return new ColorMapData(buffer, dimensions, dataType);
try {
ColorMapDataWrapper wrapper = (ColorMapDataWrapper) SerializationUtil
.transformFromThrift(serializedColorMapData);
return wrapper.getColorMapData();
} catch (SerializationException e) {
Activator.statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
}
return null;
} }
/** /**
@ -88,15 +70,65 @@ public class ColorMapDataEvent extends AbstractDispatchingObjectEvent {
* the colorMapData to set * the colorMapData to set
*/ */
public void setColorMapData(ColorMapData colorMapData) { public void setColorMapData(ColorMapData colorMapData) {
ColorMapDataWrapper wrapper = new ColorMapDataWrapper(); // Copy data via serialization
wrapper.setColorMapData(colorMapData); this.dimensions = colorMapData.getDimensions();
this.dataType = colorMapData.getDataType();
try { try {
serializedColorMapData = SerializationUtil // Copy the buffer since it is the same buffer that will be used for
.transformToThrift(wrapper); // rendering in a separate thread and serializing Buffer access is
// not thread safe
this.buffer = (Buffer) SerializationUtil
.transformFromThrift(SerializationUtil
.transformToThrift(colorMapData.getBuffer()));
} catch (SerializationException e) { } catch (SerializationException e) {
Activator.statusHandler.handle(Priority.PROBLEM, throw new RuntimeException("Error copying data Buffer: "
e.getLocalizedMessage(), e); + e.getLocalizedMessage(), e);
} }
} }
/**
* @return the dimensions
*/
public int[] getDimensions() {
return dimensions;
}
/**
* @param dimensions
* the dimensions to set
*/
public void setDimensions(int[] dimensions) {
this.dimensions = dimensions;
}
/**
* @return the dataType
*/
public ColorMapDataType getDataType() {
return dataType;
}
/**
* @param dataType
* the dataType to set
*/
public void setDataType(ColorMapDataType dataType) {
this.dataType = dataType;
}
/**
* @return the buffer
*/
public Buffer getBuffer() {
return buffer;
}
/**
* @param buffer
* the buffer to set
*/
public void setBuffer(Buffer buffer) {
this.buffer = buffer;
}
} }

View file

@ -1,172 +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.events.colormap;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
import com.raytheon.uf.common.serialization.IDeserializationContext;
import com.raytheon.uf.common.serialization.ISerializationContext;
import com.raytheon.uf.common.serialization.ISerializationTypeAdapter;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeTypeAdapter;
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback.ColorMapData;
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback.ColorMapDataType;
import com.raytheon.uf.viz.remote.graphics.events.colormap.ColorMapDataWrapper.ColorMapDataWrapperAdapter;
/**
* Object that wraps ColorMapData
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 25, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
@DynamicSerialize
@DynamicSerializeTypeAdapter(factory = ColorMapDataWrapperAdapter.class)
public class ColorMapDataWrapper {
public static class ColorMapDataWrapperAdapter implements
ISerializationTypeAdapter<ColorMapDataWrapper> {
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.serialization.ISerializationTypeAdapter#serialize
* (com.raytheon.uf.common.serialization.ISerializationContext,
* java.lang.Object)
*/
@Override
public void serialize(ISerializationContext serializer,
ColorMapDataWrapper object) throws SerializationException {
ColorMapData colorMapData = object.getColorMapData();
serializer.writeString(colorMapData.getDataType().name());
int[] dimensions = colorMapData.getDimensions();
serializer.writeI32(dimensions[0]);
serializer.writeI32(dimensions[1]);
Buffer buffer = colorMapData.getBuffer();
serializer.writeBool(buffer.isDirect());
buffer.position(0);
ByteBuffer bb = null;
byte[] bytes = null;
switch (colorMapData.getDataType()) {
case BYTE:
case SIGNED_BYTE:
bytes = new byte[buffer.capacity()];
bb = ByteBuffer.wrap(bytes);
bb.put((ByteBuffer) buffer);
break;
case SHORT:
case UNSIGNED_SHORT:
bytes = new byte[2 * buffer.capacity()];
bb = ByteBuffer.wrap(bytes);
bb.asShortBuffer().put((ShortBuffer) buffer);
break;
case FLOAT:
bytes = new byte[4 * buffer.capacity()];
bb = ByteBuffer.wrap(bytes);
bb.asFloatBuffer().put((FloatBuffer) buffer);
break;
case INT:
bytes = new byte[4 * buffer.capacity()];
bb = ByteBuffer.wrap(bytes);
bb.asIntBuffer().put((IntBuffer) buffer);
break;
}
serializer.writeBinary(bb.array());
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.common.serialization.ISerializationTypeAdapter#
* deserialize
* (com.raytheon.uf.common.serialization.IDeserializationContext)
*/
@Override
public ColorMapDataWrapper deserialize(
IDeserializationContext deserializer)
throws SerializationException {
ColorMapDataWrapper wrapper = new ColorMapDataWrapper();
ColorMapDataType dataType = ColorMapDataType.valueOf(deserializer
.readString());
int[] dimensions = new int[] { deserializer.readI32(),
deserializer.readI32() };
boolean direct = deserializer.readBool();
byte[] bytes = deserializer.readBinary();
ByteBuffer buffer = direct ? ByteBuffer
.allocateDirect(bytes.length) : ByteBuffer
.allocate(bytes.length);
buffer.put(bytes);
buffer.rewind();
Buffer dataBuffer = null;
switch (dataType) {
case BYTE:
case SIGNED_BYTE:
dataBuffer = buffer;
break;
case SHORT:
case UNSIGNED_SHORT:
dataBuffer = buffer.asShortBuffer();
break;
case INT:
dataBuffer = buffer.asIntBuffer();
break;
case FLOAT:
dataBuffer = buffer.asFloatBuffer();
break;
}
wrapper.setColorMapData(new ColorMapData(dataBuffer, dimensions,
dataType));
return wrapper;
}
}
private ColorMapData colorMapData;
/**
* @return the colorMapData
*/
public ColorMapData getColorMapData() {
return colorMapData;
}
/**
* @param colorMapData
* the colorMapData to set
*/
public void setColorMapData(ColorMapData colorMapData) {
this.colorMapData = colorMapData;
}
}

View file

@ -19,12 +19,9 @@
**/ **/
package com.raytheon.uf.viz.remote.graphics.events.colormap; package com.raytheon.uf.viz.remote.graphics.events.colormap;
import java.util.Arrays;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.remote.graphics.events.rendering.AbstractRemoteGraphicsRenderEvent; import com.raytheon.uf.viz.remote.graphics.events.rendering.AbstractRemoteGraphicsRenderEvent;
import com.raytheon.uf.viz.remote.graphics.events.rendering.IRenderEvent; import com.raytheon.uf.viz.remote.graphics.events.rendering.IRenderEvent;
@ -63,7 +60,7 @@ public class DrawColorRampEvent extends AbstractRemoteGraphicsRenderEvent {
private boolean interpolate = true; private boolean interpolate = true;
@DynamicSerializeElement @DynamicSerializeElement
private double[] extent; private IExtent extent;
/* /*
* (non-Javadoc) * (non-Javadoc)
@ -102,7 +99,7 @@ public class DrawColorRampEvent extends AbstractRemoteGraphicsRenderEvent {
diffObject.brightness = diffEvent.brightness; diffObject.brightness = diffEvent.brightness;
diffObject.contrast = diffEvent.contrast; diffObject.contrast = diffEvent.contrast;
diffObject.interpolate = diffEvent.interpolate; diffObject.interpolate = diffEvent.interpolate;
if (Arrays.equals(extent, diffEvent.extent) == false) { if (extent.equals(diffEvent.extent) == false) {
diffObject.extent = diffEvent.extent; diffObject.extent = diffEvent.extent;
} }
return diffObject; return diffObject;
@ -186,7 +183,7 @@ public class DrawColorRampEvent extends AbstractRemoteGraphicsRenderEvent {
/** /**
* @return the extent * @return the extent
*/ */
public double[] getExtent() { public IExtent getExtent() {
return extent; return extent;
} }
@ -194,24 +191,10 @@ public class DrawColorRampEvent extends AbstractRemoteGraphicsRenderEvent {
* @param extent * @param extent
* the extent to set * the extent to set
*/ */
public void setExtent(double[] extent) { public void setExtent(IExtent extent) {
this.extent = extent; this.extent = extent;
} }
public void setIExtent(IExtent extent) {
if (extent != null) {
setExtent(new double[] { extent.getMinX(), extent.getMaxX(),
extent.getMinY(), extent.getMaxY() });
}
}
public IExtent getIExtent() {
if (extent != null) {
return new PixelExtent(extent[0], extent[1], extent[2], extent[3]);
}
return null;
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -236,7 +219,10 @@ public class DrawColorRampEvent extends AbstractRemoteGraphicsRenderEvent {
if (Float.floatToIntBits(contrast) != Float if (Float.floatToIntBits(contrast) != Float
.floatToIntBits(other.contrast)) .floatToIntBits(other.contrast))
return false; return false;
if (!Arrays.equals(extent, other.extent)) if (extent == null) {
if (other.extent != null)
return false;
} else if (!extent.equals(other.extent))
return false; return false;
if (interpolate != other.interpolate) if (interpolate != other.interpolate)
return false; return false;

View file

@ -46,28 +46,13 @@ import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent
public class RenderedImageEvent extends AbstractDispatchingObjectEvent { public class RenderedImageEvent extends AbstractDispatchingObjectEvent {
@DynamicSerializeElement @DynamicSerializeElement
private RenderedImageWrapper wrapper = new RenderedImageWrapper(); private RenderedImage renderedImage;
/**
* @return the wrapper
*/
public RenderedImageWrapper getWrapper() {
return wrapper;
}
/**
* @param wrapper
* the wrapper to set
*/
public void setWrapper(RenderedImageWrapper wrapper) {
this.wrapper = wrapper;
}
/** /**
* @return the renderedImage * @return the renderedImage
*/ */
public RenderedImage getRenderedImage() { public RenderedImage getRenderedImage() {
return wrapper.getWrappedImage(); return renderedImage;
} }
/** /**
@ -75,7 +60,7 @@ public class RenderedImageEvent extends AbstractDispatchingObjectEvent {
* the renderedImage to set * the renderedImage to set
*/ */
public void setRenderedImage(RenderedImage renderedImage) { public void setRenderedImage(RenderedImage renderedImage) {
wrapper.setWrappedImage(renderedImage); this.renderedImage = renderedImage;
} }
} }

View file

@ -1,127 +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.events.imagery;
import java.awt.image.RenderedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.raytheon.uf.common.serialization.IDeserializationContext;
import com.raytheon.uf.common.serialization.ISerializationContext;
import com.raytheon.uf.common.serialization.ISerializationTypeAdapter;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeTypeAdapter;
import com.raytheon.uf.viz.remote.graphics.events.imagery.RenderedImageWrapper.RenderedImageSerializer;
/**
* Wraps a RenderedImage for dynamic serialization
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 13, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
@DynamicSerialize
@DynamicSerializeTypeAdapter(factory = RenderedImageSerializer.class)
public class RenderedImageWrapper {
public static class RenderedImageSerializer implements
ISerializationTypeAdapter<RenderedImageWrapper> {
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.serialization.ISerializationTypeAdapter#serialize
* (com.raytheon.uf.common.serialization.ISerializationContext,
* java.lang.Object)
*/
@Override
public void serialize(ISerializationContext serializer,
RenderedImageWrapper object) throws SerializationException {
RenderedImage image = object.getWrappedImage();
// serialize rendered image into bytes
try {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
ImageIO.write(image, "png", bytes);
serializer.writeBinary(bytes.toByteArray());
} catch (IOException e) {
throw new SerializationException(
"Error serializing rendered image", e);
}
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.common.serialization.ISerializationTypeAdapter#
* deserialize
* (com.raytheon.uf.common.serialization.IDeserializationContext)
*/
@Override
public RenderedImageWrapper deserialize(
IDeserializationContext deserializer)
throws SerializationException {
RenderedImageWrapper wrapper = new RenderedImageWrapper();
byte[] data = deserializer.readBinary();
// deserialize bytes into rendered image
try {
wrapper.setWrappedImage(ImageIO.read(new ByteArrayInputStream(
data)));
} catch (Exception e) {
throw new SerializationException(
"Error deserializing rendered image: "
+ e.getLocalizedMessage(), e);
}
return wrapper;
}
}
@DynamicSerializeElement
private RenderedImage wrappedImage;
/**
* @return the wrappedImage
*/
public RenderedImage getWrappedImage() {
return wrappedImage;
}
/**
* @param wrappedImage
* the wrappedImage to set
*/
public void setWrappedImage(RenderedImage wrappedImage) {
this.wrappedImage = wrappedImage;
}
}

View file

@ -46,69 +46,21 @@ import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent
public class UpdateSingleColorImage extends AbstractDispatchingObjectEvent { public class UpdateSingleColorImage extends AbstractDispatchingObjectEvent {
@DynamicSerializeElement @DynamicSerializeElement
private int red; private RGB color;
@DynamicSerializeElement
private int green;
@DynamicSerializeElement
private int blue;
/** /**
* @return the red * @return the color
*/ */
public int getRed() {
return red;
}
/**
* @param red
* the red to set
*/
public void setRed(int red) {
this.red = red;
}
/**
* @return the green
*/
public int getGreen() {
return green;
}
/**
* @param green
* the green to set
*/
public void setGreen(int green) {
this.green = green;
}
/**
* @return the blue
*/
public int getBlue() {
return blue;
}
/**
* @param blue
* the blue to set
*/
public void setBlue(int blue) {
this.blue = blue;
}
public void setColor(RGB color) {
if (color != null) {
red = color.red;
green = color.green;
blue = color.blue;
}
}
public RGB getColor() { public RGB getColor() {
return new RGB(red, green, blue); return color;
}
/**
* @param color
* the color to set
*/
public void setColor(RGB color) {
this.color = color;
} }
} }

View file

@ -19,12 +19,9 @@
**/ **/
package com.raytheon.uf.viz.remote.graphics.events.offscreen; package com.raytheon.uf.viz.remote.graphics.events.offscreen;
import java.util.Arrays;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent; import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent;
import com.raytheon.uf.viz.remote.graphics.events.rendering.IRenderEvent; import com.raytheon.uf.viz.remote.graphics.events.rendering.IRenderEvent;
@ -50,7 +47,7 @@ public class RenderOffscreenEvent extends AbstractDispatchingObjectEvent
implements IRenderEvent { implements IRenderEvent {
@DynamicSerializeElement @DynamicSerializeElement
private double[] extent; private IExtent extent;
/* /*
* (non-Javadoc) * (non-Javadoc)
@ -81,7 +78,7 @@ public class RenderOffscreenEvent extends AbstractDispatchingObjectEvent
/** /**
* @return the extent * @return the extent
*/ */
public double[] getExtent() { public IExtent getExtent() {
return extent; return extent;
} }
@ -89,31 +86,10 @@ public class RenderOffscreenEvent extends AbstractDispatchingObjectEvent
* @param extent * @param extent
* the extent to set * the extent to set
*/ */
public void setExtent(double[] extent) { public void setExtent(IExtent extent) {
this.extent = extent; this.extent = extent;
} }
/**
* @return the iextent
*/
public IExtent getIExtent() {
if (extent != null) {
return new PixelExtent(extent[0], extent[1], extent[2], extent[3]);
}
return null;
}
/**
* @param iextent
* the iextent to set
*/
public void setIExtent(IExtent extent) {
if (extent != null) {
this.extent = new double[] { extent.getMinX(), extent.getMaxX(),
extent.getMinY(), extent.getMaxY() };
}
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -128,7 +104,10 @@ public class RenderOffscreenEvent extends AbstractDispatchingObjectEvent
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
RenderOffscreenEvent other = (RenderOffscreenEvent) obj; RenderOffscreenEvent other = (RenderOffscreenEvent) obj;
if (!Arrays.equals(extent, other.extent)) if (extent == null) {
if (other.extent != null)
return false;
} else if (!extent.equals(other.extent))
return false; return false;
return true; return true;
} }

View file

@ -121,13 +121,7 @@ public class DrawPointsEvent extends AbstractRemoteGraphicsRenderEvent {
private float magnification; private float magnification;
@DynamicSerializeElement @DynamicSerializeElement
private int red; private RGB color;
@DynamicSerializeElement
private int green;
@DynamicSerializeElement
private int blue;
/* /*
* (non-Javadoc) * (non-Javadoc)
@ -141,9 +135,7 @@ public class DrawPointsEvent extends AbstractRemoteGraphicsRenderEvent {
public IRenderEvent createDiffObject(IRenderEvent diffEvent) { public IRenderEvent createDiffObject(IRenderEvent diffEvent) {
DrawPointsEvent event = (DrawPointsEvent) diffEvent; DrawPointsEvent event = (DrawPointsEvent) diffEvent;
DrawPointsEvent diffObject = new DrawPointsEvent(); DrawPointsEvent diffObject = new DrawPointsEvent();
diffObject.red = event.red; diffObject.color = color;
diffObject.green = event.green;
diffObject.blue = event.blue;
diffObject.magnification = event.magnification; diffObject.magnification = event.magnification;
Set<Point> additions = new HashSet<Point>(event.points); Set<Point> additions = new HashSet<Point>(event.points);
@ -171,9 +163,7 @@ public class DrawPointsEvent extends AbstractRemoteGraphicsRenderEvent {
@Override @Override
public void applyDiffObject(IRenderEvent diffEvent) { public void applyDiffObject(IRenderEvent diffEvent) {
DrawPointsEvent event = (DrawPointsEvent) diffEvent; DrawPointsEvent event = (DrawPointsEvent) diffEvent;
red = event.red; color = event.color;
green = event.green;
blue = event.blue;
magnification = event.magnification; magnification = event.magnification;
synchronized (points) { synchronized (points) {
@ -269,60 +259,18 @@ public class DrawPointsEvent extends AbstractRemoteGraphicsRenderEvent {
} }
/** /**
* @return the red * @return the color
*/ */
public int getRed() {
return red;
}
/**
* @param red
* the red to set
*/
public void setRed(int red) {
this.red = red;
}
/**
* @return the green
*/
public int getGreen() {
return green;
}
/**
* @param green
* the green to set
*/
public void setGreen(int green) {
this.green = green;
}
/**
* @return the blue
*/
public int getBlue() {
return blue;
}
/**
* @param blue
* the blue to set
*/
public void setBlue(int blue) {
this.blue = blue;
}
public void setColor(RGB color) {
if (color != null) {
red = color.red;
green = color.green;
blue = color.blue;
}
}
public RGB getColor() { public RGB getColor() {
return new RGB(red, green, blue); return color;
}
/**
* @param color
* the color to set
*/
public void setColor(RGB color) {
this.color = color;
} }
/* /*
@ -339,9 +287,10 @@ public class DrawPointsEvent extends AbstractRemoteGraphicsRenderEvent {
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
DrawPointsEvent other = (DrawPointsEvent) obj; DrawPointsEvent other = (DrawPointsEvent) obj;
if (blue != other.blue) if (color == null) {
return false; if (other.color != null)
if (green != other.green) return false;
} else if (!color.equals(other.color))
return false; return false;
if (Float.floatToIntBits(magnification) != Float if (Float.floatToIntBits(magnification) != Float
.floatToIntBits(other.magnification)) .floatToIntBits(other.magnification))
@ -351,8 +300,6 @@ public class DrawPointsEvent extends AbstractRemoteGraphicsRenderEvent {
return false; return false;
} else if (!points.equals(other.points)) } else if (!points.equals(other.points))
return false; return false;
if (red != other.red)
return false;
if (removals == null) { if (removals == null) {
if (other.removals != null) if (other.removals != null)
return false; return false;

View file

@ -19,14 +19,11 @@
**/ **/
package com.raytheon.uf.viz.remote.graphics.events.rendering; package com.raytheon.uf.viz.remote.graphics.events.rendering;
import java.util.Arrays;
import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.PixelExtent;
/** /**
* Frame that specifies the begining of a new rendering sequence. EndFrameEvent * Frame that specifies the begining of a new rendering sequence. EndFrameEvent
@ -49,67 +46,10 @@ import com.raytheon.uf.viz.core.PixelExtent;
public class BeginFrameEvent extends AbstractRemoteGraphicsRenderEvent { public class BeginFrameEvent extends AbstractRemoteGraphicsRenderEvent {
@DynamicSerializeElement @DynamicSerializeElement
private double[] extent; private IExtent extent;
@DynamicSerializeElement @DynamicSerializeElement
private int[] rgb; private RGB color;
/**
* @return the extent
*/
public double[] getExtent() {
return extent;
}
/**
* @param extent
* the extent to set
*/
public void setExtent(double[] extent) {
this.extent = extent;
}
public void setIExtent(IExtent extent) {
if (extent != null) {
setExtent(new double[] { extent.getMinX(), extent.getMaxX(),
extent.getMinY(), extent.getMaxY() });
}
}
public IExtent getIExtent() {
if (extent != null) {
return new PixelExtent(extent[0], extent[1], extent[2], extent[3]);
}
return null;
}
/**
* @return the rgb
*/
public int[] getRgb() {
return rgb;
}
/**
* @param rgb
* the rgb to set
*/
public void setRgb(int[] rgb) {
this.rgb = rgb;
}
public void setColor(RGB color) {
if (color != null) {
rgb = new int[] { color.red, color.green, color.blue };
}
}
public RGB getColor() {
if (rgb != null) {
return new RGB(rgb[0], rgb[1], rgb[2]);
}
return null;
}
/* /*
* (non-Javadoc) * (non-Javadoc)
@ -123,11 +63,11 @@ public class BeginFrameEvent extends AbstractRemoteGraphicsRenderEvent {
public IRenderEvent createDiffObject(IRenderEvent event) { public IRenderEvent createDiffObject(IRenderEvent event) {
BeginFrameEvent diffEvent = (BeginFrameEvent) event; BeginFrameEvent diffEvent = (BeginFrameEvent) event;
BeginFrameEvent diffObject = new BeginFrameEvent(); BeginFrameEvent diffObject = new BeginFrameEvent();
if (Arrays.equals(extent, diffEvent.extent) == false) { if (extent.equals(diffEvent.extent) == false) {
diffObject.extent = diffEvent.extent; diffObject.extent = diffEvent.extent;
} }
if (Arrays.equals(rgb, diffEvent.rgb) == false) { if (color.equals(diffEvent.color) == false) {
diffObject.rgb = diffEvent.rgb; diffObject.color = diffEvent.color;
} }
return diffObject; return diffObject;
} }
@ -145,11 +85,41 @@ public class BeginFrameEvent extends AbstractRemoteGraphicsRenderEvent {
if (event.extent != null) { if (event.extent != null) {
this.extent = event.extent; this.extent = event.extent;
} }
if (event.rgb != null) { if (event.color != null) {
rgb = event.rgb; color = event.color;
} }
} }
/**
* @return the extent
*/
public IExtent getExtent() {
return extent;
}
/**
* @param extent
* the extent to set
*/
public void setExtent(IExtent extent) {
this.extent = extent;
}
/**
* @return the color
*/
public RGB getColor() {
return color;
}
/**
* @param color
* the color to set
*/
public void setColor(RGB color) {
this.color = color;
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -164,9 +134,15 @@ public class BeginFrameEvent extends AbstractRemoteGraphicsRenderEvent {
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
BeginFrameEvent other = (BeginFrameEvent) obj; BeginFrameEvent other = (BeginFrameEvent) obj;
if (!Arrays.equals(extent, other.extent)) if (color == null) {
if (other.color != null)
return false;
} else if (!color.equals(other.color))
return false; return false;
if (!Arrays.equals(rgb, other.rgb)) if (extent == null) {
if (other.extent != null)
return false;
} else if (!extent.equals(other.extent))
return false; return false;
return true; return true;
} }

View file

@ -0,0 +1,64 @@
/**
* 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.rendering;
/**
* Event for drawing strings
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 3, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class DrawStringsEvent extends AbstractRemoteGraphicsRenderEvent {
/*
* (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) {
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.remote.graphics.events.rendering.
* AbstractRemoteGraphicsRenderEvent#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
return false;
}
}

View file

@ -48,13 +48,7 @@ public class RenderWireframeShapeEvent extends AbstractDispatchingObjectEvent
implements IRenderEvent { implements IRenderEvent {
@DynamicSerializeElement @DynamicSerializeElement
private Integer red; private RGB color;
@DynamicSerializeElement
private Integer green;
@DynamicSerializeElement
private Integer blue;
@DynamicSerializeElement @DynamicSerializeElement
private float lineWidth; private float lineWidth;
@ -92,59 +86,12 @@ public class RenderWireframeShapeEvent extends AbstractDispatchingObjectEvent
RenderWireframeShapeEvent event = (RenderWireframeShapeEvent) diffEvent; RenderWireframeShapeEvent event = (RenderWireframeShapeEvent) diffEvent;
this.setObjectId(event.getObjectId()); this.setObjectId(event.getObjectId());
this.alpha = event.alpha; this.alpha = event.alpha;
this.red = event.red; this.color = event.color;
this.green = event.green;
this.blue = event.blue;
this.fontId = event.fontId; this.fontId = event.fontId;
this.lineStyle = event.lineStyle; this.lineStyle = event.lineStyle;
this.lineWidth = event.lineWidth; this.lineWidth = event.lineWidth;
} }
/**
* @return the red
*/
public Integer getRed() {
return red;
}
/**
* @param red
* the red to set
*/
public void setRed(Integer red) {
this.red = red;
}
/**
* @return the green
*/
public Integer getGreen() {
return green;
}
/**
* @param green
* the green to set
*/
public void setGreen(Integer green) {
this.green = green;
}
/**
* @return the blue
*/
public Integer getBlue() {
return blue;
}
/**
* @param blue
* the blue to set
*/
public void setBlue(Integer blue) {
this.blue = blue;
}
/** /**
* @return the lineWidth * @return the lineWidth
*/ */
@ -205,20 +152,19 @@ public class RenderWireframeShapeEvent extends AbstractDispatchingObjectEvent
this.alpha = alpha; this.alpha = alpha;
} }
public void setColor(RGB color) { /**
if (color != null) { * @return the color
red = color.red; */
green = color.green; public RGB getColor() {
blue = color.blue; return color;
}
} }
public RGB getColor() { /**
RGB color = null; * @param color
if (red != null && green != null && blue != null) { * the color to set
color = new RGB(red, green, blue); */
} public void setColor(RGB color) {
return color; this.color = color;
} }
/* /*
@ -232,8 +178,6 @@ public class RenderWireframeShapeEvent extends AbstractDispatchingObjectEvent
return true; return true;
if (!super.equals(obj)) if (!super.equals(obj))
return false; return false;
if (obj == null)
return false;
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
RenderWireframeShapeEvent other = (RenderWireframeShapeEvent) obj; RenderWireframeShapeEvent other = (RenderWireframeShapeEvent) obj;
@ -242,31 +186,21 @@ public class RenderWireframeShapeEvent extends AbstractDispatchingObjectEvent
return false; return false;
} else if (!alpha.equals(other.alpha)) } else if (!alpha.equals(other.alpha))
return false; return false;
if (blue == null) { if (color == null) {
if (other.blue != null) if (other.color != null)
return false; return false;
} else if (!blue.equals(other.blue)) } else if (!color.equals(other.color))
return false; return false;
if (fontId == null) { if (fontId == null) {
if (other.fontId != null) if (other.fontId != null)
return false; return false;
} else if (!fontId.equals(other.fontId)) } else if (!fontId.equals(other.fontId))
return false; return false;
if (green == null) {
if (other.green != null)
return false;
} else if (!green.equals(other.green))
return false;
if (lineStyle != other.lineStyle) if (lineStyle != other.lineStyle)
return false; return false;
if (Float.floatToIntBits(lineWidth) != Float if (Float.floatToIntBits(lineWidth) != Float
.floatToIntBits(other.lineWidth)) .floatToIntBits(other.lineWidth))
return false; return false;
if (red == null) {
if (other.red != null)
return false;
} else if (!red.equals(other.red))
return false;
return true; return true;
} }

View file

@ -88,7 +88,7 @@ public class DispatchingOffscreenRenderingExtension extends
// Send event for offscreen rendering // Send event for offscreen rendering
RenderOffscreenEvent event = RemoteGraphicsEventFactory.createEvent( RenderOffscreenEvent event = RemoteGraphicsEventFactory.createEvent(
RenderOffscreenEvent.class, image); RenderOffscreenEvent.class, image);
event.setIExtent(extent); event.setExtent(extent.clone());
image.dispatch(event); image.dispatch(event);
} }

View file

@ -58,7 +58,6 @@ import com.raytheon.viz.awipstools.common.StormTrackData;
import com.raytheon.viz.awipstools.common.stormtrack.StormTrackState.DisplayType; import com.raytheon.viz.awipstools.common.stormtrack.StormTrackState.DisplayType;
import com.raytheon.viz.awipstools.common.stormtrack.StormTrackState.Mode; import com.raytheon.viz.awipstools.common.stormtrack.StormTrackState.Mode;
import com.raytheon.viz.awipstools.common.stormtrack.StormTrackState.StormCoord; import com.raytheon.viz.awipstools.common.stormtrack.StormTrackState.StormCoord;
import com.raytheon.viz.awipstools.ui.layer.FeatureFollowingZoomLayer;
import com.raytheon.viz.core.rsc.jts.JTSCompiler; import com.raytheon.viz.core.rsc.jts.JTSCompiler;
import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Geometry;
@ -140,8 +139,6 @@ public class StormTrackDisplay implements IRenderable {
private int lastFrame = -1; private int lastFrame = -1;
private int currentFrame = -1;
private DataTime[] currentDisplayedTimes; private DataTime[] currentDisplayedTimes;
private Coordinate theAnchorPoint = null; private Coordinate theAnchorPoint = null;
@ -158,7 +155,6 @@ public class StormTrackDisplay implements IRenderable {
this.timeFormat.setTimeZone(TimeZone.getTimeZone("GMT")); this.timeFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
this.manager = manager; this.manager = manager;
trackUtil = this.manager.getTrackUtil(); trackUtil = this.manager.getTrackUtil();
this.currentFrame = this.descriptor.getFramesInfo().getFrameIndex();
} }
public void setDescriptor(MapDescriptor descriptor) { public void setDescriptor(MapDescriptor descriptor) {
@ -174,25 +170,6 @@ public class StormTrackDisplay implements IRenderable {
@Override @Override
public void paint(IGraphicsTarget target, PaintProperties paintProps) public void paint(IGraphicsTarget target, PaintProperties paintProps)
throws VizException { throws VizException {
// Determine if the Feature Following Zoom Tool is loaded
boolean FFZToolLoaded = false;
for (ResourcePair rp : this.descriptor.getResourceList()) {
if (rp != null
&& rp.getResource() instanceof FeatureFollowingZoomLayer
&& rp.getProperties().isVisible()) {
FFZToolLoaded = true;
}
}
int newIndex = this.trackUtil.getCurrentFrame(paintProps
.getFramesInfo());
if (FFZToolLoaded && this.currentFrame != newIndex) {
this.currentFrame = newIndex;
target.setNeedsRefresh(true);
return;
}
paint(target, (StormTrackProperties) paintProps); paint(target, (StormTrackProperties) paintProps);
} }

View file

@ -82,25 +82,7 @@ public class FeatureFollowingZoomLayer extends
@Override @Override
protected void paintInternal(IGraphicsTarget target, protected void paintInternal(IGraphicsTarget target,
PaintProperties paintProps) throws VizException { PaintProperties paintProps) throws VizException {
// this is done in frameChanged() now // Nothing to paint
// StormTrackData data = ToolsDataManager.getInstance()
// .getStormTrackData();
// // Depending on frame, set center of screen to point
// Coordinate[] trackPoints = data.getCoordinates();
// int index = paintProps.getFramesInfo().getFrameIndex();
// if (lastFrame != index && index >= 0 && index < trackPoints.length
// && trackPoints.length > 0 && hasVisibleResource()) {
// Coordinate coord = trackPoints[index];
// double[] end = descriptor.worldToPixel(new double[] { coord.x,
// coord.y });
// double[] start = paintProps.getView().getExtent().getCenter();
// IExtent updatedExtent = paintProps.getView().getExtent().clone();
// updatedExtent.shift(end[0] - start[0], end[1] - start[1]);
//
// target.updateExtent(updatedExtent);
// }
// lastFrame = index;
} }
private boolean hasVisibleResource() { private boolean hasVisibleResource() {
@ -135,9 +117,7 @@ public class FeatureFollowingZoomLayer extends
updatedExtent.shift(end[0] - start[0], end[1] - start[1]); updatedExtent.shift(end[0] - start[0], end[1] - start[1]);
descriptor.getRenderableDisplay().setExtent(updatedExtent); descriptor.getRenderableDisplay().setExtent(updatedExtent);
descriptor.getRenderableDisplay().getContainer() issueRefresh();
.getActiveDisplayPane().getTarget()
.updateExtent(updatedExtent);
} }
lastFrame = index; lastFrame = index;

View file

@ -82,7 +82,6 @@ import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IFont; import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.IFont.Style; import com.raytheon.uf.viz.core.drawables.IFont.Style;
import com.raytheon.uf.viz.core.drawables.IImage; import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.drawables.IShadedShape; import com.raytheon.uf.viz.core.drawables.IShadedShape;
import com.raytheon.uf.viz.core.drawables.IWireframeShape; import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.ImagingSupport; import com.raytheon.uf.viz.core.drawables.ImagingSupport;
@ -187,8 +186,6 @@ public class GLTarget implements IGLTarget {
/** The current visible extent */ /** The current visible extent */
protected IView targetView; protected IView targetView;
protected IExtent updatedExtent;
/** The width of the screen */ /** The width of the screen */
protected final float theWidth; protected final float theWidth;
@ -378,25 +375,19 @@ public class GLTarget implements IGLTarget {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see com.raytheon.viz.IGraphicsTarget#beginFrame(IRenderableDisplay, * @see com.raytheon.viz.IGraphicsTarget#beginFrame(IView, boolean)
* boolean)
*/ */
@Override @Override
public void beginFrame(IRenderableDisplay display, boolean clearBackground) { public void beginFrame(IView view, boolean clearBackground) {
if (theCanvas != null && theCanvas.isDisposed()) { if (theCanvas != null && theCanvas.isDisposed()) {
return; return;
} }
if (this.updatedExtent != null) {
display.setExtent(this.updatedExtent);
this.updatedExtent = null;
}
this.targetView = display.getView();
makeContextCurrent(); makeContextCurrent();
setView(view);
if (clearBackground) { if (clearBackground) {
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
} }
@ -405,8 +396,6 @@ public class GLTarget implements IGLTarget {
theCurrentZoom = (viewExtent.getMaxY() - viewExtent.getMinY()) theCurrentZoom = (viewExtent.getMaxY() - viewExtent.getMinY())
/ theHeight; / theHeight;
display.setup(this);
hasLoadedTextureOnLoop = false; hasLoadedTextureOnLoop = false;
synchronized (this) { synchronized (this) {
if (refreshCount > 0) { if (refreshCount > 0) {
@ -2252,11 +2241,6 @@ public class GLTarget implements IGLTarget {
gl.glPopAttrib(); gl.glPopAttrib();
} }
@Override
public void updateExtent(IExtent updatedExtent) {
this.updatedExtent = updatedExtent;
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *

View file

@ -5,7 +5,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Rectangle;
import com.raytheon.uf.viz.core.IDisplayPane; import com.raytheon.uf.viz.core.IDisplayPane;
@ -32,7 +31,7 @@ public abstract class AbstractScreenCaptureAction extends AbstractHandler {
int startIndex = 0; int startIndex = 0;
int endIndex = editor.getActiveDisplayPane().getDescriptor() int endIndex = editor.getActiveDisplayPane().getDescriptor()
.getFramesInfo().getFrameCount(); .getFramesInfo().getFrameCount();
if(endIndex == 0){ if (endIndex == 0) {
endIndex = 1; endIndex = 1;
} }
return captureFrames(editor, startIndex, endIndex); return captureFrames(editor, startIndex, endIndex);
@ -64,11 +63,11 @@ public abstract class AbstractScreenCaptureAction extends AbstractHandler {
private void setFrameIndex(IDescriptor desc, int index) { private void setFrameIndex(IDescriptor desc, int index) {
FramesInfo fi = desc.getFramesInfo(); FramesInfo fi = desc.getFramesInfo();
if(fi.getFrameTimes() == null || fi.getFrameCount() <= 1){ if (fi.getFrameTimes() == null || fi.getFrameCount() <= 1) {
return; return;
} }
index = index % fi.getFrameCount(); index = index % fi.getFrameCount();
if(index < 0){ if (index < 0) {
index += fi.getFrameCount(); index += fi.getFrameCount();
} }
fi = new FramesInfo(fi.getFrameTimes(), index, fi.getTimeMap()); fi = new FramesInfo(fi.getFrameTimes(), index, fi.getTimeMap());
@ -92,7 +91,7 @@ public abstract class AbstractScreenCaptureAction extends AbstractHandler {
// paint in a loop until any async tasks are done // paint in a loop until any async tasks are done
while (target.isNeedsRefresh()) { while (target.isNeedsRefresh()) {
target.beginFrame(display, true); target.beginFrame(display.getView(), true);
display.paint(target, paintProps); display.paint(target, paintProps);
target.endFrame(); target.endFrame();
} }

View file

@ -499,7 +499,7 @@ public class VizDisplayPane implements IDisplayPane {
} }
synchronized (this) { synchronized (this) {
this.target.beginFrame(renderableDisplay, true); this.target.beginFrame(renderableDisplay.getView(), true);
try { try {
PaintProperties paintProps = new PaintProperties(1.0f, PaintProperties paintProps = new PaintProperties(1.0f,

View file

@ -2,6 +2,6 @@
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry exported="true" kind="lib" path="cglib-nodep-2.1_3.jar" sourcepath="net.sf.cglibsrc.zip"/> <classpathentry exported="true" kind="lib" path="cglib-nodep-2.1_3.jar" sourcepath="cglib-src-2.1_3.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

Binary file not shown.

View file

@ -26,6 +26,7 @@ import java.io.OutputStream;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.nio.Buffer;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
import java.sql.Timestamp; import java.sql.Timestamp;
@ -49,6 +50,7 @@ import org.geotools.coverage.grid.GridGeometry2D;
import com.raytheon.uf.common.serialization.BuiltInTypeSupport.CalendarSerializer; import com.raytheon.uf.common.serialization.BuiltInTypeSupport.CalendarSerializer;
import com.raytheon.uf.common.serialization.BuiltInTypeSupport.DateSerializer; import com.raytheon.uf.common.serialization.BuiltInTypeSupport.DateSerializer;
import com.raytheon.uf.common.serialization.BuiltInTypeSupport.TimestampSerializer; import com.raytheon.uf.common.serialization.BuiltInTypeSupport.TimestampSerializer;
import com.raytheon.uf.common.serialization.adapters.BufferAdapter;
import com.raytheon.uf.common.serialization.adapters.ByteBufferAdapter; import com.raytheon.uf.common.serialization.adapters.ByteBufferAdapter;
import com.raytheon.uf.common.serialization.adapters.CoordAdapter; import com.raytheon.uf.common.serialization.adapters.CoordAdapter;
import com.raytheon.uf.common.serialization.adapters.EnumSetAdapter; import com.raytheon.uf.common.serialization.adapters.EnumSetAdapter;
@ -68,9 +70,6 @@ import com.raytheon.uf.common.util.ByteArrayOutputStreamPool;
import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Envelope; import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.MultiPolygon;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.Polygon;
/** /**
* Dynamic Serialization Manager provides a serialization capability that runs * Dynamic Serialization Manager provides a serialization capability that runs
@ -108,69 +107,27 @@ public class DynamicSerializationManager {
private static final SerializationMetadata NO_METADATA = new SerializationMetadata(); private static final SerializationMetadata NO_METADATA = new SerializationMetadata();
static { static {
SerializationMetadata md = new SerializationMetadata(); // TODO: Can the registration of adapters that require dependencies be
md.serializationFactory = new CalendarSerializer(); // moved to a separate plugin somehow?
md.adapterStructName = GregorianCalendar.class.getName(); registerAdapter(GregorianCalendar.class, new CalendarSerializer());
serializedAttributes.put(GregorianCalendar.class.getName(), md); registerAdapter(Date.class, new DateSerializer());
md = new SerializationMetadata(); registerAdapter(Timestamp.class, new TimestampSerializer());
md.serializationFactory = new DateSerializer(); registerAdapter(java.sql.Date.class,
md.adapterStructName = Date.class.getName(); new BuiltInTypeSupport.SqlDateSerializer());
serializedAttributes.put(Date.class.getName(), md); registerAdapter(java.awt.Point.class, new PointAdapter());
md = new SerializationMetadata(); registerAdapter(Coordinate.class, new CoordAdapter());
md.serializationFactory = new TimestampSerializer(); registerAdapter(BigDecimal.class,
md.adapterStructName = Timestamp.class.getName(); new BuiltInTypeSupport.BigDecimalSerializer());
serializedAttributes.put(Timestamp.class.getName(), md); registerAdapter(Geometry.class, new GeometryTypeAdapter());
md = new SerializationMetadata(); registerAdapter(Envelope.class, new JTSEnvelopeAdapter());
md.serializationFactory = new BuiltInTypeSupport.SqlDateSerializer(); registerAdapter(GridGeometry2D.class, new GridGeometry2DAdapter());
md.adapterStructName = java.sql.Date.class.getName(); registerAdapter(GeneralGridGeometry.class, new GridGeometryAdapter());
serializedAttributes.put(java.sql.Date.class.getName(), md); registerAdapter(EnumSet.class, new EnumSetAdapter());
md = new SerializationMetadata(); registerAdapter(StackTraceElement.class, new StackTraceElementAdapter());
md.serializationFactory = new PointAdapter(); // These two are OBE by BufferAdapter and should be deleted sometime
md.adapterStructName = java.awt.Point.class.getName(); registerAdapter(ByteBuffer.class, new ByteBufferAdapter());
serializedAttributes.put(java.awt.Point.class.getName(), md); registerAdapter(FloatBuffer.class, new FloatBufferAdapter());
md = new SerializationMetadata(); registerAdapter(Buffer.class, new BufferAdapter());
md.serializationFactory = new CoordAdapter();
md.adapterStructName = Coordinate.class.getName();
serializedAttributes.put(Coordinate.class.getName(), md);
md = new SerializationMetadata();
md.serializationFactory = new BuiltInTypeSupport.BigDecimalSerializer();
md.adapterStructName = BigDecimal.class.getName();
serializedAttributes.put(BigDecimal.class.getName(), md);
md = new SerializationMetadata();
md.serializationFactory = new GeometryTypeAdapter();
md.adapterStructName = Geometry.class.getName();
serializedAttributes.put(Polygon.class.getName(), md);
serializedAttributes.put(MultiPolygon.class.getName(), md);
serializedAttributes.put(Point.class.getName(), md);
serializedAttributes.put(Geometry.class.getName(), md);
md = new SerializationMetadata();
md.serializationFactory = new JTSEnvelopeAdapter();
md.adapterStructName = Envelope.class.getName();
serializedAttributes.put(Envelope.class.getName(), md);
md = new SerializationMetadata();
md.serializationFactory = new GridGeometry2DAdapter();
md.adapterStructName = GridGeometry2D.class.getName();
serializedAttributes.put(GridGeometry2D.class.getName(), md);
md = new SerializationMetadata();
md.serializationFactory = new GridGeometryAdapter();
md.adapterStructName = GeneralGridGeometry.class.getName();
serializedAttributes.put(GeneralGridGeometry.class.getName(), md);
md = new SerializationMetadata();
md.serializationFactory = new EnumSetAdapter();
md.adapterStructName = EnumSet.class.getName();
serializedAttributes.put(EnumSet.class.getName(), md);
md = new SerializationMetadata();
md.serializationFactory = new StackTraceElementAdapter();
md.adapterStructName = StackTraceElement.class.getName();
serializedAttributes.put(StackTraceElement.class.getName(), md);
md = new SerializationMetadata();
md.serializationFactory = new FloatBufferAdapter();
md.adapterStructName = FloatBuffer.class.getName();
serializedAttributes.put(FloatBuffer.class.getName(), md);
md = new SerializationMetadata();
md.serializationFactory = new ByteBufferAdapter();
md.adapterStructName = ByteBuffer.class.getName();
serializedAttributes.put(ByteBuffer.class.getName(), md);
} }
public enum EnclosureType { public enum EnclosureType {
@ -297,6 +254,19 @@ public class DynamicSerializationManager {
return ((ThriftSerializationContext) ctx).deserializeMessage(); return ((ThriftSerializationContext) ctx).deserializeMessage();
} }
public static <T> void registerAdapter(Class<? extends T> clazz,
ISerializationTypeAdapter<T> adapter) {
SerializationMetadata md = new SerializationMetadata();
md.serializationFactory = adapter;
md.adapterStructName = clazz.getName();
if (serializedAttributes.containsKey(md.adapterStructName)) {
throw new RuntimeException(
"Could not create serialization metadata for class: "
+ clazz + ", metadata already exists");
}
serializedAttributes.put(md.adapterStructName, md);
}
/** /**
* Inspect a class and return the metadata for the object * Inspect a class and return the metadata for the object
* *
@ -308,7 +278,6 @@ public class DynamicSerializationManager {
* the class * the class
* @return the metadata * @return the metadata
*/ */
@SuppressWarnings("unchecked")
public static SerializationMetadata inspect(Class<?> c) { public static SerializationMetadata inspect(Class<?> c) {
// Check for base types // Check for base types
@ -327,9 +296,9 @@ public class DynamicSerializationManager {
// Check to see if there is an adapter // Check to see if there is an adapter
if (serializeAdapterTag != null) { if (serializeAdapterTag != null) {
Class factoryTag = (serializeAdapterTag).factory(); Class<?> factoryTag = (serializeAdapterTag).factory();
try { try {
attribs.serializationFactory = (ISerializationTypeAdapter) factoryTag attribs.serializationFactory = (ISerializationTypeAdapter<?>) factoryTag
.newInstance(); .newInstance();
attribs.adapterStructName = c.getName(); attribs.adapterStructName = c.getName();
} catch (Exception e) { } catch (Exception e) {

View file

@ -98,6 +98,7 @@ public class SerializationCache {
generator = new BeanMap.Generator(); generator = new BeanMap.Generator();
} }
generator.setClassLoader(SerializationCache.class.getClassLoader());
generator.setBean(obj); generator.setBean(obj);
bm = generator.create(); bm = generator.create();
generator.setBean(null); generator.setBean(null);
@ -121,7 +122,9 @@ public class SerializationCache {
synchronized (classCache) { synchronized (classCache) {
FastClass fc = classCache.get(name); FastClass fc = classCache.get(name);
if (fc == null) { if (fc == null) {
fc = FastClass.create(Class.forName(name)); fc = FastClass.create(
SerializationCache.class.getClassLoader(),
Class.forName(name));
classCache.put(name, fc); classCache.put(name, fc);
} }
return fc; return fc;

View file

@ -0,0 +1,152 @@
/**
* 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.common.serialization.adapters;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.LongBuffer;
import java.nio.ShortBuffer;
import com.raytheon.uf.common.serialization.IDeserializationContext;
import com.raytheon.uf.common.serialization.ISerializationContext;
import com.raytheon.uf.common.serialization.ISerializationTypeAdapter;
import com.raytheon.uf.common.serialization.SerializationException;
/**
* Serialization adapter that handles java.nio.Buffer objects. Buffers are not
* thread safe and therefore should only be serialized if no other threads are
* using them
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 3, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class BufferAdapter implements ISerializationTypeAdapter<Buffer> {
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.serialization.ISerializationTypeAdapter#serialize
* (com.raytheon.uf.common.serialization.ISerializationContext,
* java.lang.Object)
*/
@Override
public void serialize(ISerializationContext serializer, Buffer buffer)
throws SerializationException {
serializer.writeBool(buffer.isDirect());
buffer.position(0);
ByteBuffer bb = null;
byte[] bytes = null;
if (buffer instanceof ByteBuffer) {
serializer.writeByte((byte) 0);
bytes = new byte[buffer.capacity()];
bb = ByteBuffer.wrap(bytes);
bb.put((ByteBuffer) buffer);
} else if (buffer instanceof ShortBuffer) {
serializer.writeByte((byte) 1);
bytes = new byte[2 * buffer.capacity()];
bb = ByteBuffer.wrap(bytes);
bb.asShortBuffer().put((ShortBuffer) buffer);
} else if (buffer instanceof FloatBuffer) {
serializer.writeByte((byte) 2);
bytes = new byte[4 * buffer.capacity()];
bb = ByteBuffer.wrap(bytes);
bb.asFloatBuffer().put((FloatBuffer) buffer);
} else if (buffer instanceof IntBuffer) {
serializer.writeByte((byte) 3);
bytes = new byte[4 * buffer.capacity()];
bb = ByteBuffer.wrap(bytes);
bb.asIntBuffer().put((IntBuffer) buffer);
} else if (buffer instanceof DoubleBuffer) {
serializer.writeByte((byte) 4);
bytes = new byte[8 * buffer.capacity()];
bb = ByteBuffer.wrap(bytes);
bb.asDoubleBuffer().put((DoubleBuffer) buffer);
} else if (buffer instanceof LongBuffer) {
serializer.writeByte((byte) 5);
bytes = new byte[8 * buffer.capacity()];
bb = ByteBuffer.wrap(bytes);
bb.asLongBuffer().put((LongBuffer) buffer);
} else {
throw new SerializationException("Could not handle buffer type: "
+ buffer.getClass());
}
serializer.writeBinary(bb.array());
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.serialization.ISerializationTypeAdapter#deserialize
* (com.raytheon.uf.common.serialization.IDeserializationContext)
*/
@Override
public Buffer deserialize(IDeserializationContext deserializer)
throws SerializationException {
boolean direct = deserializer.readBool();
byte type = deserializer.readByte();
byte[] bytes = deserializer.readBinary();
ByteBuffer buffer = direct ? ByteBuffer.allocateDirect(bytes.length)
: ByteBuffer.allocate(bytes.length);
buffer.put(bytes);
buffer.rewind();
Buffer dataBuffer = null;
switch (type) {
case 0:
dataBuffer = buffer;
break;
case 1:
dataBuffer = buffer.asShortBuffer();
break;
case 2:
dataBuffer = buffer.asFloatBuffer();
break;
case 3:
dataBuffer = buffer.asIntBuffer();
break;
case 4:
dataBuffer = buffer.asDoubleBuffer();
break;
case 5:
dataBuffer = buffer.asLongBuffer();
break;
default:
throw new SerializationException("Unrecognized buffer type: "
+ type);
}
return dataBuffer;
}
}