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
paint = True
while paint:
self.target.beginFrame(self.display, True)
self.target.beginFrame(self.display.getView(), True)
if backgroundColor is not None:
self.target.setBackgroundColor(backgroundColor)
self.display.paint(self.target, props)

View file

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

View file

@ -78,7 +78,7 @@ public class DispatchingRadarMosaicExtension extends
if (imageExtent != null) {
UpdateMosaicExtent extentUpdate = RemoteGraphicsEventFactory
.createEvent(UpdateMosaicExtent.class, image);
extentUpdate.setIExtent(imageExtent);
extentUpdate.setExtent(imageExtent.clone());
creation.setExtent(extentUpdate);
}
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.DynamicSerializeElement;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.PixelExtent;
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 {
@DynamicSerializeElement
private double[] extent;
private IExtent extent;
/**
* @return the extent
*/
public double[] getExtent() {
public IExtent getExtent() {
return extent;
}
@ -58,22 +57,8 @@ public class UpdateMosaicExtent extends AbstractDispatchingObjectEvent {
* @param extent
* the extent to set
*/
public void setExtent(double[] extent) {
public void setExtent(IExtent 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;
ColorMapParameters parameters = null;
if (event.getExtent() != null) {
imageExtent = event.getExtent().getIExtent();
imageExtent = event.getExtent().getExtent();
}
if (event.getColorMapParameters() != null) {
parameters = event.getColorMapParameters().getColorMapParameters();
@ -114,7 +114,7 @@ public class RadarGraphicsExtRenderingHandler extends
IMosaicImage image = dataManager.getRenderableObject(
event.getObjectId(), IMosaicImage.class);
if (image != null) {
image.setImageExtent(event.getIExtent());
image.setImageExtent(event.getExtent());
}
}
}

View file

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

View file

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

View file

@ -137,6 +137,6 @@ public class GeneralRenderingHandler extends CollaborationRenderingHandler {
@Subscribe
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.contrast = event.getContrast();
cmap.interpolate = event.isInterpolate();
cmap.extent = event.getIExtent();
cmap.extent = event.getExtent();
try {
target.drawColorRamp(cmap);
} catch (VizException e) {

View file

@ -96,7 +96,7 @@ public class OffscreenRenderingHandler extends CollaborationRenderingHandler {
try {
if (event.getExtent() != null) {
target.getExtension(IOffscreenRenderingExtension.class)
.renderOffscreen(offscreenImage, event.getIExtent());
.renderOffscreen(offscreenImage, event.getExtent());
} else {
target.getExtension(IOffscreenRenderingExtension.class)
.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.IFont;
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.IWireframeShape;
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
* complete.
*
* @param display
* the display area that the frame covers
* @param view
* viewable area of the frame
* @param isClearBackground
* whether background should be cleared prior to drawing
*/
public abstract void beginFrame(IRenderableDisplay display,
boolean isClearBackground);
public abstract void beginFrame(IView view, boolean isClearBackground);
/**
* End a frame
@ -775,14 +773,6 @@ public interface IGraphicsTarget extends IImagingExtension {
*/
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(
* 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-Vendor: RAYTHEON
Eclipse-RegisterBuddy: com.raytheon.uf.viz.core
Eclipse-BuddyPolicy: dependent
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
com.raytheon.uf.viz.core;bundle-version="1.12.1174",

View file

@ -1,10 +1,18 @@
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.osgi.framework.BundleContext;
import com.raytheon.uf.common.serialization.DynamicSerializationManager;
import com.raytheon.uf.common.status.IUFStatusHandler;
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
@ -36,6 +44,12 @@ public class Activator extends AbstractUIPlugin {
public void start(BundleContext context) throws Exception {
super.start(context);
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.Style;
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.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.ImagingSupport;
@ -110,6 +109,8 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
private IFont defaultFont;
private RGB backgroundColor = new RGB(0, 0, 0);
private GraphicsExtensionManager extensionManager;
public DispatchGraphicsTarget(IGraphicsTarget target, Dispatcher dispatcher) {
@ -291,6 +292,8 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
for (int i = 0; i < parameters.length; ++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 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)
*/
public void beginFrame(IRenderableDisplay display, boolean isClearBackground) {
wrappedObject.beginFrame(display, isClearBackground);
public void beginFrame(IView view, boolean isClearBackground) {
wrappedObject.beginFrame(view, isClearBackground);
BeginFrameEvent beginFrame = RemoteGraphicsEventFactory.createEvent(
BeginFrameEvent.class, this);
beginFrame.setIExtent(display.getExtent());
beginFrame.setColor(display.getBackgroundColor());
beginFrame.setExtent(view.getExtent().clone());
beginFrame.setColor(backgroundColor);
dispatch(beginFrame);
}
@ -841,7 +844,7 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
wrappedObject.setupClippingPlane(extent);
SetupClippingPane event = RemoteGraphicsEventFactory.createEvent(
SetupClippingPane.class, this);
event.setIExtent(extent);
event.setExtent(extent);
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)
*/
public void setBackgroundColor(RGB backgroundColor) {
this.backgroundColor = backgroundColor;
wrappedObject.setBackgroundColor(backgroundColor);
}
@ -902,7 +906,7 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
event.setBrightness(colorMap.brightness);
event.setContrast(colorMap.contrast);
event.setInterpolate(colorMap.interpolate);
event.setIExtent(colorMap.extent);
event.setExtent(colorMap.extent);
dispatch(event);
}
@ -1017,14 +1021,6 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
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
* @throws VizException
@ -1072,11 +1068,14 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment, Double rotation)
throws VizException {
if (font instanceof DispatchingFont) {
font = ((DispatchingFont) font).getWrappedObject();
}
wrappedObject.drawString(font, text, x, y, z, textStyle, color,
horizontalAlignment, verticalAlignment, rotation);
DrawableString string = new DrawableString(text, color);
string.setCoordinates(x, y, z);
string.font = font;
string.textStyle = textStyle;
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,
HorizontalAlignment horizontalAlignment, Double rotation)
throws VizException {
if (font instanceof DispatchingFont) {
font = ((DispatchingFont) font).getWrappedObject();
}
wrappedObject.drawString(font, text, x, y, z, textStyle, color,
horizontalAlignment, rotation);
DrawableString string = new DrawableString(text, color);
string.setCoordinates(x, y, z);
string.font = font;
string.textStyle = textStyle;
string.horizontalAlignment = horizontalAlignment;
string.rotation = rotation;
drawStrings(string);
}
/**
@ -1132,11 +1133,13 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
double z, TextStyle textStyle, RGB[] colors,
HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment) throws VizException {
if (font instanceof DispatchingFont) {
font = ((DispatchingFont) font).getWrappedObject();
}
wrappedObject.drawStrings(font, text, x, y, z, textStyle, colors,
horizontalAlignment, verticalAlignment);
DrawableString string = new DrawableString(text, colors);
string.setCoordinates(x, y, z);
string.font = font;
string.textStyle = textStyle;
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,
* java.lang.Double, float, double)
*/
public void drawString(IFont font, String string, double xPos, double yPos,
double zPos, TextStyle textStyle, RGB color,
public void drawString(IFont font, String text, double x, double y,
double z, TextStyle textStyle, RGB color,
HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment, Double rotation, float alpha,
double magnification) throws VizException {
if (font instanceof DispatchingFont) {
font = ((DispatchingFont) font).getWrappedObject();
}
wrappedObject.drawString(font, string, xPos, yPos, zPos, textStyle,
color, horizontalAlignment, verticalAlignment, rotation, alpha,
magnification);
DrawableString string = new DrawableString(text, color);
string.setCoordinates(x, y, z);
string.font = font;
string.textStyle = textStyle;
string.horizontalAlignment = horizontalAlignment;
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;
import java.util.Arrays;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
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.IRenderEvent;
@ -48,7 +45,7 @@ import com.raytheon.uf.viz.remote.graphics.events.rendering.IRenderEvent;
public class SetupClippingPane extends AbstractRemoteGraphicsRenderEvent {
@DynamicSerializeElement
private double[] extent;
private IExtent extent;
/*
* (non-Javadoc)
@ -62,7 +59,7 @@ public class SetupClippingPane extends AbstractRemoteGraphicsRenderEvent {
public IRenderEvent createDiffObject(IRenderEvent event) {
SetupClippingPane diffEvent = (SetupClippingPane) event;
SetupClippingPane diffObject = new SetupClippingPane();
if (Arrays.equals(extent, diffEvent.extent) == false) {
if (extent.equals(diffEvent.extent) == false) {
diffObject.extent = diffEvent.extent;
}
return diffObject;
@ -86,7 +83,7 @@ public class SetupClippingPane extends AbstractRemoteGraphicsRenderEvent {
/**
* @return the extent
*/
public double[] getExtent() {
public IExtent getExtent() {
return extent;
}
@ -94,24 +91,10 @@ public class SetupClippingPane extends AbstractRemoteGraphicsRenderEvent {
* @param extent
* the extent to set
*/
public void setExtent(double[] extent) {
public void setExtent(IExtent 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)
*
@ -126,7 +109,10 @@ public class SetupClippingPane extends AbstractRemoteGraphicsRenderEvent {
if (getClass() != obj.getClass())
return false;
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 true;
}

View file

@ -19,13 +19,14 @@
**/
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.SerializationUtil;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
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.remote.graphics.Activator;
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback.ColorMapDataType;
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 {
@DynamicSerializeElement
private byte[] serializedColorMapData;
private int[] dimensions;
/**
* @return the serializedColorMapData
*/
public byte[] getSerializedColorMapData() {
return serializedColorMapData;
}
@DynamicSerializeElement
private ColorMapDataType dataType;
/**
* @param serializedColorMapData
* the serializedColorMapData to set
*/
public void setSerializedColorMapData(byte[] serializedColorMapData) {
this.serializedColorMapData = serializedColorMapData;
}
@DynamicSerializeElement
private Buffer buffer;
/**
* @return the colorMapData
*/
public ColorMapData getColorMapData() {
if (serializedColorMapData != null) {
try {
ColorMapDataWrapper wrapper = (ColorMapDataWrapper) SerializationUtil
.transformFromThrift(serializedColorMapData);
return wrapper.getColorMapData();
} catch (SerializationException e) {
Activator.statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
}
return null;
return new ColorMapData(buffer, dimensions, dataType);
}
/**
@ -88,15 +70,65 @@ public class ColorMapDataEvent extends AbstractDispatchingObjectEvent {
* the colorMapData to set
*/
public void setColorMapData(ColorMapData colorMapData) {
ColorMapDataWrapper wrapper = new ColorMapDataWrapper();
wrapper.setColorMapData(colorMapData);
// Copy data via serialization
this.dimensions = colorMapData.getDimensions();
this.dataType = colorMapData.getDataType();
try {
serializedColorMapData = SerializationUtil
.transformToThrift(wrapper);
// Copy the buffer since it is the same buffer that will be used for
// 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) {
Activator.statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
throw new RuntimeException("Error copying data Buffer: "
+ 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;
import java.util.Arrays;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
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.IRenderEvent;
@ -63,7 +60,7 @@ public class DrawColorRampEvent extends AbstractRemoteGraphicsRenderEvent {
private boolean interpolate = true;
@DynamicSerializeElement
private double[] extent;
private IExtent extent;
/*
* (non-Javadoc)
@ -102,7 +99,7 @@ public class DrawColorRampEvent extends AbstractRemoteGraphicsRenderEvent {
diffObject.brightness = diffEvent.brightness;
diffObject.contrast = diffEvent.contrast;
diffObject.interpolate = diffEvent.interpolate;
if (Arrays.equals(extent, diffEvent.extent) == false) {
if (extent.equals(diffEvent.extent) == false) {
diffObject.extent = diffEvent.extent;
}
return diffObject;
@ -186,7 +183,7 @@ public class DrawColorRampEvent extends AbstractRemoteGraphicsRenderEvent {
/**
* @return the extent
*/
public double[] getExtent() {
public IExtent getExtent() {
return extent;
}
@ -194,24 +191,10 @@ public class DrawColorRampEvent extends AbstractRemoteGraphicsRenderEvent {
* @param extent
* the extent to set
*/
public void setExtent(double[] extent) {
public void setExtent(IExtent 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)
*
@ -236,7 +219,10 @@ public class DrawColorRampEvent extends AbstractRemoteGraphicsRenderEvent {
if (Float.floatToIntBits(contrast) != Float
.floatToIntBits(other.contrast))
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;
if (interpolate != other.interpolate)
return false;

View file

@ -46,28 +46,13 @@ import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent
public class RenderedImageEvent extends AbstractDispatchingObjectEvent {
@DynamicSerializeElement
private RenderedImageWrapper wrapper = new RenderedImageWrapper();
/**
* @return the wrapper
*/
public RenderedImageWrapper getWrapper() {
return wrapper;
}
/**
* @param wrapper
* the wrapper to set
*/
public void setWrapper(RenderedImageWrapper wrapper) {
this.wrapper = wrapper;
}
private RenderedImage renderedImage;
/**
* @return the renderedImage
*/
public RenderedImage getRenderedImage() {
return wrapper.getWrappedImage();
return renderedImage;
}
/**
@ -75,7 +60,7 @@ public class RenderedImageEvent extends AbstractDispatchingObjectEvent {
* the renderedImage to set
*/
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 {
@DynamicSerializeElement
private int red;
@DynamicSerializeElement
private int green;
@DynamicSerializeElement
private int blue;
private RGB color;
/**
* @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() {
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;
import java.util.Arrays;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
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.rendering.IRenderEvent;
@ -50,7 +47,7 @@ public class RenderOffscreenEvent extends AbstractDispatchingObjectEvent
implements IRenderEvent {
@DynamicSerializeElement
private double[] extent;
private IExtent extent;
/*
* (non-Javadoc)
@ -81,7 +78,7 @@ public class RenderOffscreenEvent extends AbstractDispatchingObjectEvent
/**
* @return the extent
*/
public double[] getExtent() {
public IExtent getExtent() {
return extent;
}
@ -89,31 +86,10 @@ public class RenderOffscreenEvent extends AbstractDispatchingObjectEvent
* @param extent
* the extent to set
*/
public void setExtent(double[] extent) {
public void setExtent(IExtent 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)
*
@ -128,7 +104,10 @@ public class RenderOffscreenEvent extends AbstractDispatchingObjectEvent
if (getClass() != obj.getClass())
return false;
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 true;
}

View file

@ -121,13 +121,7 @@ public class DrawPointsEvent extends AbstractRemoteGraphicsRenderEvent {
private float magnification;
@DynamicSerializeElement
private int red;
@DynamicSerializeElement
private int green;
@DynamicSerializeElement
private int blue;
private RGB color;
/*
* (non-Javadoc)
@ -141,9 +135,7 @@ public class DrawPointsEvent extends AbstractRemoteGraphicsRenderEvent {
public IRenderEvent createDiffObject(IRenderEvent diffEvent) {
DrawPointsEvent event = (DrawPointsEvent) diffEvent;
DrawPointsEvent diffObject = new DrawPointsEvent();
diffObject.red = event.red;
diffObject.green = event.green;
diffObject.blue = event.blue;
diffObject.color = color;
diffObject.magnification = event.magnification;
Set<Point> additions = new HashSet<Point>(event.points);
@ -171,9 +163,7 @@ public class DrawPointsEvent extends AbstractRemoteGraphicsRenderEvent {
@Override
public void applyDiffObject(IRenderEvent diffEvent) {
DrawPointsEvent event = (DrawPointsEvent) diffEvent;
red = event.red;
green = event.green;
blue = event.blue;
color = event.color;
magnification = event.magnification;
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() {
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())
return false;
DrawPointsEvent other = (DrawPointsEvent) obj;
if (blue != other.blue)
if (color == null) {
if (other.color != null)
return false;
if (green != other.green)
} else if (!color.equals(other.color))
return false;
if (Float.floatToIntBits(magnification) != Float
.floatToIntBits(other.magnification))
@ -351,8 +300,6 @@ public class DrawPointsEvent extends AbstractRemoteGraphicsRenderEvent {
return false;
} else if (!points.equals(other.points))
return false;
if (red != other.red)
return false;
if (removals == null) {
if (other.removals != null)
return false;

View file

@ -19,14 +19,11 @@
**/
package com.raytheon.uf.viz.remote.graphics.events.rendering;
import java.util.Arrays;
import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.PixelExtent;
/**
* 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 {
@DynamicSerializeElement
private double[] extent;
private IExtent extent;
@DynamicSerializeElement
private int[] rgb;
/**
* @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;
}
private RGB color;
/*
* (non-Javadoc)
@ -123,11 +63,11 @@ public class BeginFrameEvent extends AbstractRemoteGraphicsRenderEvent {
public IRenderEvent createDiffObject(IRenderEvent event) {
BeginFrameEvent diffEvent = (BeginFrameEvent) event;
BeginFrameEvent diffObject = new BeginFrameEvent();
if (Arrays.equals(extent, diffEvent.extent) == false) {
if (extent.equals(diffEvent.extent) == false) {
diffObject.extent = diffEvent.extent;
}
if (Arrays.equals(rgb, diffEvent.rgb) == false) {
diffObject.rgb = diffEvent.rgb;
if (color.equals(diffEvent.color) == false) {
diffObject.color = diffEvent.color;
}
return diffObject;
}
@ -145,11 +85,41 @@ public class BeginFrameEvent extends AbstractRemoteGraphicsRenderEvent {
if (event.extent != null) {
this.extent = event.extent;
}
if (event.rgb != null) {
rgb = event.rgb;
if (event.color != null) {
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)
*
@ -164,9 +134,15 @@ public class BeginFrameEvent extends AbstractRemoteGraphicsRenderEvent {
if (getClass() != obj.getClass())
return false;
BeginFrameEvent other = (BeginFrameEvent) obj;
if (!Arrays.equals(extent, other.extent))
if (color == null) {
if (other.color != null)
return false;
if (!Arrays.equals(rgb, other.rgb))
} else if (!color.equals(other.color))
return false;
if (extent == null) {
if (other.extent != null)
return false;
} else if (!extent.equals(other.extent))
return false;
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 {
@DynamicSerializeElement
private Integer red;
@DynamicSerializeElement
private Integer green;
@DynamicSerializeElement
private Integer blue;
private RGB color;
@DynamicSerializeElement
private float lineWidth;
@ -92,59 +86,12 @@ public class RenderWireframeShapeEvent extends AbstractDispatchingObjectEvent
RenderWireframeShapeEvent event = (RenderWireframeShapeEvent) diffEvent;
this.setObjectId(event.getObjectId());
this.alpha = event.alpha;
this.red = event.red;
this.green = event.green;
this.blue = event.blue;
this.color = event.color;
this.fontId = event.fontId;
this.lineStyle = event.lineStyle;
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
*/
@ -205,20 +152,19 @@ public class RenderWireframeShapeEvent extends AbstractDispatchingObjectEvent
this.alpha = alpha;
}
public void setColor(RGB color) {
if (color != null) {
red = color.red;
green = color.green;
blue = color.blue;
}
/**
* @return the color
*/
public RGB getColor() {
return color;
}
public RGB getColor() {
RGB color = null;
if (red != null && green != null && blue != null) {
color = new RGB(red, green, blue);
}
return color;
/**
* @param color
* the color to set
*/
public void setColor(RGB color) {
this.color = color;
}
/*
@ -232,8 +178,6 @@ public class RenderWireframeShapeEvent extends AbstractDispatchingObjectEvent
return true;
if (!super.equals(obj))
return false;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
RenderWireframeShapeEvent other = (RenderWireframeShapeEvent) obj;
@ -242,31 +186,21 @@ public class RenderWireframeShapeEvent extends AbstractDispatchingObjectEvent
return false;
} else if (!alpha.equals(other.alpha))
return false;
if (blue == null) {
if (other.blue != null)
if (color == null) {
if (other.color != null)
return false;
} else if (!blue.equals(other.blue))
} else if (!color.equals(other.color))
return false;
if (fontId == null) {
if (other.fontId != null)
return false;
} else if (!fontId.equals(other.fontId))
return false;
if (green == null) {
if (other.green != null)
return false;
} else if (!green.equals(other.green))
return false;
if (lineStyle != other.lineStyle)
return false;
if (Float.floatToIntBits(lineWidth) != Float
.floatToIntBits(other.lineWidth))
return false;
if (red == null) {
if (other.red != null)
return false;
} else if (!red.equals(other.red))
return false;
return true;
}

View file

@ -88,7 +88,7 @@ public class DispatchingOffscreenRenderingExtension extends
// Send event for offscreen rendering
RenderOffscreenEvent event = RemoteGraphicsEventFactory.createEvent(
RenderOffscreenEvent.class, image);
event.setIExtent(extent);
event.setExtent(extent.clone());
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.Mode;
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.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
@ -140,8 +139,6 @@ public class StormTrackDisplay implements IRenderable {
private int lastFrame = -1;
private int currentFrame = -1;
private DataTime[] currentDisplayedTimes;
private Coordinate theAnchorPoint = null;
@ -158,7 +155,6 @@ public class StormTrackDisplay implements IRenderable {
this.timeFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
this.manager = manager;
trackUtil = this.manager.getTrackUtil();
this.currentFrame = this.descriptor.getFramesInfo().getFrameIndex();
}
public void setDescriptor(MapDescriptor descriptor) {
@ -174,25 +170,6 @@ public class StormTrackDisplay implements IRenderable {
@Override
public void paint(IGraphicsTarget target, PaintProperties paintProps)
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);
}

View file

@ -82,25 +82,7 @@ public class FeatureFollowingZoomLayer extends
@Override
protected void paintInternal(IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
// this is done in frameChanged() now
// 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;
// Nothing to paint
}
private boolean hasVisibleResource() {
@ -135,9 +117,7 @@ public class FeatureFollowingZoomLayer extends
updatedExtent.shift(end[0] - start[0], end[1] - start[1]);
descriptor.getRenderableDisplay().setExtent(updatedExtent);
descriptor.getRenderableDisplay().getContainer()
.getActiveDisplayPane().getTarget()
.updateExtent(updatedExtent);
issueRefresh();
}
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.Style;
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.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.ImagingSupport;
@ -187,8 +186,6 @@ public class GLTarget implements IGLTarget {
/** The current visible extent */
protected IView targetView;
protected IExtent updatedExtent;
/** The width of the screen */
protected final float theWidth;
@ -378,25 +375,19 @@ public class GLTarget implements IGLTarget {
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.IGraphicsTarget#beginFrame(IRenderableDisplay,
* boolean)
* @see com.raytheon.viz.IGraphicsTarget#beginFrame(IView, boolean)
*/
@Override
public void beginFrame(IRenderableDisplay display, boolean clearBackground) {
public void beginFrame(IView view, boolean clearBackground) {
if (theCanvas != null && theCanvas.isDisposed()) {
return;
}
if (this.updatedExtent != null) {
display.setExtent(this.updatedExtent);
this.updatedExtent = null;
}
this.targetView = display.getView();
makeContextCurrent();
setView(view);
if (clearBackground) {
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())
/ theHeight;
display.setup(this);
hasLoadedTextureOnLoop = false;
synchronized (this) {
if (refreshCount > 0) {
@ -2252,11 +2241,6 @@ public class GLTarget implements IGLTarget {
gl.glPopAttrib();
}
@Override
public void updateExtent(IExtent updatedExtent) {
this.updatedExtent = updatedExtent;
}
/*
* (non-Javadoc)
*

View file

@ -5,7 +5,6 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.graphics.Rectangle;
import com.raytheon.uf.viz.core.IDisplayPane;
@ -92,7 +91,7 @@ public abstract class AbstractScreenCaptureAction extends AbstractHandler {
// paint in a loop until any async tasks are done
while (target.isNeedsRefresh()) {
target.beginFrame(display, true);
target.beginFrame(display.getView(), true);
display.paint(target, paintProps);
target.endFrame();
}

View file

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

View file

@ -2,6 +2,6 @@
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<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"/>
</classpath>

Binary file not shown.

View file

@ -26,6 +26,7 @@ import java.io.OutputStream;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.math.BigDecimal;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
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.DateSerializer;
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.CoordAdapter;
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.Envelope;
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
@ -108,69 +107,27 @@ public class DynamicSerializationManager {
private static final SerializationMetadata NO_METADATA = new SerializationMetadata();
static {
SerializationMetadata md = new SerializationMetadata();
md.serializationFactory = new CalendarSerializer();
md.adapterStructName = GregorianCalendar.class.getName();
serializedAttributes.put(GregorianCalendar.class.getName(), md);
md = new SerializationMetadata();
md.serializationFactory = new DateSerializer();
md.adapterStructName = Date.class.getName();
serializedAttributes.put(Date.class.getName(), md);
md = new SerializationMetadata();
md.serializationFactory = new TimestampSerializer();
md.adapterStructName = Timestamp.class.getName();
serializedAttributes.put(Timestamp.class.getName(), md);
md = new SerializationMetadata();
md.serializationFactory = new BuiltInTypeSupport.SqlDateSerializer();
md.adapterStructName = java.sql.Date.class.getName();
serializedAttributes.put(java.sql.Date.class.getName(), md);
md = new SerializationMetadata();
md.serializationFactory = new PointAdapter();
md.adapterStructName = java.awt.Point.class.getName();
serializedAttributes.put(java.awt.Point.class.getName(), md);
md = new SerializationMetadata();
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);
// TODO: Can the registration of adapters that require dependencies be
// moved to a separate plugin somehow?
registerAdapter(GregorianCalendar.class, new CalendarSerializer());
registerAdapter(Date.class, new DateSerializer());
registerAdapter(Timestamp.class, new TimestampSerializer());
registerAdapter(java.sql.Date.class,
new BuiltInTypeSupport.SqlDateSerializer());
registerAdapter(java.awt.Point.class, new PointAdapter());
registerAdapter(Coordinate.class, new CoordAdapter());
registerAdapter(BigDecimal.class,
new BuiltInTypeSupport.BigDecimalSerializer());
registerAdapter(Geometry.class, new GeometryTypeAdapter());
registerAdapter(Envelope.class, new JTSEnvelopeAdapter());
registerAdapter(GridGeometry2D.class, new GridGeometry2DAdapter());
registerAdapter(GeneralGridGeometry.class, new GridGeometryAdapter());
registerAdapter(EnumSet.class, new EnumSetAdapter());
registerAdapter(StackTraceElement.class, new StackTraceElementAdapter());
// These two are OBE by BufferAdapter and should be deleted sometime
registerAdapter(ByteBuffer.class, new ByteBufferAdapter());
registerAdapter(FloatBuffer.class, new FloatBufferAdapter());
registerAdapter(Buffer.class, new BufferAdapter());
}
public enum EnclosureType {
@ -297,6 +254,19 @@ public class DynamicSerializationManager {
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
*
@ -308,7 +278,6 @@ public class DynamicSerializationManager {
* the class
* @return the metadata
*/
@SuppressWarnings("unchecked")
public static SerializationMetadata inspect(Class<?> c) {
// Check for base types
@ -327,9 +296,9 @@ public class DynamicSerializationManager {
// Check to see if there is an adapter
if (serializeAdapterTag != null) {
Class factoryTag = (serializeAdapterTag).factory();
Class<?> factoryTag = (serializeAdapterTag).factory();
try {
attribs.serializationFactory = (ISerializationTypeAdapter) factoryTag
attribs.serializationFactory = (ISerializationTypeAdapter<?>) factoryTag
.newInstance();
attribs.adapterStructName = c.getName();
} catch (Exception e) {

View file

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