AccordionTreeDrawer
Class TreeEdge

java.lang.Object
  |
  +--AccordionTreeDrawer.TreeEdge
All Implemented Interfaces:
CellGeom

public class TreeEdge
extends java.lang.Object
implements CellGeom

A class representing an edge of a (phylognenetic) tree A TreeEdge represents a horizontal or vertical line segment used in drawing a tree.

     a--- firstChild 
     |               
     |               
     ---  .          
 n   |    .          
 o---|c   .	       
 d   ---             
 e   |               
     |               
     b--- lastChild  
 
 
In this figure (node,c), (a,b), (firstChild,a) and (lastChild,b) are line segments Each of them is represented by a TreeEdge (node,c) corresponds to a horizontal TreeEdge associated with TreeNode node (a,b) corresponds to a vertical TreeEdge associated with TreeNode node

Version:
Author:
Tamara Munzner, Serdar Tasiran, Li Zhang, Yunhong Zhou
See Also:
AccordionDrawer.Tree, AccordionDrawer.TreeNode, GridCell

Field Summary
 GridCell encloses
          The GridCell that this TreeEdge is attached to
 GridCell end
          The GridCell the other endpoint (the "end" node) of the TreeEdge is attached to
 boolean horiz
          Whether this TreeEdge is horizontal
private  java.lang.String label
           
private  LabelBox lb
           
 TreeNode node
           
(package private)  float[] posEnd
           
(package private)  float[] posStart
          The starting and ending points of an edge.
 GridCell start
          The GridCell that one endpoint (the "start" node) of the TreeEdge is attached to
(package private)  int[] xInterval
           
(package private)  int[] yInterval
           
 
Constructor Summary
TreeEdge(TreeNode n, GridCell startCell, GridCell endCell)
           
 
Method Summary
 void close()
          clean the tree edge
 void drawInCell(java.awt.Color col, float plane, AccordionDrawer d)
          Draws this TreeEdge inside the GridCell to which it is attached, and its label if appropriate.
 void drawLabelBig(int x, int y)
          Draw label of this TreeEdge at maximum size (intended for mouseover highlighting).
private  void drawLabelBox(LabelBox lb, int fontheight, boolean drawBig)
          Draw a LabelBox.
private  void drawLabelBoxDown(AccordionTreeDrawer d, gl4java.GLFunc gl, LabelBox lb, int fontheight, boolean drawBig)
           
private  void drawLabelBoxLR(AccordionTreeDrawer d, gl4java.GLFunc gl, LabelBox lb, int fontheight, boolean drawBig)
          draw label box in left or right direction
private  void drawLabelBoxUp(AccordionTreeDrawer d, gl4java.GLFunc gl, LabelBox lb, int fontheight, boolean drawBig)
          draw label box in vertical direction
protected  void finalize()
           
(package private)  void findPos()
          Computes the start- and end-point coordinates of this TreeEdge in window coordinates.
 GridCell getCell()
           
 AccordionTreeDrawer getDrawer()
           
 int getKey()
           
 int getMax()
           
 int getMin()
           
 java.lang.String getName()
           
 int[] getXInterval()
           
 int[] getYInterval()
           
private  boolean intersectLabelBox(LabelBox lb)
          Occlusion check of LabelBox against array of all drawn labels.
protected  LabelBox makeLabelBox(int fontheight, int x, int y)
          Create a LabelBox for the given fontheight
private  LabelBox makeLabelBoxDown(int fontheight, int x, int y)
          make label box in vertical direction
private  LabelBox makeLabelBoxHor(int fontheight, int x, int y)
          make label box in horizontal direction
private  LabelBox makeLabelBoxUp(int fontheight, int x, int y)
          make label box in vertical direction
 boolean pick(int x, int y)
          Determines whether the window coordinates (x,y) fall on this TreeEdge There is a "snap" factor, determined by the pickFuzz field of the enclosing cell.
 void setCell(GridCell gc)
           
 void setLabel(java.lang.String label)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

node

public TreeNode node

start

public GridCell start
The GridCell that one endpoint (the "start" node) of the TreeEdge is attached to


end

public GridCell end
The GridCell the other endpoint (the "end" node) of the TreeEdge is attached to


encloses

public GridCell encloses
The GridCell that this TreeEdge is attached to


horiz

public boolean horiz
Whether this TreeEdge is horizontal


posStart

float[] posStart
The starting and ending points of an edge. XXX: it has to be from left to right or top to bottom. Otherwise, the picking would not work.


posEnd

float[] posEnd

