gov.noaa.pmel.sgt
Class SGLabel

java.lang.Object
  |
  +--gov.noaa.pmel.sgt.SGLabel
All Implemented Interfaces:
java.lang.Cloneable, LayerChild, Moveable, Selectable

public class SGLabel
extends java.lang.Object
implements java.lang.Cloneable, LayerChild, Moveable

Draws text on a layer object. SGLabel uses the drawString() method of the Graphics class. SGLabel allows the user to align the text both vertically (TOP, MIDDLE, and BOTTOM) and horizontally (LEFT, MIDDLE, and RIGHT). The font, color, and height (in user coordinates) can also be specified. The SGLabel can also be drawn either HORIZONTAL or VERTICAL.

Since:
1.0
Version:
$Revision: 1.19 $, $Date: 2001/12/13 19:07:05 $
Author:
Donald Denbo
See Also:
Graphics

Field Summary
static int ANGLE
          Orient label at an angle
static int BOTTOM
          Align bottom of label
static int CENTER
          Align center of label
static int HORIZONTAL
          Orient label horizontal
static int LEFT
          Align left of label
static int MIDDLE
          Align middle of label
static int RIGHT
          Align right of label
static int TOP
          Align top of label
static int VERTICAL
          Orient label vertical
 
Constructor Summary
SGLabel(java.lang.String id, java.lang.String lbl, double hgt, Point2D.Double loc, int valign, int halign)
          Long SGLabel constructor.
SGLabel(java.lang.String id, java.lang.String lbl, Point2D.Double loc)
          Quick SGLabel constructor.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Add a new PropertyChangeListener.
 LayerChild copy()
          Create a copy of the LayerChild.
 void draw(java.awt.Graphics g)
          Draw the LayerChild.
 double getAngle()
          Get label drawing angle.
 java.awt.Rectangle getBounds()
          Get the label bounds in device units.
 Rectangle2D.Double getBoundsP()
          Get the label bounds in physical units.
 java.awt.Color getColor()
          Get the color.
 java.awt.Font getFont()
          Get the font.
 int getHAlign()
          Get the horizontal alignment.
 int getHeight()
          Get the label height in device coordinates.
 double getHeightP()
          Get the label height in physical coordinates.
 java.lang.String getId()
          Get the label identifier.
 Layer getLayer()
          Get the layer.
 java.awt.Point getLocation()
          Get the label position in device coordinates.
 Point2D.Double getLocationP()
          Get the label reference location in physcial coordinates.
 int getOrientation()
          Get the origentation.
 AbstractPane getPane()
          Get AbstractPane of the LayerChild.
 float getStringHeight(java.awt.Graphics g)
          Get the string height in device units.
 float getStringWidth(java.awt.Graphics g)
          Get the string width in device units.
 java.lang.String getText()
          Get the label text.
 int getVAlign()
          Get the vertical alignment.
 boolean isMoveable()
          Returns true if the current state is moveable
 boolean isSelectable()
          Returns true if the current state is selectable.
 boolean isSelected()
          Returns true if the object's selected property is set.
 boolean isVisible()
          Check if LayerChild is visible.
 void modified(java.lang.String text)
          Used by sgt internally.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Remove a listener.
 void setAlign(int vert, int horz)
          Set the vertical and horizontal alignment.
 void setAngle(double angle)
          Draw label at arbitrary rotation.
 void setBounds(int x, int y, int width, int height)
          Set the label bounds in device units.
 void setBounds(java.awt.Rectangle r)
          Set the label bounds in device units.
 void setColor(java.awt.Color color)
          Set the color.
 void setFont(java.awt.Font fnt)
          Set the font.
 void setHAlign(int horz)
          Set the horizontal alignment.
 void setHeightP(double hgt)
          Set the height of the label in physical coordinates.
 void setId(java.lang.String id)
          Set the label identifier.
 void setLayer(Layer l)
          Associate a Layer with the LayerChild.
 void setLocation(java.awt.Point loc)
          Set the label reference location in pixel coordinates.
 void setLocationP(Point2D.Double loc)
          Set the label reference location in physcial coordinates.
 void setMoveable(boolean moveable)
          Set the moveable property.
 void setOrientation(int orient)
          Set the orientation.
 void setSelectable(boolean select)
          Set the Selectable property.
 void setSelected(boolean sel)
          Sets the selected property.
 void setText(java.lang.String lbl)
          Set the label text.
 void setVAlign(int vert)
          Set the vertical alignment.
 void setVisible(boolean visible)
          Set visibility for a LayerChild.
 java.lang.String toString()
          Return a string that represents the LayerChild.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TOP

