anl.aida.palette
Class ColorMapLoader

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.xml.sax.ext.DefaultHandler2
          extended by anl.aida.palette.ColorMapLoader
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.DeclHandler, org.xml.sax.ext.EntityResolver2, org.xml.sax.ext.LexicalHandler

public class ColorMapLoader
extends org.xml.sax.ext.DefaultHandler2

Loads a ColorMap from an appropriate xml file.

Version:
$Revision$ $Date$

Field Summary
private static java.lang.String COLOR_EL
           
static java.lang.String COLOR_MAP_EL
           
private  boolean colorOn
           
private  java.util.List<java.awt.Color> colors
           
private  java.lang.String description
           
private static java.lang.String DESCRIPTION
           
private static java.lang.String INTERVAL_TYPE
           
private  java.util.List<java.lang.Double> intervals
           
private  java.lang.String intervalType
           
private  ColorMap map
           
private  double max
           
private static java.lang.String MAX
           
private  double min
           
private static java.lang.String MIN
           
private static java.lang.String PALETTE_EL
           
private static java.lang.String PALETTE_TYPE
           
private  java.lang.String paletteType
           
private  boolean scaleOn
           
private static java.lang.String STEP_EL
           
 
Constructor Summary
ColorMapLoader()
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          Receive notification of character data inside an element.
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
          Receive notification of the end of an element.
 ColorMap getColorMap()
           
 ColorMap load(java.io.File file)
           
 ColorMap load(java.net.URL url)
           
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
          Receive notification of the start of an element.
 
Methods inherited from class org.xml.sax.ext.DefaultHandler2
attributeDecl, comment, elementDecl, endCDATA, endDTD, endEntity, externalEntityDecl, getExternalSubset, internalEntityDecl, resolveEntity, resolveEntity, startCDATA, startDTD, startEntity
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLOR_MAP_EL

public static final java.lang.String COLOR_MAP_EL
See Also:
Constant Field Values

PALETTE_EL

private static final java.lang.String PALETTE_EL
See Also:
Constant Field Values

COLOR_EL

private static final java.lang.String COLOR_EL
See Also:
Constant Field Values

STEP_EL

private static final java.lang.String STEP_EL
See Also:
Constant Field Values

DESCRIPTION

private static final java.lang.String DESCRIPTION
See Also:
Constant Field Values

INTERVAL_TYPE

private static final java.lang.String INTERVAL_TYPE
See Also:
Constant Field Values

PALETTE_TYPE

private static final java.lang.String PALETTE_TYPE
See Also:
Constant Field Values

MIN

private static final java.lang.String MIN
See Also:
Constant Field Values

MAX

private static final java.lang.String MAX
See Also:
Constant Field Values

map

private ColorMap map

intervalType

private java.lang.String intervalType

paletteType

private java.lang.String paletteType

min

private double min

max

private double max

colors

private java.util.List<java.awt.Color> colors

intervals

private java.util.List<java.lang.Double> intervals

colorOn

private boolean colorOn

scaleOn

private boolean scaleOn

description

private java.lang.String description
Constructor Detail

ColorMapLoader

public ColorMapLoader()
Method Detail

load

public ColorMap load(java.io.File file)
              throws java.io.IOException,
                     javax.xml.parsers.ParserConfigurationException,
                     org.xml.sax.SAXException
Throws:
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException

load

public ColorMap load(java.net.URL url)
              throws java.io.IOException,
                     org.xml.sax.SAXException,
                     javax.xml.parsers.ParserConfigurationException
Throws:
java.io.IOException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException

getColorMap

public ColorMap getColorMap()

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException
Receive notification of the start of an element.

By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each element (such as allocating a new tree node or writing output to a file).

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
localName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
qName - The qualified name (with prefix), or the empty string if qualified names are not available.
attributes - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Receive notification of the end of an element.

By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of each element (such as finalising a tree node or writing output to a file).

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
localName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
qName - The qualified name (with prefix), or the empty string if qualified names are not available.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Receive notification of character data inside an element.

By default, do nothing. Application writers may override this method to take specific actions for each chunk of character data (such as adding the data to a node or buffer, or printing it to a file).

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Parameters:
ch - The characters.
start - The start position in the character array.
length - The number of characters to use from the character array.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.characters(char[], int, int)