gov.noaa.pmel.sgt
Class ColorKey

java.lang.Object
  |
  +--gov.noaa.pmel.sgt.ColorKey
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, LayerChild, java.beans.PropertyChangeListener, Selectable

public class ColorKey
extends java.lang.Object
implements java.lang.Cloneable, LayerChild, 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: 1.18 $, $Date: 2001/12/13 19:07:04 $
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(Rectangle2D.Double pr, int valign, int halign)
          ColorKey constructor that include location, size, and alignment information.
 
Method Summary
 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)
          This method gets called when a bound property is changed.
 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 setHAlign(int horz)
          Set horizontal alignment
 void setId(java.lang.String id)
          Set ColorKey identifier.
 void setLayer(Layer l)
          Set parent Layer.
 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PLAIN_LINE

public static final int PLAIN_LINE
Use plain line border.

RAISED

public static final int RAISED
Use raised border.

NO_BORDER

public static final int NO_BORDER
Do not draw a border.

TOP

public static final int TOP
Align to top of key.

MIDDLE

public static final int MIDDLE
Align to middle of key.

BOTTOM

public static final int BOTTOM
Align to bottom of key.

LEFT

public static final int LEFT
Align to left of key.

CENTER

public static final int CENTER
Align to center of key.

RIGHT

public static final int RIGHT
Align to right of key.

HORIZONTAL

public static final int HORIZONTAL
Orient key horizontally.

VERTICAL

public static final int VERTICAL
Orient key vertically.
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
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
Since:
2.0

isSelectable

public boolean isSelectable()
Tests the selectable property.
Specified by:
isSelectable in interface 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

getColorMap

public ColorMap getColorMap()
Get color map.
Returns:
color map

setBorderStyle

public void setBorderStyle(int style)
Set border style.
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.
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
Parameters:
vert - vertical alignment

setHAlign

public void setHAlign(int horz)
Set horizontal alignment
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.
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.
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
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
Since:
2.0

setVisible

public void setVisible(boolean visible)
Set visibility state for ColorKey.
Specified by:
setVisible in interface LayerChild
Since:
2.0

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Description copied from interface: java.beans.PropertyChangeListener
This method gets called when a bound property is changed.
Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Following copied from interface: java.beans.PropertyChangeListener
Parameters:
evt - A PropertyChangeEvent object describing the event source and the property that has changed.


Send comments about the Scientific Graphics toolkit to dwd@pmel.noaa.gov. For more information about Java Development in the EPIC Group see the EPIC Software Page
Generated on December 13 2001