gov.noaa.pmel.sgt
Class ColorKey

java.lang.Object
  extended by gov.noaa.pmel.sgt.ColorKey
All Implemented Interfaces:
DataKey, LayerChild, Selectable, java.beans.PropertyChangeListener, java.lang.Cloneable, java.util.EventListener

public class ColorKey
extends java.lang.Object
implements java.lang.Cloneable, DataKey, java.beans.PropertyChangeListener

The ColorKey class provides a graphical depiction of the relationship between a ColorMap and user values. A single ColorKey can be attached to a Layer. A ColorMap is associated with the Key and therefor with a specific transformation and optionally a SGTData object.

Since:
1.0
Version:
$Revision$, $Date$
Author:
Donald Denbo
See Also:
Ruler, ColorMap, Layer

Field Summary
static int BOTTOM
          Align to bottom of key.
static int CENTER
          Align to center of key.
static int HORIZONTAL
          Orient key horizontally.
static int LEFT
          Align to left of key.
static int MIDDLE
          Align to middle of key.
static int NO_BORDER
          Do not draw a border.
static int PLAIN_LINE
          Use plain line border.
static int RAISED
          Use raised border.
static int RIGHT
          Align to right of key.
static int TOP
          Align to top of key.
static int VERTICAL
          Orient key vertically.
 
Constructor Summary
ColorKey()
          Default ColorKey constructor.
ColorKey(Point2D.Double pt, Dimension2D size, int valign, int halign)
           
ColorKey(Rectangle2D.Double pr, int valign, int halign)
          ColorKey constructor that include location, size, and alignment information.
 
Method Summary
 void addGraph(CartesianRenderer rend, SGLabel label)
          Add a GridCartesianRenderer and label to the ColorKey.
 LayerChild copy()
          Create a copy of ColorKey.
 void draw(java.awt.Graphics g)
          Draw the ColorKey.
 int getBorderStyle()
          Get border style.
 java.awt.Rectangle getBounds()
          Gets the bounding rectangle in device coordinates.
 Rectangle2D.Double getBoundsP()
          Get the bounding rectangle for the key in physical coordinates.
 ColorMap getColorMap()
          Get color map.
 int getHAlign()
          Get horizontal alignment
 java.lang.String getId()
          Get ColorKey identifier
 Layer getLayer()
          Returns the layer the ColorKey is attached.
 AbstractPane getPane()
          Get the parent pane.
 Ruler getRuler()
          Get the Ruler associated with the key.
 SGLabel getTitle()
          Get the key's title.
 int getVAlign()
          Get vertical alignment
 boolean isSelectable()
          Tests the selectable property.
 boolean isSelected()
          Returns true if the selected property is set.
 boolean isVisible()
          Check if ColorKey is visible.
 void modified(java.lang.String mess)
          For internal sgt use.
 void propertyChange(java.beans.PropertyChangeEvent evt)
           
 void setAlign(int vert, int horz)
          Set color key alignment.
 void setBorderStyle(int style)
          Set border style.
 void setBounds(int x, int y, int width, int height)
          Change the selected objects bounding rectangle in device coordinates.
 void setBounds(java.awt.Rectangle r)
          Change the selected objects bounding rectangle in device coordinates.
 void setBoundsP(Rectangle2D.Double r)
          Set the bounds of the key in physical coordinates.
 void setColorMap(ColorMap cm)
          Set color map.
 void setColumns(int col)
          Set columns.
 void setHAlign(int horz)
          Set horizontal alignment
 void setId(java.lang.String id)
          Set ColorKey identifier.
 void setLayer(Layer l)
          Set parent Layer.
 void setLineLengthP(double len)
          Set line lenght.
 void setLocationP(Point2D.Double loc)
          Set location of key in physical coordinates.
 void setOrientation(int orient)
          Set orientation.
 void setSelectable(boolean select)
          Sets the selectable property.
 void setSelected(boolean sel)
          Sets the selected property.
 void setSizeP(Dimension2D d)
          Set the size of the key in physical coordinates.
 void setTitle(SGLabel title)
          Set the title of the key.
 void setVAlign(int vert)
          Set vertical alignment
 void setVisible(boolean visible)
          Set visibility state for ColorKey.
 java.lang.String toString()
          Get a string representation of the key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PLAIN_LINE

