simtools.shapes
Class LabelShape

java.lang.Object
  extended by simtools.shapes.AbstractShape
      extended by simtools.shapes.LabelShape
All Implemented Interfaces:
java.awt.Shape, java.io.Serializable, java.lang.Cloneable, NamedProperties

public class LabelShape
extends AbstractShape
implements java.io.Serializable, java.lang.Cloneable

This class enables to display strings on one line with a left or right or center position versus an anchor

Version:
1.0 2001
Author:
Claude Cazenave
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class simtools.shapes.AbstractShape
AbstractShape.AbstractShapePropertiesNames
 
Field Summary
protected static java.awt.font.FontRenderContext _frch
           
protected static java.awt.geom.AffineTransform _trv
           
protected  int anchorSide
           
static int CENTER
           
static int CENTERDOWN
           
static int CENTERUP
           
protected  java.awt.Font font
           
static int LEFT
           
static int LEFTDOWN
           
static int LEFTUP
           
static int RIGHT
           
static int RIGHTDOWN
           
static int RIGHTUP
           
protected  java.lang.String text
           
protected  boolean vertical
           
 
Fields inherited from class simtools.shapes.AbstractShape
_h, _ox, _oy, _propertyNames, _w, _x, _y, ANTI_ALIASING, currentDialogBox, FONT_NAMES, listeners, REFRESH_PERIOD
 
Constructor Summary
LabelShape(java.lang.String s, int ox, int oy, int anchorSide, boolean vertical)
          Creates a new label
 
Method Summary
 void draw(java.awt.Graphics2D g)
          Draws the label
static void draw(java.awt.Graphics2D g, LabelShape[] l)
          Draws a set of label and assume they share the same direction
protected  void drawText(java.awt.Graphics2D g, int x, int y, int w, int h)
          Draws the text in the rectangle specified, presupposing it is correct and match the graphics transform.
 int getAnchorSide()
           
 int getSide()
          Gets the text side wrt the anchor
 java.lang.String getString()
          Gets the text string
 java.lang.String getText()
           
 boolean isVertical()
           
 void setAnchorSide(int anchorSide)
           
 void setBounds(java.awt.Font f)
          Computes the shape bounds
 void setSide(int s)
          Sets the text side wrt the anchor
 void setString(java.lang.String s)
          Sets the text string
 void setText(java.lang.String text)
           
 void setVertical(boolean vertical)
           
 
Methods inherited from class simtools.shapes.AbstractShape
addListener, cloneShape, contains, contains, contains, contains, getAnchor, getBounds, getBounds2D, getInnerProperties, getMax, getMaxTranslated, getMin, getPathIterator, getPathIterator, getPropertyNames, getPropertyValue, intersects, intersects, notifyChange, notifyChange, refresh, removeListener, setAnchor, setAnchor, setProperties, setPropertyValue, translate, wipeOff
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_trv

protected static final java.awt.geom.AffineTransform _trv

_frch

protected static final java.awt.font.FontRenderContext _frch

LEFT

public static final int LEFT
See Also:
Constant Field Values

RIGHT

public static final int RIGHT
See Also:
Constant Field Values

CENTER

public static final int CENTER
See Also:
Constant Field Values

LEFTUP

public static final int LEFTUP
See Also:
Constant Field Values

RIGHTUP

public static final int RIGHTUP
See Also:
Constant Field Values

CENTERUP

public static final int CENTERUP
See Also:
Constant Field Values

LEFTDOWN

public static final int LEFTDOWN
See Also:
Constant Field Values

RIGHTDOWN

public static final int RIGHTDOWN
See Also:
Constant Field Values

CENTERDOWN

public static final int CENTERDOWN
See Also:
Constant Field Values

anchorSide

protected int anchorSide

vertical

protected boolean vertical

text

protected java.lang.String text

font

protected java.awt.Font font
Constructor Detail

LabelShape

public LabelShape(java.lang.String s,
                  int ox,
                  int oy,
                  int anchorSide,
                  boolean vertical)
Creates a new label

Parameters:
s - the string to display
ox - the anchor x position
oy - the anchor y position
anchorSide - the text postion wrt the anchor (LEFT, CENTER, ...)
vertical - true if string is vertically displayed
Method Detail

getText

public java.lang.String getText()
Returns:

setText

public void setText(java.lang.String text)
Parameters:
text -

getAnchorSide

public int getAnchorSide()
Returns:

setAnchorSide

public void setAnchorSide(int anchorSide)
Parameters:
anchorSide -

isVertical

public boolean isVertical()
Returns:

setVertical

public void setVertical(boolean vertical)
Parameters:
vertical -

setSide

public void setSide(int s)
Sets the text side wrt the anchor

Parameters:
s - the new side

getSide

public int getSide()
Gets the text side wrt the anchor

Returns:
the side

setString

public void setString(java.lang.String s)
Sets the text string

Parameters:
s - the new string

getString

public java.lang.String getString()
Gets the text string

Returns:
the string

setBounds

public void setBounds(java.awt.Font f)
Computes the shape bounds

Parameters:
f - the font to be used

draw

public void draw(java.awt.Graphics2D g)
Draws the label

Specified by:
draw in class AbstractShape
Parameters:
g - the graphics context

draw

public static void draw(java.awt.Graphics2D g,
                        LabelShape[] l)
Draws a set of label and assume they share the same direction

Parameters:
g - the graphics context
l - the labels

drawText

protected void drawText(java.awt.Graphics2D g,
                        int x,
                        int y,
                        int w,
                        int h)
Draws the text in the rectangle specified, presupposing it is correct and match the graphics transform.