JHotDraw 7.0.6

org.jhotdraw.draw
Class TextFigure

java.lang.Object
  extended by org.jhotdraw.draw.AbstractFigure
      extended by org.jhotdraw.draw.AttributedFigure
          extended by org.jhotdraw.draw.TextFigure
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Figure, TextHolder, DOMStorable
Direct Known Subclasses:
LabelFigure, NodeFigure, SVGText

public class TextFigure
extends AttributedFigure
implements TextHolder

A text figure.

See Also:
TextTool, Serialized Form

Field Summary
protected  java.awt.geom.Point2D.Double origin
           
 
Fields inherited from class org.jhotdraw.draw.AbstractFigure
changingDepth, decorator, listenerList
 
Constructor Summary
TextFigure()
          Creates a new instance.
TextFigure(java.lang.String text)
           
 
Method Summary
 void basicSetBounds(java.awt.geom.Point2D.Double anchor, java.awt.geom.Point2D.Double lead)
          Sets the logical bounds of the figure and of its decorator figure.
 void basicTransform(java.awt.geom.AffineTransform tx)
          Moves the figure.
 TextFigure clone()
          Returns a clone of the figure.
 boolean contains(java.awt.geom.Point2D.Double p)
          Checks if a point is contained by the figure.
 java.util.Collection<Handle> createHandles(int detailLevel)
          Creates handles used to manipulate the figure.
protected  void drawFill(java.awt.Graphics2D g)
          This method is called by method draw() to draw the fill area of the figure.
protected  void drawStroke(java.awt.Graphics2D g)
          This method is called by method draw() to draw the text of the figure .
protected  void drawText(java.awt.Graphics2D g)
           
 java.awt.geom.Rectangle2D.Double getBounds()
          Returns the logical bounds of the figure as a Rectangle.
 java.awt.geom.Rectangle2D.Double getFigureDrawBounds()
           
 java.awt.Color getFillColor()
           
 java.awt.Font getFont()
           
 float getFontSize()
           
 Insets2DDouble getInsets()
           
 TextHolder getLabelFor()
           
 Dimension2DDouble getPreferredSize()
          The preferred size is used by Layouter to determine the preferred size of a Figure.
 java.lang.Object getRestoreData()
          Gets data which can be used to restore the shape of the figure after a basicTransform has been applied to it.
 int getTabSize()
          Gets the number of characters used to expand tabs.
 java.lang.String getText()
          Gets the text shown by the text figure.
 java.awt.Color getTextColor()
           
 int getTextColumns()
          Gets the number of columns to be overlaid when the figure is edited.
protected  java.awt.font.TextLayout getTextLayout()
           
 Tool getTool(java.awt.geom.Point2D.Double p)
          Returns a specialized tool for the given coordinate.
 void invalidate()
          Informs that a figure needs to be redrawn.
 boolean isEditable()
           
 void read(DOMInput in)
           
 void restoreTo(java.lang.Object geometry)
          Restores the shape of the figure to a previously stored state.
 void setEditable(boolean b)
           
 void setFontSize(float size)
           
 void setText(java.lang.String newText)
          Sets the text shown by the text figure.
protected  void validate()
           
 void write(DOMOutput out)
           
 
Methods inherited from class org.jhotdraw.draw.AttributedFigure
applyAttributesTo, basicSetAttribute, drawConnectors, drawFigure, getAttribute, getAttributeKey, getAttributes, getStroke, getStrokeMiterLimitFactor, hasAttribute, isAttributeEnabled, readAttributes, removeAttribute, setAttribute, setAttributeEnabled, setAttributes, writeAttributes
 
Methods inherited from class org.jhotdraw.draw.AbstractFigure
addFigureListener, addNotify, addUndoableEditListener, basicClone, canConnect, changed, draw, drawDecorator, findCompatibleConnector, findConnector, findFigureInside, fireAreaInvalidated, fireAreaInvalidated, fireAttributeChanged, fireFigureAdded, fireFigureChanged, fireFigureChanged, fireFigureChanged, fireFigureRemoved, fireFigureRequestRemove, fireUndoableEditHappened, getActions, getChangingDepth, getCourtingConnection, getCursor, getDecomposition, getDecorator, getDrawBounds, getDrawing, getEndPoint, getFontRenderContext, getLayer, getLock, getStartPoint, getTooltip, handleDrop, handleMouseClick, includes, isChanging, isConnectorsVisible, isDrawDecoratorFirst, isInteractive, isVisible, remap, remap, removeFigureListener, removeNotify, removeUndoableEditListener, requestRemove, setBounds, setBounds, setConnectorsVisible, setDecorator, setDrawDecoratorFirst, setInteractive, setVisible, toString, transform, updateDecoratorBounds, willChange
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jhotdraw.draw.Figure
addFigureListener, addNotify, addUndoableEditListener, basicSetAttribute, canConnect, changed, draw, findCompatibleConnector, findConnector, findFigureInside, getActions, getAttribute, getAttributes, getCursor, getDecomposition, getDecorator, getDrawBounds, getEndPoint, getLayer, getStartPoint, getTooltip, handleDrop, handleMouseClick, includes, isConnectorsVisible, isInteractive, isVisible, remap, removeFigureListener, removeNotify, removeUndoableEditListener, requestRemove, setAttribute, setConnectorsVisible, setDecorator, setVisible, willChange
 

Field Detail

origin

protected java.awt.geom.Point2D.Double origin
Constructor Detail

TextFigure

public TextFigure()
Creates a new instance.


TextFigure

public TextFigure(java.lang.String text)
Method Detail

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

basicTransform

