org.opensha.commons.util.cpt
Class CPT

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<CPTVal>
              extended by org.opensha.commons.util.cpt.CPT
All Implemented Interfaces:
Serializable, Cloneable, Iterable<CPTVal>, Collection<CPTVal>, List<CPTVal>, RandomAccess, Named, XMLSaveable

public class CPT
extends ArrayList<CPTVal>
implements Named, Serializable, Cloneable, XMLSaveable

This class represents a GMT CPT file.

Author:
kevin
See Also:
Serialized Form

Field Summary
 Blender blender
           
static String XML_METADATA_NAME
           
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
CPT()
          Constructor which has no colors except for the default nanColor as Color.ORANGE,gapColor as Color.MAGENTA , belowMin as Color.BLACK, and aboveMax as Color.WHITE.
CPT(double minVal, double maxVal, Color... colors)
          Constructor to quickly generate evenly split CPT ranges.
CPT(String name)
           
 
Method Summary
 CPT asLog10()
           
 CPT asPow10()
           
 Object clone()
           
static CPT fromXMLMetadata(Element cptElem)
           
 Color getAboveMaxColor()
           
 Color getBelowMinColor()
           
 Blender getBlender()
           
 Color getColor(float value)
          This returns a color given a value for this specific CPT file or null if the color is undefined
 CPTVal getCPTVal(float value)
          Does a lookup for the color range (CPTVal) associated with this value
 Color getGapColor()
           
 Color getMaxColor()
           
 float getMaxValue()
           
 Color getMinColor()
           
 float getMinValue()
           
 String getName()
          Returns the name of this object
 Color getNaNColor()
           
static CPT loadFromFile(File dataFile)
          This loads a CPT file into a CPT object The CPT format can be found here: http://hraun.vedur.is/~gg/hugb/gmt/doc/html/tutorial/node68.html The default overflow and underflow colors are the colors associated with the min and max values of the CPT file
static CPT loadFromStream(InputStream is)
           
static void main(String[] args)
           
 void paintGrid(BufferedImage bi)
           
 CPT rescale(double min, double max)
           
 CPT reverse()
           
 void setAboveMaxColor(Color color)
          Set The value of the color returned by getColor if the value is above the range of the CPT class using r,g,b values as used in Color3f.
 void setAboveMaxColor(int r, int g, int b)
           
 void setBelowMinColor(Color color)
          Set The value of the color returned by getColor if the value is below the range of the CPT class using r,g,b values as used in Color3f.
 void setBelowMinColor(int r, int g, int b)
           
 void setBlender(Blender blender)
           
 void setCPTVal(CPTVal newcpt)
          Adds the cpt_val into this list.
 void setGapColor(Color color)
          Sets the color to be take on for values in the range of the minValue and maxValue, but without a specified color
 void setGapColor(int r, int g, int b)
           
 void setName(String name)
           
 void setNanColor(Color color)
          Sets color to be used when given value is not a number (NaN)
 void setNanColor(int r, int g, int b)
          Sets color to be used when given value is not a number (NaN)
static String tabDelimColor(Color color)
           
 String toString()
           
 Element toXMLMetadata(Element root)
           
 void writeCPTFile(File file)
           
 void writeCPTFile(String fileName)
           
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Field Detail

XML_METADATA_NAME

public static final String XML_METADATA_NAME
See Also:
Constant Field Values

blender

public Blender blender
Constructor Detail

CPT

public CPT()
Constructor which has no colors except for the default nanColor as Color.ORANGE,gapColor as Color.MAGENTA , belowMin as Color.BLACK, and aboveMax as Color.WHITE. NOTE: the gapColor and naNColor are not blended Use the ArrayList getters and setter for finer control.

See Also:
ArrayList

CPT

public CPT(String name)

CPT

public CPT(double minVal,
           double maxVal,
           Color... colors)
Constructor to quickly generate evenly split CPT ranges. Must supply at least 2 colors. Above max and below min colors will be set to the last/fist colors.

Parameters:
minVal -
maxVal -
colors -
Method Detail

setNanColor

public void setNanColor(int r,
                        int g,
                        int b)
Sets color to be used when given value is not a number (NaN)

Parameters:
r -
g -
b -
See Also:
for more information on rgb values.

setNanColor