public static final int TOP
Align top of label

MIDDLE

public static final int MIDDLE
Align middle of label

BOTTOM

public static final int BOTTOM
Align bottom of label

LEFT

public static final int LEFT
Align left of label

CENTER

public static final int CENTER
Align center of label

RIGHT

public static final int RIGHT
Align right of label

HORIZONTAL

public static final int HORIZONTAL
Orient label horizontal

VERTICAL

public static final int VERTICAL
Orient label vertical

ANGLE

public static final int ANGLE
Orient label at an angle
Since:
2.0
Constructor Detail

SGLabel

public SGLabel(java.lang.String id,
               java.lang.String lbl,
               Point2D.Double loc)
Quick SGLabel constructor. Default alignment of BOTTOM and LEFT are used. Default height is 0.12.
Parameters:
id - Label identifier
lbl - String to be plotted.

SGLabel

public SGLabel(java.lang.String id,
               java.lang.String lbl,
               double hgt,
               Point2D.Double loc,
               int valign,
               int halign)
Long SGLabel constructor.
Parameters:
id - Label identifier
lbl - String to be plotted
hgt - String height in physical units
loc - Location to plot label in physical units
valign - Vertical alignment
halign - Horizontal alignment
Method Detail

copy

public LayerChild copy()
Description copied from interface: LayerChild
Create a copy of the LayerChild.
Specified by:
copy in interface LayerChild
Following copied from interface: gov.noaa.pmel.sgt.LayerChild
Returns:
A copy of the LayerChild.

draw

public void draw(java.awt.Graphics g)
          throws LayerNotFoundException
Description copied from interface: LayerChild
Draw the LayerChild.
Specified by:
draw in interface LayerChild
Following copied from interface: gov.noaa.pmel.sgt.LayerChild
Parameters:
g - Graphics context
Throws:
LayerNotFoundException - No layer is associated with the LayerChild.

setSelected

public void setSelected(boolean sel)
Description copied from interface: Selectable
Sets the selected property.
Specified by:
setSelected in interface Selectable
Following copied from interface: gov.noaa.pmel.sgt.Selectable
Parameters:
sel - true if selected, false if not.

isSelected

public boolean isSelected()
Description copied from interface: Selectable
Returns true if the object's selected property is set.
Specified by:
isSelected in interface Selectable
Following copied from interface: gov.noaa.pmel.sgt.Selectable
Returns:
true if selected, false if not.

setSelectable

public void setSelectable(boolean select)
Description copied from interface: Selectable
Set the Selectable property.
Specified by:
setSelectable in interface Selectable
Following copied from interface: gov.noaa.pmel.sgt.Selectable
Parameters:
select - if true object is selectable

isSelectable

public boolean isSelectable()
Description copied from interface: Selectable
Returns true if the current state is selectable.
Specified by:
isSelectable in interface Selectable
Following copied from interface: gov.noaa.pmel.sgt.Selectable
Returns:
true if selectable

setColor

public void setColor(java.awt.Color color)
Set the color.
Parameters:
color - The color of the label.
See Also:
Color

getColor

public java.awt.Color getColor()
Get the color.
Returns:
The current color of the label.

setFont

public void setFont(java.awt.Font fnt)
Set the font.
Parameters:
fnt - The Font to use to draw the label.
See Also:
Font

getFont

public java.awt.Font getFont()
Get the font.
Returns:
The current font for the label.

setHeightP

public void setHeightP(double hgt)
Set the height of the label in physical coordinates.
Parameters:
hgt - The label height.

getHeightP

public double getHeightP()
Get the label height in physical coordinates.
Returns:
The label height.

setAlign

public void setAlign(int vert,
                     int horz)
Set the vertical and horizontal alignment. The vertical alignment can be TOP, MIDDLE, or BOTTOM, and the horizontal alignment LEFT, CENTER, or RIGHT.
Parameters:
vert - The vertical alignment.
horz - The horizontal alignment.

setHAlign

public void setHAlign(int horz)
Set the horizontal alignment. The alignment can be LEFT, CENTER, or RIGHT.
Parameters:
horz - The horizontal alignment.

getHAlign

public int getHAlign()
Get the horizontal alignment.
Returns:
the horizontal alignment.

setVAlign

public void setVAlign(int vert)
Set the vertical alignment. The alignment can be TOP, MIDDLE, or BOTTOM.
Parameters:
vert - The vertical alignment.

getVAlign

public int getVAlign()
Get the vertical alignment.
Returns:
the vertical alignment.

setLocationP

public void setLocationP(Point2D.Double loc)
Set the label reference location in physcial coordinates.
Property Change: location.
Parameters:
loc - physical location of label

