net.sf.vex.layout
Class DocumentTextBox

java.lang.Object
  |
  +--net.sf.vex.layout.AbstractBox
        |
        +--net.sf.vex.layout.TextBox
              |
              +--net.sf.vex.layout.DocumentTextBox
All Implemented Interfaces:
Box, InlineBox

public class DocumentTextBox
extends TextBox

A TextBox that gets its text from the document.


Nested Class Summary
 
Nested classes inherited from class net.sf.vex.layout.InlineBox
InlineBox.Pair
 
Constructor Summary
DocumentTextBox(LayoutContext context, Element element, int startRelative, int length)
          Class constructor.
DocumentTextBox(LayoutContext context, Element element, Text text)
          Class constructor, accepting a Text object.
 
Method Summary
 int getEndOffset()
          Returns the offset of the end of the content that the box covers.
 int getStartOffset()
          Returns the offset of the start of the content that the box covers.
 java.lang.String getText()
          Return the text that comprises this text box.
 boolean hasContent()
          Returns true if this box represents a portion of the XML document's content.
 void paint(LayoutContext context, int x, int y)
          Draws the box's content in the given Graphics context.
 InlineBox.Pair splitAt(LayoutContext context, int offset)
          Return a pair of boxes representing a split at the given offset.
 int viewToModel(LayoutContext context, int x, int y)
          Returns the offset in the content closest to the given view position.
 
Methods inherited from class net.sf.vex.layout.TextBox
calculateSize, canBreakAtEnd, getBaseline, getCaretShapes, getElement, isSplitChar, split, toString
 
Methods inherited from class net.sf.vex.layout.AbstractBox
containsOffset, getChildren, getHeight, getWidth, getX, getY, setHeight, setWidth, setX, setY, skipPaint
 
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, getHeight, getWidth, getX, getY, setX, setY
 

Constructor Detail

DocumentTextBox

public DocumentTextBox(LayoutContext context,
                       Element element,
                       Text text)
Class constructor, accepting a Text object.

Parameters:
context - LayoutContext in use
element - Element being used
text -

DocumentTextBox

public DocumentTextBox(LayoutContext context,
                       Element element,
                       int startRelative,
                       int length)
Class constructor.

Parameters:
context - LayoutContext used to calculate the box's size.
element - Element that directly contains the text.
startRelative - start offset of the text, relative to the start offset of the element
length - length of the text
Method Detail

getEndOffset

public int getEndOffset()
Description copied from interface: Box
Returns the offset of the end of the content that the box covers.

Specified by:
getEndOffset in interface Box
Overrides:
getEndOffset in class AbstractBox
See Also:
Box.getEndOffset()

getStartOffset

public int getStartOffset()
Description copied from interface: Box
Returns the offset of the start of the content that the box covers.

Specified by:
getStartOffset in interface Box
Overrides:
getStartOffset in class AbstractBox
See Also:
Box.getStartOffset()

getText

public java.lang.String getText()
Description copied from class: TextBox
Return the text that comprises this text box. The actual text can come from the document content or from a static string.

Specified by:
getText in class TextBox
See Also:
TextBox.getText()

hasContent

public boolean hasContent()
Description copied from interface: Box
Returns true if this box represents a portion of the XML document's content. If false is returned, the following methods are not supported by this box.

Specified by:
hasContent in interface Box
Overrides:
hasContent in class AbstractBox
See Also:
Box.hasContent()

paint

public void paint(LayoutContext context,
                  int x,
                  int y)
Description copied from interface: Box
Draws the box's content in the given Graphics context.

Specified by:
paint in interface Box
Overrides:
paint in class TextBox
See Also:
Box.paint(net.sf.vex.layout.LayoutContext, int, int)

splitAt

public InlineBox.Pair splitAt(LayoutContext context,
                              int offset)
Description copied from class: TextBox
Return a pair of boxes representing a split at the given offset. If split is zero, then the returned left box should be null. If the split is equal to the length of the text, then the right box should be null.

Specified by:
splitAt in class TextBox
Parameters:
context - LayoutContext used to calculate the sizes of the resulting boxes.
offset - location of the split, relative to the start of the text box.
Returns:
See Also:
net.sf.vex.layout.TextBox#splitAt(int)

viewToModel

public int viewToModel(LayoutContext context,
                       int x,
                       int y)
Description copied from interface: Box
Returns the offset in the content closest to the given view position.

Specified by:
viewToModel in interface Box
Overrides:
viewToModel in class AbstractBox
Parameters:
context - LayoutContext for this box tree
x - x offset of the view position for which the model offset is to be determined.
y - y offset of the view position for which the model offset is to be determined.
See Also:
Box.viewToModel(net.sf.vex.layout.LayoutContext, int, int)