CH.ifa.draw.figures
Class TextFigure

java.lang.Object
  extended by CH.ifa.draw.standard.AbstractFigure
      extended by CH.ifa.draw.figures.AttributeFigure
          extended by CH.ifa.draw.figures.TextFigure
All Implemented Interfaces:
Figure, FigureChangeListener, TextHolder, Storable, java.io.Serializable, java.lang.Cloneable, java.util.EventListener
Direct Known Subclasses:
NodeFigure, NumberTextFigure

public class TextFigure
extends AttributeFigure
implements FigureChangeListener, TextHolder

A text figure.

See Also:
TextTool, Serialized Form

Field Summary
 
Fields inherited from interface CH.ifa.draw.framework.Figure
POPUP_MENU
 
Constructor Summary
TextFigure()
           
 
Method Summary
 boolean acceptsTyping()
          Tests whether the figure accepts typing.
 void basicDisplayBox(java.awt.Point newOrigin, java.awt.Point newCorner)
          Sets the display box of a figure.
protected  void basicMoveBy(int x, int y)
          Moves the figure.
 void changed()
          Updates the location whenever the figure changes itself.
 void connect(Figure figure)
          Connects a figure to another figure.
static java.awt.Font createCurrentFont()
          Creates the current font to be used for new text figures.
 void disconnect()
          Disconnects the text figure.
 java.awt.Rectangle displayBox()
          Gets the display box of a figure.
 void drawBackground(java.awt.Graphics g)
          Draws the background of the figure.
 void drawFrame(java.awt.Graphics g)
          Draws the frame of the figure.
 void figureChanged(FigureChangeEvent e)
          Sent when a figure changed
 void figureInvalidated(FigureChangeEvent e)
          Sent when an area is invalid
 void figureRemoved(FigureChangeEvent e)
          Sent when a figure was removed
 void figureRequestRemove(FigureChangeEvent e)
          Sent when requesting to remove a figure.
 void figureRequestUpdate(FigureChangeEvent e)
          Sent when an update should happen.
 java.lang.Object getAttribute(java.lang.String name)
          A text figure understands the "FontSize", "FontStyle", and "FontName" attributes.
 java.awt.Font getFont()
          Gets the font.
 java.lang.String getText()
          Gets the text shown by the text figure.
 java.util.Vector handles()
          Returns the handles of a Figure that can be used to manipulate some of its attributes.
 void moveBy(int x, int y)
          Moves the figure by the given offset.
 int overlayColumns()
          Gets the number of columns to be overlaid when the figure is edited.
 void read(StorableInput dr)
          Reads the Figure from a StorableInput.
 boolean readOnly()
          Tests whether this figure is read only.
 void release()
          A figure is released from the drawing.
 void setAttribute(java.lang.String name, java.lang.Object value)
          A text figure understands the "FontSize", "FontStyle", and "FontName" attributes.
static void setCurrentFontName(java.lang.String name)
          Sets the current font name
static void setCurrentFontSize(int size)
          Sets the current font size.
static void setCurrentFontStyle(int style)
          Sets the current font style.
 void setFont(java.awt.Font newFont)
          Sets the font.
 void setReadOnly(boolean isReadOnly)
          Sets the read only status of the text figure.
 void setText(java.lang.String newText)
          Sets the text shown by the text figure.
 java.awt.Rectangle textDisplayBox()
           
protected  void updateLocation()
          Updates the location relative to the connected figure.
 void write(StorableOutput dw)
          Stores the Figure to a StorableOutput.
 
Methods inherited from class CH.ifa.draw.figures.AttributeFigure
draw, getDefaultAttribute, getFillColor, getFrameColor
 
Methods inherited from class CH.ifa.draw.standard.AbstractFigure
addFigureChangeListener, addToContainer, canConnect, center, clone, connectedTextLocator, connectionInsets, connectorAt, connectorVisibility, containsPoint, decompose, displayBox, displayBox, figures, findFigureInside, includes, invalidate, isEmpty, listener, removeFigureChangeListener, removeFromContainer, size, willChange
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextFigure

public TextFigure()
Method Detail

moveBy

public void moveBy(int x,
                   int y)
Description copied from class: AbstractFigure
Moves the figure by the given offset.

Specified by:
moveBy in interface Figure
Overrides:
moveBy in class AbstractFigure

basicMoveBy

protected void basicMoveBy(int x,
                           int y)
Description copied from class: AbstractFigure
Moves the figure. This is the method that subclassers override. Clients usually call displayBox.

Specified by:
basicMoveBy in class AbstractFigure
See Also:
AbstractFigure.moveBy(int, int)

basicDisplayBox

public void basicDisplayBox(java.awt.Point newOrigin,
                            java.awt.Point newCorner)
Description copied from class: AbstractFigure
Sets the display box of a figure. This is the method that subclassers override. Clients usually call displayBox.

Specified by:
basicDisplayBox in interface Figure
Specified by:
basicDisplayBox in class AbstractFigure
Parameters:
newOrigin - the new origin
newCorner - the new corner
See Also:
AbstractFigure.displayBox(java.awt.Point, java.awt.Point)

