|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.zaval.util.ValidationObject | +--org.zaval.lw.LwView | +--org.zaval.lw.LwRender | +--org.zaval.lw.LwTextRender
This is text render. The render is used to paint a text that is represented with org.zaval.data.TextModel target object. The data class has not any connections with painting or light weight functionality, it just provides handly interface to manipulate text data. The render defines set of properties that are bound with the view:
The render listens when the text has been modified to conrol it validation state, so it is not necessary to synchronize the render validation state with the modifying the text data.
The render overrides ownerChanged
method to have reference to a light weight
component that uses the render. The reference is used to synchronize validation status of
the light weight component with the render. It means if the render is invalidated than
the component (target) will be invalidated with the render too.
Fields inherited from class org.zaval.lw.LwView |
MOSAIC, ORIGINAL, STRETCH |
Fields inherited from class org.zaval.util.ValidationObject |
isValidFlag |
Constructor Summary | |
LwTextRender(java.lang.String text)
Constructs the render with the specified target string. |
|
LwTextRender(TextModel text)
Constructs the render with the specified target text model. |
Method Summary | |
protected java.awt.Dimension |
calcPreferredSize()
Calculates and returns the render preferred size. |
int |
getAscent()
Gets the text font ascent. |
java.awt.Font |
getFont()
Gets the font of the text render. |
protected java.awt.FontMetrics |
getFontMetrics()
Gets the font metrics of the text render. |
java.awt.Color |
getForeground()
Gets the foreground color. |
protected java.lang.String |
getLine(int r)
Gets the string presentation of the specified line. |
int |
getLineHeight()
Gets line height. |
int |
getLineIndent()
Gets the line indent. |
java.lang.String |
getText()
Gets the target text as a string. |
TextModel |
getTextModel()
Gets the target object as the text model. |
void |
invalidate()
Invalidates the render. |
protected void |
invalidate(int start,
int size)
|
int |
lineWidth(int line)
Returns the total advance width for showing the specified line number. |
protected void |
ownerChanged(Validationable v)
The method is called whenever the view owner have been changed. |
void |
paint(java.awt.Graphics g,
int x,
int y,
int w,
int h,
Drawable d)
Renders the text model using the specified graphics context, location, size and owner component. |
protected void |
paintLine(java.awt.Graphics g,
int x,
int y,
int line,
Drawable d)
Invoked to render a line with the specified index, at the given location, graphics context and owner component. |
protected void |
recalc()
Invoked with validate method if the render is invalid. |
void |
setFont(java.awt.Font f)
Sets the font for the text render. |
void |
setForeground(java.awt.Color c)
Sets the foreground color that is used as the text color to render the target text. |
int |
stringWidth(java.lang.String s)
Returns the total advance width for showing the specified string. |
int |
substrWidth(java.lang.String s,
int off,
int len)
Returns the total advance width for showing the specified substring. |
protected void |
targetWasChanged(java.lang.Object o,
java.lang.Object n)
Invoked whenever the target object has been changed. |
void |
textInserted(TextEvent e)
Invoked when a new text has been inserted in the target text. |
void |
textRemoved(TextEvent e)
Invoked when a part of the target text has been removed. |
void |
textUpdated(TextEvent e)
Invoked when a part of the target text has been updated. |
Methods inherited from class org.zaval.lw.LwRender |
getTarget, setTarget |
Methods inherited from class org.zaval.lw.LwView |
getInsets, getPreferredSize, getType, paint, setType |
Methods inherited from class org.zaval.util.ValidationObject |
isValid, validate |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public LwTextRender(java.lang.String text)
text
- the specified target string.public LwTextRender(TextModel text)
text
- the specified target text model.Method Detail |
public int getLineHeight()
public void setFont(java.awt.Font f)
f
- the font.public java.awt.Font getFont()
protected java.awt.FontMetrics getFontMetrics()
public java.awt.Color getForeground()
public void setForeground(java.awt.Color c)
c
- the foreground color. Use null
to set the default
foreground color.
default value.public int getLineIndent()
protected void targetWasChanged(java.lang.Object o, java.lang.Object n)
targetWasChanged
in class LwRender
o
- the old target object.n
- the new target object.protected java.awt.Dimension calcPreferredSize()
calcPreferredSize
in class LwView
public TextModel getTextModel()
public java.lang.String getText()
public void invalidate()
invalidate
in class ValidationObject
protected void recalc()
validate
method if the render is invalid. The method
is overrided to calculate size of the target text according to the font and indent.recalc
in class LwView
public void textRemoved(TextEvent e)
textRemoved
in interface TextListener
e
- the text event.public void textUpdated(TextEvent e)
textUpdated
in interface TextListener
e
- the text event.public void textInserted(TextEvent e)
textInserted
in interface TextListener
e
- the text event.protected void invalidate(int start, int size)
protected void paintLine(java.awt.Graphics g, int x, int y, int line, Drawable d)
g
- the graphics context.x
- the x coordinate of the text line location.y
- the y coordinate of the text line location.line
- the specified line index.d
- the specified owner component that uses the render.public void paint(java.awt.Graphics g, int x, int y, int w, int h, Drawable d)
paint
in class LwView
g
- the graphics context.x
- the x coordinate of the text location.y
- the y coordinate of the text location.w
- the specified width.h
- the specified height.d
- the specified owner component that uses the render.public int getAscent()
public int lineWidth(int line)
line
- the specified line number.public int stringWidth(java.lang.String s)
line
- the specified string.public int substrWidth(java.lang.String s, int off, int len)
s
- the specified string.off
- the specified starting offset of the substring.len
- the specified length of the substring.protected java.lang.String getLine(int r)
r
- the specified line number.protected void ownerChanged(Validationable v)
ownerChanged
in class LwView
v
- the new owner component.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |