Interface Box

All Known Subinterfaces:
FlexibleBox, RigidBox
All Known Implementing Classes:
AbstractBox

public interface Box

Specifies a box. A box has two characteristic properties: it's width and height which is accessed with getWidth() and getHeight().

A box should also be able to draw itself, see drawAt(int, int, DocumentView), but after it has been given a chance to calculate it's layout with a call to doLayout(Graphics, JComponent, int).


Method Summary
 void doLayout(java.awt.Graphics g, javax.swing.JComponent c, int w)
          Makes the box update it's own width and height, and layout it's child-boxes.
 void drawAt(int x, int y, DocumentView v)
          Draws the box with it's upper-left corner at (x, y).
 int getHeight()
          Returns the height of this box.
 int getMinimumWidth()
          Returns the minimum width of this box.
 int getPreferredWidth()
          Returns the preferred width of this box.
 int getWidth()
          Returns the width of this box.
 java.lang.String toString()
          Gives you information about the box.
 

Method Detail

getWidth

public int getWidth()
Returns the width of this box.
Returns:
the width of the box.

getMinimumWidth

public int getMinimumWidth()
Returns the minimum width of this box.
Returns:
the minimum width of this box.

getPreferredWidth

public int getPreferredWidth()
Returns the preferred width of this box. This can be used to get an indication of the amount of space this box would like to researve for itself.
Returns:
the preferred width for this box.

getHeight

public int getHeight()
Returns the height of this box.
Returns:
the height of the box.

doLayout

public void doLayout(java.awt.Graphics g,
                     javax.swing.JComponent c,
                     int w)
Makes the box update it's own width and height, and layout it's child-boxes.
Parameters:
g - the graphics context. Some boxes, like TextFragments, need a graphics context before they can determine their width and height.
c - the component into which the box will be drawn. An ImageBox needs to know the component to calculate the width and height.
w - the width available for to the Box.

drawAt

public void drawAt(int x,
                   int y,
                   DocumentView v)
Draws the box with it's upper-left corner at (x, y).
Parameters:
v - the DocumentView that does the actual drawing.
x - the x-coordinate of the upper-left corner.
x - the y-coordinate of the upper-left corner.

toString

public java.lang.String toString()
Gives you information about the box.
Overrides:
toString in class java.lang.Object
Returns:
information about the box - usefull for debugging.