Class TreeDisplay

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--TreeDisplay
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class TreeDisplay
extends javax.swing.JComponent

This class is responsible for drawing different kinds of trees in different windows.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TreeDisplay()
          Constructs a defalut tree display object.
TreeDisplay(boolean inBegin)
          Constructs a tree display object with the value indicating whether the drawing begins.
 
Method Summary
 void compute()
          Defines how to compute the positions of all the nodes.
 int compute(Node node, int x, int y, int unit_x, int unit_y)
          Defines how to compute the positions of a node.
 void computeMaxSeqWidth(java.awt.FontMetrics fm, Node node)
          Defines how to compute the pixels needed to draw the longest sequence.
 int computeNJRight(Node node, int x, int y, int unit_x, int unit_y)
          Defines how to compute the positions of a node in the last step of the NJ and the FM algorithms.
 int draw(java.awt.Graphics g, Node node, int type)
          Defines how to draw a tree.
 void drawMPRight(java.awt.Graphics g, Node node)
          Defines how to draw the right tree in the last step of the MP algorithm.
 void drawNJRight(java.awt.Graphics g, Node node, int type)
          Defines how to draw the right tree in the last step of the NJ and the FM algorithms.
 java.util.Vector getRoots()
          Gets the roots of a tree.
 void initialize_init_x(java.awt.Graphics g)
          Defines how to compute the initial x position to draw a tree.
 void initialize_init_y(java.awt.Graphics g)
          Defines how to compute the initial y position to draw a tree.
 void initialize_unit_x()
          Defines how to initialize the x axis scaling factor.
 void initialize_unit_y()
          Defines how to initialize the y axis scaling factor.
 void paintComponent(java.awt.Graphics g)
          Defines how a tree is redrawn every time.
 void reCalculate(Node root, int dif_x, int dif_y)
          Defines how to adjust the values to all nodes in the x axis and the y axis for a specified root.
 void reCalculateX(Node root, int diff)
          Defines how to adjust the values to all nodes in the x axis for a specified root.
 void reset()
          Defines how to clean a tree in the display areas.
 void scaleTree(int begin_x, int end_x, int begin_y, int end_y, Node node)
          Defines how to scale a node in the tree.
 void scaleTreeRight(int begin_x, int end_x, int begin_y, int end_y, Node node)
          Defines how to scale a node in the right part of a final tree in the NJ and the FM algorithms.
 void setAlgorithm(Algorithm inAlgorithm)
          Sets the algorithm with the drawing object.
 void setDisplay(boolean inDisplay)
          Sets the display status.
 void setFlagString(java.lang.String inFlagString)
          Sets the flag string used in the FM algorithm.
 void setMaxName(java.lang.String inMaxName)
          Sets the longest name of the species.
 void setParameters(int inRadius, int inRect_width, int inSize)
          Sets the parameters used in drawing.
 void setRatio(double ratio)
          Sets the zoom in or the zoom out ratio of a tree.
 void setType(int inType)
          Sets the window drawing type, either a big one in the main phylogenetic tree or a small one in other windows.
 void start()
          Defines how to begin to draw a tree.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TreeDisplay

public TreeDisplay()
Constructs a defalut tree display object.


TreeDisplay

public TreeDisplay(boolean inBegin)
Constructs a tree display object with the value indicating whether the drawing begins.

Parameters:
inBegin - the value indicating whether the drawing begins
Method Detail

getRoots

public java.util.Vector getRoots()
Gets the roots of a tree.

Returns:
the roots of a tree

setParameters

public void setParameters(int inRadius,
                          int inRect_width,
                          int inSize)
Sets the parameters used in drawing.

Parameters:
inRadius - the radius of the circle representing an interior node
inRect_width - the width of the rectangle representing a leaf node
inSize - the size of the font

setType

public void setType(int inType)
Sets the window drawing type, either a big one in the main phylogenetic tree or a small one in other windows.

Parameters:
inType - the window type

setAlgorithm

public void setAlgorithm(Algorithm inAlgorithm)
Sets the algorithm with the drawing object.

Parameters:
inAlgorithm - the algorithm to be drawn

setDisplay

public void setDisplay(boolean inDisplay)
Sets the display status.

Parameters:
inDisplay - the display status

setMaxName

public void setMaxName(java.lang.String inMaxName)
Sets the longest name of the species.

