Got efficient sending of events working where it only sends if events changed
Change-Id: I499a38c1b9cbbd3ede5b04356d2f7788153f836b Former-commit-id:84b8ffa490
[formerly84b8ffa490
[formerly 2f1f6dd97555c46547a7440c97a5314f7a26dc8d]] Former-commit-id:28693e6991
Former-commit-id:e608125f9d
This commit is contained in:
parent
9d0fd819ff
commit
0ba535a60b
28 changed files with 616 additions and 371 deletions
|
@ -23,6 +23,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
|||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.ICreationEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.colormap.UpdateColorMapEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.colormap.UpdateColorMapParametersEvent;
|
||||
|
||||
/**
|
||||
|
@ -54,6 +55,9 @@ public class CreateMosaicImageEvent extends AbstractDispatchingObjectEvent
|
|||
@DynamicSerializeElement
|
||||
private UpdateColorMapParametersEvent colorMapParameters;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private UpdateColorMapEvent colorMap;
|
||||
|
||||
/**
|
||||
* @return the bounds
|
||||
*/
|
||||
|
@ -100,4 +104,19 @@ public class CreateMosaicImageEvent extends AbstractDispatchingObjectEvent
|
|||
this.colorMapParameters = colorMapParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the colorMap
|
||||
*/
|
||||
public UpdateColorMapEvent getColorMap() {
|
||||
return colorMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param colorMap
|
||||
* the colorMap to set
|
||||
*/
|
||||
public void setColorMap(UpdateColorMapEvent colorMap) {
|
||||
this.colorMap = colorMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@ public class DispatchingMosaicImage extends
|
|||
|
||||
private PaintImageEvent[] imagesToMosaic;
|
||||
|
||||
private IExtent imageExtent;
|
||||
|
||||
/**
|
||||
* @param targetObject
|
||||
* @param extensionClass
|
||||
|
@ -62,8 +64,10 @@ public class DispatchingMosaicImage extends
|
|||
*/
|
||||
public DispatchingMosaicImage(IMosaicImage targetObject,
|
||||
Class<? extends IImagingExtension> extensionClass,
|
||||
Dispatcher dispatcher, ColorMapParameters parameters) {
|
||||
Dispatcher dispatcher, ColorMapParameters parameters,
|
||||
IExtent imageExtent) {
|
||||
super(targetObject, extensionClass, dispatcher, parameters);
|
||||
this.imageExtent = imageExtent;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -75,6 +79,8 @@ public class DispatchingMosaicImage extends
|
|||
*/
|
||||
@Override
|
||||
public void setImagesToMosaic(DrawableImage... images) {
|
||||
wrappedObject.setImagesToMosaic(PaintImagesEvent
|
||||
.extractTargetImages(images));
|
||||
PaintImageEvent[] imagesToMosaic = PaintImagesEvent
|
||||
.toPaintEvents(images);
|
||||
if (Arrays.equals(imagesToMosaic, this.imagesToMosaic) == false) {
|
||||
|
@ -82,8 +88,6 @@ public class DispatchingMosaicImage extends
|
|||
UpdateImagesToMosaic event = RemoteGraphicsEventFactory
|
||||
.createEvent(UpdateImagesToMosaic.class, this);
|
||||
event.setImagesToMosaic(imagesToMosaic);
|
||||
wrappedObject.setImagesToMosaic(PaintImagesEvent
|
||||
.extractTargetImages(images));
|
||||
dispatch(event);
|
||||
}
|
||||
}
|
||||
|
@ -98,10 +102,13 @@ public class DispatchingMosaicImage extends
|
|||
@Override
|
||||
public void setImageExtent(IExtent imageExtent) {
|
||||
wrappedObject.setImageExtent(imageExtent);
|
||||
UpdateMosaicExtent extentUpdate = RemoteGraphicsEventFactory
|
||||
.createEvent(UpdateMosaicExtent.class, this);
|
||||
extentUpdate.setIExtent(imageExtent);
|
||||
dispatch(extentUpdate);
|
||||
if (imageExtent.equals(this.imageExtent) == false) {
|
||||
this.imageExtent = imageExtent;
|
||||
UpdateMosaicExtent extentUpdate = RemoteGraphicsEventFactory
|
||||
.createEvent(UpdateMosaicExtent.class, this);
|
||||
extentUpdate.setIExtent(imageExtent);
|
||||
dispatch(extentUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ import com.raytheon.uf.viz.core.IExtent;
|
|||
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.RemoteGraphicsEventFactory;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.colormap.UpdateColorMapEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.colormap.UpdateColorMapParametersEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.extensions.AbstractDispatchingImageExtension;
|
||||
import com.raytheon.viz.radar.rsc.mosaic.ext.IRadarMosaicImageExtension;
|
||||
|
||||
|
@ -62,14 +64,16 @@ public class DispatchingRadarMosaicExtension extends
|
|||
.getExtension(IRadarMosaicImageExtension.class)
|
||||
.initializeRaster(imageBounds, imageExtent, params),
|
||||
DispatchingRadarMosaicExtension.class, target.getDispatcher(),
|
||||
params);
|
||||
params, imageExtent);
|
||||
// Send creation event
|
||||
CreateMosaicImageEvent creation = RemoteGraphicsEventFactory
|
||||
.createEvent(CreateMosaicImageEvent.class, image);
|
||||
creation.setBounds(imageBounds);
|
||||
if (params != null) {
|
||||
creation.setColorMapParameters(DispatchingMosaicImage
|
||||
.createColorMapParametersUpdateEvent(image));
|
||||
creation.setColorMapParameters(UpdateColorMapParametersEvent
|
||||
.createEvent(image, params));
|
||||
creation.setColorMap(UpdateColorMapEvent.createEvent(image,
|
||||
params.getColorMap()));
|
||||
}
|
||||
if (imageExtent != null) {
|
||||
UpdateMosaicExtent extentUpdate = RemoteGraphicsEventFactory
|
||||
|
|
|
@ -76,7 +76,10 @@ public class RadarGraphicsExtRenderingHandler extends
|
|||
imageExtent = event.getExtent().getIExtent();
|
||||
}
|
||||
if (event.getColorMapParameters() != null) {
|
||||
parameters = event.getColorMapParameters().asColorMapParameters();
|
||||
parameters = event.getColorMapParameters().getColorMapParameters();
|
||||
if (event.getColorMap() != null && parameters != null) {
|
||||
parameters.setColorMap(event.getColorMap().getColorMap());
|
||||
}
|
||||
}
|
||||
dataManager.putRenderableObject(
|
||||
imageId,
|
||||
|
|
|
@ -19,7 +19,8 @@ Require-Bundle: com.raytheon.viz.ui,
|
|||
com.raytheon.viz.core;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.viz.drawing;bundle-version="1.0.0",
|
||||
com.raytheon.uf.viz.remote.graphics;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.comm;bundle-version="1.12.1174"
|
||||
com.raytheon.uf.common.comm;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.colormap;bundle-version="1.12.1174"
|
||||
Import-Package: com.raytheon.uf.common.status,
|
||||
com.raytheon.uf.viz.core.maps.display,
|
||||
com.raytheon.uf.viz.core.maps.rsc,
|
||||
|
|
|
@ -103,18 +103,7 @@ public class CollaborationDispatcher extends Dispatcher {
|
|||
byte[] data = Tools.compress(SerializationUtil
|
||||
.transformToThrift(eventObject));
|
||||
if (data.length > IMMEDIATE_SEND_SIZE) {
|
||||
System.err.println("Object: "
|
||||
+ eventObject.getClass().getSimpleName()
|
||||
+ " is too large to send immediately, size is "
|
||||
+ data.length + " bytes");
|
||||
immediateSend = false;
|
||||
} else {
|
||||
System.out
|
||||
.println("Object: "
|
||||
+ eventObject.getClass()
|
||||
.getSimpleName()
|
||||
+ " is small enough to send immediately, size is "
|
||||
+ data.length + " bytes");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Activator.statusHandler.handle(Priority.PROBLEM,
|
||||
|
|
|
@ -68,8 +68,6 @@ public class CollaborationObjectEventStorage implements
|
|||
|
||||
private static final int SESSION_DATA_PORT = 80;
|
||||
|
||||
private volatile long EVENT_ID_COUNTER = 0;
|
||||
|
||||
public static IObjectEventPersistance createPersistanceObject(
|
||||
ISharedDisplaySession session) throws CollaborationException {
|
||||
CollaborationObjectEventStorage persistance = new CollaborationObjectEventStorage(
|
||||
|
@ -133,13 +131,13 @@ public class CollaborationObjectEventStorage implements
|
|||
try {
|
||||
CollaborationHttpPersistedEvent wrapped = new CollaborationHttpPersistedEvent();
|
||||
String eventObjectURL = sessionDataURL + event.getObjectId() + "/"
|
||||
+ (++EVENT_ID_COUNTER) + ".obj";
|
||||
+ event.getClass().getName() + ".obj";
|
||||
HttpPut put = new HttpPut(eventObjectURL);
|
||||
|
||||
put.setEntity(new ByteArrayEntity(Tools.compress(SerializationUtil
|
||||
.transformToThrift(event))));
|
||||
HttpClientResponse response = executeRequest(put);
|
||||
if (response.code != 201) {
|
||||
if (isSuccess(response.code) == false) {
|
||||
throw new CollaborationException(
|
||||
"Error uploading event object to server @ "
|
||||
+ eventObjectURL + " : "
|
||||
|
@ -182,7 +180,7 @@ public class CollaborationObjectEventStorage implements
|
|||
.getResourceURL();
|
||||
HttpGet get = new HttpGet(objectURL);
|
||||
HttpClientResponse response = executeRequest(get);
|
||||
if (response.code == 200) {
|
||||
if (isSuccess(response.code)) {
|
||||
try {
|
||||
return (AbstractDispatchingObjectEvent) SerializationUtil
|
||||
.transformFromThrift(Tools
|
||||
|
@ -227,7 +225,7 @@ public class CollaborationObjectEventStorage implements
|
|||
};
|
||||
mkcol.setURI(URI.create(sessionDataURL + folderPath));
|
||||
HttpClientResponse rsp = executeRequest(mkcol);
|
||||
if (rsp.code != 201) {
|
||||
if (isSuccess(rsp.code) == false) {
|
||||
throw new CollaborationException("Folder creation failed for "
|
||||
+ folderPath + ": " + new String(rsp.data));
|
||||
}
|
||||
|
@ -235,10 +233,8 @@ public class CollaborationObjectEventStorage implements
|
|||
|
||||
private void deleteResource(URI uri) throws CollaborationException {
|
||||
HttpClientResponse rsp = executeRequest(new HttpDelete(uri));
|
||||
// Valid DELETE return codes are 200, 202, and 204, 404 means resource
|
||||
// has already been deleted
|
||||
if (rsp.code != 200 && rsp.code != 202 && rsp.code != 204
|
||||
&& rsp.code != 404) {
|
||||
// If request was success or resource doesn't exist, we are good
|
||||
if (isSuccess(rsp.code) == false && isNotExists(rsp.code) == false) {
|
||||
throw new CollaborationException("Folder creation failed for "
|
||||
+ uri + ": " + new String(rsp.data));
|
||||
}
|
||||
|
@ -253,6 +249,14 @@ public class CollaborationObjectEventStorage implements
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isSuccess(int code) {
|
||||
return code >= 200 && code < 300;
|
||||
}
|
||||
|
||||
private boolean isNotExists(int code) {
|
||||
return code == 404 || code == 410;
|
||||
}
|
||||
|
||||
@DynamicSerialize
|
||||
public static class CollaborationHttpPersistedEvent implements
|
||||
IPersistedEvent {
|
||||
|
|
|
@ -77,6 +77,8 @@ public class RenderFrameEvent extends AbstractDispatchingObjectEvent {
|
|||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!super.equals(obj))
|
||||
return false;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.raytheon.uf.common.colormap.IColorMap;
|
||||
import com.raytheon.uf.viz.core.DrawableImage;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.IMesh;
|
||||
|
@ -41,6 +42,7 @@ import com.raytheon.uf.viz.core.exception.VizException;
|
|||
import com.raytheon.uf.viz.core.map.IMapMeshExtension;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.colormap.ColorMapDataEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.colormap.CreateColormappedImageEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.colormap.UpdateColorMapEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.colormap.UpdateColorMapParametersEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.imagery.CreateIImageEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.imagery.CreateSingleColorImage;
|
||||
|
@ -71,6 +73,8 @@ import com.raytheon.uf.viz.remote.graphics.events.mesh.ReprojectMeshEvent;
|
|||
|
||||
public class ImagingRenderingHandler extends CollaborationRenderingHandler {
|
||||
|
||||
private Object colorMapLock = new Object();
|
||||
|
||||
@Subscribe
|
||||
public void renderImages(PaintImagesEvent event) throws VizException {
|
||||
PaintProperties paintProps = getPaintProperties();
|
||||
|
@ -188,10 +192,14 @@ public class ImagingRenderingHandler extends CollaborationRenderingHandler {
|
|||
IGraphicsTarget target = getTarget();
|
||||
int imageId = event.getObjectId();
|
||||
IColorMapDataRetrievalCallback callback = new ColorMapDataCallback();
|
||||
UpdateColorMapParametersEvent cmapEvent = event.getColorMapParameters();
|
||||
UpdateColorMapParametersEvent cmapParamEvent = event
|
||||
.getColorMapParameters();
|
||||
ColorMapParameters params = null;
|
||||
if (cmapEvent != null) {
|
||||
params = cmapEvent.asColorMapParameters();
|
||||
if (cmapParamEvent != null) {
|
||||
params = cmapParamEvent.getColorMapParameters();
|
||||
if (event.getColorMap() != null && params != null) {
|
||||
params.setColorMap(event.getColorMap().getColorMap());
|
||||
}
|
||||
}
|
||||
IColormappedImage image = target.getExtension(
|
||||
IColormappedImageExtension.class).initializeRaster(callback,
|
||||
|
@ -200,6 +208,41 @@ public class ImagingRenderingHandler extends CollaborationRenderingHandler {
|
|||
new Object[] { image, callback });
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void updateColorMapParameters(UpdateColorMapParametersEvent event) {
|
||||
IColormappedImage image = dataManager.getRenderableObject(
|
||||
event.getObjectId(), IColormappedImage.class);
|
||||
if (image != null) {
|
||||
ColorMapParameters newParams = event.getColorMapParameters();
|
||||
synchronized (colorMapLock) {
|
||||
ColorMapParameters params = image.getColorMapParameters();
|
||||
if (params != null && newParams != null) {
|
||||
newParams.setColorMap(params.getColorMap());
|
||||
}
|
||||
image.setColorMapParameters(newParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void updateColorMap(UpdateColorMapEvent event) {
|
||||
IColormappedImage image = dataManager.getRenderableObject(
|
||||
event.getObjectId(), IColormappedImage.class);
|
||||
if (image != null) {
|
||||
IColorMap colorMap = event.getColorMap();
|
||||
synchronized (colorMapLock) {
|
||||
ColorMapParameters params = image.getColorMapParameters();
|
||||
if (params == null && colorMap != null) {
|
||||
params = new ColorMapParameters();
|
||||
params.setColorMap(colorMap);
|
||||
image.setColorMapParameters(params);
|
||||
} else if (params != null) {
|
||||
params.setColorMap(colorMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void dataArrived(ColorMapDataEvent event) {
|
||||
ColorMapDataCallback callback = dataManager.getRenderableObject(
|
||||
|
|
|
@ -64,7 +64,7 @@ public class OffscreenRenderingHandler extends CollaborationRenderingHandler {
|
|||
if (event.getColorMapParamters() != null) {
|
||||
offscreenImage = ext.constructOffscreenImage(bufferType,
|
||||
dims, event.getColorMapParamters()
|
||||
.asColorMapParameters());
|
||||
.getColorMapParameters());
|
||||
} else {
|
||||
offscreenImage = ext.constructOffscreenImage(bufferType,
|
||||
dims);
|
||||
|
|
|
@ -28,9 +28,8 @@ import com.raytheon.uf.viz.remote.graphics.events.wireframe.AllocatePointsEvent;
|
|||
import com.raytheon.uf.viz.remote.graphics.events.wireframe.CreateWireframeShapeEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.wireframe.RenderWireframeShapeEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.wireframe.SimpleWireframeShapeEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.wireframe.UpdateWireframeShapeEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.wireframe.WireframeShapeData;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.wireframe.WireframeShapeData.Label;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.wireframe.WireframeShapeDataEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.wireframe.WireframeShapeDataEvent.Label;
|
||||
|
||||
/**
|
||||
* Handles render events for wireframe shapes
|
||||
|
@ -86,15 +85,15 @@ public class WireframeShapeRenderingHandler extends
|
|||
}
|
||||
|
||||
@Subscribe
|
||||
public void updateWireframeShapeData(UpdateWireframeShapeEvent event) {
|
||||
public void wireframeShapeDataArrived(WireframeShapeDataEvent event) {
|
||||
IWireframeShape shape = dataManager.getRenderableObject(
|
||||
event.getObjectId(), IWireframeShape.class);
|
||||
if (shape != null) {
|
||||
WireframeShapeData data = event.getWireframeData();
|
||||
for (Label label : data.getLabels()) {
|
||||
shape.reset();
|
||||
for (Label label : event.getLabels()) {
|
||||
shape.addLabel(label.getText(), label.getPoint());
|
||||
}
|
||||
for (double[][] coords : data.getCoordinates()) {
|
||||
for (double[][] coords : event.getCoordinates()) {
|
||||
shape.addLineSegment(coords);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,6 +121,7 @@ public class GLMosaicImage extends GLDelegateImage<GLColormappedImage>
|
|||
@Override
|
||||
public void setImageExtent(IExtent imageExtent) {
|
||||
this.extent = imageExtent;
|
||||
repaint = true;
|
||||
}
|
||||
|
||||
public IExtent getImageExtent() {
|
||||
|
|
|
@ -489,7 +489,7 @@ public class DispatchGraphicsTarget extends DispatchingObject<IGraphicsTarget>
|
|||
private void sendDrawWireframeShapeEvent(DispatchingWireframeShape shape,
|
||||
RGB color, float lineWidth, LineStyle lineStyle, IFont font,
|
||||
Float alpha) {
|
||||
shape.updateState();
|
||||
shape.flushState();
|
||||
RenderWireframeShapeEvent event = RemoteGraphicsEventFactory
|
||||
.createEvent(RenderWireframeShapeEvent.class, shape);
|
||||
event.setColor(color);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.remote.graphics;
|
||||
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
|
|
|
@ -69,4 +69,23 @@ public abstract class AbstractDispatchingObjectEvent extends
|
|||
this.objectId = objectId;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
AbstractDispatchingObjectEvent other = (AbstractDispatchingObjectEvent) obj;
|
||||
if (objectId != other.objectId)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,25 +19,18 @@
|
|||
**/
|
||||
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.SerializationUtil;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeTypeAdapter;
|
||||
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.ColorMapDataType;
|
||||
import com.raytheon.uf.viz.remote.graphics.Activator;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.colormap.ColorMapDataEvent.ColorMapDataEventAdapter;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Event for sending ColorMapData, serializes object immediately to avoid
|
||||
* concurrency issues with other threads using the buffer async
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -53,117 +46,41 @@ import com.raytheon.uf.viz.remote.graphics.events.colormap.ColorMapDataEvent.Col
|
|||
* @version 1.0
|
||||
*/
|
||||
@DynamicSerialize
|
||||
@DynamicSerializeTypeAdapter(factory = ColorMapDataEventAdapter.class)
|
||||
public class ColorMapDataEvent extends AbstractDispatchingObjectEvent {
|
||||
|
||||
public static class ColorMapDataEventAdapter implements
|
||||
ISerializationTypeAdapter<ColorMapDataEvent> {
|
||||
@DynamicSerializeElement
|
||||
private byte[] serializedColorMapData;
|
||||
|
||||
/*
|
||||
* (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,
|
||||
ColorMapDataEvent object) throws SerializationException {
|
||||
serializer.writeI32(object.getDisplayId());
|
||||
serializer.writeI32(object.getObjectId());
|
||||
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 ColorMapDataEvent deserialize(
|
||||
IDeserializationContext deserializer)
|
||||
throws SerializationException {
|
||||
ColorMapDataEvent event = new ColorMapDataEvent();
|
||||
event.setDisplayId(deserializer.readI32());
|
||||
event.setObjectId(deserializer.readI32());
|
||||
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;
|
||||
}
|
||||
event.setColorMapData(new ColorMapData(dataBuffer, dimensions,
|
||||
dataType));
|
||||
return event;
|
||||
}
|
||||
/**
|
||||
* @return the serializedColorMapData
|
||||
*/
|
||||
public byte[] getSerializedColorMapData() {
|
||||
return serializedColorMapData;
|
||||
}
|
||||
|
||||
private ColorMapData colorMapData;
|
||||
/**
|
||||
* @param serializedColorMapData
|
||||
* the serializedColorMapData to set
|
||||
*/
|
||||
public void setSerializedColorMapData(byte[] serializedColorMapData) {
|
||||
this.serializedColorMapData = serializedColorMapData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the colorMapData
|
||||
*/
|
||||
public ColorMapData getColorMapData() {
|
||||
return colorMapData;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,7 +88,15 @@ public class ColorMapDataEvent extends AbstractDispatchingObjectEvent {
|
|||
* the colorMapData to set
|
||||
*/
|
||||
public void setColorMapData(ColorMapData colorMapData) {
|
||||
this.colorMapData = colorMapData;
|
||||
ColorMapDataWrapper wrapper = new ColorMapDataWrapper();
|
||||
wrapper.setColorMapData(colorMapData);
|
||||
try {
|
||||
serializedColorMapData = SerializationUtil
|
||||
.transformToThrift(wrapper);
|
||||
} catch (SerializationException e) {
|
||||
Activator.statusHandler.handle(Priority.PROBLEM,
|
||||
e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,172 @@
|
|||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
}
|
|
@ -47,6 +47,9 @@ public class CreateColormappedImageEvent extends AbstractDispatchingObjectEvent
|
|||
@DynamicSerializeElement
|
||||
private UpdateColorMapParametersEvent colorMapParameters;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private UpdateColorMapEvent colorMap;
|
||||
|
||||
/**
|
||||
* @return the colorMapParameters
|
||||
*/
|
||||
|
@ -63,4 +66,19 @@ public class CreateColormappedImageEvent extends AbstractDispatchingObjectEvent
|
|||
this.colorMapParameters = colorMapParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the colorMap
|
||||
*/
|
||||
public UpdateColorMapEvent getColorMap() {
|
||||
return colorMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param colorMap
|
||||
* the colorMap to set
|
||||
*/
|
||||
public void setColorMap(UpdateColorMapEvent colorMap) {
|
||||
this.colorMap = colorMap;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
/**
|
||||
* 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 com.raytheon.uf.common.colormap.ColorMap;
|
||||
import com.raytheon.uf.common.colormap.IColorMap;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.RemoteGraphicsEventFactory;
|
||||
import com.raytheon.uf.viz.remote.graphics.objects.AbstractDispatchingImage;
|
||||
|
||||
/**
|
||||
* Event for updating the IColorMap on an IColormappedImage
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 25, 2012 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
@DynamicSerialize
|
||||
public class UpdateColorMapEvent extends AbstractDispatchingObjectEvent {
|
||||
|
||||
@DynamicSerializeElement
|
||||
private float[] red;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private float[] blue;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private float[] green;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private float[] alpha;
|
||||
|
||||
/**
|
||||
* @return the red
|
||||
*/
|
||||
public float[] getRed() {
|
||||
return red;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param red
|
||||
* the red to set
|
||||
*/
|
||||
public void setRed(float[] red) {
|
||||
this.red = red;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the blue
|
||||
*/
|
||||
public float[] getBlue() {
|
||||
return blue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param blue
|
||||
* the blue to set
|
||||
*/
|
||||
public void setBlue(float[] blue) {
|
||||
this.blue = blue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the green
|
||||
*/
|
||||
public float[] getGreen() {
|
||||
return green;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param green
|
||||
* the green to set
|
||||
*/
|
||||
public void setGreen(float[] green) {
|
||||
this.green = green;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the alpha
|
||||
*/
|
||||
public float[] getAlpha() {
|
||||
return alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param alpha
|
||||
* the alpha to set
|
||||
*/
|
||||
public void setAlpha(float[] alpha) {
|
||||
this.alpha = alpha;
|
||||
}
|
||||
|
||||
public IColorMap getColorMap() {
|
||||
if (red != null && green != null && blue != null && alpha != null) {
|
||||
return new ColorMap("" + getObjectId(), red, green, blue, alpha);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setColorMap(IColorMap colorMap) {
|
||||
if (colorMap != null) {
|
||||
red = colorMap.getRed();
|
||||
green = colorMap.getGreen();
|
||||
blue = colorMap.getBlue();
|
||||
alpha = colorMap.getAlpha();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param wrapper
|
||||
* @param parameters
|
||||
* @return
|
||||
*/
|
||||
public static UpdateColorMapEvent createEvent(
|
||||
AbstractDispatchingImage<?> wrapper, IColorMap colorMap) {
|
||||
UpdateColorMapEvent event = RemoteGraphicsEventFactory.createEvent(
|
||||
UpdateColorMapEvent.class, wrapper);
|
||||
event.setColorMap(colorMap);
|
||||
return event;
|
||||
}
|
||||
}
|
|
@ -19,17 +19,15 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.remote.graphics.events.colormap;
|
||||
|
||||
import com.raytheon.uf.common.colormap.ColorMap;
|
||||
import com.raytheon.uf.common.colormap.IColorMap;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
|
||||
import com.raytheon.uf.viz.remote.graphics.DispatchingObject;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.RemoteGraphicsEventFactory;
|
||||
import com.raytheon.uf.viz.remote.graphics.objects.AbstractDispatchingImage;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Event for updating the ColorMapParameters on an IColormappedImage
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -51,18 +49,6 @@ public class UpdateColorMapParametersEvent extends
|
|||
@DynamicSerializeElement
|
||||
private byte[] alphaMask;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private float[] red;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private float[] blue;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private float[] green;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private float[] alpha;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private float colorMapMax;
|
||||
|
||||
|
@ -102,66 +88,6 @@ public class UpdateColorMapParametersEvent extends
|
|||
this.alphaMask = alphaMask;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the red
|
||||
*/
|
||||
public float[] getRed() {
|
||||
return red;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param red
|
||||
* the red to set
|
||||
*/
|
||||
public void setRed(float[] red) {
|
||||
this.red = red;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the blue
|
||||
*/
|
||||
public float[] getBlue() {
|
||||
return blue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param blue
|
||||
* the blue to set
|
||||
*/
|
||||
public void setBlue(float[] blue) {
|
||||
this.blue = blue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the green
|
||||
*/
|
||||
public float[] getGreen() {
|
||||
return green;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param green
|
||||
* the green to set
|
||||
*/
|
||||
public void setGreen(float[] green) {
|
||||
this.green = green;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the alpha
|
||||
*/
|
||||
public float[] getAlpha() {
|
||||
return alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param alpha
|
||||
* the alpha to set
|
||||
*/
|
||||
public void setAlpha(float[] alpha) {
|
||||
this.alpha = alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the colorMapMax
|
||||
*/
|
||||
|
@ -282,12 +208,31 @@ public class UpdateColorMapParametersEvent extends
|
|||
this.useMask = useMask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ColorMapParameters for the event
|
||||
*
|
||||
* @param parameters
|
||||
*/
|
||||
public void setColorMapParameters(ColorMapParameters parameters) {
|
||||
if (parameters != null) {
|
||||
setAlphaMask(parameters.getAlphaMask());
|
||||
setColorMapMin(parameters.getColorMapMin());
|
||||
setColorMapMax(parameters.getColorMapMax());
|
||||
setDataMin(parameters.getDataMin());
|
||||
setDataMax(parameters.getDataMax());
|
||||
setLogarithmic(parameters.isLogarithmic());
|
||||
setLogFactor(parameters.getLogFactor());
|
||||
setMirror(parameters.isMirror());
|
||||
setUseMask(parameters.isUseMask());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the update colormap parameters event as ColorMapParameters object
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ColorMapParameters asColorMapParameters() {
|
||||
public ColorMapParameters getColorMapParameters() {
|
||||
ColorMapParameters params = new ColorMapParameters();
|
||||
params.setAlphaMask(getAlphaMask());
|
||||
params.setColorMapMin(getColorMapMin());
|
||||
|
@ -298,33 +243,19 @@ public class UpdateColorMapParametersEvent extends
|
|||
params.setLogFactor(getLogFactor());
|
||||
params.setMirror(isMirror());
|
||||
params.setUseMask(isUseMask());
|
||||
if (red != null && green != null && blue != null && alpha != null) {
|
||||
params.setColorMap(new ColorMap("" + getObjectId(), red, green,
|
||||
blue, alpha));
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param wrapper
|
||||
* @param parameters
|
||||
* @return
|
||||
*/
|
||||
public static UpdateColorMapParametersEvent createEvent(
|
||||
DispatchingObject<?> creator, ColorMapParameters parameters) {
|
||||
AbstractDispatchingImage<?> wrapper, ColorMapParameters parameters) {
|
||||
UpdateColorMapParametersEvent event = RemoteGraphicsEventFactory
|
||||
.createEvent(UpdateColorMapParametersEvent.class, creator);
|
||||
event.setAlphaMask(parameters.getAlphaMask());
|
||||
IColorMap cmap = parameters.getColorMap();
|
||||
if (cmap != null) {
|
||||
event.setRed(cmap.getRed());
|
||||
event.setBlue(cmap.getBlue());
|
||||
event.setGreen(cmap.getGreen());
|
||||
event.setAlpha(cmap.getAlpha());
|
||||
}
|
||||
event.setColorMapMin(parameters.getColorMapMin());
|
||||
event.setColorMapMax(parameters.getColorMapMax());
|
||||
event.setDataMin(parameters.getDataMin());
|
||||
event.setDataMax(parameters.getDataMax());
|
||||
event.setLogarithmic(parameters.isLogarithmic());
|
||||
event.setLogFactor(parameters.getLogFactor());
|
||||
event.setMirror(parameters.isMirror());
|
||||
event.setUseMask(parameters.isUseMask());
|
||||
.createEvent(UpdateColorMapParametersEvent.class, wrapper);
|
||||
event.setColorMapParameters(parameters);
|
||||
return event;
|
||||
}
|
||||
|
||||
|
|
|
@ -152,6 +152,8 @@ public class PaintImageEvent extends AbstractDispatchingObjectEvent implements
|
|||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!super.equals(obj))
|
||||
return false;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
|
|
|
@ -97,7 +97,7 @@ public class RenderOffscreenEvent extends AbstractDispatchingObjectEvent
|
|||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
if (!super.equals(obj))
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
|
|
|
@ -198,6 +198,8 @@ public class RenderWireframeShapeEvent extends AbstractDispatchingObjectEvent
|
|||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!super.equals(obj))
|
||||
return false;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
|
|
|
@ -1,63 +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.wireframe;
|
||||
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 29, 2012 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
@DynamicSerialize
|
||||
public class UpdateWireframeShapeEvent extends AbstractDispatchingObjectEvent {
|
||||
|
||||
@DynamicSerializeElement
|
||||
private WireframeShapeData wireframeData;
|
||||
|
||||
/**
|
||||
* @return the wireframeData
|
||||
*/
|
||||
public WireframeShapeData getWireframeData() {
|
||||
return wireframeData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param wireframeData
|
||||
* the wireframeData to set
|
||||
*/
|
||||
public void setWireframeData(WireframeShapeData wireframeData) {
|
||||
this.wireframeData = wireframeData;
|
||||
}
|
||||
|
||||
}
|
|
@ -29,7 +29,8 @@ 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.wireframe.WireframeShapeData.WireframeShapeDataAdapter;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.AbstractDispatchingObjectEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.wireframe.WireframeShapeDataEvent.WireframeShapeDataAdapter;
|
||||
|
||||
/**
|
||||
* Wireframe shape data event which contains coordinates and labels to add to
|
||||
|
@ -50,10 +51,10 @@ import com.raytheon.uf.viz.remote.graphics.events.wireframe.WireframeShapeData.W
|
|||
*/
|
||||
@DynamicSerialize
|
||||
@DynamicSerializeTypeAdapter(factory = WireframeShapeDataAdapter.class)
|
||||
public class WireframeShapeData {
|
||||
public class WireframeShapeDataEvent extends AbstractDispatchingObjectEvent {
|
||||
|
||||
public static class WireframeShapeDataAdapter implements
|
||||
ISerializationTypeAdapter<WireframeShapeData> {
|
||||
ISerializationTypeAdapter<WireframeShapeDataEvent> {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -64,7 +65,9 @@ public class WireframeShapeData {
|
|||
*/
|
||||
@Override
|
||||
public void serialize(ISerializationContext serializer,
|
||||
WireframeShapeData object) throws SerializationException {
|
||||
WireframeShapeDataEvent object) throws SerializationException {
|
||||
serializer.writeI32(object.getDisplayId());
|
||||
serializer.writeI32(object.getObjectId());
|
||||
serializer.writeI32(object.labels.size());
|
||||
for (Label l : object.labels) {
|
||||
serializer.writeString(l.getText());
|
||||
|
@ -87,10 +90,12 @@ public class WireframeShapeData {
|
|||
* (com.raytheon.uf.common.serialization.IDeserializationContext)
|
||||
*/
|
||||
@Override
|
||||
public WireframeShapeData deserialize(
|
||||
public WireframeShapeDataEvent deserialize(
|
||||
IDeserializationContext deserializer)
|
||||
throws SerializationException {
|
||||
WireframeShapeData data = new WireframeShapeData();
|
||||
WireframeShapeDataEvent data = new WireframeShapeDataEvent();
|
||||
data.setDisplayId(deserializer.readI32());
|
||||
data.setObjectId(deserializer.readI32());
|
||||
int size = deserializer.readI32();
|
||||
for (int i = 0; i < size; ++i) {
|
||||
data.addLabel(deserializer.readString(),
|
|
@ -27,10 +27,13 @@ import com.raytheon.uf.viz.core.exception.VizException;
|
|||
import com.raytheon.uf.viz.remote.graphics.events.RemoteGraphicsEventFactory;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.colormap.ColorMapDataEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.colormap.CreateColormappedImageEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.colormap.UpdateColorMapEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.colormap.UpdateColorMapParametersEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.objects.DispatchingColormappedImage;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* IColormappedImageExtension that is responsible for creating and dispatching
|
||||
* events for IColormappedImages
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -113,13 +116,14 @@ public class DispatchColormappedImageExtension extends
|
|||
CreateColormappedImageEvent creation = RemoteGraphicsEventFactory
|
||||
.createEvent(CreateColormappedImageEvent.class, image);
|
||||
if (colorMapParameters != null) {
|
||||
creation.setColorMapParameters(DispatchingColormappedImage
|
||||
.createColorMapParametersUpdateEvent(image));
|
||||
creation.setColorMapParameters(UpdateColorMapParametersEvent
|
||||
.createEvent(image, colorMapParameters));
|
||||
creation.setColorMap(UpdateColorMapEvent.createEvent(image,
|
||||
colorMapParameters.getColorMap()));
|
||||
}
|
||||
target.dispatch(creation);
|
||||
|
||||
// Return image
|
||||
return image;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.raytheon.uf.viz.core.drawables.IColorMapParametersListener;
|
|||
import com.raytheon.uf.viz.core.drawables.IColormappedImage;
|
||||
import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
|
||||
import com.raytheon.uf.viz.remote.graphics.Dispatcher;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.colormap.UpdateColorMapEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.colormap.UpdateColorMapParametersEvent;
|
||||
|
||||
/**
|
||||
|
@ -94,7 +95,7 @@ public class DispatchingColormappedImage<T extends IColormappedImage> extends
|
|||
wrappedObject.setColorMapParameters(params);
|
||||
if (params != null) {
|
||||
params.addListener(this);
|
||||
dispatch(createColorMapParametersUpdateEvent(this));
|
||||
updateColorMapParameters();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,26 +121,17 @@ public class DispatchingColormappedImage<T extends IColormappedImage> extends
|
|||
public void colorMapChanged() {
|
||||
ColorMapParameters parameters = getColorMapParameters();
|
||||
if (parameters != null) {
|
||||
dispatch(createColorMapParametersUpdateEvent(this));
|
||||
updateColorMapParameters();
|
||||
}
|
||||
}
|
||||
|
||||
public static UpdateColorMapParametersEvent createColorMapParametersUpdateEvent(
|
||||
DispatchingColormappedImage<?> image) {
|
||||
ColorMapParameters parameters = image.getColorMapParameters();
|
||||
UpdateColorMapParametersEvent event = UpdateColorMapParametersEvent
|
||||
.createEvent(image, parameters);
|
||||
if (parameters.getColorMap() == image.colorMap
|
||||
&& image.colorMap != null) {
|
||||
// Same colormap, discard cm data
|
||||
event.setRed(null);
|
||||
event.setBlue(null);
|
||||
event.setGreen(null);
|
||||
event.setAlpha(null);
|
||||
} else {
|
||||
image.colorMap = parameters.getColorMap();
|
||||
public void updateColorMapParameters() {
|
||||
ColorMapParameters parameters = getColorMapParameters();
|
||||
dispatch(UpdateColorMapParametersEvent.createEvent(this, parameters));
|
||||
if (parameters.getColorMap() != colorMap) {
|
||||
colorMap = parameters.getColorMap();
|
||||
dispatch(UpdateColorMapEvent.createEvent(this, colorMap));
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.remote.graphics.objects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
import org.geotools.referencing.operation.DefaultMathTransformFactory;
|
||||
import org.opengis.referencing.operation.MathTransform;
|
||||
|
@ -35,8 +37,8 @@ import com.raytheon.uf.viz.remote.graphics.events.RemoteGraphicsEventFactory;
|
|||
import com.raytheon.uf.viz.remote.graphics.events.wireframe.AllocatePointsEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.wireframe.SimpleWireframeShapeEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.wireframe.SimpleWireframeShapeEvent.EventAction;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.wireframe.UpdateWireframeShapeEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.wireframe.WireframeShapeData;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.wireframe.WireframeShapeDataEvent;
|
||||
import com.raytheon.uf.viz.remote.graphics.events.wireframe.WireframeShapeDataEvent.Label;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
/**
|
||||
|
@ -62,7 +64,7 @@ public class DispatchingWireframeShape extends
|
|||
|
||||
private MathTransform worldToTargetGrid;
|
||||
|
||||
private WireframeShapeData shapeData;
|
||||
private WireframeShapeDataEvent updateEvent;
|
||||
|
||||
private boolean dirty = true;
|
||||
|
||||
|
@ -73,7 +75,7 @@ public class DispatchingWireframeShape extends
|
|||
public DispatchingWireframeShape(IWireframeShape targetObject,
|
||||
Dispatcher dispatcher, GeneralGridGeometry targetGeometry) {
|
||||
super(targetObject, dispatcher);
|
||||
this.shapeData = new WireframeShapeData();
|
||||
this.updateEvent = createNewUpdateEvent();
|
||||
MathTransform worldToCRS = AbstractDescriptor
|
||||
.getWorldToCRSTransform(targetGeometry);
|
||||
if (worldToCRS != null) {
|
||||
|
@ -97,22 +99,31 @@ public class DispatchingWireframeShape extends
|
|||
public void compile() {
|
||||
wrappedObject.compile();
|
||||
// flush data
|
||||
updateState();
|
||||
flushState();
|
||||
// Event if original shape was mutable, once compiled we should not
|
||||
// accept more data
|
||||
updateEvent = null;
|
||||
// Send compile event
|
||||
sendSimpleEvent(EventAction.COMPILE);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Flush the new data for the wireframe shape
|
||||
*/
|
||||
public void updateState() {
|
||||
public void flushState() {
|
||||
if (dirty) {
|
||||
if (shapeData != null) {
|
||||
UpdateWireframeShapeEvent event = RemoteGraphicsEventFactory
|
||||
.createEvent(UpdateWireframeShapeEvent.class, this);
|
||||
event.setWireframeData(shapeData);
|
||||
shapeData = new WireframeShapeData();
|
||||
dispatch(event);
|
||||
if (updateEvent != null) {
|
||||
WireframeShapeDataEvent toSend = updateEvent;
|
||||
if (wrappedObject.isMutable()) {
|
||||
toSend = createNewUpdateEvent();
|
||||
toSend.setCoordinates(new ArrayList<double[][]>(updateEvent
|
||||
.getCoordinates()));
|
||||
toSend.setLabels(new ArrayList<Label>(updateEvent
|
||||
.getLabels()));
|
||||
} else {
|
||||
updateEvent = null;
|
||||
}
|
||||
dispatch(toSend);
|
||||
}
|
||||
dirty = false;
|
||||
}
|
||||
|
@ -163,8 +174,8 @@ public class DispatchingWireframeShape extends
|
|||
*/
|
||||
public void addLineSegment(double[][] screenCoordinates) {
|
||||
wrappedObject.addLineSegment(screenCoordinates);
|
||||
if (shapeData != null) {
|
||||
shapeData.addCoordinates(screenCoordinates);
|
||||
if (updateEvent != null) {
|
||||
updateEvent.addCoordinates(screenCoordinates);
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
|
@ -185,8 +196,8 @@ public class DispatchingWireframeShape extends
|
|||
*/
|
||||
public void addLabel(String label, double[] screenCoordinate) {
|
||||
wrappedObject.addLabel(label, screenCoordinate);
|
||||
if (shapeData != null) {
|
||||
shapeData.addLabel(label, screenCoordinate);
|
||||
if (updateEvent != null) {
|
||||
updateEvent.addLabel(label, screenCoordinate);
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
|
@ -200,7 +211,7 @@ public class DispatchingWireframeShape extends
|
|||
// Send dispose event
|
||||
dispatch(RemoteGraphicsEventFactory.createEvent(
|
||||
DisposeObjectEvent.class, this));
|
||||
shapeData = null;
|
||||
updateEvent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -211,8 +222,8 @@ public class DispatchingWireframeShape extends
|
|||
wrappedObject.clearLabels();
|
||||
// Send clear labels event
|
||||
sendSimpleEvent(EventAction.CLEAR_LABELS);
|
||||
if (shapeData != null) {
|
||||
shapeData.getLabels().clear();
|
||||
if (updateEvent != null) {
|
||||
updateEvent.getLabels().clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,10 +245,15 @@ public class DispatchingWireframeShape extends
|
|||
* @see com.raytheon.uf.viz.core.drawables.IShape#reset()
|
||||
*/
|
||||
public void reset() {
|
||||
// TODO: Reset will not currently work if shape was disposed
|
||||
wrappedObject.reset();
|
||||
// Send reset event
|
||||
sendSimpleEvent(EventAction.RESET);
|
||||
shapeData = new WireframeShapeData();
|
||||
updateEvent = createNewUpdateEvent();
|
||||
}
|
||||
|
||||
private WireframeShapeDataEvent createNewUpdateEvent() {
|
||||
return RemoteGraphicsEventFactory.createEvent(
|
||||
WireframeShapeDataEvent.class, this);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue