Class AbstractBox

java.lang.Object
  |
  +--AbstractBox
All Implemented Interfaces:
Box
Direct Known Subclasses:
AbstractFlexibleBox, AbstractRigidBox

public abstract class AbstractBox
extends java.lang.Object
implements Box

Adaptor class that implements Box by supplying reasonable default for most of the methods.


Field Summary
protected  int height
          The height of the box, defaults to -1.
protected  int min_width
          The minimum width of this box, defaults to -1.
protected  int pref_width
          The preferred width of the box, defaults to -1.
protected  int width
          The width of the box, defaults to -1.
 
Constructor Summary
AbstractBox()
           
 
Method Summary
abstract  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.
abstract  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()
          Returns a representation of the box.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

width

protected int width
The width of the box, defaults to -1.

height

protected int height
The height of the box, defaults to -1.

min_width

protected int min_width
The minimum width of this box, defaults to -1.

pref_width

protected int pref_width
The preferred width of the box, defaults to -1. The preferred width is used when someone needs to get an indication of the size of a box.
Constructor Detail

AbstractBox

public AbstractBox()
Method Detail

getWidth

public int getWidth()
Description copied from interface: Box
Returns the width of this box.
Specified by:
getWidth in interface Box
Following copied from interface: Box
Returns:
the width of the box.

getMinimumWidth

public int getMinimumWidth()
Description copied from interface: Box
Returns the minimum width of this box.
Specified by:
getMinimumWidth in interface Box
Following copied from interface: Box
Returns:
the minimum width of this box.

getPreferredWidth

public int getPreferredWidth()
Description copied from interface: Box
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.
Specified by:
getPreferredWidth in interface Box
Following copied from interface: Box
Returns:
the preferred width for this box.

getHeight

public int getHeight()
Description copied from interface: Box
Returns the height of this box.
Specified by:
getHeight in interface Box
Following copied from interface: Box
Returns:
the height of the box.

doLayout

public abstract void doLayout(java.awt.Graphics g,
                              javax.swing.JComponent c,
                              int w)
Description copied from interface: Box
Makes the box update it's own width and height, and layout it's child-boxes.
Specified by:
doLayout in interface Box
Following copied from interface: Box
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 abstract void drawAt(int x,
                            int y,
                            DocumentView v)
Description copied from interface: Box
Draws the box with it's upper-left corner at (x, y).
Specified by:
drawAt in interface Box
Following copied from interface: Box
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()
Returns a representation of the box. The string contains the widht, height, and class-name of the box. It is only meant to be used when debugging.
Specified by:
toString in interface Box
Overrides:
toString in class java.lang.Object
Returns:
information about the box.