public void basicTransform(java.awt.geom.AffineTransform tx)
Description copied from class: AbstractFigure
Moves the figure. This is the method that subclasses override.

This is a basic operation for which no events are fired.

Specified by:
basicTransform in interface Figure
Specified by:
basicTransform in class AbstractFigure
Parameters:
tx - The transformation.

basicSetBounds

public void basicSetBounds(java.awt.geom.Point2D.Double anchor,
                           java.awt.geom.Point2D.Double lead)
Description copied from interface: Figure
Sets the logical bounds of the figure and of its decorator figure.

This is used by Tool's which create a new Figure and by Tool's which connect a Figure to another Figure.

This is a basic operation which does not fire events.

Specified by:
basicSetBounds in interface Figure
Parameters:
anchor - the start point of the bounds
lead - the end point of the bounds
See Also:
Figure.getBounds()

contains

public boolean contains(java.awt.geom.Point2D.Double p)
Description copied from interface: Figure
Checks if a point is contained by the figure.

This is used for hit testing by Tool's.

Specified by:
contains in interface Figure

drawStroke

protected void drawStroke(java.awt.Graphics2D g)
Description copied from class: AttributedFigure
This method is called by method draw() to draw the text of the figure . AttributedFigure configures the Graphics2D object with the TEXT_COLOR attribute before calling this method. If the TEXT_COLOR attribute is null, this method is not called.

Specified by:
drawStroke in class AttributedFigure

drawFill

protected void drawFill(java.awt.Graphics2D g)
Description copied from class: AttributedFigure
This method is called by method draw() to draw the fill area of the figure. AttributedFigure configures the Graphics2D object with the FILL_COLOR attribute before calling this method. If the FILL_COLOR attribute is null, this method is not called.

Specified by:
drawFill in class AttributedFigure

drawText

protected void drawText(java.awt.Graphics2D g)
Overrides:
drawText in class AttributedFigure

invalidate

public void invalidate()
Description copied from class: AbstractFigure
Informs that a figure needs to be redrawn.

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

getTextLayout

protected java.awt.font.TextLayout getTextLayout()

getBounds

public java.awt.geom.Rectangle2D.Double getBounds()
Description copied from interface: Figure
Returns the logical bounds of the figure as a Rectangle. The logical bounds are used by some Handle objects for adjusting the figure.

Specified by:
getBounds in interface Figure

getPreferredSize

public Dimension2DDouble getPreferredSize()
Description copied from interface: Figure
The preferred size is used by Layouter to determine the preferred size of a Figure. For most Figure's this is the same as the dimensions returned by getBounds.

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

getFigureDrawBounds

public java.awt.geom.Rectangle2D.Double getFigureDrawBounds()
Overrides:
getFigureDrawBounds in class AttributedFigure

createHandles

public java.util.Collection<Handle> createHandles(int detailLevel)
Description copied from interface: Figure
Creates handles used to manipulate the figure.

Specified by:
createHandles in interface Figure
Overrides:
createHandles in class AbstractFigure
Parameters:
detailLevel - The detail level of the handles. Usually this is 0 for bounding box handles and 1 for point handles.
Returns:
a Collection of handles
See Also:
Handle

validate

protected void validate()
Overrides:
validate in class AbstractFigure

isEditable

public boolean isEditable()
Specified by:
isEditable in interface TextHolder

setEditable

public void setEditable(boolean b)

getTextColumns

public int getTextColumns()
Description copied from interface: TextHolder
Gets the number of columns to be overlaid when the figure is edited.

Specified by:
getTextColumns in interface TextHolder

getTool

public Tool getTool(java.awt.geom.Point2D.Double p)
Returns a specialized tool for the given coordinate.

Returns null, if no specialized tool is available.

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

read

public void read(DOMInput in)
          throws java.io.IOException
Specified by:
read in interface DOMStorable
Overrides:
read in class AttributedFigure
Throws:
java.io.IOException

write

public void write(DOMOutput out)
           throws java.io.IOException
Specified by:
write in interface DOMStorable
Overrides:
write in class AttributedFigure
Throws:
java.io.IOException

getTabSize

public int getTabSize()
Gets the number of characters used to expand tabs.

Specified by:
getTabSize in interface TextHolder

getLabelFor

public TextHolder getLabelFor()
Specified by:
getLabelFor in interface TextHolder

getInsets

public Insets2DDouble getInsets()
Specified by:
getInsets in interface TextHolder

restoreTo

public void restoreTo(java.lang.Object geometry)
Description copied from interface: Figure
Restores the shape of the figure to a previously stored state.

Specified by:
restoreTo in interface Figure

getRestoreData

public java.lang.Object getRestoreData()
Description copied from interface: Figure
Gets data which can be used to restore the shape of the figure after a basicTransform has been applied to it.

Specified by:
getRestoreData in interface Figure
See Also:
Figure.basicTransform(AffineTransform)

clone

public TextFigure clone()
Description copied from interface: Figure
Returns a clone of the figure.

Specified by:
clone in interface Figure
Overrides:
clone in class AttributedFigure

getFont

public java.awt.Font getFont()
Specified by:
getFont in interface TextHolder

getTextColor

public java.awt.Color getTextColor()
Specified by:
getTextColor in interface TextHolder

getFillColor

public java.awt.Color getFillColor()
Specified by:
getFillColor in interface TextHolder

setFontSize

public void setFontSize(float size)
Specified by:
setFontSize in interface TextHolder

getFontSize

public float getFontSize()
Specified by:
getFontSize in interface TextHolder

Copyright 1996-2006 © JHotDraw.org