displayBox

public java.awt.Rectangle displayBox()
Description copied from class: AbstractFigure
Gets the display box of a figure.

Specified by:
displayBox in interface Figure
Specified by:
displayBox in class AbstractFigure
See Also:
Figure.basicDisplayBox(java.awt.Point, java.awt.Point)

textDisplayBox

public java.awt.Rectangle textDisplayBox()
Specified by:
textDisplayBox in interface TextHolder

readOnly

public boolean readOnly()
Tests whether this figure is read only.


setReadOnly

public void setReadOnly(boolean isReadOnly)
Sets the read only status of the text figure.


getFont

public java.awt.Font getFont()
Gets the font.

Specified by:
getFont in interface TextHolder

setFont

public void setFont(java.awt.Font newFont)
Sets the font.


changed

public void changed()
Updates the location whenever the figure changes itself.

Specified by:
changed in interface Figure
Overrides:
changed in class AbstractFigure
See Also:
FigureChangeEvent, Figure.changed()

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
A text figure understands the "FontSize", "FontStyle", and "FontName" attributes.

Specified by:
getAttribute in interface Figure
Overrides:
getAttribute in class AttributeFigure

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
A text figure understands the "FontSize", "FontStyle", and "FontName" attributes.

Specified by:
setAttribute in interface Figure
Overrides:
setAttribute in class AttributeFigure

getText

public java.lang.String getText()
Gets the text shown by the text figure.

Specified by:
getText in interface TextHolder

setText

public void setText(java.lang.String newText)
Sets the text shown by the text figure.

Specified by:
setText in interface TextHolder

acceptsTyping

public boolean acceptsTyping()
Tests whether the figure accepts typing.

Specified by:
acceptsTyping in interface TextHolder

drawBackground

public void drawBackground(java.awt.Graphics g)
Description copied from class: AttributeFigure
Draws the background of the figure.

Overrides:
drawBackground in class AttributeFigure
See Also:
AttributeFigure.draw(java.awt.Graphics)

drawFrame

public void drawFrame(java.awt.Graphics g)
Description copied from class: AttributeFigure
Draws the frame of the figure.

Overrides:
drawFrame in class AttributeFigure
See Also:
AttributeFigure.draw(java.awt.Graphics)

overlayColumns

public int overlayColumns()
Gets the number of columns to be overlaid when the figure is edited.

Specified by:
overlayColumns in interface TextHolder

handles

public java.util.Vector handles()
Description copied from class: AbstractFigure
Returns the handles of a Figure that can be used to manipulate some of its attributes.

Specified by:
handles in interface Figure
Specified by:
handles in class AbstractFigure
Returns:
a Vector of handles
See Also:
Handle

write

public void write(StorableOutput dw)
Description copied from class: AttributeFigure
Stores the Figure to a StorableOutput.

Specified by:
write in interface Storable
Overrides:
write in class AttributeFigure

read

public void read(StorableInput dr)
          throws java.io.IOException
Description copied from class: AttributeFigure
Reads the Figure from a StorableInput.

Specified by:
read in interface Storable
Overrides:
read in class AttributeFigure
Throws:
java.io.IOException

connect

public void connect(Figure figure)
Description copied from interface: TextHolder
Connects a figure to another figure.

Specified by:
connect in interface TextHolder

figureChanged

public void figureChanged(FigureChangeEvent e)
Description copied from interface: FigureChangeListener
Sent when a figure changed

Specified by:
figureChanged in interface FigureChangeListener

figureRemoved

public void figureRemoved(FigureChangeEvent e)
Description copied from interface: FigureChangeListener
Sent when a figure was removed

Specified by:
figureRemoved in interface FigureChangeListener

figureRequestRemove

public void figureRequestRemove(FigureChangeEvent e)
Description copied from interface: FigureChangeListener
Sent when requesting to remove a figure.

Specified by:
figureRequestRemove in interface FigureChangeListener

figureInvalidated

public void figureInvalidated(FigureChangeEvent e)
Description copied from interface: FigureChangeListener
Sent when an area is invalid

Specified by:
figureInvalidated in interface FigureChangeListener

figureRequestUpdate

public void figureRequestUpdate(FigureChangeEvent e)
Description copied from interface: FigureChangeListener
Sent when an update should happen.

Specified by:
figureRequestUpdate in interface FigureChangeListener

updateLocation

protected void updateLocation()
Updates the location relative to the connected figure. The TextFigure is centered around the located point.


release

public void release()
Description copied from class: AbstractFigure
A figure is released from the drawing. You never call this method directly. Release notifies its listeners.

Specified by:
release in interface Figure
Overrides:
release in class AbstractFigure
See Also:
Figure.release()

disconnect

public void disconnect()
Disconnects the text figure.


createCurrentFont

public static java.awt.Font createCurrentFont()
Creates the current font to be used for new text figures.


setCurrentFontName

public static void setCurrentFontName(java.lang.String name)
Sets the current font name


setCurrentFontSize

public static void setCurrentFontSize(int size)
Sets the current font size.


setCurrentFontStyle

public static void setCurrentFontStyle(int style)
Sets the current font style.