net.sourceforge.olduvai.accordiondrawer
Class LabelBox

java.lang.Object
  extended by net.sourceforge.olduvai.accordiondrawer.LabelBox
All Implemented Interfaces:
java.lang.Comparable

public class LabelBox
extends java.lang.Object
implements java.lang.Comparable

Axis-aligned bounding box class for label drawing. Stores information in screen coordintes, checks for overlap with other bounding boxes.

Author:
Tamara Munzner, James Slack

Field Summary
private  CellGeom attachedObject
          Attached object for this label, if applicable.
protected  int[] bl
          Bottom left coordinates, in pixels
protected  int[] blbg
          Bottom left corner of the label box, shifted by the label buffer distance (the "real" bottom left corner)
protected  int[] center
          Center of the label box, between bl and tr
protected  int[] extent
          The size of the label box, from bl to tr
protected  int fontHeight
          Font height in points
protected  int frameNum
          Last frame in which this box is drawn
private  java.lang.String name
          The string to draw as the label
protected  int[] tr
          Top right coordinates, in pixels
 
Constructor Summary
LabelBox(int[] bottomLeft, int[] topRight, int[] bottomLeftBG, int computedFrame, java.lang.String name, CellGeom attachedObject, int fontHeight)
          Label box constructor.
 
Method Summary
 int bottomLeftPos(int xy)
          Return a coordinate (in screen space) for the bottom or left edge of this box.
 int compareTo(java.lang.Object o)
          Compare label boxes with another for vertical overlap (0 = overlap).
 CellGeom getAttachedObject()
          Get the object that is attached to this label box.
 int getFontHeight()
          Accessor for font height value for this label box.
 java.lang.String getName()
          Accessor for the name (label) contained in this label box.
 boolean overlaps(LabelBox other, int[] bufferSize)
          Test for box overlap with another Label box.
 int size(int xy)
          Returns the size of the label box, in the given dimension.
 int topRightPos(int xy)
          Return a coordinate (in screen space) for the top or right edge of this box.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bl

protected int[] bl
Bottom left coordinates, in pixels


tr

protected int[] tr
Top right coordinates, in pixels


blbg

protected int[] blbg
Bottom left corner of the label box, shifted by the label buffer distance (the "real" bottom left corner)


center

protected int[] center
Center of the label box, between bl and tr


extent

protected int[] extent
The size of the label box, from bl to tr


frameNum

protected int frameNum
Last frame in which this box is drawn


name

private java.lang.String name
The string to draw as the label


attachedObject

private CellGeom attachedObject
Attached object for this label, if applicable.


fontHeight

protected int fontHeight
Font height in points

Constructor Detail

LabelBox

public LabelBox(int[] bottomLeft,
                int[] topRight,
                int[] bottomLeftBG,
                int computedFrame,
                java.lang.String name,
                CellGeom attachedObject,
                int fontHeight)
Label box constructor.

Parameters:
bottomLeft - Bottom left corner of actual label box, not including buffers.
topRight - Top right corner of actual label box, not including buffers.
bottomLeftBG - Bottom left corner of buffer sounding label box.
computedFrame - Current frame for this label box.
name - String to be drawn in as the label.
attachedObject - The object attached to this label, if any.
fontHeight - Height of font used to draw string in points.
Method Detail

getAttachedObject

public CellGeom getAttachedObject()
Get the object that is attached to this label box.

Returns:
The cell geom stored in attachedObject

compareTo

public int compareTo(java.lang.Object o)
Compare label boxes with another for vertical overlap (0 = overlap).

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - Label box to test for overlaps.
Returns:
0 if overlap, 1 if o is above this, -1 if o is below this

bottomLeftPos

public int bottomLeftPos(int xy)
Return a coordinate (in screen space) for the bottom or left edge of this box.

Parameters:
xy - Either AccordionDrawer.X for left edge or AccordionDrawer.Y for bottom edge.
Returns:
The coordinate for the given edge in screen space.

topRightPos

public int topRightPos(int xy)
Return a coordinate (in screen space) for the top or right edge of this box.

Parameters:
xy - Either AccordionDrawer.X for right edge or AccordionDrawer.Y for top edge.
Returns:
The coordinate for the given edge in screen space.

getName

public java.lang.String getName()
Accessor for the name (label) contained in this label box.

Returns:
Current value of name.

size

public int size(int xy)
Returns the size of the label box, in the given dimension.

Parameters:
xy - The dimension, either AccordionDrawer.X or AccordionDrawer.Y.
Returns:
The absolute value of the size of this label box, in X or Y.

getFontHeight

public int getFontHeight()
Accessor for font height value for this label box.

Returns:
Current value of fontHeight.

overlaps

public boolean overlaps(LabelBox other,
                        int[] bufferSize)
Test for box overlap with another Label box.

Parameters:
other - A second Label box to test for overlaps.
Returns:
True if boxes overlap, with respect to blbg and tr values of each