Interface RigidBox

All Superinterfaces:
Box
All Known Implementing Classes:
AbstractRigidBox

public interface RigidBox
extends Box

A RigidBox is a box that can only be split, not resized. As you can't resize such a box, the box must be able to find it's own width and height as soon as it has been given a Graphics context via a call to Box.doLayout(java.awt.Graphics, javax.swing.JComponent, int).

Rigid boxes are the leaves of the parse-tree, as they are the boxes with the actual contents (substrings, links, images, etc).


Field Summary
static int BOTH
          The constant denoting both edges.
static int LEFT
          The left edge constant.
static int RIGHT
          The right edge constant.
 
Method Summary
 Box getLargestTail()
          Returns the right part of a split, where the right part is as large at possible.
 Box getSmallestHead()
          Returns the left part of a split, where the left part is as small as possible.
 Box splitHead(int w)
          Tries to split the box at w.
 boolean splitIsPossible(int w)
          Reports wether or not the box can be split at w.
 Box splitTail(int w)
          Tries to split the box at w.
 void trim(int edge)
          Trims the box.
 
Methods inherited from interface Box
doLayout, drawAt, getHeight, getMinimumWidth, getPreferredWidth, getWidth, toString
 

Field Detail

LEFT

public static final int LEFT
The left edge constant. Used when calling trim(int) on boxes.

RIGHT

public static final int RIGHT
The right edge constant. Used when calling trim(int) on boxes.

BOTH

public static final int BOTH
The constant denoting both edges. Used when calling trim(int) on boxes.
Method Detail

splitIsPossible

public boolean splitIsPossible(int w)
Reports wether or not the box can be split at w.
Parameters:
w - the place where the split should be.
Returns:
true if it's possible to split the box, false otherwise.

splitHead

public Box splitHead(int w)
Tries to split the box at w.
Parameters:
w - the place where the split should be.
Returns:
a new box that is the left part of the split. The box is guaranteed to be smaller than w, if possible. If the box can't be split, null is returned.

splitTail

public Box splitTail(int w)
Tries to split the box at w.
Parameters:
w - the place where the split should be.
Returns:
a new box that is the right part of a split, where the left part is guaranteed to be smaller than w, if possible. If the box can't be split, null is returned.

getSmallestHead

public Box getSmallestHead()
Returns the left part of a split, where the left part is as small as possible. If the box can't be splitted at all, null is returned instead.
Returns:
a new box that can't be splitted into furhter pieces.

getLargestTail

public Box getLargestTail()
Returns the right part of a split, where the right part is as large at possible. If the box can't be splitted at all, null is returned instead.
Returns:
a new box that can't be splitted into furhter pieces.

trim

public void trim(int edge)
Trims the box. The box should remove any borders and white space it might have on left or right.
Parameters:
edge - to be trimmed. It must be one of LEFT, RIGHT, or BOTH.