public void setNanColor(Color color)
Sets color to be used when given value is not a number (NaN)

See Also:
Color

setBelowMinColor

public void setBelowMinColor(Color color)
Set The value of the color returned by getColor if the value is below the range of the CPT class using r,g,b values as used in Color3f.

See Also:
Color

setAboveMaxColor

public void setAboveMaxColor(Color color)
Set The value of the color returned by getColor if the value is above the range of the CPT class using r,g,b values as used in Color3f.

See Also:
Color

setGapColor

public void setGapColor(Color color)
Sets the color to be take on for values in the range of the minValue and maxValue, but without a specified color

Parameters:
color -

setGapColor

public void setGapColor(int r,
                        int g,
                        int b)
See Also:
setGapColor(Color3f color), Color

setBelowMinColor

public void setBelowMinColor(int r,
                             int g,
                             int b)
See Also:
setBelowMinColor(Color3f color), Color

setAboveMaxColor

public void setAboveMaxColor(int r,
                             int g,
                             int b)
See Also:
setAboveMaxColor(Color3f color), Color

getAboveMaxColor

public Color getAboveMaxColor()
Returns:
The value of the color returned by getColor if the value is above the range of the CPT class

getBelowMinColor

public Color getBelowMinColor()
Returns:
The value of the color returned by getColor if the value is below the range of the CPT class

getMinColor

public Color getMinColor()
Returns:
the Color3f associated with the minimum value in the CPT color range

getMaxColor

public Color getMaxColor()
Returns:
the Color3f associated with the maximum value in the CPT color range or null if the color is undefined

getNaNColor

public Color getNaNColor()

getGapColor

public Color getGapColor()
Returns:
the color for values within the range of the CPT val/color combination, but unspecified

getColor

public Color getColor(float value)
This returns a color given a value for this specific CPT file or null if the color is undefined

Parameters:
value -
Returns:
Color corresponding to value

loadFromFile

public static CPT loadFromFile(File dataFile)
                        throws FileNotFoundException,
                               IOException
This loads a CPT file into a CPT object The CPT format can be found here: http://hraun.vedur.is/~gg/hugb/gmt/doc/html/tutorial/node68.html The default overflow and underflow colors are the colors associated with the min and max values of the CPT file

Parameters:
dataFile -
Returns:
Throws:
FileNotFoundException
IOException

loadFromStream

public static CPT loadFromStream(InputStream is)
                          throws IOException
Throws:
IOException

toXMLMetadata

public Element toXMLMetadata(Element root)
Specified by:
toXMLMetadata in interface XMLSaveable

fromXMLMetadata

public static CPT fromXMLMetadata(Element cptElem)

writeCPTFile

public void writeCPTFile(String fileName)
                  throws IOException
Throws:
IOException

writeCPTFile

public void writeCPTFile(File file)
                  throws IOException
Throws:
IOException

getBlender

public Blender getBlender()
Returns:
this objects blender

setBlender

public void setBlender(Blender blender)
Parameters:
blender, - the blender to be used
See Also:
Blender

getCPTVal

public CPTVal getCPTVal(float value)
Does a lookup for the color range (CPTVal) associated with this value

Parameters:
containingValue -
Returns:
null if the color range was not found

setCPTVal

public void setCPTVal(CPTVal newcpt)
Adds the cpt_val into this list. Note it will overwrite and replace intersecting cpt_vals

Parameters:
cpt_val -

paintGrid

public void paintGrid(BufferedImage bi)

tabDelimColor

public static String tabDelimColor(Color color)

toString

public String toString()
Overrides:
toString in class AbstractCollection<CPTVal>

getMinValue

public float getMinValue()

getMaxValue

public float getMaxValue()

main

public static void main(String[] args)
                 throws FileNotFoundException,
                        IOException
Throws:
FileNotFoundException
IOException

getName

public String getName()
Description copied from interface: Named
Returns the name of this object

Specified by:
getName in interface Named

setName

public void setName(String name)

clone

public Object clone()
Overrides:
clone in class ArrayList<CPTVal>

asLog10

public CPT asLog10()

asPow10

public CPT asPow10()

rescale

public CPT rescale(double min,
                   double max)
Returns:
rescaled version of this CPT

reverse

public CPT reverse()
Returns:
reversed version of this CPT file