Issue #2361 remove ISerializableObject for hydro colors

Change-Id: Icc4a1e2ebff06ff389e95563406176663000ad7c

Former-commit-id: 54a13cef30 [formerly 472c2693c4] [formerly 0fe5979eac] [formerly 83fafc638b [formerly 0fe5979eac [formerly f23474913e08b34d1eb82e2106549f57fd36538c]]]
Former-commit-id: 83fafc638b
Former-commit-id: 67c022fe0bf860e2b4d22e1b1209c2a4000de21f [formerly 7fb250b184]
Former-commit-id: 91ddf05a6b
This commit is contained in:
Nate Jensen 2013-10-10 10:40:25 -05:00
parent b726353f42
commit 4454f61a27
5 changed files with 103 additions and 78 deletions

View file

@ -1,8 +1,5 @@
com.raytheon.viz.hydrocommon.resource.RadarRingOverlayResourceData
com.raytheon.viz.hydrocommon.resource.HRAPOverlayResourceData
com.raytheon.viz.hydrocommon.colorscalemgr.ColorDataClassXML
com.raytheon.viz.hydrocommon.colorscalemgr.ColorThresholdXML
com.raytheon.viz.hydrocommon.colorscalemgr.DefaultColorScaleXML
com.raytheon.viz.hydrocommon.resource.FFGGridResourceData
com.raytheon.viz.hydrocommon.resource.FFGGridLoadProperties
com.raytheon.viz.hydrocommon.resource.XmrgResourceData

View file

