Issue #3016 Fix ColormappedImage and ColorMapper.

Change-Id: Ic4828f393ef628b16a2a29e78446f3569974cc5b

Former-commit-id: 9f085a0856 [formerly f7d07544e07552c7fccf744c269ee4aa54dc745c]
Former-commit-id: 6e0147169f
This commit is contained in:
Ron Anderson 2014-04-15 17:22:12 -05:00
parent 9132d9004e
commit 2a68e875a5
2 changed files with 18 additions and 5 deletions

View file

@ -44,7 +44,10 @@ import com.raytheon.uf.viz.core.exception.VizException;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 16, 2011 mschenke Initial creation
* Dec 16, 2011 mschenke Initial creation
* Feb 27, 2013 #1532 bsteffen Delete uf.common.colormap.image
* Nov 11, 2013 #2492 mschenke Added getDataUnti to IColormappedImage
* Apr 15, 2014 #3016 randerso Fix null pointer during construction
*
* </pre>
*
@ -107,7 +110,9 @@ public class ColormappedImage implements IColormappedImage,
*/
@Override
public void dispose() {
image.dispose();
if (image != null) {
image.dispose();
}
}
/*

View file

@ -57,6 +57,7 @@ import com.raytheon.uf.common.colormap.prefs.ColorMapParameters;
* Aug 13, 2010 mschenke Initial creation
* Feb 15, 2013 1638 mschenke Moved IndexColorModel creation to common.colormap utility
* Nov 4, 2013 2492 mschenke Rewritten to model glsl equivalent
* Apr 15, 2014 3016 randerso Check in Max's fix for getColorByIndex
*
* </pre>
*
@ -241,7 +242,7 @@ public class Colormapper {
rangeMin = rangeMax;
rangeMax = tmp;
}
double index = 0.0;
// Flag if min/max values are on opposite sides of zero
boolean minMaxOpposite = (cmapMin < 0 && cmapMax > 0)
@ -384,8 +385,15 @@ public class Colormapper {
* high.getAlpha());
return new Color(r, g, b, a);
} else {
return colorMap.getColors().get(
(int) (index * (colorMap.getSize() - 1)));
int colorIndex = (int) (index * colorMap.getSize());
if (colorIndex < 0) {
colorIndex = 0;
} else if (colorIndex >= colorMap.getSize()) {
colorIndex = colorMap.getSize() - 1;
}
return colorMap.getColors().get(colorIndex);
}
}