|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sf.vex.layout.AbstractBox | +--net.sf.vex.layout.TextBox
An inline box containing text. The getText
and splitAt
methods are abstract and must be implemented by subclasses.
Nested Class Summary |
Nested classes inherited from class net.sf.vex.layout.InlineBox |
InlineBox.Pair |
Constructor Summary | |
TextBox(Element element)
Class constructor. |
Method Summary | |
protected void |
calculateSize(LayoutContext context)
Causes the box to recalculate it size. |
boolean |
canBreakAtEnd()
Returns true if a line break can occur after this box. |
int |
getBaseline()
Returns the distance from the top of the inline box to the baseline. |
java.awt.Shape[] |
getCaretShapes(LayoutContext context,
int offset)
Returns shapes for the primary and secondary carets for the given offset. |
Element |
getElement()
Returns the element that controls the styling for this text element. |
abstract java.lang.String |
getText()
Return the text that comprises this text box. |
static boolean |
isSplitChar(char c)
Returns true if the given character is one where a linebreak should occur, e.g. |
void |
paint(LayoutContext context,
int x,
int y)
Draws the box's content in the given Graphics context. |
InlineBox.Pair |
split(LayoutContext context,
int maxWidth,
boolean force)
Splits this inline box into two. |
abstract InlineBox.Pair |
splitAt(LayoutContext context,
int offset)
Return a pair of boxes representing a split at the given offset. |
java.lang.String |
toString()
|
Methods inherited from class net.sf.vex.layout.AbstractBox |
containsOffset, getChildren, getEndOffset, getHeight, getStartOffset, getWidth, getX, getY, hasContent, setHeight, setWidth, setX, setY, skipPaint, viewToModel |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.sf.vex.layout.Box |
containsOffset, getChildren, getEndOffset, getHeight, getStartOffset, getWidth, getX, getY, hasContent, setX, setY, viewToModel |
Constructor Detail |
public TextBox(Element element)
element
- Element containing the text. This is used for styling
information.Method Detail |
protected void calculateSize(LayoutContext context)
context
- LayoutContext used to calculate size.public boolean canBreakAtEnd()
InlineBox
canBreakAtEnd
in interface InlineBox
InlineBox.canBreakAtEnd()
public int getBaseline()
InlineBox
getBaseline
in interface InlineBox
InlineBox.getBaseline()
public java.awt.Shape[] getCaretShapes(LayoutContext context, int offset)
Box
getCaretShapes
in interface Box
getCaretShapes
in class AbstractBox
context
- LayoutContext to be usedoffset
- offset for which to retrieve the caret
Shape
objectsBox.getCaretShapes(net.sf.vex.layout.LayoutContext, int)
public Element getElement()
getElement
in interface Box
getElement
in class AbstractBox
Box.getElement()
public abstract java.lang.String getText()
public static boolean isSplitChar(char c)
c
- the character to testpublic void paint(LayoutContext context, int x, int y)
Box
paint
in interface Box
paint
in class AbstractBox
context
- LayoutContext
containing the
Graphics
object into which the box should be
paintedx
- the x-offset at which the box should be paintedy
- the y-offset at which the box should be paintedBox.paint(net.sf.vex.layout.LayoutContext, int, int)
public InlineBox.Pair split(LayoutContext context, int maxWidth, boolean force)
InlineBox
force
is false, this
method should find a natural split point (e.g. after a space) and
return two boxes representing a split at that point. The width of the
last box must not exceed maxWidth
. If no such natural split
exists, null should be returned as the left box and this
returned as the right box.
If force
is true, it means we are adding the first inline
box to a line, therefore we must return something as the left box.
In some cases, we may find a suboptimal split (e.g. between characters)
that satisfies this. In other cases, this
should be returned
as the left box even though it exceeds maxWidth.
In both cases, the right box should contain null if this box fits
into maxWidth
split
in interface InlineBox
context
- the layout context to be used.maxWidth
- Maximum width of the left part of the box.force
- if true, force a suboptimal splitInlineBox.split(net.sf.vex.layout.LayoutContext, int, boolean)
public abstract InlineBox.Pair splitAt(LayoutContext context, int offset)
context
- LayoutContext used to calculate the sizes of the resulting
boxes.offset
- location of the split, relative to the start of the
text box.
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |