|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jhotdraw.standard.AbstractFigure
org.jhotdraw.figures.AttributeFigure
org.jhotdraw.contrib.TextAreaFigure
A TextAreaFigure contains formatted text.
It automatically rearranges the text to fit its allocated display area,
breaking the lines at word boundaries whenever possible.
The text can contain either LF or CRLF sequences to separate paragraphs,
as well as tab characters for table like formatting and alignment.
Currently the tabs are distributed at regular intervals as determined by
the TabSize property. Tabs align correctly with either fixed
or variable fonts.
If, when resizing, the vertical size of the display box is not enough to
display all the text, TextAreaFigure displays a dashed red line at the
bottom of the figure to indicate there is hidden text.
TextAreFigure uses all standard attributes for the area rectangle,
ie: FillColor, PenColor for the border, FontSize, FontStyle, and FontName,
as well as four additional attributes LeftMargin, RightMargin, TopMargin,
and TabSize.
Field Summary | |
protected java.util.Hashtable |
attributesMap
Map of attributes for the AttributedString used for the figure's text. |
protected java.awt.Font |
fFont
The current font |
protected boolean |
fFontIsDirty
True if the font has changed and font related calculations need to be remade |
protected float |
fFontWidth
The width of the current font |
protected boolean |
fIsReadOnly
True if the figure is read only |
protected OffsetLocator |
fLocator
Description of the Field |
protected Figure |
fObservedFigure
A connected figure |
protected java.util.List |
fParagraphs
Paragraph cache resulting from splitting the text |
protected boolean |
fSizeIsDirty
True if the sizing needs to be recalculated |
protected java.lang.String |
fText
The text |
protected boolean |
fTextIsDirty
True if the paragraph's cache needs to be reconstructed |
Fields inherited from interface org.jhotdraw.framework.Figure |
POPUP_MENU |
Constructor Summary | |
TextAreaFigure()
Constructor for the TextAreaFigure object |
Method Summary | |
boolean |
acceptsTyping()
Tests whether the figure accepts typing. |
void |
basicDisplayBox(java.awt.Point origin,
java.awt.Point corner)
Sets the display box for the figure |
protected void |
basicMoveBy(int x,
int y)
Moves the figure the supplied offset |
void |
connect(Figure figure)
Connects the figure to another figure |
java.awt.Font |
createFont()
Creates the font from current attributes. |
void |
disconnect(Figure disconnectFigure)
Disconnects a text holder from a connect figure. |
java.awt.Rectangle |
displayBox()
Returns the current display box for the figure |
void |
draw(java.awt.Graphics g)
Draws the figure. |
void |
drawBackground(java.awt.Graphics g)
Draws the background for the figure. |
void |
drawFrame(java.awt.Graphics g)
Draws the frame around the text |
protected float |
drawText(java.awt.Graphics g,
java.awt.Rectangle displayBox)
Formats and draws the text for the figure |
void |
figureChanged(FigureChangeEvent e)
A connected figure has changed, update the figure's location |
void |
figureInvalidated(FigureChangeEvent e)
Description of the Method |
void |
figureRemoved(FigureChangeEvent e)
The figure is about to be removed from another composite figure |
void |
figureRequestRemove(FigureChangeEvent e)
A request to remove the figure from another composite figure |
void |
figureRequestUpdate(FigureChangeEvent e)
Sent when an update should happen. |
java.lang.Object |
getAttribute(java.lang.String name)
Deprecated. use getAttribute(FigureAttributeConstant) |
java.awt.Font |
getFont()
Gets the font. |
protected float |
getFontWidth()
Gets the font width for the active font. |
protected java.lang.String |
getNextParagraph(java.lang.String text,
java.awt.Point pos)
Gets the next paragraph in the supplied string Paragraphs are defined by a LF or CRLF sequence Scanning starts from the next characters as given by the pos.y value |
Figure |
getRepresentingFigure()
Usually, a TextHolders is implemented by a Figure subclass. |
java.lang.String |
getText()
Gets the text of the figure |
java.awt.Color |
getTextColor()
Gets the text color of a figure. |
HandleEnumeration |
handles()
Returns an iterator of standard sizing handles to manipulate the figure |
boolean |
isEmpty()
Gets the empty attribute of the figure. |
boolean |
isFontDirty()
Gets the fontDirty attribute of the TextAreaFigure object |
boolean |
isReadOnly()
|
boolean |
isSizeDirty()
Returns the current size dirty status |
boolean |
isTextDirty()
Gets the textDirty attribute of the TextAreaFigure object |
protected void |
markFontDirty()
Called whenever the something changes that requires font recomputing |
protected void |
markSizeDirty()
Called whenever the something changes that requires size recomputing |
protected void |
markTextDirty()
Called whenever the something changes that requires text recomputing |
void |
moveBy(int x,
int y)
Moves the figure the supplied offset |
int |
overlayColumns()
Gets the number of columns to be overlaid when the figure is edited. |
protected void |
prepareText()
Splits the text into paragraphs. |
void |
read(StorableInput dr)
Reads the figure from StorableInput |
protected void |
readObject(java.io.ObjectInputStream s)
Reads the figure from an object stream |
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Deprecated. use setAttribute(FigureAttributeConstant, Object) |
void |
setFont(java.awt.Font newFont)
Sets the font. |
void |
setFontDirty(boolean newFontIsDirty)
Sets the fontDirty attribute of the TextAreaFigure object |
void |
setReadOnly(boolean newReadOnly)
|
void |
setSizeDirty(boolean newSizeIsDirty)
Called to set the dirty status of the size |
void |
setText(java.lang.String newText)
Sets the text of the figure |
protected void |
setTextDirty(boolean newTextDirty)
Sets the textDirty attribute of the TextAreaFigure object |
java.awt.Rectangle |
textDisplayBox()
Returns the display box for the text |
protected void |
updateFontInfo()
Retrieve all Font information needed |
protected void |
updateLocation()
Updates the location relative to the connected figure. |
void |
write(StorableOutput dw)
Writes the figure to StorableOutput |
Methods inherited from class org.jhotdraw.figures.AttributeFigure |
getAttribute, getDefaultAttribute, getDefaultAttribute, getFillColor, getFrameColor, initDefaultAttribute, setAttribute, setDefaultAttribute |
Methods inherited from class org.jhotdraw.standard.AbstractFigure |
addDependendFigure, addFigureChangeListener, addToContainer, canConnect, center, changed, clone, connectedTextLocator, connectionInsets, connectorAt, connectorVisibility, containsPoint, decompose, displayBox, displayBox, figures, findFigureInside, getDecoratedFigure, getDependendFigures, getTextHolder, getZValue, includes, invalidate, invalidateRectangle, listener, release, removeDependendFigure, removeFigureChangeListener, removeFromContainer, setZValue, size, visit, willChange |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected boolean fTextIsDirty
protected transient boolean fSizeIsDirty
protected java.util.List fParagraphs
protected java.lang.String fText
protected java.awt.Font fFont
protected boolean fFontIsDirty
protected float fFontWidth
protected java.util.Hashtable attributesMap
protected boolean fIsReadOnly
protected Figure fObservedFigure
protected OffsetLocator fLocator
Constructor Detail |
public TextAreaFigure()
Method Detail |
public java.lang.String getText()
getText
in interface TextHolder
public void setText(java.lang.String newText)
setText
in interface TextHolder
newText
- The new text valuepublic java.awt.Rectangle textDisplayBox()
textDisplayBox
in interface TextHolder
public java.awt.Font createFont()
public boolean isReadOnly()
public void setReadOnly(boolean newReadOnly)
public boolean acceptsTyping()
acceptsTyping
in interface TextHolder
protected void markTextDirty()
protected void setTextDirty(boolean newTextDirty)
newTextDirty
- The new textDirty valuepublic boolean isTextDirty()
protected void markSizeDirty()
public void setSizeDirty(boolean newSizeIsDirty)
newSizeIsDirty
- The new sizeDirty valuepublic boolean isSizeDirty()
public java.awt.Font getFont()
getFont
in interface TextHolder
public void setFont(java.awt.Font newFont)
newFont
- The new font valuepublic int overlayColumns()
overlayColumns
in interface TextHolder
public void basicDisplayBox(java.awt.Point origin, java.awt.Point corner)
basicDisplayBox
in interface Figure
basicDisplayBox
in class AbstractFigure
origin
- origin pointcorner
- corner pointFigure
public HandleEnumeration handles()
handles
in interface Figure
handles
in class AbstractFigure
Handle
public java.awt.Rectangle displayBox()
displayBox
in interface Figure
displayBox
in class AbstractFigure
public void moveBy(int x, int y)
moveBy
in interface Figure
moveBy
in class AbstractFigure
x
- x displacementy
- y displacementprotected void basicMoveBy(int x, int y)
basicMoveBy
in class AbstractFigure
x
- x displacementy
- y displacementAbstractFigure.moveBy(int, int)
public void drawBackground(java.awt.Graphics g)
drawBackground
in class AttributeFigure
g
- The graphics to use for the drawingAttributeFigure.draw(java.awt.Graphics)
public void draw(java.awt.Graphics g)
draw
in interface Figure
draw
in class AttributeFigure
g
- The graphics to use for the drawingpublic void drawFrame(java.awt.Graphics g)
drawFrame
in class AttributeFigure
g
- The graphics to use for the drawingAttributeFigure.draw(java.awt.Graphics)
protected float drawText(java.awt.Graphics g, java.awt.Rectangle displayBox)
g
- the graphics for the drawing. It can be null when
called just to compute the sizedisplayBox
- the display box within which the text should be formatted and drawn
protected void prepareText()
protected java.lang.String getNextParagraph(java.lang.String text, java.awt.Point pos)
text
- the text to break into paragraphspos
- a point where pos.x is the position of the first character of the paragraph in
the string and pos.y is the last
public java.lang.Object getAttribute(java.lang.String name)
getAttribute
in interface Figure
getAttribute
in class AttributeFigure
name
- the attribute's name
public void setAttribute(java.lang.String name, java.lang.Object value)
setAttribute
in interface Figure
setAttribute
in class AttributeFigure
name
- the new attribute namevalue
- the new attribute valuepublic void write(StorableOutput dw)
write
in interface Storable
write
in class AttributeFigure
dw
- the output storablepublic void read(StorableInput dr) throws java.io.IOException
read
in interface Storable
read
in class AttributeFigure
dr
- Description of the Parameter
java.io.IOException
- the inout storableprotected void readObject(java.io.ObjectInputStream s) throws java.lang.ClassNotFoundException, java.io.IOException
s
- the input stream
java.lang.ClassNotFoundException
- thrown by called methods
java.io.IOException
- thrown by called methodspublic void connect(Figure figure)
connect
in interface TextHolder
figure
- the connecting figurepublic void disconnect(Figure disconnectFigure)
disconnect
in interface TextHolder
disconnectFigure
- the disconnecting figurepublic void figureInvalidated(FigureChangeEvent e)
figureInvalidated
in interface FigureChangeListener
e
- Description of the Parameterpublic void figureChanged(FigureChangeEvent e)
figureChanged
in interface FigureChangeListener
e
- Description of the Parameterprotected void updateLocation()
public void figureRemoved(FigureChangeEvent e)
figureRemoved
in interface FigureChangeListener
e
- Description of the Parameterpublic void figureRequestRemove(FigureChangeEvent e)
figureRequestRemove
in interface FigureChangeListener
e
- Description of the Parameterpublic void figureRequestUpdate(FigureChangeEvent e)
FigureChangeListener
figureRequestUpdate
in interface FigureChangeListener
e
- Description of the Parameterprotected float getFontWidth()
protected void updateFontInfo()
public java.awt.Color getTextColor()
getAttribute(java.lang.String)
public boolean isEmpty()
isEmpty
in interface Figure
isEmpty
in class AbstractFigure
Figure.isEmpty()
protected void markFontDirty()
public boolean isFontDirty()
public void setFontDirty(boolean newFontIsDirty)
newFontIsDirty
- The new fontDirty valuepublic Figure getRepresentingFigure()
getRepresentingFigure
in interface TextHolder
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |