Class Label

  extended byjfig.objects.FigBaseobject
      extended byjfig.objects.FigText
          extended byhades.symbols.Label
All Implemented Interfaces:
FigDrawable, FigObject, java.io.Serializable
Direct Known Subclasses:
BindkeyLabel, ClassLabel, ColoredValueLabel, ColoredValueLabel, FatLabel, InstanceLabel, PortLabel

public class Label
extends FigText
implements java.io.Serializable

Label: a basic label on a SimObject's symbol.

This class is realized as a subclass of FigText with specific attributes: layer 10, color red, SansSerif 10pt, left aligned and may be subclassed for other attributes.

See Also:
Serialized Form

Field Summary
protected  ColorSource colorSource
protected  TextSource textSource
Fields inherited from class jfig.objects.FigText
Fields inherited from class jfig.objects.FigBaseobject
attribs, bbox, comment, debug, painter, printer, sc_bbox, sc_bbox_timestamp, selected, showPoints, syncRedrawFlag, timestamp, trafo, visible, x, y
Constructor Summary
          construct an empty Label.
Method Summary
protected  void build_attribs()
 FigObject copy()
          build a copy of this FigText object.
 boolean initialize(java.lang.String s)
          initialize an Label from a String.
 void mirrorY(int mirror_x, int mirror_y)
          mirrorY(): we override the method of our base class FigText, because we don't want to put the text upside down, but just to set a new text base point (text origin).
 void paint(java.awt.Graphics g)
          paint this Label to Graphics g.
 void setColorSource(ColorSource _colorSource)
 void setTextSource(TextSource _textSource)
          set the TextSource for deferred repaints on this Label.
 java.lang.String toString()
          toString() - the usual info method
 void writeAsResource(java.io.PrintWriter ps)
          default implementation of 'writeAsResource'.
Methods inherited from class jfig.objects.FigText
canRotate, createRenderer, getPoints, getText, getTextCursorIndex, initializeCursor, isShowCursor, keyPressed, minDistance_OLD, minDistance, minDistanceEuclid, mirrorX, move, moveCursorTo, paint, paintSave, rebuild, rotate, scale, setColor, setCursor, setFont, setFontSize, setPoints, setText, setTextAlignment, setTrafo, showCursor, symbol_recode, update_bbox, update
Methods inherited from class jfig.objects.FigBaseobject
appendPoint, build_sc_bbox, clonePoints, deletePoint, deselect, get_sc_bbox, getAttributes, getBbox, getComment, getLayer, getMovePointNeighbors, getNearestPoint, getNeighborPoints, getPosition, getSyncRedrawFlag, getTimestamp, getTrafo, insertPoint, isClosed, isSelected, isShowPoints, isVisible, isVisible, manhattan, message, movePoint, numPoints, reset_debug, select, set_debug, setAttributes, setComment, setConsole, setObjectPainter, setSyncRedrawFlag, setVisible, showPoints, supportsPointOps, updateAttributes
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail


protected TextSource textSource


protected ColorSource colorSource
Constructor Detail


public Label()
construct an empty Label.

Method Detail


public boolean initialize(java.lang.String s)
initialize an Label from a String. The String contains either the x and y coordinates and the label String or the x and y coordinates, and alignment index, and the label String, or a 6 attributes format:
x y label
x y 3 label
x y align FIG_font_index size color_rgb label
The possible alignments are 1 (left), 2 (center), and 3 (right). Example: (16=FIG Helvetica, 27=27, 36864=0x009000=green4
"1200 2400 2 16 24 36864 my_nice_label"

Specified by:
initialize in interface FigObject
initialize in class FigBaseobject


protected void build_attribs()


public void writeAsResource(java.io.PrintWriter ps)
Description copied from class: FigBaseobject
default implementation of 'writeAsResource'. This will write a nearly xfig-compatible version of all basic FigObjects.

Specified by:
writeAsResource in interface FigObject
writeAsResource in class FigBaseobject


public FigObject copy()
Description copied from class: FigText
build a copy of this FigText object.

Specified by:
copy in interface FigObject
copy in class FigText


public void mirrorY(int mirror_x,
                    int mirror_y)
mirrorY(): we override the method of our base class FigText, because we don't want to put the text upside down, but just to set a new text base point (text origin). In order to keep the relative position of Labels within Symbols, we try to center the text string inside its bounding box, using the FontMetrics info (ascent, descent, ...).

Specified by:
mirrorY in interface FigObject
mirrorY in class FigText


public void setTextSource(TextSource _textSource)
set the TextSource for deferred repaints on this Label.

If a (non-null) TextSource is specified for a Label, it is no longer necessary to call setText() to change the Label text. Instead, the text to be displayed is fetched from the TextSource every time the Label is paint()ed.

This defers the construction and formatting of the String object and the (costly) accesses to the AWT FontMetrics until the Label is actually used.


public void setColorSource(ColorSource _colorSource)


public void paint(java.awt.Graphics g)
paint this Label to Graphics g.

Note that the String to be displayed by this Label is reconstructed on every repaint, if our TextSource is non-null;

Specified by:
paint in interface FigObject
paint in class FigText


public java.lang.String toString()
toString() - the usual info method

Specified by:
toString in interface FigObject
toString in class FigText