net.sf.vex.layout
Class SpaceBox

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

public class SpaceBox
extends AbstractBox
implements InlineBox

An empty inline box that simply takes up space.


Nested Class Summary
 
Nested classes inherited from class net.sf.vex.layout.InlineBox
InlineBox.Pair
 
Constructor Summary
SpaceBox(int width, int height)
          Class constructor.
 
Method Summary
 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.
 InlineBox.Pair split(LayoutContext context, int maxWidth, boolean force)
          Splits this inline box into two.
 java.lang.String toString()
           
 
Methods inherited from class net.sf.vex.layout.AbstractBox
containsOffset, getCaretShapes, getChildren, getElement, getEndOffset, getHeight, getStartOffset, getWidth, getX, getY, hasContent, paint, 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, getCaretShapes, getChildren, getElement, getEndOffset, getHeight, getStartOffset, getWidth, getX, getY, hasContent, paint, setX, setY, viewToModel
 

Constructor Detail

SpaceBox

public SpaceBox(int width,
                int height)
Class constructor.

Parameters:
width - width of the box
height - height of the box
Method Detail

canBreakAtEnd

public boolean canBreakAtEnd()
Description copied from interface: InlineBox
Returns true if a line break can occur after this box. For example, this would be true for text boxes that end with a space.

Specified by:
canBreakAtEnd in interface InlineBox
See Also:
InlineBox.canBreakAtEnd()

getBaseline

public int getBaseline()
Description copied from interface: InlineBox
Returns the distance from the top of the inline box to the baseline.

Specified by:
getBaseline in interface InlineBox
See Also:
InlineBox.getBaseline()

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)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()