net.sf.vex.layout
Class CompositeInlineBox
java.lang.Object
|
+--net.sf.vex.layout.AbstractBox
|
+--net.sf.vex.layout.CompositeInlineBox
- All Implemented Interfaces:
- Box, InlineBox
- Direct Known Subclasses:
- InlineElementBox, LineBox
- public abstract class CompositeInlineBox
- extends AbstractBox
- implements InlineBox
InlineBox consisting of several children. This is the parent class
of InlineElementBox and LineBox, and implements the split method.
Methods inherited from class net.sf.vex.layout.AbstractBox |
containsOffset, getChildren, getElement, getEndOffset, getHeight, getStartOffset, getWidth, getX, getY, hasContent, paint, setHeight, setWidth, setX, setY, skipPaint |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.sf.vex.layout.Box |
containsOffset, getChildren, getElement, getEndOffset, getHeight, getStartOffset, getWidth, getX, getY, hasContent, paint, setX, setY |
CompositeInlineBox
public CompositeInlineBox()
getCaretShapes
public java.awt.Shape[] getCaretShapes(LayoutContext context,
int offset)
- Description copied from interface:
Box
- Returns shapes for the primary and secondary carets for the given offset.
A two-element array is returned, with the first entry being the primary
caret and the second being the secondary caret. The second entry will be
null if there is no secondary caret at the given offset. The position of
the carets is relative to the top-left corner of the box.
- Specified by:
getCaretShapes
in interface Box
- Overrides:
getCaretShapes
in class AbstractBox
- Parameters:
context
- LayoutContext to be usedoffset
- offset for which to retrieve the caret
- Returns:
- a two-element array of
Shape
objects - See Also:
Box.getCaretShapes(net.sf.vex.layout.LayoutContext, int)
split
public InlineBox.Pair split(LayoutContext context,
int maxWidth,
boolean force)
- Description copied from interface:
InlineBox
- Splits this inline box into two. If
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
- Specified by:
split
in interface InlineBox
- Parameters:
context
- the layout context to be used.maxWidth
- Maximum width of the left part of the box.force
- if true, force a suboptimal split- See Also:
InlineBox.split(net.sf.vex.layout.LayoutContext, int, boolean)
split
protected abstract InlineBox.Pair split(LayoutContext context,
InlineBox[] lefts,
InlineBox[] rights)
- Creates a Pair of InlineBoxes, each with its own set of children.
- Parameters:
context
- LayoutContext used for this layout.lefts
- Child boxes to be given to the left box.rights
- Child boxes to be given to the right box.
- Returns:
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 treex
- 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)