Parameters:
inMaxName - the longest name of the species

setFlagString

public void setFlagString(java.lang.String inFlagString)
Sets the flag string used in the FM algorithm.

Parameters:
inFlagString - the flag string

setRatio

public void setRatio(double ratio)
Sets the zoom in or the zoom out ratio of a tree.

Parameters:
ratio - the zoom in or the zoom out ratio

start

public void start()
Defines how to begin to draw a tree.


reset

public void reset()
Defines how to clean a tree in the display areas.


paintComponent

public void paintComponent(java.awt.Graphics g)
Defines how a tree is redrawn every time.

Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
g - the Graphics object used to draw graphics

initialize_unit_x

public void initialize_unit_x()
Defines how to initialize the x axis scaling factor.


initialize_unit_y

public void initialize_unit_y()
Defines how to initialize the y axis scaling factor.


initialize_init_x

public void initialize_init_x(java.awt.Graphics g)
Defines how to compute the initial x position to draw a tree.

Parameters:
g - the Graphics object used to draw graphics

initialize_init_y

public void initialize_init_y(java.awt.Graphics g)
Defines how to compute the initial y position to draw a tree.

Parameters:
g - the Graphics object used to draw graphics

computeMaxSeqWidth

public void computeMaxSeqWidth(java.awt.FontMetrics fm,
                               Node node)
Defines how to compute the pixels needed to draw the longest sequence.

Parameters:
fm - the FontMetrics object for a specified font
node - the Node object

compute

public void compute()
Defines how to compute the positions of all the nodes.


compute

public int compute(Node node,
                   int x,
                   int y,
                   int unit_x,
                   int unit_y)
Defines how to compute the positions of a node.

Parameters:
node - the Node object
x - the initial x axis position
y - the initial x axis position
unit_x - the x axis scaling factor
unit_y - the y axis scaling factor
Returns:
the last y axis value

computeNJRight

public int computeNJRight(Node node,
                          int x,
                          int y,
                          int unit_x,
                          int unit_y)
Defines how to compute the positions of a node in the last step of the NJ and the FM algorithms.

Parameters:
node - the Node object
x - the initial x axis position
y - the initial y axis position
unit_x - the x axis scaling factor
unit_y - the y axis scaling factor
Returns:
the last y axis value

scaleTree

public void scaleTree(int begin_x,
                      int end_x,
                      int begin_y,
                      int end_y,
                      Node node)
Defines how to scale a node in the tree.

Parameters:
begin_x - the begin x axis value
end_x - the end x axis value
begin_y - the begin y axis value
end_y - the end y axis value
node - the Node object

scaleTreeRight

public void scaleTreeRight(int begin_x,
                           int end_x,
                           int begin_y,
                           int end_y,
                           Node node)
Defines how to scale a node in the right part of a final tree in the NJ and the FM algorithms.

Parameters:
begin_x - the begin x axis value
end_x - the end x axis value
begin_y - the begin y axis value
end_y - the end y axis value
node - the Node object

draw

public int draw(java.awt.Graphics g,
                Node node,
                int type)
Defines how to draw a tree.

Parameters:
g - the Graphics object used to draw graphics
node - the Node object
type - the type of the node (either a left node or a right node)
Returns:
the last node y axis position

drawNJRight

public void drawNJRight(java.awt.Graphics g,
                        Node node,
                        int type)
Defines how to draw the right tree in the last step of the NJ and the FM algorithms.

Parameters:
g - the Graphics object used to draw graphics
node - the Node object
type - the type of the node (either a left node or a right node)

drawMPRight

public void drawMPRight(java.awt.Graphics g,
                        Node node)
Defines how to draw the right tree in the last step of the MP algorithm.

Parameters:
g - the Graphics object used to draw graphics
node - the Node object

reCalculateX

public void reCalculateX(Node root,
                         int diff)
Defines how to adjust the values to all nodes in the x axis for a specified root.

Parameters:
root - the root node
diff - the value adjusted to all nodes in x axis

reCalculate

public void reCalculate(Node root,
                        int dif_x,
                        int dif_y)
Defines how to adjust the values to all nodes in the x axis and the y axis for a specified root.

Parameters:
root - the root node
dif_x - the value adjusted to all nodes in x axis
dif_y - the value adjusted to all nodes in y axis