jimmc.treepar
Class Box

java.lang.Object
  |
  +--jimmc.treepar.Box
Direct Known Subclasses:
RootsBox

public class Box
extends java.lang.Object

Box is the primary visual object in a Layout. The following fields in the Box object must be set: name, size, text, textPosition.

See Also:
Layout

Field Summary
protected  Connector[] connectors
          Our connectors.
protected  java.util.Vector connectorVector
           
protected  Layout layout
          The layout we are a part of.
protected  java.lang.String name
          The name of this box.
protected  boolean orderSet
          True when the row ordering has been set for this box.
protected  java.awt.Point origin
          The location of the lower left corner of the box.
protected  boolean positionSet
          True after we have fixed the position of the box in the row.
protected  Row row
          The row containing this box.
protected  int rowNumber
          The row number for this box.
protected  boolean rowNumberSet
          True when rowNumber has been set.
protected  int rowOrder
          The ordering of this box within its row.
protected  java.awt.Dimension size
          The size of the box.
protected  java.lang.String text
          The text to display inside the box.
protected  java.lang.String[] textLines
          The text split up into single lines.
protected  java.awt.Point textPosition
          The position of the text within the box.
 
Constructor Summary
Box(Layout layout, java.lang.String name)
          Create a new Box in a layout.
 
Method Summary
protected  void addConnector(Connector connector)
          Add a connector to this box.
protected  void addNetForce(int side, int[] forcesums)
          Add in the force data for all of the connectors on the specified side of the box.
protected  void addToBounds(BoundsRectangle bounds)
          Increase the bounds if necessary to include this box.
protected  void clearRowNumber()
          Clear the row number and pointer for the box.
protected  void clearRowOrder()
          Clear the row ordering of this box.
protected  void connectorsDone()
          Create the array of connectors from the vector.
protected  boolean contains(int x, int y)
          True if the box contains the specified point.
protected  int countLines(java.lang.String s)
          Count the number of newlines found in the string.
protected  int countWidth(java.lang.String s)
          Count the length of the longest line.
static void dump(java.io.PrintWriter f, Box[] boxes, java.lang.String prefix, boolean details)
          Dump an array of boxes.
 void dump(java.io.PrintWriter f, java.lang.String prefix, boolean details)
          Dump a box for debugging.
protected  LayoutHitText getHitText(int x, int y)
          Find the text at the specified point.
protected  int getLength()
          Get the length of this box.
protected  int getR()
          Get the R coordinat.
protected  int getThickness()
          Get the thickness of this box.
protected  boolean isPositionSet()
          Return true if the positionSet flag has been set.
protected  boolean isRowOrderSet()
          Return true if the row order has already been set on this box.
protected  void moveR(int d)
          Change the R coordinate of this box.
protected  void paint(LayoutGraphics g)
          Draw the box.
protected  void setConnectorsRowOrder(int side, boolean negdir)
          Set the ordering on the connectors on the specified side of this box.
protected  void setPositionSet(boolean b)
          Set the positionSet flag.
protected  void setR(int d)
          Set the R coordinate as specified.
protected  void setRow(Row row)
          Set the row for the box.
 void setRowNumber(int rowNum)
          Set the row number for the box.
protected  void setRowOrder(boolean negdir)
          Set the row ordering of this box and neighbors.
protected  void setS()
          Set the S coordinate of this box to the same as its row.
 void setSize(int width, int height)
          Set the size of the Box.
 void setText(java.lang.String text)
          Set the text inside the Box.
 void setTextPosition(int x, int y)
          Set the location of the text relative to the box origin.
 void setupDone()
          Call this method when setup on this box is done, after all connectors have been added.
protected  void textDone()
          Create the array of text lines from the text string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

layout

protected Layout layout
The layout we are a part of.

name

protected java.lang.String name
The name of this box.

size

protected java.awt.Dimension size
The size of the box.

text

protected java.lang.String text
The text to display inside the box.

textPosition

protected java.awt.Point textPosition
The position of the text within the box.