@ -27,33 +27,32 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import com.raytheon.uf.common.serialization.ISerializableObject;
/**
* Individual data class xml elements.
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 26, 2010 4671 mpduff Initial creation.
*
*
* </pre>
*
*
* @author mpduff
* @version 1.0
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.NONE)
public class ColorDataClassXML implements ISerializableObject {
@XmlElements( { @XmlElement(name = "threshold", type = ColorThresholdXML.class) })
public class ColorDataClassXML {
@XmlElements({ @XmlElement(name = "threshold", type = ColorThresholdXML.class) })
private ArrayList<ColorThresholdXML> thresholdList = new ArrayList<ColorThresholdXML>();
@XmlAttribute(name = "useName")
private String colorUseName;
@XmlAttribute(name = "dbUseName")
private String dbColorUseName;
@ -65,7 +64,8 @@ public class ColorDataClassXML implements ISerializableObject {
}
/**
* @param colorUseName the colorUseName to set
* @param colorUseName
* the colorUseName to set
*/
public void setColorUseName(String colorUseName) {
this.colorUseName = colorUseName;
@ -79,7 +79,8 @@ public class ColorDataClassXML implements ISerializableObject {
}
/**
* @param dbColorUseName the dbColorUseName to set
* @param dbColorUseName
* the dbColorUseName to set
*/
public void setDbColorUseName(String dbColorUseName) {
this.dbColorUseName = dbColorUseName;
@ -93,11 +94,11 @@ public class ColorDataClassXML implements ISerializableObject {
}
/**
* @param thresholdList the thresholdList to set
* @param thresholdList
* the thresholdList to set
*/
public void setThresholdList(ArrayList<ColorThresholdXML> thresholdList) {
this.thresholdList = thresholdList;
}
}

View file

@ -23,30 +23,29 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import com.raytheon.uf.common.serialization.ISerializableObject;
/**
* Individual Threshold xml elements.
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 26, 2010 4671 mpduff Initial creation.
*
*
* </pre>
*
*
* @author mpduff
* @version 1.0
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.NONE)
public class ColorThresholdXML implements ISerializableObject {
public class ColorThresholdXML {
@XmlAttribute(name = "color")
private String color;
@XmlAttribute(name = "value")
private Double value;
@ -58,7 +57,8 @@ public class ColorThresholdXML implements ISerializableObject {
}
/**
* @param color the color to set
* @param color
* the color to set
*/
public void setColor(String color) {
this.color = color;
@ -72,7 +72,8 @@ public class ColorThresholdXML implements ISerializableObject {
}
/**
* @param value the value to set
* @param value
* the value to set
*/
public void setValue(Double value) {
this.value = value;

View file

@ -27,30 +27,29 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.serialization.ISerializableObject;
/**
* HydroviewDefaultColorScale.xml java object. Holds the default color
* scale data for the Color Scale Manager.
* HydroviewDefaultColorScale.xml java object. Holds the default color scale
* data for the Color Scale Manager.
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 26, 2010 4671 mpduff Initial creation.
*
*
* </pre>
*
*
* @author mpduff
* @version 1.0
* @version 1.0
*/
@XmlRootElement(name = "defaultColorScale")
@XmlAccessorType(XmlAccessType.NONE)
public class DefaultColorScaleXML implements ISerializableObject {
@XmlElements( { @XmlElement(name = "colorDataClass", type = ColorDataClassXML.class) })
public class DefaultColorScaleXML {
@XmlElements({ @XmlElement(name = "colorDataClass", type = ColorDataClassXML.class) })
private ArrayList<ColorDataClassXML> colorDataClassList = new ArrayList<ColorDataClassXML>();
/**
@ -61,9 +60,11 @@ public class DefaultColorScaleXML implements ISerializableObject {
}
/**
* @param colorDataClass the colorDataClassList to set
* @param colorDataClass
* the colorDataClassList to set
*/
public void setColorDataClassList(ArrayList<ColorDataClassXML> colorDataClassList) {
public void setColorDataClassList(
ArrayList<ColorDataClassXML> colorDataClassList) {
this.colorDataClassList = colorDataClassList;
}
}

View file

@ -22,27 +22,55 @@ package com.raytheon.viz.hydrocommon.colorscalemgr;
import java.util.ArrayList;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.serialization.SingleTypeJAXBManager;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.viz.hydrocommon.whfslib.colorthreshold.NamedColorUseSet;
/**
* Color manager for Hydro
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* --/--/---- Initial creation.
* 10/10/2013 2361 njensen Use JAXBManager for XML
*
* </pre>
*
*/
public class HydroColorManager extends ColorManager {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(HydroColorManager.class);
private static final SingleTypeJAXBManager<DefaultColorScaleXML> jaxb = SingleTypeJAXBManager
.createWithoutException(DefaultColorScaleXML.class);
/** Instance of this class */
private static HydroColorManager instance = null;
/**
* The application name.
*/
public static final String APPLICATION_NAME = "hydroview";
public static final int MISSING_INDEX = 0;
public static final int MISSING_STAGE_INDEX = 1;
public static final int NO_FLOOD_INDEX = 2;
public static final int NEAR_FLOOD_INDEX = 3;
public static final int FLOOD_INDEX = 4;
/**
* HydroviewDefaultcolorScale.xml
*/
@ -51,26 +79,25 @@ public class HydroColorManager extends ColorManager {
private HydroColorManager() {
applicationName = APPLICATION_NAME;
}
public static HydroColorManager getInstance() {
if (instance == null) {
instance = new HydroColorManager();
}
return instance;
}
/**
* Read in the Default Color Scale file.
*
* @return
* The DefaultColorScaleXML object
* @return The DefaultColorScaleXML object
*/
public NamedColorSetGroup getDefaultColorSetGroup() {
String filename = "hydro/HydroviewDefaultColorScale.xml";
DefaultColorScaleXML defaultXmltmp = null;
NamedColorSetGroup namedColorSetGroup = new NamedColorSetGroup();
try {
IPathManager pm = PathManagerFactory.getPathManager();
@ -79,60 +106,58 @@ public class HydroColorManager extends ColorManager {
LocalizationLevel.BASE), filename)
.getAbsolutePath();
defaultXmltmp = (DefaultColorScaleXML) SerializationUtil
.jaxbUnmarshalFromXmlFile(path.toString());
defaultXmltmp = jaxb.unmarshalFromXmlFile(path.toString());
defaultXml = defaultXmltmp;
} catch (Exception e) {
// e.printStackTrace();
System.err.println("No configuration file found");
statusHandler.error("Error reading " + filename, e);
}
ArrayList<ColorDataClassXML> dataClassList = defaultXmltmp.getColorDataClassList();
for (ColorDataClassXML cdc: dataClassList) {
ArrayList<ColorDataClassXML> dataClassList = defaultXmltmp
.getColorDataClassList();
for (ColorDataClassXML cdc : dataClassList) {
String dbColorUseName = cdc.getDbColorUseName();
String colorUseName = cdc.getColorUseName();
insertColorUseStringIntoHashMap(colorUseName, dbColorUseName);
colorNameMap.put(dbColorUseName, colorUseName);
ArrayList<ColorThresholdXML> threshList = cdc.getThresholdList();
ArrayList<Double> thresholdValueArray = new ArrayList<Double>();
ArrayList<String> thresholdColorArray = new ArrayList<String>();
for (int i = 0; i < threshList.size(); i++) {
thresholdValueArray.add(threshList.get(i).getValue());
thresholdColorArray.add(threshList.get(i).getColor());
thresholdColorArray.add(threshList.get(i).getColor());
}
String missingColorName = thresholdColorArray.get(0);
String defaultColorName = thresholdColorArray.get(1);
// Create arrays
String[] colorArray = thresholdColorArray.toArray(new String[thresholdColorArray.size()]);
String[] colorArray = thresholdColorArray
.toArray(new String[thresholdColorArray.size()]);
double[] colorValueArray = new double[thresholdValueArray.size()];
for (int i = 0; i < thresholdValueArray.size(); i++) {
colorValueArray[i] = thresholdValueArray.get(i);
}
NamedColorUseSet namedColorUseSet = new NamedColorUseSet(dbColorUseName,
colorUseName, colorValueArray, colorArray,
NamedColorUseSet namedColorUseSet = new NamedColorUseSet(
dbColorUseName, colorUseName, colorValueArray, colorArray,
missingColorName, defaultColorName, 0);
namedColorSetGroup.addNamedColorUseSet(namedColorUseSet);
}
return namedColorSetGroup;
}
private void insertColorUseStringIntoHashMap(String colorUseString,
String databaseColorUseString) {
colorNameMap.put(colorUseString,
databaseColorUseString);
colorNameMap.put(databaseColorUseString,
colorUseString);
}
colorNameMap.put(colorUseString, databaseColorUseString);
colorNameMap.put(databaseColorUseString, colorUseString);
}
@Override
public String getApplicationName() {