Merge "Issue #2211 Reverted changes for SS DR 16070 and fixed satellite sampling as percentage" into development

Former-commit-id: e7949c04ad [formerly 0bf9eed643 [formerly 311a4e792edd9c1a83fe2debfee1a00e43f12807]]
Former-commit-id: 0bf9eed643
Former-commit-id: fb6b9a8b42
This commit is contained in:
Nate Jensen 2013-08-06 14:14:27 -05:00 committed by Gerrit Code Review
commit 746a96fd40
3 changed files with 219 additions and 329 deletions

View file

@ -18,7 +18,7 @@
<vmArgs>-Xincgc -Xmx1024M -Dosgi.instance.area.readOnly=true
-Declipse.log.enabled=false
-XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass
-Dorg.eclipse.update.reconcile=false -XX:MaxPermSize=128m
-Dorg.eclipse.update.reconcile=false -XX:MaxPermSize=256m
-Dorg.eclipse.ui/KEY_CONFIGURATION_ID=com.raytheon.viz.ui.awips.scheme
-Dqpid.dest_syntax=BURL
-Dcom.sun.management.jmxremote

View file

@ -35,7 +35,6 @@ import javax.xml.bind.annotation.XmlElement;
import com.raytheon.uf.common.colormap.AbstractColorMap;
import com.raytheon.uf.common.colormap.Color;
import com.raytheon.uf.common.colormap.IColorMap;
import com.raytheon.uf.common.colormap.prefs.DataMappingPreferences;
import com.raytheon.uf.common.colormap.prefs.DataMappingPreferences.DataMappingEntry;
import com.raytheon.uf.common.serialization.ISerializableObject;
@ -54,7 +53,9 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
* Feb 14, 2013 1616 bsteffen Add option for interpolation of
* colormap parameters, disable colormap
* interpolation by default.
* Jun 14, 2013 DR 16070 jgerth Utilize data mapping
* Jun 14, 2013 DR 16070 jgerth Utilize data mapping
* Aug 2, 2013 2211 mschenke Backed out 16070 changes, made
* dataUnit/imageUnit properly commutative.
*
* </pre>
*
@ -522,7 +523,7 @@ public class ColorMapParameters implements Cloneable, ISerializableObject {
public void setDataUnit(Unit<?> dataUnit) {
this.dataUnit = dataUnit;
if (imageUnit == null) {
if (dataUnit != null && imageUnit == null) {
setImageUnit(dataUnit);
}
@ -618,6 +619,11 @@ public class ColorMapParameters implements Cloneable, ISerializableObject {
*/
public void setImageUnit(Unit<?> imageUnit) {
this.imageUnit = imageUnit;
if (imageUnit != null && dataUnit == null) {
setDataUnit(imageUnit);
}
recomputeLabels = true;
imageToDataConverter = null;
@ -910,18 +916,7 @@ public class ColorMapParameters implements Cloneable, ISerializableObject {
if (colorMapRange != 0.0) {
double pixelValue;
// START DR 16070 fix
if (this.dataMapping != null)
if (this.dataMapping.getEntries() != null)
if (this.dataMapping.getEntries().get(0) != null)
if (this.dataMapping.getEntries().get(0).getOperator() != null)
if (this.dataMapping.getEntries().get(0).getOperator().equals("i")) {
Double dValue = this.dataMapping.getDataValueforNumericValue(dispValue);
if (dValue != null)
return (dValue.floatValue() - colorMapMin) / colorMapRange;
}
// END fix
if (displayToImage != null) {
if (displayToImage != null) {
pixelValue = displayToImage.convert(dispValue);
} else {
pixelValue = dispValue;

View file

@ -31,13 +31,14 @@ import javax.xml.bind.annotation.XmlElement;
import com.raytheon.uf.common.units.PiecewisePixel;
/**
* TODO Add Description
* Preference object for specifying data mapping relationships
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 6/2013 DR 16070 jgerth Interpolation capability
* 6/2013 DR 16070 jgerth Interpolation capability
* Aug 2, 2013 2211 mschenke Backed out 16070 changes
*
* </pre>
*
@ -47,351 +48,245 @@ import com.raytheon.uf.common.units.PiecewisePixel;
@XmlAccessorType(XmlAccessType.NONE)
public class DataMappingPreferences {
private String formatString;
@XmlAccessorType(XmlAccessType.NONE)
public static class DataMappingEntry implements
Comparable<DataMappingEntry> {
@XmlAttribute
private Double displayValue;
@XmlAccessorType(XmlAccessType.NONE)
public static class DataMappingEntry implements
Comparable<DataMappingEntry> {
@XmlAttribute
private Double displayValue;
@XmlAttribute
private Double pixelValue;
@XmlAttribute
private Double pixelValue;
@XmlAttribute
private String label;
@XmlAttribute
private String label;
@XmlAttribute
private String sample;
@XmlAttribute
private String sample;
@XmlAttribute
private String operator;
@XmlAttribute
private String operator;
/**
* @return the displayValue
*/
public Double getDisplayValue() {
return displayValue;
}
/**
* @return the displayValue
*/
public Double getDisplayValue() {
return displayValue;
}
/**
* @param displayValue
* the displayValue to set
*/
public void setDisplayValue(Double displayValue) {
this.displayValue = displayValue;
}
/**
* @param displayValue
* the displayValue to set
*/
public void setDisplayValue(Double displayValue) {
this.displayValue = displayValue;
}
/**
* @return the pixelValue
*/
public Double getPixelValue() {
return pixelValue;
}
/**
* @return the pixelValue
*/
public Double getPixelValue() {
return pixelValue;
}
/**
* @param pixelValue
* the pixelValue to set
*/
public void setPixelValue(Double pixelValue) {
this.pixelValue = pixelValue;
}
/**
* @param pixelValue
* the pixelValue to set
*/
public void setPixelValue(Double pixelValue) {
this.pixelValue = pixelValue;
}
/**
* @return the label
*/
public String getLabel() {
return label;
}
/**
* @return the label
*/
public String getLabel() {
return label;
}
/**
* @param label
* the label to set
*/
public void setLabel(String label) {
this.label = label;
}
/**
* @param label
* the label to set
*/
public void setLabel(String label) {
this.label = label;
}
/**
* @return the sample
*/
public String getSample() {
return sample;
}
/**
* @return the sample
*/
public String getSample() {
return sample;
}
/**
* @param sample
* the sample to set
*/
public void setSample(String sample) {
this.sample = sample;
}
/**
* @param sample
* the sample to set
*/
public void setSample(String sample) {
this.sample = sample;
}
/**
* @param operator
* the operator to set
*/
public void setOperator(String operator) {
this.operator = operator;
}
/**
* @param operator
* the operator to set
*/
public void setOperator(String operator) {
this.operator = operator;
}
/**
* @return the operator
*/
public String getOperator() {
return operator;
}
/**
* @return the operator
*/
public String getOperator() {
return operator;
}
/*
* Compares pixelValue
*
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public int compareTo(DataMappingEntry o2) {
if (o2 == null) {
return 1;
}
Double pixelValue1 = this.pixelValue;
Double pixelValue2 = o2.pixelValue;
if (pixelValue1 == null) {
if (pixelValue2 == null) {
return 0;
}
return -1;
}
if (pixelValue2 == null) {
return 1;
}
/*
* Compares pixelValue
*
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public int compareTo(DataMappingEntry o2) {
if (o2 == null) {
return 1;
}
Double pixelValue1 = this.pixelValue;
Double pixelValue2 = o2.pixelValue;
if (pixelValue1 == null) {
if (pixelValue2 == null) {
return 0;
}
return -1;
}
if (pixelValue2 == null) {
return 1;
}
if (pixelValue1 == pixelValue2) {
return 0;
} else if (pixelValue1 > pixelValue2) {
return 1;
}
if (pixelValue1 == pixelValue2) {
return 0;
} else if (pixelValue1 > pixelValue2) {
return 1;
}
return -1;
}
return -1;
}
}
}
private final ArrayList<DataMappingEntry> entries = new ArrayList<DataMappingEntry>();
private final ArrayList<DataMappingEntry> greaterThanEntries = new ArrayList<DataMappingEntry>();
private final ArrayList<DataMappingEntry> lessThanEntries = new ArrayList<DataMappingEntry>();
private final ArrayList<DataMappingEntry> equalsEntries = new ArrayList<DataMappingEntry>();
private final ArrayList<DataMappingEntry> interpEntries = new ArrayList<DataMappingEntry>();
private Unit<?> imageUnit;
private final ArrayList<DataMappingEntry> entries = new ArrayList<DataMappingEntry>();
@SuppressWarnings({ "unchecked", "rawtypes" })
public Unit<?> getImageUnit(Unit<?> displayUnit) {
if (imageUnit == null) {
ArrayList<Double> pixelValues = new ArrayList<Double>();
ArrayList<Double> dispValues = new ArrayList<Double>();
for (DataMappingEntry entry : entries) {
if (entry.getPixelValue() != null
&& entry.getDisplayValue() != null) {
pixelValues.add(entry.getPixelValue());
dispValues.add(entry.getDisplayValue());
}
}
private final ArrayList<DataMappingEntry> greaterThanEntries = new ArrayList<DataMappingEntry>();
int n = pixelValues.size();
if (n > 1) {
double[] pix = new double[n];
double[] disp = new double[n];
private final ArrayList<DataMappingEntry> lessThanEntries = new ArrayList<DataMappingEntry>();
for (int i = 0; i < n; i++) {
pix[i] = pixelValues.get(i);
disp[i] = dispValues.get(i);
}
private final ArrayList<DataMappingEntry> equalsEntries = new ArrayList<DataMappingEntry>();
imageUnit = new PiecewisePixel(displayUnit, pix, disp);
}
}
return imageUnit;
}
private Unit<?> imageUnit;
/**
* @return the entries
*/
@XmlElement(name = "entry")
public DataMappingEntry[] getSerializableEntries() {
return entries.toArray(new DataMappingEntry[entries.size()]);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public Unit<?> getImageUnit(Unit<?> displayUnit) {
if (imageUnit == null) {
ArrayList<Double> pixelValues = new ArrayList<Double>();
ArrayList<Double> dispValues = new ArrayList<Double>();
for (DataMappingEntry entry : entries) {
if (entry.getPixelValue() != null
&& entry.getDisplayValue() != null) {
pixelValues.add(entry.getPixelValue());
dispValues.add(entry.getDisplayValue());
}
}
public void setSerializableEntries(DataMappingEntry[] entryArray) {
entries.clear();
greaterThanEntries.clear();
lessThanEntries.clear();
equalsEntries.clear();
for (DataMappingEntry entry : entryArray) {
addEntry(entry);
}
}
int n = pixelValues.size();
if (n > 1) {
double[] pix = new double[n];
double[] disp = new double[n];
public ArrayList<DataMappingEntry> getEntries() {
return entries;
}
for (int i = 0; i < n; i++) {
pix[i] = pixelValues.get(i);
disp[i] = dispValues.get(i);
}
public void addEntry(DataMappingEntry entry) {
entries.add(entry);
sortEntry(entry);
}
imageUnit = new PiecewisePixel(displayUnit, pix, disp);
}
}
return imageUnit;
}
private void sortEntry(DataMappingEntry entry) {
String operator = entry.getOperator();
Double pixelValue = entry.getPixelValue();
if (pixelValue != null) {
if (operator == null || "=".equals(operator)) {
equalsEntries.add(entry);
} else if (">".equals(operator)) {
greaterThanEntries.add(entry);
Collections
.sort(greaterThanEntries, Collections.reverseOrder());
} else if ("<".equals(operator)) {
lessThanEntries.add(entry);
Collections.sort(lessThanEntries);
} else if ("i".equals(operator)) {
interpEntries.add(entry);
}
}
}
/**
* @return the entries
*/
@XmlElement(name = "entry")
public DataMappingEntry[] getSerializableEntries() {
return entries.toArray(new DataMappingEntry[entries.size()]);
}
/**
* Matches a number against the pixelValue and displays value to the
* number of decimal places set in formatString
*
* DR 16070
*
* @param dataValue
* @param formatString
* @return
*/
public String getLabelValueForDataValue(double dataValue,
String formatString) {
this.setFormatString(formatString);
return this.getLabelValueForDataValue(dataValue);
}
public void setSerializableEntries(DataMappingEntry[] entryArray) {
entries.clear();
greaterThanEntries.clear();
lessThanEntries.clear();
equalsEntries.clear();
for (DataMappingEntry entry : entryArray) {
addEntry(entry);
}
}
/**
* Matches a number against the pixelValue in each entry based on the
* operator until the first match is found.
*
* @param dataValue
* the data value to match
* @return The entry label, if one exists.
*/
public String getLabelValueForDataValue(double dataValue) {
for (DataMappingEntry entry : equalsEntries) {
Double entryValue = entry.getPixelValue();
if (entryValue.equals(dataValue)) {
return entry.getLabel();
}
}
public ArrayList<DataMappingEntry> getEntries() {
return entries;
}
for (DataMappingEntry entry : lessThanEntries) {
Double entryValue = entry.getPixelValue();
if (dataValue < entryValue) {
return entry.getLabel();
}
}
public void addEntry(DataMappingEntry entry) {
entries.add(entry);
sortEntry(entry);
}
for (DataMappingEntry entry : greaterThanEntries) {
Double entryValue = entry.getPixelValue();
if (dataValue > entryValue) {
return entry.getLabel();
}
}
// START DR 16070 fix
Double interpValue = this.getNumericValueforDataValue(dataValue);
int ies = interpEntries.size();
for (int i = 1; i < ies; i++) {
Double pixelValue1 = interpEntries.get(i - 1).getPixelValue();
Double pixelValue2 = interpEntries.get(i).getPixelValue();
if ((dataValue >= pixelValue1) && (dataValue <= pixelValue2)) {
if (this.getFormatString() != null)
return String.format("%." + this.getFormatString() + "f%s",
interpValue, interpEntries.get(i).getLabel());
else
return String.format("%.1f%s", interpValue, interpEntries
.get(i).getLabel());
}
}
// END fix
return null;
}
private void sortEntry(DataMappingEntry entry) {
String operator = entry.getOperator();
Double pixelValue = entry.getPixelValue();
if (pixelValue != null) {
if (operator == null || "=".equals(operator)) {
equalsEntries.add(entry);
} else if (">".equals(operator)) {
greaterThanEntries.add(entry);
Collections
.sort(greaterThanEntries, Collections.reverseOrder());
} else if ("<".equals(operator)) {
lessThanEntries.add(entry);
Collections.sort(lessThanEntries);
}
}
}
/**
* Get numeric value for data value
*
* DR 16070
*/
public Double getNumericValueforDataValue(double dataValue) {
Double interpValue;
int ies = interpEntries.size();
for (int i = 1; i < ies; i++) {
Double pixelValue1 = interpEntries.get(i - 1).getPixelValue();
Double pixelValue2 = interpEntries.get(i).getPixelValue();
Double displValue1 = interpEntries.get(i - 1).getDisplayValue();
Double displValue2 = interpEntries.get(i).getDisplayValue();
if ((dataValue >= pixelValue1) && (dataValue <= pixelValue2)) {
interpValue = displValue1 + (dataValue - pixelValue1)
/ (pixelValue2 - pixelValue1)
* (displValue2 - displValue1);
return interpValue;
}
}
return null;
}
/**
* Matches a number against the pixelValue in each entry based on the
* operator until the first match is found.
*
* @param dataValue
* the data value to match
* @return The entry label, if one exists.
*/
public String getLabelValueForDataValue(double dataValue) {
for (DataMappingEntry entry : equalsEntries) {
Double entryValue = entry.getPixelValue();
if (entryValue.equals(dataValue)) {
return entry.getLabel();
}
}
/**
* Get data value for numeric value
*
* DR 16070
*/
public Double getDataValueforNumericValue(double numericValue) {
Double interpValue;
int ies = interpEntries.size();
for (int i = 1; i < ies; i++) {
Double pixelValue1 = interpEntries.get(i - 1).getPixelValue();
Double pixelValue2 = interpEntries.get(i).getPixelValue();
Double displValue1 = interpEntries.get(i - 1).getDisplayValue();
Double displValue2 = interpEntries.get(i).getDisplayValue();
if (displValue1 > displValue2) {
if ((numericValue <= displValue1) && (numericValue >= displValue2)) {
interpValue = pixelValue1 + (numericValue - displValue1)
/ (displValue2 - displValue1)
* (pixelValue2 - pixelValue1);
return interpValue;
}
} else {
if ((numericValue >= displValue1) && (numericValue <= displValue2)) {
interpValue = pixelValue1 + (numericValue - displValue1)
/ (displValue2 - displValue1)
* (pixelValue2 - pixelValue1);
return interpValue;
}
}
}
return null;
}
for (DataMappingEntry entry : lessThanEntries) {
Double entryValue = entry.getPixelValue();
if (dataValue < entryValue) {
return entry.getLabel();
}
}
/**
* Set formatString
*
* DR 16070
*/
public void setFormatString(String formatString) {
this.formatString = formatString;
}
/**
* Get formatString
*
* DR 16070
*/
public String getFormatString() {
return formatString;
}
for (DataMappingEntry entry : greaterThanEntries) {
Double entryValue = entry.getPixelValue();
if (dataValue > entryValue) {
return entry.getLabel();
}
}
return null;
}
}