getLocationP

public Point2D.Double getLocationP()
Get the label reference location in physcial coordinates.
Returns:
the labels position.

setOrientation

public void setOrientation(int orient)
Set the orientation. The orientation can be HORIZONTAL or VERTICAL.
Parameters:
orient - The orientation.

getOrientation

public int getOrientation()
Get the origentation.
Returns:
the orientation

setAngle

public void setAngle(double angle)
Draw label at arbitrary rotation. Warning: Rotated labels are not drawn very well when using JDK1.1. For best results use JDK1.2 or newer.
Since:
2.0

getAngle

public double getAngle()
Get label drawing angle.
Since:
2.0

setLayer

public void setLayer(Layer l)
Description copied from interface: LayerChild
Associate a Layer with the LayerChild.
Specified by:
setLayer in interface LayerChild
Following copied from interface: gov.noaa.pmel.sgt.LayerChild
Parameters:
l - Parent layer.

getLayer

public Layer getLayer()
Get the layer.
Specified by:
getLayer in interface LayerChild
Returns:
the layer object.

getPane

public AbstractPane getPane()
Description copied from interface: LayerChild
Get AbstractPane of the LayerChild.
Specified by:
getPane in interface LayerChild

modified

public void modified(java.lang.String text)
Description copied from interface: LayerChild
Used by sgt internally.
Specified by:
modified in interface LayerChild

getText

public java.lang.String getText()
Get the label text.
Returns:
the label text

setText

public void setText(java.lang.String lbl)
Set the label text.
Parameters:
lbl - the label text

getId

public java.lang.String getId()
Get the label identifier.
Specified by:
getId in interface LayerChild
Returns:
the identifier

setId

public void setId(java.lang.String id)
Set the label identifier.
Specified by:
setId in interface LayerChild
Parameters:
id - the label identifier

getHeight

public int getHeight()
Get the label height in device coordinates.
Returns:
the label height

getLocation

public java.awt.Point getLocation()
Get the label position in device coordinates.
Specified by:
getLocation in interface Moveable
Returns:
the label position

setLocation

public void setLocation(java.awt.Point loc)
Set the label reference location in pixel coordinates.
Property Change: location.
Specified by:
setLocation in interface Moveable
Parameters:
loc - physical location of label

getBoundsP

public Rectangle2D.Double getBoundsP()
Get the label bounds in physical units.
Returns:
the label bounds

getBounds

public java.awt.Rectangle getBounds()
Get the label bounds in device units.
Specified by:
getBounds in interface Selectable
Returns:
the label bounds

setBounds

public void setBounds(java.awt.Rectangle r)
Set the label bounds in device units.

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Set the label bounds in device units.

toString

public java.lang.String toString()
Description copied from interface: LayerChild
Return a string that represents the LayerChild.
Specified by:
toString in interface LayerChild
Overrides:
toString in class java.lang.Object
Following copied from interface: gov.noaa.pmel.sgt.LayerChild
Returns:
Stringified LayerChild representation.

isVisible

public boolean isVisible()
Description copied from interface: LayerChild
Check if LayerChild is visible.
Specified by:
isVisible in interface LayerChild
Following copied from interface: gov.noaa.pmel.sgt.LayerChild
Returns:
true if visible

setVisible

public void setVisible(boolean visible)
Description copied from interface: LayerChild
Set visibility for a LayerChild.
Specified by:
setVisible in interface LayerChild
Following copied from interface: gov.noaa.pmel.sgt.LayerChild
Parameters:
visible - visible if true

isMoveable

public boolean isMoveable()
Description copied from interface: Moveable
Returns true if the current state is moveable
Specified by:
isMoveable in interface Moveable
Following copied from interface: gov.noaa.pmel.sgt.Moveable
Returns:
true if moveable

setMoveable

public void setMoveable(boolean moveable)
Description copied from interface: Moveable
Set the moveable property.
Specified by:
setMoveable in interface Moveable
Following copied from interface: gov.noaa.pmel.sgt.Moveable
Parameters:
select - if true object is moveable

getStringWidth

public float getStringWidth(java.awt.Graphics g)
Get the string width in device units.
Since:
2.0

getStringHeight

public float getStringHeight(java.awt.Graphics g)
Get the string height in device units.
Since:
2.0

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Description copied from interface: Moveable
Add a new PropertyChangeListener. Properties will include "moved". Implementation of the following two methods will normally be via the PropertyChangeSupport class.
Specified by:
addPropertyChangeListener in interface Moveable

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Description copied from interface: Moveable
Remove a listener.
Specified by:
removePropertyChangeListener in interface Moveable


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