public static final int PLAIN_LINE
Use plain line border.

See Also:
Constant Field Values

RAISED

public static final int RAISED
Use raised border.

See Also:
Constant Field Values

NO_BORDER

public static final int NO_BORDER
Do not draw a border.

See Also:
Constant Field Values

TOP

public static final int TOP
Align to top of key.

See Also:
Constant Field Values

MIDDLE

public static final int MIDDLE
Align to middle of key.

See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
Align to bottom of key.

See Also:
Constant Field Values

LEFT

public static final int LEFT
Align to left of key.

See Also:
Constant Field Values

CENTER

public static final int CENTER
Align to center of key.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
Align to right of key.

See Also:
Constant Field Values

HORIZONTAL

public static final int HORIZONTAL
Orient key horizontally.

See Also:
Constant Field Values

VERTICAL

public static final int VERTICAL
Orient key vertically.

See Also:
Constant Field Values
Constructor Detail

ColorKey

public ColorKey()
Default ColorKey constructor. The location and size must be specified before the ColorKey is attached to a layer!


ColorKey

public ColorKey(Rectangle2D.Double pr,
                int valign,
                int halign)
ColorKey constructor that include location, size, and alignment information. Default orientation is HORIZONTAL.

Parameters:
pr - a Rectangle2D object that includes location and size
valign - vertical alignment
halign - horizontal alignment

ColorKey

public ColorKey(Point2D.Double pt,
                Dimension2D size,
                int valign,
                int halign)
Since:
3.0
Method Detail

copy

public LayerChild copy()
Create a copy of ColorKey.

Specified by:
copy in interface LayerChild
Returns:
a copy of the key

setSelected

public void setSelected(boolean sel)
Sets the selected property.

Specified by:
setSelected in interface Selectable
Parameters:
sel - true if selected, false if not.
Since:
2.0

isSelected

public boolean isSelected()
Returns true if the selected property is set.

Specified by:
isSelected in interface Selectable
Returns:
true is selected, false if not.

setSelectable

public void setSelectable(boolean select)
Sets the selectable property.

Specified by:
setSelectable in interface Selectable
Parameters:
select - if true object is selectable
Since:
2.0

isSelectable

public boolean isSelectable()
Tests the selectable property.

Specified by:
isSelectable in interface Selectable
Returns:
true if selectable
Since:
2.0

setId

public void setId(java.lang.String id)
Set ColorKey identifier.

Specified by:
setId in interface LayerChild
Parameters:
id - key identifier

getId

public java.lang.String getId()
Get ColorKey identifier

Specified by:
getId in interface LayerChild
Returns:
identifier

setLayer

public void setLayer(Layer l)
Set parent Layer. Method should not be called directly, called when the Layer.addChild method is called.

Specified by:
setLayer in interface LayerChild
Parameters:
l - parent layer

getLayer

public Layer getLayer()
Returns the layer the ColorKey is attached.

Specified by:
getLayer in interface LayerChild
Returns:
The parent layer.
See Also:
Layer

getPane

public AbstractPane getPane()
Get the parent pane.

Specified by:
getPane in interface LayerChild
Since:
2.0

modified

public void modified(java.lang.String mess)
For internal sgt use.

Specified by:
modified in interface LayerChild
Since:
2.0

setColorMap

public void setColorMap(ColorMap cm)
Set color map.

Parameters:
cm - color map

addGraph

public void addGraph(CartesianRenderer rend,
                     SGLabel label)
              throws java.lang.IllegalArgumentException
Add a GridCartesianRenderer and label to the ColorKey.

