net.sf.vex.layout
Interface BlockBox

All Superinterfaces:
Box
All Known Implementing Classes:
BlockElementBox, BlockPseudoElementBox, ParagraphBox, RootBox

public interface BlockBox
extends Box

Represents a block box. Block boxes are stacked one on top of another.


Method Summary
 LineBox getFirstLine()
          Returns the first LineBox contained by this block, or null if the block contains no lines.
 LineBox getLastLine()
          Returns the last LineBox contained by this block, or null if the block contains no lines.
 int getLineEndOffset(int offset)
          Returns the offset of the end of the line containing the given offset.
 int getLineStartOffset(int offset)
          Returns the offset of the start of the line containing the given offset.
 int getMarginBottom()
          Returns the bottom margin of this box.
 int getMarginTop()
          Returns the top margin of this box.
 int getNextLineOffset(LayoutContext context, int offset, int x)
          Returns the offset on the next line that is closest to the given x coordinate.
 int getPreviousLineOffset(LayoutContext context, int offset, int x)
          Returns the offset on the previous line that is closest to the given x coordinate.
 void layout(LayoutContext context, int width, boolean force)
          Layout this box.
 
Methods inherited from interface net.sf.vex.layout.Box
containsOffset, getCaretShapes, getChildren, getElement, getEndOffset, getHeight, getStartOffset, getWidth, getX, getY, hasContent, paint, setX, setY, viewToModel
 

Method Detail

getFirstLine

public LineBox getFirstLine()
Returns the first LineBox contained by this block, or null if the block contains no lines.


getLastLine

public LineBox getLastLine()
Returns the last LineBox contained by this block, or null if the block contains no lines.


getLineEndOffset

public int getLineEndOffset(int offset)
Returns the offset of the end of the line containing the given offset.

Parameters:
offset - offset identifying the current line.

getLineStartOffset

public int getLineStartOffset(int offset)
Returns the offset of the start of the line containing the given offset.

Parameters:
offset - offset identifying the current line.

getMarginBottom

public int getMarginBottom()
Returns the bottom margin of this box. The actual bottom margin may be different than specified by the style sheet since it may be increased by a child box.


getMarginTop

public int getMarginTop()
Returns the top margin of this box. The actual top margin may be different than specified by the style sheet since it may be increased by a child box.


getNextLineOffset

public int getNextLineOffset(LayoutContext context,
                             int offset,
                             int x)
Returns the offset on the next line that is closest to the given x coordinate. The given offset may be before the start of this box in which case this method should return the offset of the first line in this box.

Parameters:
context - LayoutContext used for the layout
offset - the current offset
x - the x coordinate

getPreviousLineOffset

public int getPreviousLineOffset(LayoutContext context,
                                 int offset,
                                 int x)
Returns the offset on the previous line that is closest to the given x coordinate. The given offset may be after the end of this box in which case this method should return the offset of the last line in this box.

Parameters:
context - LayoutContext used for the layout
offset - the current offset
x - the x coordinate

layout

public void layout(LayoutContext context,
                   int width,
                   boolean force)
Layout this box. This method is responsible for the following.

Boxes with no children should simply calculate their width and height here

Parameters:
context - The layout context to be used.
width - Width available for this box. This is typically ignored by inline-formatted boxes.