Issue #1329 Committing some of the core classes touched for MPE time refactor. Made GL data mapping work properly with non float types. Made GriddedImageDisplay2 use new TileSetRenderable for processing and memory efficieny
Change-Id: Ib12a3a6bb1f20f1e8eeb6dbd170802cf79359cfb Former-commit-id:be99f6c7ca
[formerly3e128b266a
] [formerly5db71ca943
[formerly eaeb75b4f2dd1c19f805c8cf4f4d010b455d99e8]] Former-commit-id:5db71ca943
Former-commit-id:b74d788909
This commit is contained in:
parent
f4624af03c
commit
d43e0c1c25
37 changed files with 663 additions and 437 deletions
|
@ -22,7 +22,6 @@ package com.raytheon.uf.viz.core.data;
|
|||
import java.awt.Rectangle;
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
|
@ -47,7 +46,8 @@ import java.nio.ShortBuffer;
|
|||
public class BufferSlicer {
|
||||
|
||||
/**
|
||||
* Given a Buffer, a Rectangle for the Buffer, and a totalBounds
|
||||
* Slices a Buffer represented by a 2D bounds totalBounds into a Buffer
|
||||
* represented by bounds dataBounds.
|
||||
*
|
||||
* @param data
|
||||
* @param dataBounds
|
||||
|
@ -57,72 +57,138 @@ public class BufferSlicer {
|
|||
*/
|
||||
public static Buffer slice(Buffer data, Rectangle dataBounds,
|
||||
Rectangle totalBounds) {
|
||||
if (dataBounds.getMinX() < totalBounds.getMinX()
|
||||
|| dataBounds.getMinY() < totalBounds.getMinY()
|
||||
|| dataBounds.getMaxX() > totalBounds.getMaxX()
|
||||
|| dataBounds.getMaxY() > totalBounds.getMaxY()) {
|
||||
throw new RuntimeException(
|
||||
"Data bounds defines region outside of buffer's total bounds");
|
||||
}
|
||||
|
||||
data = duplicate(data);
|
||||
int dataSize = dataBounds.width * dataBounds.height;
|
||||
if (dataSize == totalBounds.width * totalBounds.height) {
|
||||
return data;
|
||||
}
|
||||
Buffer newData = null;
|
||||
// Get our new Buffer object
|
||||
if (data instanceof ByteBuffer) {
|
||||
return slice((ByteBuffer) data, dataBounds, totalBounds, dataSize);
|
||||
} else if (data instanceof ShortBuffer) {
|
||||
return slice((ShortBuffer) data, dataBounds, totalBounds, dataSize);
|
||||
} else if (data instanceof IntBuffer) {
|
||||
return slice((IntBuffer) data, dataBounds, totalBounds, dataSize);
|
||||
} else if (data instanceof FloatBuffer) {
|
||||
return slice((FloatBuffer) data, dataBounds, totalBounds, dataSize);
|
||||
} else {
|
||||
throw new RuntimeException(
|
||||
"Unhandled buffer passed in: " + data != null ? data
|
||||
.getClass().getSimpleName() : null);
|
||||
}
|
||||
}
|
||||
|
||||
private static Buffer duplicate(Buffer data) {
|
||||
if (data instanceof ByteBuffer) {
|
||||
return ((ByteBuffer) data).duplicate();
|
||||
} else if (data instanceof ShortBuffer) {
|
||||
return ((ShortBuffer) data).duplicate();
|
||||
} else if (data instanceof IntBuffer) {
|
||||
return ((IntBuffer) data).duplicate();
|
||||
} else if (data instanceof FloatBuffer) {
|
||||
return ((FloatBuffer) data).duplicate();
|
||||
} else {
|
||||
throw new RuntimeException(
|
||||
"Unhandled buffer passed in: " + data != null ? data
|
||||
.getClass().getSimpleName() : null);
|
||||
}
|
||||
}
|
||||
|
||||
private static ByteBuffer slice(ByteBuffer data, Rectangle dataBounds,
|
||||
Rectangle totalBounds, int dataSize) {
|
||||
ByteBuffer newData = null;
|
||||
// Get our new Buffer object
|
||||
if (data.isDirect()) {
|
||||
newData = ByteBuffer.allocateDirect(dataSize).order(
|
||||
ByteOrder.nativeOrder());
|
||||
newData = ByteBuffer.allocateDirect(dataSize).order(data.order());
|
||||
} else {
|
||||
newData = ByteBuffer.allocate(dataSize);
|
||||
}
|
||||
} else if (data instanceof ShortBuffer) {
|
||||
|
||||
newData.position(0);
|
||||
byte[] bytes = new byte[dataBounds.width];
|
||||
for (int i = 0; i < dataBounds.height; ++i) {
|
||||
data.position((dataBounds.y * totalBounds.width + dataBounds.x) + i
|
||||
* totalBounds.width);
|
||||
data.get(bytes);
|
||||
newData.put(bytes);
|
||||
}
|
||||
newData.rewind();
|
||||
return newData;
|
||||
}
|
||||
|
||||
private static ShortBuffer slice(ShortBuffer data, Rectangle dataBounds,
|
||||
Rectangle totalBounds, int dataSize) {
|
||||
ShortBuffer newData = null;
|
||||
// Get our new Buffer object
|
||||
if (data.isDirect()) {
|
||||
newData = ByteBuffer.allocateDirect(dataSize * 2)
|
||||
.order(ByteOrder.nativeOrder()).asShortBuffer();
|
||||
.order(data.order()).asShortBuffer();
|
||||
} else {
|
||||
newData = ShortBuffer.allocate(dataSize);
|
||||
}
|
||||
} else if (data instanceof IntBuffer) {
|
||||
|
||||
newData.position(0);
|
||||
short[] shorts = new short[dataBounds.width];
|
||||
for (int i = 0; i < dataBounds.height; ++i) {
|
||||
data.position((dataBounds.y * totalBounds.width + dataBounds.x) + i
|
||||
* totalBounds.width);
|
||||
data.get(shorts);
|
||||
newData.put(shorts);
|
||||
}
|
||||
newData.rewind();
|
||||
return newData;
|
||||
}
|
||||
|
||||
private static IntBuffer slice(IntBuffer data, Rectangle dataBounds,
|
||||
Rectangle totalBounds, int dataSize) {
|
||||
IntBuffer newData = null;
|
||||
// Get our new Buffer object
|
||||
if (data.isDirect()) {
|
||||
newData = ByteBuffer.allocateDirect(dataSize * 4)
|
||||
.order(ByteOrder.nativeOrder()).asIntBuffer();
|
||||
.order(data.order()).asIntBuffer();
|
||||
} else {
|
||||
newData = IntBuffer.allocate(dataSize);
|
||||
}
|
||||
} else if (data instanceof FloatBuffer) {
|
||||
|
||||
newData.position(0);
|
||||
int[] ints = new int[dataBounds.width];
|
||||
for (int i = 0; i < dataBounds.height; ++i) {
|
||||
data.position((dataBounds.y * totalBounds.width + dataBounds.x) + i
|
||||
* totalBounds.width);
|
||||
data.get(ints);
|
||||
newData.put(ints);
|
||||
}
|
||||
newData.rewind();
|
||||
return newData;
|
||||
}
|
||||
|
||||
private static FloatBuffer slice(FloatBuffer data, Rectangle dataBounds,
|
||||
Rectangle totalBounds, int dataSize) {
|
||||
FloatBuffer newData = null;
|
||||
// Get our new Buffer object
|
||||
if (data.isDirect()) {
|
||||
newData = ByteBuffer.allocateDirect(dataSize * 4)
|
||||
.order(ByteOrder.nativeOrder()).asFloatBuffer();
|
||||
.order(data.order()).asFloatBuffer();
|
||||
} else {
|
||||
newData = FloatBuffer.allocate(dataSize);
|
||||
}
|
||||
} else {
|
||||
// Unsupported type
|
||||
return data;
|
||||
}
|
||||
|
||||
// Synchronize on the data buffer if multi threads slicing same buffer
|
||||
// at the same time
|
||||
synchronized (data) {
|
||||
newData.position(0);
|
||||
for (int i = 0; i < dataBounds.height; ++i) {
|
||||
data.position((dataBounds.y * totalBounds.width + dataBounds.x)
|
||||
+ i * totalBounds.width);
|
||||
if (data instanceof ByteBuffer) {
|
||||
byte[] bytes = new byte[dataBounds.width];
|
||||
((ByteBuffer) data).get(bytes);
|
||||
((ByteBuffer) newData).put(bytes);
|
||||
} else if (data instanceof ShortBuffer) {
|
||||
short[] shorts = new short[dataBounds.width];
|
||||
((ShortBuffer) data).get(shorts);
|
||||
((ShortBuffer) newData).put(shorts);
|
||||
} else if (data instanceof IntBuffer) {
|
||||
int[] ints = new int[dataBounds.width];
|
||||
((IntBuffer) data).get(ints);
|
||||
((IntBuffer) newData).put(ints);
|
||||
} else {
|
||||
// FloatBuffer by default
|
||||
float[] floats = new float[dataBounds.width];
|
||||
((FloatBuffer) data).get(floats);
|
||||
((FloatBuffer) newData).put(floats);
|
||||
for (int i = 0; i < dataBounds.height; ++i) {
|
||||
data.position((dataBounds.y * totalBounds.width + dataBounds.x) + i
|
||||
* totalBounds.width);
|
||||
data.get(floats);
|
||||
newData.put(floats);
|
||||
}
|
||||
}
|
||||
}
|
||||
return newData.rewind();
|
||||
newData.rewind();
|
||||
return newData;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import com.raytheon.uf.common.status.UFStatus;
|
|||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.core.AbstractGraphicsFactoryAdapter;
|
||||
import com.raytheon.uf.viz.core.GraphicsFactory;
|
||||
import com.raytheon.uf.viz.core.IDisplayPane;
|
||||
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
||||
import com.raytheon.uf.viz.core.IExtent;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
|
@ -247,6 +246,7 @@ public abstract class AbstractRenderableDisplay implements IRenderableDisplay {
|
|||
this.descriptor = (AbstractDescriptor) desc;
|
||||
this.descriptor.getResourceList().addPostAddListener(this.listener);
|
||||
this.descriptor.getResourceList().addPostRemoveListener(this.listener);
|
||||
this.descriptor.setRenderableDisplay(this);
|
||||
|
||||
customizeResourceList(this.descriptor.getResourceList());
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ public abstract class AbstractRenderableDisplay implements IRenderableDisplay {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void clear(IDisplayPane parentPane) {
|
||||
public void clear() {
|
||||
|
||||
}
|
||||
|
||||
|
@ -562,7 +562,6 @@ public abstract class AbstractRenderableDisplay implements IRenderableDisplay {
|
|||
@Override
|
||||
public void setContainer(IDisplayPaneContainer container) {
|
||||
this.container = container;
|
||||
this.descriptor.setRenderableDisplay(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.eclipse.swt.graphics.RGB;
|
|||
import org.eclipse.swt.graphics.Rectangle;
|
||||
|
||||
import com.raytheon.uf.viz.core.AbstractGraphicsFactoryAdapter;
|
||||
import com.raytheon.uf.viz.core.IDisplayPane;
|
||||
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
||||
import com.raytheon.uf.viz.core.IExtent;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
|
@ -266,7 +265,7 @@ public interface IRenderableDisplay extends IRenderable {
|
|||
/**
|
||||
* Triggers the clearing of the RenderableDisplay
|
||||
*/
|
||||
public void clear(IDisplayPane parentPane);
|
||||
public void clear();
|
||||
|
||||
/**
|
||||
* Set the background color of the display
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
package com.raytheon.uf.viz.core.tile;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.nio.Buffer;
|
||||
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
|
||||
import com.raytheon.uf.viz.core.DrawableImage;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.RasterMode;
|
||||
import com.raytheon.uf.viz.core.IMesh;
|
||||
import com.raytheon.uf.viz.core.PixelCoverage;
|
||||
import com.raytheon.uf.viz.core.data.BufferSlicer;
|
||||
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback;
|
||||
import com.raytheon.uf.viz.core.drawables.IImage;
|
||||
import com.raytheon.uf.viz.core.drawables.ext.colormap.IColormappedImageExtension;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.map.IMapMeshExtension;
|
||||
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
|
||||
import com.raytheon.uf.viz.core.tile.TileSetRenderable.TileImageCreator;
|
||||
|
||||
/**
|
||||
* {@link TileImageCreator} for {@link TileSetRenderable} that creates image
|
||||
* tiles for Buffers. Only supports single level tiling
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 29, 2012 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
public class BufferTileImageCreator implements TileImageCreator {
|
||||
|
||||
private class BufferColorMapRetrievalCallback implements
|
||||
IColorMapDataRetrievalCallback {
|
||||
|
||||
private Rectangle slice;
|
||||
|
||||
private BufferColorMapRetrievalCallback(Rectangle slice) {
|
||||
this.slice = slice;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback#
|
||||
* getColorMapData()
|
||||
*/
|
||||
@Override
|
||||
public ColorMapData getColorMapData() throws VizException {
|
||||
return new ColorMapData(BufferSlicer.slice(buffer, slice,
|
||||
bufferBounds), new int[] { slice.width, slice.height });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Buffer buffer;
|
||||
|
||||
private Rectangle bufferBounds;
|
||||
|
||||
private ColorMapCapability cmapCapability;
|
||||
|
||||
public BufferTileImageCreator(Buffer buffer, Rectangle bufferBounds,
|
||||
ColorMapCapability cmapCapability) {
|
||||
this.buffer = buffer;
|
||||
this.bufferBounds = bufferBounds;
|
||||
this.cmapCapability = cmapCapability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DrawableImage createTileImage(IGraphicsTarget target, Tile tile,
|
||||
GeneralGridGeometry targetGeometry) throws VizException {
|
||||
if (tile.tileLevel != 0) {
|
||||
throw new VizException(getClass().getSimpleName()
|
||||
+ " only supports single level tiled data");
|
||||
}
|
||||
|
||||
IImage image = target
|
||||
.getExtension(IColormappedImageExtension.class)
|
||||
.initializeRaster(
|
||||
new BufferColorMapRetrievalCallback(tile.getRectangle()),
|
||||
cmapCapability.getColorMapParameters());
|
||||
IMesh mesh = target.getExtension(IMapMeshExtension.class)
|
||||
.constructMesh(tile.tileGeometry, targetGeometry);
|
||||
return new DrawableImage(image, new PixelCoverage(mesh),
|
||||
RasterMode.ASYNCHRONOUS);
|
||||
}
|
||||
}
|
|
@ -49,7 +49,6 @@ import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
|
|||
import com.raytheon.uf.viz.core.rsc.IResourceDataChanged;
|
||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
|
||||
import com.raytheon.uf.viz.core.status.StatusConstants;
|
||||
import com.raytheon.uf.viz.core.style.ParamLevelMatchCriteria;
|
||||
import com.raytheon.uf.viz.core.style.StyleManager;
|
||||
import com.raytheon.uf.viz.core.style.StyleRule;
|
||||
|
@ -79,7 +78,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
public class CWATResource extends
|
||||
AbstractVizResource<CWATResourceData, MapDescriptor> implements
|
||||
IResourceDataChanged {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(CWATResource.class);
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(CWATResource.class);
|
||||
|
||||
public String icao;
|
||||
|
||||
|
@ -206,9 +206,7 @@ public class CWATResource extends
|
|||
|
||||
if (gridDisplay == null) {
|
||||
gridDisplay = new GriddedImageDisplay2(ShortBuffer.wrap(record
|
||||
.getDataArray()), record.getGridGeometry(), this,
|
||||
target.getViewType());
|
||||
gridDisplay.init(target);
|
||||
.getDataArray()), record.getGridGeometry(), this);
|
||||
this.previousDataTime = displayedDataTime;
|
||||
griddedDisplayMap.put(displayedDataTime, gridDisplay);
|
||||
}
|
||||
|
@ -298,7 +296,7 @@ public class CWATResource extends
|
|||
for (DataTime dTime : griddedDisplayMap.keySet()) {
|
||||
GriddedImageDisplay2 gDisplay = griddedDisplayMap.get(dTime);
|
||||
if (gDisplay != null) {
|
||||
gDisplay.reproject();
|
||||
gDisplay.project(descriptor.getGridGeometry());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.viz.core.IDisplayPane;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.VizConstants;
|
||||
import com.raytheon.uf.viz.core.drawables.AbstractDescriptor;
|
||||
|
@ -267,8 +266,7 @@ public class D2DMapRenderableDisplay extends MapRenderableDisplay implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void clear(IDisplayPane parentPane) {
|
||||
super.clear(parentPane);
|
||||
public void clear() {
|
||||
descriptor.getResourceList().clear();
|
||||
File scaleFile = MapScales.getInstance().getScaleByName(getScale())
|
||||
.getFile();
|
||||
|
|
|
@ -49,7 +49,6 @@ import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
|
|||
import com.raytheon.uf.viz.core.rsc.IResourceDataChanged;
|
||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
|
||||
import com.raytheon.uf.viz.core.status.StatusConstants;
|
||||
import com.raytheon.uf.viz.core.style.ParamLevelMatchCriteria;
|
||||
import com.raytheon.uf.viz.core.style.StyleManager;
|
||||
import com.raytheon.uf.viz.core.style.StyleRule;
|
||||
|
@ -79,7 +78,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
public class VILResource extends
|
||||
AbstractVizResource<VILResourceData, MapDescriptor> implements
|
||||
IResourceDataChanged {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(VILResource.class);
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(VILResource.class);
|
||||
|
||||
public String icao;
|
||||
|
||||
|
@ -218,9 +218,7 @@ public class VILResource extends
|
|||
gridDisplay = griddedDisplayMap.get(displayedDataTime);
|
||||
if (gridDisplay == null) {
|
||||
gridDisplay = new GriddedImageDisplay2(FloatBuffer.wrap(record
|
||||
.getDataArray()), record.getGridGeometry(), this,
|
||||
target.getViewType());
|
||||
gridDisplay.init(target);
|
||||
.getDataArray()), record.getGridGeometry(), this);
|
||||
this.previousDataTime = displayedDataTime;
|
||||
griddedDisplayMap.put(displayedDataTime, gridDisplay);
|
||||
}
|
||||
|
@ -334,7 +332,7 @@ public class VILResource extends
|
|||
for (DataTime dTime : griddedDisplayMap.keySet()) {
|
||||
GriddedImageDisplay2 gDisplay = griddedDisplayMap.get(dTime);
|
||||
if (gDisplay != null) {
|
||||
gDisplay.reproject();
|
||||
gDisplay.project(descriptor.getGridGeometry());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import com.raytheon.uf.viz.core.IDisplayPane;
|
||||
import com.raytheon.uf.viz.core.IExtent;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.VizConstants;
|
||||
|
@ -136,8 +135,8 @@ public abstract class AbstractXyRenderableDisplay extends
|
|||
}
|
||||
|
||||
@Override
|
||||
public void clear(IDisplayPane parentPane) {
|
||||
super.clear(parentPane);
|
||||
public void clear() {
|
||||
super.clear();
|
||||
IWorkbenchPage page = PlatformUI.getWorkbench()
|
||||
.getActiveWorkbenchWindow().getActivePage();
|
||||
page.closeEditor(getEditor(), false);
|
||||
|
|
|
@ -56,6 +56,26 @@ public abstract class AbstractGLColorMapDataFormat {
|
|||
*/
|
||||
public abstract int getTextureInternalFormat();
|
||||
|
||||
/**
|
||||
* Gets the absolute minimum value a pixel can have in this format. For
|
||||
* example, the minimum value for an unsigned byte is 0, signed byte is
|
||||
* -127, etc. {@link Double#NaN} can be returned in case no absolute minimum
|
||||
* exists (such as case with floats and doubles)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract double getDataFormatMin();
|
||||
|
||||
/**
|
||||
* Gets the absolute maximum value a pixel can have in this format. For
|
||||
* example, the minimum value for an unsigned byte is 255, signed byte is
|
||||
* 128, etc. {@link Double#NaN} can be returned in case no absolute maximum
|
||||
* exists (such as case with floats and doubles)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract double getDataFormatMax();
|
||||
|
||||
/**
|
||||
* Create a buffer object for specified data for copying data from out of GL
|
||||
*
|
||||
|
|
|
@ -66,6 +66,28 @@ public class GLByteDataFormat extends AbstractGLColorMapDataFormat {
|
|||
return GL.GL_LUMINANCE8;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.gl.dataformat.AbstractGLColorMapDataFormat#
|
||||
* getDataFormatMin()
|
||||
*/
|
||||
@Override
|
||||
public double getDataFormatMin() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.gl.dataformat.AbstractGLColorMapDataFormat#
|
||||
* getDataFormatMax()
|
||||
*/
|
||||
@Override
|
||||
public double getDataFormatMax() {
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
|
|
@ -43,7 +43,7 @@ import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback.ColorMapData
|
|||
*/
|
||||
public class GLColorMapData {
|
||||
|
||||
private AbstractGLColorMapDataFormat dataFormat;
|
||||
private final AbstractGLColorMapDataFormat dataFormat;
|
||||
|
||||
private Buffer data;
|
||||
|
||||
|
@ -55,8 +55,8 @@ public class GLColorMapData {
|
|||
|
||||
public GLColorMapData(ColorMapData cmData,
|
||||
AbstractGLColorMapDataFormat dataFormat) {
|
||||
this.dimensions = cmData.getDimensions();
|
||||
this.dataFormat = dataFormat;
|
||||
this.dimensions = cmData.getDimensions();
|
||||
this.dataType = cmData.getDataType();
|
||||
this.textureType = dataFormat.getTextureType();
|
||||
this.data = dataFormat.formatForGL(cmData.getBuffer(), this);
|
||||
|
@ -94,6 +94,14 @@ public class GLColorMapData {
|
|||
return dataFormat.getCopyBackTextureType();
|
||||
}
|
||||
|
||||
public double getDataFormatMin() {
|
||||
return dataFormat.getDataFormatMin();
|
||||
}
|
||||
|
||||
public double getDataFormatMax() {
|
||||
return dataFormat.getDataFormatMax();
|
||||
}
|
||||
|
||||
public Buffer getCopybackBuffer() {
|
||||
return dataFormat.getCopybackBuffer(this);
|
||||
}
|
||||
|
|
|
@ -58,6 +58,28 @@ public class GLFloatDataFormat extends AbstractGLColorMapDataFormat {
|
|||
return GL.GL_FLOAT;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.gl.dataformat.AbstractGLColorMapDataFormat#
|
||||
* getDataFormatMin()
|
||||
*/
|
||||
@Override
|
||||
public double getDataFormatMin() {
|
||||
return Double.NaN;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.gl.dataformat.AbstractGLColorMapDataFormat#
|
||||
* getDataFormatMax()
|
||||
*/
|
||||
@Override
|
||||
public double getDataFormatMax() {
|
||||
return Double.NaN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloatBuffer getCopybackBuffer(GLColorMapData data) {
|
||||
int width = data.getDimensionSize(0);
|
||||
|
|
|
@ -67,6 +67,28 @@ public class GLHalfFloatDataFormat extends AbstractGLColorMapDataFormat {
|
|||
return GL.GL_HALF_FLOAT_ARB;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.gl.dataformat.AbstractGLColorMapDataFormat#
|
||||
* getDataFormatMin()
|
||||
*/
|
||||
@Override
|
||||
public double getDataFormatMin() {
|
||||
return Double.NaN;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.gl.dataformat.AbstractGLColorMapDataFormat#
|
||||
* getDataFormatMax()
|
||||
*/
|
||||
@Override
|
||||
public double getDataFormatMax() {
|
||||
return Double.NaN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShortBuffer getCopybackBuffer(GLColorMapData data) {
|
||||
int width = getAlignedWidth(data.getDimensionSize(0));
|
||||
|
|
|
@ -63,6 +63,28 @@ public class GLIntDataFormat extends AbstractGLColorMapDataFormat {
|
|||
return GL.GL_UNSIGNED_INT;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.gl.dataformat.AbstractGLColorMapDataFormat#
|
||||
* getDataFormatMin()
|
||||
*/
|
||||
@Override
|
||||
public double getDataFormatMin() {
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.gl.dataformat.AbstractGLColorMapDataFormat#
|
||||
* getDataFormatMax()
|
||||
*/
|
||||
@Override
|
||||
public double getDataFormatMax() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntBuffer getCopybackBuffer(GLColorMapData data) {
|
||||
int width = data.getDimensionSize(0);
|
||||
|
|
|
@ -62,6 +62,28 @@ public class GLShortDataFormat extends AbstractGLColorMapDataFormat {
|
|||
return GL.GL_UNSIGNED_SHORT;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.gl.dataformat.AbstractGLColorMapDataFormat#
|
||||
* getDataFormatMin()
|
||||
*/
|
||||
@Override
|
||||
public double getDataFormatMin() {
|
||||
return Short.MIN_VALUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.gl.dataformat.AbstractGLColorMapDataFormat#
|
||||
* getDataFormatMax()
|
||||
*/
|
||||
@Override
|
||||
public double getDataFormatMax() {
|
||||
return Short.MAX_VALUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
|
|
@ -72,6 +72,28 @@ public class GLSignedByteDataFormat extends GLByteDataFormat {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.core.gl.dataformat.GLByteDataFormat#getDataFormatMin()
|
||||
*/
|
||||
@Override
|
||||
public double getDataFormatMin() {
|
||||
return Byte.MIN_VALUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.core.gl.dataformat.GLByteDataFormat#getDataFormatMax()
|
||||
*/
|
||||
@Override
|
||||
public double getDataFormatMax() {
|
||||
return Byte.MAX_VALUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
|
|
@ -53,6 +53,28 @@ public class GLUnsignedShortDataFormat extends GLShortDataFormat {
|
|||
return GL.GL_UNSIGNED_SHORT;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.gl.dataformat.AbstractGLColorMapDataFormat#
|
||||
* getDataFormatMin()
|
||||
*/
|
||||
@Override
|
||||
public double getDataFormatMin() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.core.gl.dataformat.AbstractGLColorMapDataFormat#
|
||||
* getDataFormatMax()
|
||||
*/
|
||||
@Override
|
||||
public double getDataFormatMax() {
|
||||
return 0xFFFF;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
|
|
@ -192,6 +192,14 @@ public class GLCMTextureData implements IImageCacheable {
|
|||
return data.getTextureInternalFormat();
|
||||
}
|
||||
|
||||
public double getDataMin() {
|
||||
return data.getDataFormatMin();
|
||||
}
|
||||
|
||||
public double getDataMax() {
|
||||
return data.getDataFormatMax();
|
||||
}
|
||||
|
||||
public int getTexId() {
|
||||
if (isLoaded()) {
|
||||
ImageCache.getInstance(CacheType.TEXTURE).put(this);
|
||||
|
|
|
@ -140,6 +140,26 @@ public class GLColormappedImage extends AbstractGLImage implements
|
|||
return data.getTexId();
|
||||
}
|
||||
|
||||
/**
|
||||
* the absolute minimum value of a pixel in this image. {@link Double#NaN}
|
||||
* if no absolute minimum exists
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public double getDataMin() {
|
||||
return data.getDataMin();
|
||||
}
|
||||
|
||||
/**
|
||||
* the absolute maximum value of a pixel in this image. {@link Double#NaN}
|
||||
* if no absolute maximum exists
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public double getDataMax() {
|
||||
return data.getDataMax();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
|
|
@ -208,9 +208,18 @@ public class GLColormappedImageExtension extends AbstractGLSLImagingExtension
|
|||
|
||||
program.setUniform("colorMapSz", colorMapParameters.getColorMap()
|
||||
.getSize());
|
||||
int textureType = ((GLColormappedImage) image).getTextureType();
|
||||
program.setUniform("isFloat", textureType == GL.GL_FLOAT
|
||||
|| textureType == GL.GL_HALF_FLOAT_ARB ? 1 : 0);
|
||||
int textureType = image.getTextureType();
|
||||
boolean isFloat = textureType == GL.GL_FLOAT
|
||||
|| textureType == GL.GL_HALF_FLOAT_ARB;
|
||||
double dataMin = colorMapParameters.getDataMin();
|
||||
double dataMax = colorMapParameters.getDataMax();
|
||||
if (isFloat == false) {
|
||||
// get format from image and get data min/max from it
|
||||
dataMin = image.getDataMin();
|
||||
dataMax = image.getDataMax();
|
||||
}
|
||||
|
||||
program.setUniform("isFloat", isFloat);
|
||||
program.setUniform("logarithmic",
|
||||
colorMapParameters.isLogarithmic() ? 1 : 0);
|
||||
program.setUniform("logFactor", colorMapParameters.getLogFactor());
|
||||
|
@ -218,8 +227,8 @@ public class GLColormappedImageExtension extends AbstractGLSLImagingExtension
|
|||
|
||||
program.setUniform("applyMask", colorMapParameters.isUseMask() ? 1 : 0);
|
||||
|
||||
program.setUniform("naturalMin", colorMapParameters.getDataMin());
|
||||
program.setUniform("naturalMax", colorMapParameters.getDataMax());
|
||||
program.setUniform("naturalMin", dataMin);
|
||||
program.setUniform("naturalMax", dataMax);
|
||||
program.setUniform("cmapMin", colorMapParameters.getColorMapMin());
|
||||
program.setUniform("cmapMax", colorMapParameters.getColorMapMax());
|
||||
|
||||
|
|
|
@ -19,48 +19,40 @@
|
|||
**/
|
||||
package com.raytheon.viz.core.rsc.displays;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.nio.Buffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
|
||||
import com.raytheon.uf.common.datastorage.StorageException;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.data.IDataPreparer;
|
||||
import com.raytheon.uf.viz.core.data.prep.CMDataPreparerManager;
|
||||
import com.raytheon.uf.viz.core.drawables.IImage;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.map.IMapDescriptor;
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
|
||||
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
|
||||
import com.raytheon.viz.core.rsc.hdf5.AbstractTileSet;
|
||||
import com.raytheon.uf.viz.core.rsc.capabilities.ImagingCapability;
|
||||
import com.raytheon.uf.viz.core.tile.BufferTileImageCreator;
|
||||
import com.raytheon.uf.viz.core.tile.TileSetRenderable;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* Gridded Buffer object, just a convenience class for thing already using it.
|
||||
* Just extends {@link TileSetRenderable} and uses the
|
||||
* {@link BufferTileImageCreator} as the {@link TileImageCreator} for the
|
||||
* {@link TileSetRenderable}. Also projects on construction as convenience so
|
||||
* creators don't have to
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 27, 2008 randerso Initial creation
|
||||
* Feb 01, 2011 #4237 ekladstrup Rewrite to extend AbstractTileSet
|
||||
* Dec 11, 2012 mschenke Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author randerso
|
||||
* @version 2.0
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class GriddedImageDisplay2 extends AbstractTileSet {
|
||||
|
||||
private Buffer data;
|
||||
|
||||
private DataType dataType = null;
|
||||
|
||||
private static enum DataType {
|
||||
BYTE, FLOAT, INT, SHORT
|
||||
}
|
||||
public class GriddedImageDisplay2 extends TileSetRenderable {
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -75,12 +67,13 @@ public class GriddedImageDisplay2 extends AbstractTileSet {
|
|||
*/
|
||||
public GriddedImageDisplay2(int size, Buffer data,
|
||||
GridGeometry2D gridGeometry,
|
||||
AbstractVizResource<?, ? extends IMapDescriptor> rsc,
|
||||
String viewType) throws VizException {
|
||||
super(1, size, gridGeometry, rsc, viewType);
|
||||
this.setMapDescriptor(rsc.getDescriptor());
|
||||
this.data = data;
|
||||
setDataType();
|
||||
AbstractVizResource<?, ? extends IMapDescriptor> rsc)
|
||||
throws VizException {
|
||||
super(rsc.getCapability(ImagingCapability.class), gridGeometry,
|
||||
new BufferTileImageCreator(data, gridGeometry.getGridRange2D()
|
||||
.getBounds(),
|
||||
rsc.getCapability(ColorMapCapability.class)), 1, size);
|
||||
project(rsc.getDescriptor().getGridGeometry());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,166 +86,9 @@ public class GriddedImageDisplay2 extends AbstractTileSet {
|
|||
* @throws VizException
|
||||
*/
|
||||
public GriddedImageDisplay2(Buffer data, GridGeometry2D gridGeometry,
|
||||
AbstractVizResource<?, ? extends IMapDescriptor> rsc,
|
||||
String viewType) throws VizException {
|
||||
super(1, 512, gridGeometry, rsc, viewType);
|
||||
this.setMapDescriptor(rsc.getDescriptor());
|
||||
this.data = data;
|
||||
setDataType();
|
||||
}
|
||||
|
||||
private void setDataType() {
|
||||
Object arr = data.array();
|
||||
|
||||
if (arr instanceof byte[]) {
|
||||
dataType = DataType.BYTE;
|
||||
} else if (arr instanceof float[]) {
|
||||
dataType = DataType.FLOAT;
|
||||
} else if (arr instanceof int[]) {
|
||||
dataType = DataType.INT;
|
||||
} else if (arr instanceof short[]) {
|
||||
dataType = DataType.SHORT;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preloadDataObject(int level) throws StorageException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDataPreloaded(int level) {
|
||||
// TODO Auto-generated method stub
|
||||
if (level == 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IImage createTile(IGraphicsTarget target, int level, int i, int j)
|
||||
AbstractVizResource<?, ? extends IMapDescriptor> rsc)
|
||||
throws VizException {
|
||||
|
||||
if (dataType == null) {
|
||||
throw new VizException("Unsupported buffer type used");
|
||||
this(512, data, gridGeometry, rsc);
|
||||
}
|
||||
|
||||
// tile bounds
|
||||
Rectangle rect = this.tileSet.getTileSet().get(level)[i][j]
|
||||
.getRectangle();
|
||||
// total width
|
||||
int width = gridGeometry[level].getGridRange().getSpan(0);
|
||||
IImage image = null;
|
||||
switch (dataType) {
|
||||
case BYTE: {
|
||||
throw new VizException("Unsupported buffer type used (BYTE)");
|
||||
// image = createByteTile(target, rect, width, i, j);
|
||||
// break;
|
||||
}
|
||||
case FLOAT: {
|
||||
image = createFloatTile(target, rect, width, i, j);
|
||||
break;
|
||||
}
|
||||
case INT: {
|
||||
throw new VizException("Unsupported buffer type used (INT)");
|
||||
// image = createIntTile(target, rect, width, i, j);
|
||||
// break;
|
||||
}
|
||||
case SHORT: {
|
||||
// throw new VizException("Unsupported buffer type used (SHORT)");
|
||||
image = createShortTile(target, rect, width, i, j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
private IImage createShortTile(IGraphicsTarget target, Rectangle rect,
|
||||
int width, int i, int j) {
|
||||
// buffer to copy into
|
||||
short[] dest = new short[rect.width * rect.height];
|
||||
ShortBuffer srcBuff = (ShortBuffer) data;
|
||||
|
||||
short[] tmp = new short[rect.width];
|
||||
int initSize = tileSize * j * width;
|
||||
|
||||
for (int r = 0; r < rect.height; r++) {
|
||||
int curY = (r * width) + initSize;
|
||||
synchronized (this) {
|
||||
srcBuff.position(curY + rect.x);
|
||||
|
||||
srcBuff.get(tmp);
|
||||
}
|
||||
|
||||
for (int destIndex = r * rect.width; destIndex < (r * rect.width)
|
||||
+ rect.width; ++destIndex) {
|
||||
dest[destIndex] = tmp[destIndex - (r * rect.width)];
|
||||
}
|
||||
}
|
||||
|
||||
ShortBuffer destBuff = ShortBuffer.wrap(dest);
|
||||
|
||||
return generateImage(destBuff, target, rect);
|
||||
}
|
||||
|
||||
private IImage createIntTile(IGraphicsTarget target, Rectangle rect,
|
||||
int width, int i, int j) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private IImage createFloatTile(IGraphicsTarget target, Rectangle rect,
|
||||
int width, int i, int j) {
|
||||
|
||||
// buffer to copy into
|
||||
FloatBuffer destBuff = FloatBuffer.allocate(rect.width * rect.height);
|
||||
FloatBuffer srcBuff = (FloatBuffer) data;
|
||||
|
||||
float[] tmp = new float[rect.width];
|
||||
int initSize = tileSize * j * width;
|
||||
|
||||
for (int r = 0; r < rect.height; r++) {
|
||||
int curY = (r * width) + initSize;
|
||||
synchronized (this) {
|
||||
srcBuff.position(curY + rect.x);
|
||||
|
||||
srcBuff.get(tmp);
|
||||
}
|
||||
|
||||
destBuff.put(tmp);
|
||||
}
|
||||
|
||||
return generateImage(destBuff, target, rect);
|
||||
}
|
||||
|
||||
private IImage createByteTile(IGraphicsTarget target, Rectangle rect,
|
||||
int width, int i, int j) {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected IImage generateImage(Buffer tileData, IGraphicsTarget target,
|
||||
Rectangle rect) {
|
||||
|
||||
// create image at i,j index
|
||||
int[] dims = { rect.width, rect.height };
|
||||
IDataPreparer preparer = CMDataPreparerManager.getDataPreparer(
|
||||
tileData, rect, dims);
|
||||
|
||||
return target.initializeRaster(preparer,
|
||||
rsc.getCapability(ColorMapCapability.class)
|
||||
.getColorMapParameters());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelRequest(int level, int i, int j) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the data
|
||||
*/
|
||||
public Buffer getData() {
|
||||
return data;
|
||||
}
|
||||
}
|
|
@ -476,8 +476,7 @@ public abstract class AbstractGridResource<T extends AbstractResourceData>
|
|||
.getColorMapParameters();
|
||||
data.convert(params.getImageUnit());
|
||||
GriddedImageDisplay2 imageRenderable = new GriddedImageDisplay2(
|
||||
data.getScalarData(), gridGeometry, this, "2D");
|
||||
imageRenderable.init(target);
|
||||
data.getScalarData(), gridGeometry, this);
|
||||
renderable = imageRenderable;
|
||||
break;
|
||||
case BARB:
|
||||
|
@ -730,7 +729,8 @@ public abstract class AbstractGridResource<T extends AbstractResourceData>
|
|||
protected boolean projectRenderable(IRenderable renderable,
|
||||
CoordinateReferenceSystem crs) throws VizException {
|
||||
if (renderable instanceof GriddedImageDisplay2) {
|
||||
((GriddedImageDisplay2) renderable).reproject();
|
||||
((GriddedImageDisplay2) renderable).project(descriptor
|
||||
.getGridGeometry());
|
||||
return true;
|
||||
} else if (renderable instanceof AbstractGriddedDisplay<?>) {
|
||||
((AbstractGriddedDisplay<?>) renderable).reproject();
|
||||
|
|
|
@ -298,10 +298,7 @@ public class FFGGridResource extends
|
|||
}
|
||||
|
||||
if (gridDisplay == null) {
|
||||
gridDisplay = new GriddedImageDisplay2(buf, gridGeometry, this,
|
||||
target.getViewType());
|
||||
gridDisplay.init(target);
|
||||
|
||||
gridDisplay = new GriddedImageDisplay2(buf, gridGeometry, this);
|
||||
}
|
||||
|
||||
gridDisplay.paint(target, paintProps);
|
||||
|
|
|
@ -38,9 +38,9 @@ import org.geotools.coverage.grid.GridGeometry2D;
|
|||
import org.geotools.coverage.grid.InvalidGridGeometryException;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue;
|
||||
import com.raytheon.uf.common.colormap.Color;
|
||||
import com.raytheon.uf.common.colormap.ColorMap;
|
||||
import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue;
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.raytheon.uf.common.hydro.spatial.HRAPCoordinates;
|
||||
import com.raytheon.uf.common.hydro.spatial.HRAPSubGrid;
|
||||
|
@ -231,8 +231,8 @@ public class MeanArealPrecipResource extends
|
|||
meanAreaNodes = (ArrayList<GeoAreaLineSegs>) GeoUtil.getInstance()
|
||||
.getGeoAreaLinesegs(areaType);
|
||||
if (extent != null) {
|
||||
compute_mean_areal_precip(buf, meanAreaNodes, xor, yor, max_columns,
|
||||
max_rows);
|
||||
compute_mean_areal_precip(buf, meanAreaNodes, xor, yor,
|
||||
max_columns, max_rows);
|
||||
try {
|
||||
subGrid = new HRAPSubGrid(extent);
|
||||
} catch (Exception e) {
|
||||
|
@ -516,9 +516,7 @@ public class MeanArealPrecipResource extends
|
|||
// target.setUseBuiltinColorbar(false);
|
||||
|
||||
if (gridDisplay == null) {
|
||||
gridDisplay = new GriddedImageDisplay2(buf2, gridGeometry, this,
|
||||
target.getViewType());
|
||||
gridDisplay.init(target);
|
||||
gridDisplay = new GriddedImageDisplay2(buf2, gridGeometry, this);
|
||||
}
|
||||
|
||||
gridDisplay.paint(target, paintProps);
|
||||
|
@ -594,7 +592,8 @@ public class MeanArealPrecipResource extends
|
|||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(dman.getAccumInterval()
|
||||
+ " hr Accumulated Best Estimate QPE Ending "
|
||||
+ HydroConstants.DISPLAY_DATE_FORMAT.format(dman.getDataDate())+"z (in)");
|
||||
+ HydroConstants.DISPLAY_DATE_FORMAT.format(dman.getDataDate())
|
||||
+ "z (in)");
|
||||
|
||||
if (noData) {
|
||||
sb.append(" No Data Available");
|
||||
|
@ -649,7 +648,7 @@ public class MeanArealPrecipResource extends
|
|||
@Override
|
||||
public void project(CoordinateReferenceSystem crs) throws VizException {
|
||||
if (gridDisplay != null) {
|
||||
gridDisplay.reproject();
|
||||
gridDisplay.project(descriptor.getGridGeometry());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -387,9 +387,7 @@ public class RFCGriddedBasinFFGResource extends
|
|||
}
|
||||
|
||||
if (gridDisplay == null) {
|
||||
gridDisplay = new GriddedImageDisplay2(buf, gridGeometry, this,
|
||||
target.getViewType());
|
||||
gridDisplay.init(target);
|
||||
gridDisplay = new GriddedImageDisplay2(buf, gridGeometry, this);
|
||||
}
|
||||
|
||||
gridDisplay.paint(target, paintProps);
|
||||
|
|
|
@ -235,13 +235,14 @@ public class XmrgResource extends
|
|||
name = "FFG No Data Available";
|
||||
} else {
|
||||
name = "FFG " + res.getResolution() + " " + hours + " "
|
||||
+ hourStr + " " + sdf.format(dataDate)+"z (in)" + noData;
|
||||
+ hourStr + " " + sdf.format(dataDate) + "z (in)"
|
||||
+ noData;
|
||||
}
|
||||
} else {
|
||||
name = dman.getAccumInterval()
|
||||
+ " hr Accumulated Best Estimate QPE Ending "
|
||||
+ HydroConstants.DISPLAY_DATE_FORMAT.format(dman
|
||||
.getDataDate()) +"z (in)"+ noData;
|
||||
.getDataDate()) + "z (in)" + noData;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
@ -484,9 +485,7 @@ public class XmrgResource extends
|
|||
}
|
||||
|
||||
if (gridDisplay == null) {
|
||||
gridDisplay = new GriddedImageDisplay2(buf, gridGeometry, this,
|
||||
target.getViewType());
|
||||
gridDisplay.init(target);
|
||||
gridDisplay = new GriddedImageDisplay2(buf, gridGeometry, this);
|
||||
}
|
||||
|
||||
GriddedImagePaintProperties giProps = new GriddedImagePaintProperties(
|
||||
|
|
|
@ -40,9 +40,9 @@ import org.geotools.coverage.grid.GridGeometry2D;
|
|||
import org.geotools.coverage.grid.InvalidGridGeometryException;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue;
|
||||
import com.raytheon.uf.common.colormap.Color;
|
||||
import com.raytheon.uf.common.colormap.ColorMap;
|
||||
import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue;
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.raytheon.uf.common.hydro.spatial.HRAPCoordinates;
|
||||
import com.raytheon.uf.common.hydro.spatial.HRAPSubGrid;
|
||||
|
@ -375,9 +375,7 @@ public class DisplayMeanArealPrecipResource extends
|
|||
|
||||
if (mode.contains(DisplayMode.Image)) {
|
||||
if (gridDisplay == null) {
|
||||
gridDisplay = new GriddedImageDisplay2(buf2, gridGeometry,
|
||||
this, target.getViewType());
|
||||
gridDisplay.init(target);
|
||||
gridDisplay = new GriddedImageDisplay2(buf2, gridGeometry, this);
|
||||
}
|
||||
|
||||
gridDisplay.paint(target, paintProps);
|
||||
|
|
|
@ -479,9 +479,7 @@ public class PlotGriddedPrecipResource extends
|
|||
|
||||
if (mode.contains(DisplayMode.Image)) {
|
||||
if (gridDisplay == null) {
|
||||
gridDisplay = new GriddedImageDisplay2(buf, gridGeometry, this,
|
||||
target.getViewType());
|
||||
gridDisplay.init(target);
|
||||
gridDisplay = new GriddedImageDisplay2(buf, gridGeometry, this);
|
||||
// gridDisplay.setColorMapParameters(getCapability(
|
||||
// ColorMapCapability.class).getColorMapParameters());
|
||||
}
|
||||
|
|
|
@ -452,9 +452,7 @@ public class PlotGriddedTempResource extends
|
|||
|
||||
if (mode.contains(DisplayMode.Image)) {
|
||||
if (gridDisplay == null) {
|
||||
gridDisplay = new GriddedImageDisplay2(buf, gridGeometry, this,
|
||||
target.getViewType());
|
||||
gridDisplay.init(target);
|
||||
gridDisplay = new GriddedImageDisplay2(buf, gridGeometry, this);
|
||||
// gridDisplay.setColorMapParameters(getCapability(
|
||||
// ColorMapCapability.class).getColorMapParameters());
|
||||
}
|
||||
|
|
|
@ -41,9 +41,9 @@ import org.eclipse.swt.graphics.RGB;
|
|||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue;
|
||||
import com.raytheon.uf.common.colormap.Color;
|
||||
import com.raytheon.uf.common.colormap.ColorMap;
|
||||
import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue;
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.raytheon.uf.common.hydro.spatial.HRAPCoordinates;
|
||||
import com.raytheon.uf.common.hydro.spatial.HRAPSubGrid;
|
||||
|
@ -350,8 +350,7 @@ public class TimeLapseResource extends
|
|||
if (gridDisplay == null) {
|
||||
GriddedImageData dat = dataMap.get(displayedDate);
|
||||
gridDisplay = new GriddedImageDisplay2(dat.buff, dat.geometry,
|
||||
this, target.getViewType());
|
||||
gridDisplay.init(target);
|
||||
this);
|
||||
|
||||
bufferMap.put(displayedDate, gridDisplay);
|
||||
// project(gridGeometry.getCoordinateReferenceSystem());
|
||||
|
@ -389,7 +388,7 @@ public class TimeLapseResource extends
|
|||
for (DataTime dTime : bufferMap.keySet()) {
|
||||
GriddedImageDisplay2 gDisplay = bufferMap.get(dTime);
|
||||
if (gDisplay != null) {
|
||||
gDisplay.reproject();
|
||||
gDisplay.project(descriptor.getGridGeometry());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -464,10 +464,7 @@ public class XmrgResource extends
|
|||
|
||||
if (mode.contains(DisplayMode.Image)) {
|
||||
if (gridDisplay == null) {
|
||||
gridDisplay = new GriddedImageDisplay2(buf, gridGeometry, this,
|
||||
target.getViewType());
|
||||
gridDisplay.init(target);
|
||||
|
||||
gridDisplay = new GriddedImageDisplay2(buf, gridGeometry, this);
|
||||
}
|
||||
|
||||
GriddedImagePaintProperties giProps = new GriddedImagePaintProperties(
|
||||
|
@ -582,9 +579,9 @@ public class XmrgResource extends
|
|||
} else if (s > 0 && s <= 24) {
|
||||
s = 0;
|
||||
}
|
||||
if ((cv_use.equalsIgnoreCase("Locbias") || cv_use.equalsIgnoreCase("height") || cv_use.equalsIgnoreCase("locspan") ||
|
||||
tempsval == -1))
|
||||
{
|
||||
if ((cv_use.equalsIgnoreCase("Locbias")
|
||||
|| cv_use.equalsIgnoreCase("height")
|
||||
|| cv_use.equalsIgnoreCase("locspan") || tempsval == -1)) {
|
||||
f = (float) parameters.getDataToDisplayConverter()
|
||||
.convert(s);
|
||||
} else {
|
||||
|
|
|
@ -63,7 +63,6 @@ import org.eclipse.ui.IWorkbenchPage;
|
|||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.viz.core.IDisplayPane;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.PixelExtent;
|
||||
import com.raytheon.uf.viz.core.VizConstants;
|
||||
|
@ -324,8 +323,8 @@ public class SkewtDisplay extends AbstractRenderableDisplay implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void clear(IDisplayPane parentPane) {
|
||||
super.clear(parentPane);
|
||||
public void clear() {
|
||||
super.clear();
|
||||
IWorkbenchPage page = PlatformUI.getWorkbench()
|
||||
.getActiveWorkbenchWindow().getActivePage();
|
||||
page.closeEditor(getEditor(), false);
|
||||
|
|
|
@ -339,9 +339,18 @@ public class UiUtil {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the currently active window
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static IWorkbenchWindow getCurrentWindow() {
|
||||
return VizWorkbenchManager.getInstance().getCurrentWindow();
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the editor id and the renderable displays, create or open an editor
|
||||
* with the given displays
|
||||
* with the given displays on the active window
|
||||
*
|
||||
* @param editor
|
||||
* @param displays
|
||||
|
@ -349,10 +358,28 @@ public class UiUtil {
|
|||
*/
|
||||
public static AbstractEditor createOrOpenEditor(String editor,
|
||||
IRenderableDisplay... displays) {
|
||||
return createOrOpenEditor(getCurrentWindow(), editor, displays);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the editor id and the renderable displays, create or open an editor
|
||||
* with the given displays on the specified window
|
||||
*
|
||||
* @param windowToLoadTo
|
||||
* @param editor
|
||||
* @param displays
|
||||
* @return the created or opened editor
|
||||
*/
|
||||
public static AbstractEditor createOrOpenEditor(
|
||||
IWorkbenchWindow windowToLoadTo, String editor,
|
||||
IRenderableDisplay... displays) {
|
||||
String editorName = (editor == null ? "com.raytheon.viz.ui.glmap.GLMapEditor"
|
||||
: editor);
|
||||
if (windowToLoadTo == null) {
|
||||
windowToLoadTo = getCurrentWindow();
|
||||
}
|
||||
// Check the current editor first
|
||||
IEditorPart ep = EditorUtil.getActiveEditor();
|
||||
IEditorPart ep = EditorUtil.getActiveEditor(windowToLoadTo);
|
||||
if (ep instanceof AbstractEditor) {
|
||||
AbstractEditor currentEditor = (AbstractEditor) ep;
|
||||
if (currentEditor != null
|
||||
|
@ -364,8 +391,7 @@ public class UiUtil {
|
|||
}
|
||||
}
|
||||
|
||||
IWorkbenchPage activePage = PlatformUI.getWorkbench()
|
||||
.getActiveWorkbenchWindow().getActivePage();
|
||||
IWorkbenchPage activePage = windowToLoadTo.getActivePage();
|
||||
IEditorReference[] references = new IEditorReference[0];
|
||||
if (activePage != null) {
|
||||
references = activePage.getEditorReferences();
|
||||
|
@ -374,18 +400,12 @@ public class UiUtil {
|
|||
for (IEditorReference ref : references) {
|
||||
if (editorName.equals(ref.getId())) {
|
||||
IEditorPart editorPart = ref.getEditor(false);
|
||||
// IMultiPaneEditor multiPane = editorPart instanceof
|
||||
// IMultiPaneEditor ? (IMultiPaneEditor) editorPart
|
||||
// : null;
|
||||
if (editorPart instanceof AbstractEditor) {
|
||||
AbstractEditor aEditor = (AbstractEditor) editorPart;
|
||||
aEditor = makeCompatible(aEditor, displays);
|
||||
if (aEditor != null) {
|
||||
|
||||
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getActivePage().bringToTop(editorPart);
|
||||
activePage.bringToTop(aEditor);
|
||||
return aEditor;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -393,7 +413,7 @@ public class UiUtil {
|
|||
|
||||
// If we get here, the editor isn't there, or has a different number of
|
||||
// panes... construct it
|
||||
return createEditor(editorName, displays);
|
||||
return createEditor(windowToLoadTo, editorName, displays);
|
||||
}
|
||||
|
||||
private static AbstractEditor makeCompatible(AbstractEditor currentEditor,
|
||||
|
@ -428,7 +448,8 @@ public class UiUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Given the editor id and displays, create the editor
|
||||
* Opens a new editor with the specified displays on the currently active
|
||||
* window
|
||||
*
|
||||
* @param editor
|
||||
* @param displays
|
||||
|
@ -436,13 +457,28 @@ public class UiUtil {
|
|||
*/
|
||||
public static AbstractEditor createEditor(String editor,
|
||||
IRenderableDisplay... displays) {
|
||||
return createEditor(getCurrentWindow(), editor, displays);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a new editor with the specified displays on the specified window
|
||||
*
|
||||
* @param windowToLoadTo
|
||||
* @param editor
|
||||
* @param displays
|
||||
* @return
|
||||
*/
|
||||
public static AbstractEditor createEditor(IWorkbenchWindow windowToLoadTo,
|
||||
String editor, IRenderableDisplay... displays) {
|
||||
String editorName = (editor == null ? "com.raytheon.viz.ui.glmap.GLMapEditor"
|
||||
: editor);
|
||||
if (windowToLoadTo == null) {
|
||||
windowToLoadTo = getCurrentWindow();
|
||||
}
|
||||
AbstractEditor aEditor = null;
|
||||
EditorInput cont = new EditorInput(displays);
|
||||
try {
|
||||
IWorkbenchPage activePage = PlatformUI.getWorkbench()
|
||||
.getActiveWorkbenchWindow().getActivePage();
|
||||
IWorkbenchPage activePage = windowToLoadTo.getActivePage();
|
||||
if (activePage != null) {
|
||||
aEditor = (AbstractEditor) activePage.openEditor(cont,
|
||||
editorName);
|
||||
|
|
|
@ -512,9 +512,6 @@ public class PaneManager extends InputAdapter implements IMultiPaneEditor {
|
|||
registerHandlers(pane);
|
||||
} catch (VizException e) {
|
||||
statusHandler.handle(Priority.PROBLEM, "Error adding pane", e);
|
||||
if (pane != null) {
|
||||
pane.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
if (pane != null) {
|
||||
|
|
|
@ -903,7 +903,7 @@ public class VizDisplayPane implements IDisplayPane {
|
|||
|
||||
@Override
|
||||
public void clear() {
|
||||
renderableDisplay.clear(this);
|
||||
renderableDisplay.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -114,7 +114,7 @@ public abstract class AbstractVizPerspectiveManager implements
|
|||
if (mgr != null) {
|
||||
for (AbstractModalTool tool : mgr.getToolManager()
|
||||
.getSelectedModalTools()) {
|
||||
if (tool != null) {
|
||||
if (tool != null && tool.getCurrentEditor() != part) {
|
||||
tool.deactivate();
|
||||
tool.setEditor((IDisplayPaneContainer) part);
|
||||
tool.activate();
|
||||
|
|
|
@ -172,25 +172,26 @@ public class FileLocker {
|
|||
if (file.isDirectory()) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
// Get executing thread
|
||||
Thread myThread = Thread.currentThread();
|
||||
LockedFile lock = null;
|
||||
// synchronize on the locks map while operating on map
|
||||
|
||||
boolean grabbedLock = false;
|
||||
synchronized (locks) {
|
||||
lock = locks.get(file);
|
||||
if (lock == null) {
|
||||
// New lock, allocate and add and return
|
||||
lock = allocateLock(locker, file, type, myThread);
|
||||
lock = new LockedFile();
|
||||
locks.put(file, lock);
|
||||
return true;
|
||||
grabbedLock = true;
|
||||
}
|
||||
}
|
||||
|
||||
// File is currently locked, check for Thread compatibility
|
||||
// Synchronize on the lock while checking lock
|
||||
synchronized (lock) {
|
||||
if (lock.lockingThread == myThread
|
||||
if (grabbedLock) {
|
||||
// We were able to grab the lock file ourselves
|
||||
return allocateLock(locker, file, type, myThread, lock);
|
||||
} else if (lock.lockingThread == myThread
|
||||
|| (type == lock.lockType && type == Type.READ)) {
|
||||
// Locked on same thread to avoid indefinite waiting. If
|
||||
// there are issues on how locked, they will be known
|
||||
|
@ -204,7 +205,8 @@ public class FileLocker {
|
|||
// Wait for lock to be released
|
||||
LockWaiter waiter = new LockWaiter();
|
||||
Deque<LockWaiter> lws = null;
|
||||
// become a waiter on the file
|
||||
// become a waiter on the file, ensures when file is unlocked by
|
||||
// other Thread, they don't delete the lock file
|
||||
synchronized (waiters) {
|
||||
lws = waiters.get(file);
|
||||
if (lws == null) {
|
||||
|
@ -222,6 +224,7 @@ public class FileLocker {
|
|||
// Ignore
|
||||
}
|
||||
|
||||
grabbedLock = false;
|
||||
synchronized (locks) {
|
||||
lock = locks.get(file);
|
||||
if (lock == null) {
|
||||
|
@ -229,31 +232,30 @@ public class FileLocker {
|
|||
synchronized (lws) {
|
||||
if (lws.peek() == waiter) {
|
||||
lws.poll();
|
||||
return lockInternal(locker, file, type,
|
||||
false);
|
||||
lock = new LockedFile();
|
||||
locks.put(file, lock);
|
||||
grabbedLock = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if (lock.lockFile != null) {
|
||||
synchronized (lock) {
|
||||
if (lock.lockFile.exists() == false
|
||||
|| (System.currentTimeMillis()
|
||||
- lock.lockFile.lastModified() > MAX_WAIT)) {
|
||||
if ((System.currentTimeMillis() - lock.lockFile
|
||||
.lastModified()) > MAX_WAIT) {
|
||||
System.err
|
||||
.println("Releasing lock since: "
|
||||
+ (lock.lockFile.exists() ? "Lock has been allocated for more than "
|
||||
+ (MAX_WAIT / 1000)
|
||||
+ "s"
|
||||
: "Lock file no longer exists!"));
|
||||
+ "Lock has been allocated for more than "
|
||||
+ (MAX_WAIT / 1000) + "s");
|
||||
locks.remove(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (grabbedLock) {
|
||||
// We were able to grab the lock file ourselves
|
||||
allocateLock(locker, file, type, myThread, lock);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
UFStatus.getHandler().handle(Priority.PROBLEM,
|
||||
"Error locking file: " + file, t);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -313,10 +315,8 @@ public class FileLocker {
|
|||
* @throws FileNotFoundException
|
||||
* @throws IOException
|
||||
*/
|
||||
private synchronized LockedFile allocateLock(Object locker, File file,
|
||||
Type type, Thread thread) throws FileNotFoundException, IOException {
|
||||
LockedFile lock = new LockedFile();
|
||||
|
||||
private boolean allocateLock(Object locker, File file, Type type,
|
||||
Thread thread, LockedFile lock) {
|
||||
// Set tht thread of the lock and add lock allocator
|
||||
lock.lockingThread = Thread.currentThread();
|
||||
lock.lockers.add(locker);
|
||||
|
@ -327,11 +327,13 @@ public class FileLocker {
|
|||
// If we can't write to the parent directory of the file we are locking,
|
||||
// can't do any locking
|
||||
if (parentDir.canWrite() == false) {
|
||||
return lock;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean gotLock = false;
|
||||
File lockFile = new File(parentDir, "." + file.getName() + "_LOCK");
|
||||
boolean gotLock = lockFile.createNewFile();
|
||||
try {
|
||||
gotLock = lockFile.createNewFile();
|
||||
if (!gotLock) {
|
||||
long waitInterval = 500;
|
||||
long tryCount = MAX_WAIT / waitInterval;
|
||||
|
@ -344,6 +346,9 @@ public class FileLocker {
|
|||
gotLock = lockFile.createNewFile();
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (!gotLock) {
|
||||
System.err.println("Failed to obtain lock for: " + file
|
||||
|
@ -351,11 +356,10 @@ public class FileLocker {
|
|||
Thread.dumpStack();
|
||||
}
|
||||
lock.lockFile = lockFile;
|
||||
return lock;
|
||||
return gotLock;
|
||||
}
|
||||
|
||||
private synchronized void unallocateLock(LockedFile lock)
|
||||
throws IOException {
|
||||
private void unallocateLock(LockedFile lock) throws IOException {
|
||||
if (lock.lockFile != null) {
|
||||
lock.lockFile.delete();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue