Issue #1616 Add option for interpolation of colormap parameters, disable colormap interpolation by default.

Change-Id: I48738965df0da9052f810dfc1f312ed032693390

Former-commit-id: ccf08fbd82aac8b1ae1d4f42b455ec7c3f995970
This commit is contained in:
Ben Steffensmeier 2013-02-14 15:06:11 -06:00
parent e55eb5cc70
commit 8c0e9d3d9e
10 changed files with 64 additions and 27 deletions

View file

@ -33,6 +33,9 @@ import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 20, 2011 mschenke Initial creation
* Feb 14, 2013 1616 bsteffen Add option for interpolation of colormap
* parameters, disable colormap interpolation
* by default.
*
* </pre>
*
@ -56,9 +59,6 @@ public class DrawableColorMap {
/** The contrast to draw at */
public float contrast = 1.0f;
/** Specify whether the colormap should be interpolated */
public boolean interpolate = true;
/**
* Uses the ColorMapParameters passed in for drawing color map
*

View file

@ -53,6 +53,9 @@ import com.raytheon.uf.viz.core.style.DataMappingPreferences.DataMappingEntry;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 24, 2007 chammack Initial Creation.
* Feb 14, 2013 1616 bsteffen Add option for interpolation of
* colormap parameters, disable colormap
* interpolation by default.
*
* </pre>
*
@ -195,6 +198,9 @@ public class ColorMapParameters implements Cloneable, ISerializableObject {
/** Values >0 enable log scaling of the colormap. */
private float logFactor = -1.0f;
/** Specify whether the colormap should be interpolated */
protected boolean interpolate = false;
public static class LabelEntry {
private float location;
@ -933,14 +939,7 @@ public class ColorMapParameters implements Cloneable, ISerializableObject {
* @return
*/
public RGB getRGBByValue(float value) {
float index = getIndexByValue(value);
if (index < 0.0f) {
index = 0.0f;
} else if (index > 1.0f) {
index = 1.0f;
}
return colorToRGB(colorMap.getColors().get(
(int) (index * (colorMap.getSize()-1))));
return colorToRGB(getColorByValue(value));
}
/**
@ -956,7 +955,25 @@ public class ColorMapParameters implements Cloneable, ISerializableObject {
} else if (index > 1.0f) {
index = 1.0f;
}
return colorMap.getColors().get((int) (index * (colorMap.getSize()-1)));
if (isInterpolate()) {
index = 0.5f;
index = (index * (colorMap.getSize() - 1));
int lowIndex = (int) Math.floor(index);
int highIndex = (int) Math.ceil(index);
float lowWeight = highIndex - index;
float highWeight = 1.0f - lowWeight;
Color low = colorMap.getColors().get(lowIndex);
Color high = colorMap.getColors().get(highIndex);
float r = lowWeight * low.getRed() + highWeight * high.getRed();
float g = lowWeight * low.getGreen() + highWeight * high.getGreen();
float b = lowWeight * low.getBlue() + highWeight * high.getBlue();
float a = lowWeight * low.getAlpha() + highWeight * high.getAlpha();
return new Color(r, g, b, a);
} else {
return colorMap.getColors().get(
(int) (index * (colorMap.getSize() - 1)));
}
}
public static RGB colorToRGB(Color c) {
@ -1027,4 +1044,12 @@ public class ColorMapParameters implements Cloneable, ISerializableObject {
this.noDataValue = noDataValue;
}
public boolean isInterpolate() {
return interpolate;
}
public void setInterpolate(boolean interpolate) {
this.interpolate = interpolate;
}
}

View file

@ -42,6 +42,9 @@ import com.raytheon.uf.viz.core.exception.VizException;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 26, 2012 bsteffen Initial creation
* Feb 14, 2013 1616 bsteffen Add option for interpolation of colormap
* parameters, disable colormap interpolation
* by default.
*
* </pre>
*
@ -128,7 +131,6 @@ public class GeneralCanvasRenderingExtension extends
newColorMap.alpha = colorMap.alpha;
newColorMap.brightness = colorMap.brightness;
newColorMap.contrast = colorMap.contrast;
newColorMap.interpolate = colorMap.interpolate;
double x1 = colorMap.extent.getMinX();
double y1 = colorMap.extent.getMinY();
double x2 = colorMap.extent.getMaxX();

View file

@ -37,6 +37,9 @@ import com.raytheon.uf.viz.remote.graphics.events.rendering.IRenderEvent;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 3, 2012 mschenke Initial creation
* Feb 14, 2013 1616 bsteffen Add option for interpolation of colormap
* parameters, disable colormap interpolation
* by default.
*
* </pre>
*
@ -120,7 +123,6 @@ public class DrawColorRampEvent extends AbstractRemoteGraphicsRenderEvent {
this.alpha = colorMap.alpha;
this.brightness = colorMap.brightness;
this.contrast = colorMap.contrast;
this.interpolate = colorMap.interpolate;
this.extent = colorMap.extent;
}
@ -129,7 +131,6 @@ public class DrawColorRampEvent extends AbstractRemoteGraphicsRenderEvent {
colorMap.alpha = alpha;
colorMap.brightness = brightness;
colorMap.contrast = contrast;
colorMap.interpolate = interpolate;
colorMap.extent = extent;
return colorMap;
}

View file

@ -119,6 +119,10 @@ import com.sun.opengl.util.j2d.TextRenderer;
* 07/19/10 5952 bkowal GLTarget will now check for the existence of updated extents
* before drawing. A method has also been added to notify
* GLTarget of when there are updated extents to load.
* Feb 14, 2013 1616 bsteffen Add option for interpolation of colormap
* parameters, disable colormap
* interpolation by default.
*
*
* </pre>
*
@ -539,7 +543,7 @@ public class GLTarget extends AbstractGraphicsTarget implements IGLTarget {
gl.glActiveTexture(GL.GL_TEXTURE0);
i.bind(gl, GL.GL_TEXTURE_1D);
if (drawableColorMap.interpolate) {
if (colorMapParams.isInterpolate()) {
gl.glTexParameteri(GL.GL_TEXTURE_1D, GL.GL_TEXTURE_MIN_FILTER,
GL.GL_LINEAR);
gl.glTexParameteri(GL.GL_TEXTURE_1D, GL.GL_TEXTURE_MAG_FILTER,

View file

@ -48,6 +48,9 @@ import com.raytheon.viz.core.gl.objects.GLTextureObject;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 18, 2011 mschenke Initial creation
* Feb 14, 2013 1616 bsteffen Add option for interpolation of colormap
* parameters, disable colormap interpolation
* by default.
*
* </pre>
*
@ -130,7 +133,7 @@ public class GLColormappedImageExtension extends AbstractGLSLImagingExtension
gl.glActiveTexture(GL.GL_TEXTURE1);
cmapTexture.bind(gl, GL.GL_TEXTURE_1D);
if (glImage.isInterpolated()) {
if (usedColorMapParameters.isInterpolate()) {
gl.glTexParameteri(GL.GL_TEXTURE_1D, GL.GL_TEXTURE_MIN_FILTER,
GL.GL_LINEAR);
gl.glTexParameteri(GL.GL_TEXTURE_1D, GL.GL_TEXTURE_MAG_FILTER,

View file

@ -24,7 +24,6 @@ import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GFERecord.GridType;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.DrawableColorMap;
import com.raytheon.uf.viz.core.DrawableLine;
import com.raytheon.uf.viz.core.DrawableString;
@ -38,9 +37,7 @@ import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.ImagingCapability;
import com.raytheon.viz.gfe.Activator;
import com.raytheon.viz.gfe.GFEOperationFailedException;
import com.raytheon.viz.gfe.core.DataManager;
import com.raytheon.viz.gfe.core.ISpatialDisplayManager;
import com.raytheon.viz.gfe.core.parm.Parm;
@ -59,6 +56,9 @@ import com.raytheon.viz.gfe.rsc.GFEResource;
* 03/26/2008 chammack Initial Creation.
* 04/13/2009 2092 njensen Support for custom labels
* 08/20/2012 #1083 randerso Fixed user defined labels
* Feb 14, 2013 1616 bsteffen Add option for interpolation of colormap
* parameters, disable colormap interpolation
* by default.
*
* </pre>
*
@ -144,8 +144,6 @@ public class ContinuousColorbar implements IColorBarDisplay {
DrawableColorMap dcm = new DrawableColorMap(cmap);
dcm.alpha = 1.0f;
dcm.extent = pe;
dcm.interpolate = rscPair.getResource()
.getCapability(ImagingCapability.class).isInterpolationState();
target.drawColorRamp(dcm);
GFEResource rsc = (GFEResource) rscPair.getResource();

View file

@ -62,6 +62,9 @@ import com.raytheon.viz.ui.cmenu.IContextMenuContributor;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 20, 2009 mpduff Initial creation
* Feb 14, 2013 1616 bsteffen Add option for interpolation of colormap
* parameters, disable colormap interpolation
* by default.
*
* </pre>
*
@ -193,8 +196,6 @@ public class HydroColorBarResource extends
.getCapability(ColorMapCapability.class);
DrawableColorMap cmap = new DrawableColorMap(rsc.getCapability(
ColorMapCapability.class).getColorMapParameters());
;
cmap.interpolate = false;
cmap.alpha = 1.0f;
// The y value to use for drawing

View file

@ -51,6 +51,9 @@ import com.raytheon.viz.hydrocommon.HydroDisplayManager;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 19, 2008 randerso Initial creation
* Feb 14, 2013 1616 bsteffen Add option for interpolation of colormap
* parameters, disable colormap interpolation
* by default.
*
* </pre>
*
@ -157,7 +160,6 @@ public class MPELegendResource extends
DrawableColorMap cmap = new DrawableColorMap(rsc.getCapability(
ColorMapCapability.class).getColorMapParameters());
cmap.interpolate = false;
cmap.alpha = alpha;
IColorMap cm = cmap.getColorMapParams().getColorMap();

View file

@ -92,6 +92,9 @@ import com.vividsolutions.jts.geom.GeometryFactory;
* Nov 19, 2008 randerso Initial creation
* Dec 02, 2009 3237 snaples Added options for 6/24 hour
* display filtering.
* Feb 14, 2013 1616 bsteffen Add option for interpolation of colormap
* parameters, disable colormap interpolation
* by default.
*
* </pre>
*
@ -273,7 +276,6 @@ public class MPELegendResource extends
DrawableColorMap cmap = new DrawableColorMap(rsc.getCapability(
ColorMapCapability.class).getColorMapParameters());
cmap.interpolate = false;
cmap.alpha = alpha;
IColorMap cm = cmap.getColorMapParams().getColorMap();
@ -377,7 +379,6 @@ public class MPELegendResource extends
if (rsc.getStatus().equals(ResourceStatus.INITIALIZED)) {
cmap = new DrawableColorMap(rsc.getCapability(
ColorMapCapability.class).getColorMapParameters());
cmap.interpolate = false;
cmap.alpha = alpha;
cmapSize = cmap.getColorMapParams().getColorMap().getSize();