connectors

protected Connector[] connectors
Our connectors.

connectorVector

protected java.util.Vector connectorVector

textLines

protected java.lang.String[] textLines
The text split up into single lines.

rowNumber

protected int rowNumber
The row number for this box.

rowNumberSet

protected boolean rowNumberSet
True when rowNumber has been set.

row

protected Row row
The row containing this box.

rowOrder

protected int rowOrder
The ordering of this box within its row.

orderSet

protected boolean orderSet
True when the row ordering has been set for this box.

origin

protected java.awt.Point origin
The location of the lower left corner of the box.

positionSet

protected boolean positionSet
True after we have fixed the position of the box in the row.
Constructor Detail

Box

public Box(Layout layout,
           java.lang.String name)
Create a new Box in a layout.
Method Detail

setSize

public void setSize(int width,
                    int height)
Set the size of the Box.

setText

public void setText(java.lang.String text)
Set the text inside the Box.

setTextPosition

public void setTextPosition(int x,
                            int y)
Set the location of the text relative to the box origin.

addConnector

protected void addConnector(Connector connector)
Add a connector to this box. This method is called from the contructor for Connector.

setupDone

public void setupDone()
Call this method when setup on this box is done, after all connectors have been added.

connectorsDone

protected void connectorsDone()
Create the array of connectors from the vector.

textDone

protected void textDone()
Create the array of text lines from the text string.

getThickness

protected int getThickness()
Get the thickness of this box.

getLength

protected int getLength()
Get the length of this box.

clearRowNumber

protected void clearRowNumber()
Clear the row number and pointer for the box.

setRowNumber

public void setRowNumber(int rowNum)
Set the row number for the box.

setRow

protected void setRow(Row row)
Set the row for the box.

setR

protected void setR(int d)
Set the R coordinate as specified.

getR

protected int getR()
Get the R coordinat.

moveR

protected void moveR(int d)
Change the R coordinate of this box.
Parameters:
d - the amount to add to the R coordinate.

setS

protected void setS()
Set the S coordinate of this box to the same as its row.

clearRowOrder

protected void clearRowOrder()
Clear the row ordering of this box.

setRowOrder

protected void setRowOrder(boolean negdir)
Set the row ordering of this box and neighbors.
Parameters:
negdir - if set, expand in the negative direction.

isRowOrderSet

protected boolean isRowOrderSet()
Return true if the row order has already been set on this box.

setPositionSet

protected void setPositionSet(boolean b)
Set the positionSet flag.

isPositionSet

protected boolean isPositionSet()
Return true if the positionSet flag has been set.

setConnectorsRowOrder

protected void setConnectorsRowOrder(int side,
                                     boolean negdir)
Set the ordering on the connectors on the specified side of this box.
Parameters:
side - the side of the box out of which connectors we propagate to the network.
negdir - true means new items are added to the lesser end of the row.

addNetForce

protected void addNetForce(int side,
                           int[] forcesums)
Add in the force data for all of the connectors on the specified side of the box.
Parameters:
side - ignore connectors not on this side of the box.
forcesums - [0] is the force sum, [1] is the count. We add to these two numbers.

addToBounds

protected void addToBounds(BoundsRectangle bounds)
Increase the bounds if necessary to include this box.

countLines

protected int countLines(java.lang.String s)
Count the number of newlines found in the string.

countWidth

protected int countWidth(java.lang.String s)
Count the length of the longest line.
Returns:
The number of characters in the longest line.

paint

protected void paint(LayoutGraphics g)
Draw the box.

contains

protected boolean contains(int x,
                           int y)
True if the box contains the specified point.

getHitText

protected LayoutHitText getHitText(int x,
                                   int y)
Find the text at the specified point.

dump

public void dump(java.io.PrintWriter f,
                 java.lang.String prefix,
                 boolean details)
Dump a box for debugging.

dump

public static void dump(java.io.PrintWriter f,
                        Box[] boxes,
                        java.lang.String prefix,
                        boolean details)
Dump an array of boxes.