Specified by:
addGraph in interface DataKey
Parameters:
rend - GridCartesianRenderer object
label - descriptive label
Throws:
java.lang.IllegalArgumentException
Since:
3.0

getColorMap

public ColorMap getColorMap()
Get color map.

Returns:
color map

setBorderStyle

public void setBorderStyle(int style)
Set border style.

Specified by:
setBorderStyle in interface DataKey
Parameters:
style - border style
See Also:
PLAIN_LINE, RAISED, NO_BORDER

getBorderStyle

public int getBorderStyle()
Get border style.

Returns:
border style

setAlign

public void setAlign(int vert,
                     int horz)
Set color key alignment.

Specified by:
setAlign in interface DataKey
Parameters:
vert - vertical alignment
horz - horizontal alignment

setOrientation

public void setOrientation(int orient)
Set orientation.

Parameters:
orient - key orientation

setVAlign

public void setVAlign(int vert)
Set vertical alignment

Specified by:
setVAlign in interface DataKey
Parameters:
vert - vertical alignment

setHAlign

public void setHAlign(int horz)
Set horizontal alignment

Specified by:
setHAlign in interface DataKey
Parameters:
horz - horizontal alignment

getVAlign

public int getVAlign()
Get vertical alignment

Returns:
vertical alignment

getHAlign

public int getHAlign()
Get horizontal alignment

Returns:
horizontal alignment

setLocationP

public void setLocationP(Point2D.Double loc)
Set location of key in physical coordinates.

Specified by:
setLocationP in interface DataKey
Parameters:
loc - key location

setSizeP

public void setSizeP(Dimension2D d)
Set the size of the key in physical coordinates.

Parameters:
d - size of key

setBoundsP

public void setBoundsP(Rectangle2D.Double r)
Set the bounds of the key in physical coordinates.

Specified by:
setBoundsP in interface DataKey
Parameters:
r - bounding rectangle

getBoundsP

public Rectangle2D.Double getBoundsP()
Get the bounding rectangle for the key in physical coordinates.

Returns:
bounding rectangle

getBounds

public java.awt.Rectangle getBounds()
Gets the bounding rectangle in device coordinates.

Specified by:
getBounds in interface Selectable
Returns:
bounding rectangle

setBounds

public void setBounds(java.awt.Rectangle r)
Change the selected objects bounding rectangle in device coordinates. The object will move to the new bounding rectangle.

Parameters:
r - new bounding rectangle

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Change the selected objects bounding rectangle in device coordinates. The object will move to the new bounding rectangle.

Parameters:
x - horizontal location, positive right
y - vertical location, positive down
width - horizontal size
height - vertical size

setTitle

public void setTitle(SGLabel title)
Set the title of the key.

Parameters:
title - key title

getTitle

public SGLabel getTitle()
Get the key's title.

Returns:
the title

getRuler

public Ruler getRuler()
Get the Ruler associated with the key.

Returns:
the ruler

draw

public void draw(java.awt.Graphics g)
Draw the ColorKey. This method should not be directly called.

Specified by:
draw in interface LayerChild
Parameters:
g - Graphics context
See Also:
Pane.draw()

toString

public java.lang.String toString()
Get a string representation of the key.

Specified by:
toString in interface LayerChild
Overrides:
toString in class java.lang.Object
Returns:
string representation

isVisible

public boolean isVisible()
Check if ColorKey is visible.

Specified by:
isVisible in interface LayerChild
Returns:
true if visible
Since:
2.0

setVisible

public void setVisible(boolean visible)
Set visibility state for ColorKey.

Specified by:
setVisible in interface LayerChild
Parameters:
visible - visible if true
Since:
2.0

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

setColumns

public void setColumns(int col)
Set columns. Unimplmented.

Specified by:
setColumns in interface DataKey
Parameters:
col -
Since:
3.0

setLineLengthP

public void setLineLengthP(double len)
Set line lenght. Unimplemented.

Specified by:
setLineLengthP in interface DataKey
Since:
3.0