lb

private LabelBox lb

label

private java.lang.String label

xInterval

int[] xInterval

yInterval

int[] yInterval
Constructor Detail

TreeEdge

public TreeEdge(TreeNode n,
                GridCell startCell,
                GridCell endCell)
Method Detail

getDrawer

public AccordionTreeDrawer getDrawer()

close

public void close()
clean the tree edge

See Also:
TreeNode.close

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
java.lang.Throwable

getKey

public int getKey()
Specified by:
getKey in interface CellGeom

getName

public java.lang.String getName()
Specified by:
getName in interface CellGeom

setCell

public void setCell(GridCell gc)
Specified by:
setCell in interface CellGeom

getCell

public GridCell getCell()
Specified by:
getCell in interface CellGeom

getMin

public int getMin()
Specified by:
getMin in interface CellGeom

getMax

public int getMax()
Specified by:
getMax in interface CellGeom

setLabel

public void setLabel(java.lang.String label)

getXInterval

public int[] getXInterval()

getYInterval

public int[] getYInterval()

drawInCell

public void drawInCell(java.awt.Color col,
                       float plane,
                       AccordionDrawer d)
Draws this TreeEdge inside the GridCell to which it is attached, and its label if appropriate. Find font size to use for drawing the label, by checking for occlusions. Don't draw it all if it's occluded even at the smallest size.

Specified by:
drawInCell in interface CellGeom
Parameters:
col - The color to draw this node in
plane - Z depth at which to draw label
See Also:
GridCell

drawLabelBig

public void drawLabelBig(int x,
                         int y)
Draw label of this TreeEdge at maximum size (intended for mouseover highlighting).


makeLabelBox

protected LabelBox makeLabelBox(int fontheight,
                                int x,
                                int y)
Create a LabelBox for the given fontheight

Parameters:
x - horizontal base location in screen/pixel coordinates
y - vertical base location in screen/pixel coordinates
See Also:
LabelBox

makeLabelBoxHor

private LabelBox makeLabelBoxHor(int fontheight,
                                 int x,
                                 int y)
make label box in horizontal direction

Parameters:
fontheight -
x -
y -
Returns:

makeLabelBoxUp

private LabelBox makeLabelBoxUp(int fontheight,
                                int x,
                                int y)
make label box in vertical direction

Parameters:
fontheight -
x -
y -
Returns:

makeLabelBoxDown

private LabelBox makeLabelBoxDown(int fontheight,
                                  int x,
                                  int y)
make label box in vertical direction

Parameters:
fontheight -
x -
y -
Returns:

intersectLabelBox

private boolean intersectLabelBox(LabelBox lb)
Occlusion check of LabelBox against array of all drawn labels. AccordionDrawer.drawnArray is sorted in y - the skinny direction, to avoid work. We do a binary search to check for occlusions, so it's log in the number of pixels (with a very small constant).

See Also:
LabelBox

drawLabelBox

private void drawLabelBox(LabelBox lb,
                          int fontheight,
                          boolean drawBig)
Draw a LabelBox.

Parameters:
lb - LabelBox to use
fontheight - Size of font to use, in points/pixels.
drawBig - whether to draw maximum size ignoring occlusions

drawLabelBoxLR

private void drawLabelBoxLR(AccordionTreeDrawer d,
                            gl4java.GLFunc gl,
                            LabelBox lb,
                            int fontheight,
                            boolean drawBig)
draw label box in left or right direction

Parameters:
lb -
fontheight -
drawBig -

drawLabelBoxUp

private void drawLabelBoxUp(AccordionTreeDrawer d,
                            gl4java.GLFunc gl,
                            LabelBox lb,
                            int fontheight,
                            boolean drawBig)
draw label box in vertical direction

Parameters:
d -
gl -
lb -
fontheight -
drawBig -

drawLabelBoxDown

private void drawLabelBoxDown(AccordionTreeDrawer d,
                              gl4java.GLFunc gl,
                              LabelBox lb,
                              int fontheight,
                              boolean drawBig)

pick

public boolean pick(int x,
                    int y)
Determines whether the window coordinates (x,y) fall on this TreeEdge There is a "snap" factor, determined by the pickFuzz field of the enclosing cell.

Specified by:
pick in interface CellGeom
See Also:
GridCell, AccordionDrawer.AccordionTreeDrawer

findPos

void findPos()
Computes the start- and end-point coordinates of this TreeEdge in window coordinates. We calculate on the fly, instead of having single layout pass at beginning, since absolute cell positions move all around.