jebl.gui.trees.treeviewer_dev
Class TreePane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by jebl.gui.trees.treeviewer_dev.TreePane
All Implemented Interfaces:
ImageObserver, MenuContainer, Printable, Serializable, PainterListener

public class TreePane
extends JComponent
implements PainterListener, Printable

Author:
Andrew Rambaut
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 String COLLAPSE_ATTRIBUTE_NAME
           
 
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.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TreePane()
           
 
Method Summary
 void addSelectedClade(Node selectedNode)
           
 void addSelectedNode(Node selectedNode)
           
 void addSelectedTip(Node selectedTip)
           
 void addSelectedTips(Node selectedNode)
           
 void addTreePaneListener(TreePaneListener listener)
           
 void addTreeSelectionListener(TreeSelectionListener treeSelectionListener)
           
 void annotateSelectedNodes(String name, Object value)
           
 void annotateSelectedTips(String name, Object value)
           
 void clearSelection()
           
 void collapseSelectedNodes()
           
 void drawTree(Graphics2D g2, double width, double height)
           
 void fireTreePaneSettingsChanged()
           
 Painter<Node> getBranchLabelPainter()
           
 SortedRootedTree.BranchOrdering getBranchOrdering()
           
 BasicStroke getBranchStroke()
           
 TransformedRootedTree.Transform getBranchTransform()
           
 BasicStroke getCalloutStroke()
           
 Rectangle2D getDragRectangle()
           
 double getHeightAt(Graphics2D graphics2D, Point2D point)
           
 Node getNodeAt(Graphics2D g2, Point point)
           
 Painter<Node> getNodeBarPainter()
           
 Painter<Node> getNodeLabelPainter()
           
 Set<Node> getNodesAt(Graphics2D g2, Rectangle rect)
           
 RootedTree getOriginalTree()
           
 Painter<TreePane> getScaleBarPainter()
           
 Set<Node> getSelectedNodes()
           
 Set<Node> getSelectedTips()
           
 Paint getSelectionPaint()
           
 Painter<Node> getTipLabelPainter()
           
 RootedTree getTree()
           
 Rectangle2D getTreeBounds()
           
 TreeLayout getTreeLayout()
           
 double getTreeScale()
          This returns the scaling factor between the graphical image and the branch lengths of the tree
 boolean hasSelection()
           
 boolean isOrderBranchesOn()
           
 boolean isShowingTipCallouts()
           
 boolean isTransformBranchesOn()
           
 boolean maintainAspectRatio()
          Return whether the two axis scales should be maintained relative to each other
 void paint(Graphics graphics)
           
 void painterChanged()
           
 void painterSettingsChanged()
           
 int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
           
 void removeTreePaneListener(TreePaneListener listener)
           
 void removeTreeSelectionListener(TreeSelectionListener treeSelectionListener)
           
 void scrollPointToVisible(Point point)
           
 void selectAllNodes()
           
 void selectAllTaxa()
           
 void selectCladesFromSelectedNodes()
           
 void selectNodesFromSelectedTips()
           
 void selectTipsFromSelectedNodes()
           
 void setBounds(int x, int y, int width, int height)
           
 void setBounds(Rectangle rectangle)
           
 void setBranchColouringDecorator(String branchColouringAttribute, Decorator branchColouringDecorator)
           
 void setBranchDecorator(Decorator branchDecorator)
           
 void setBranchLabelPainter(LabelPainter<Node> branchLabelPainter)
           
 void setBranchOrdering(SortedRootedTree.BranchOrdering branchOrdering)
           
 void setBranchStroke(BasicStroke stroke)
           
 void setBranchTransform(TransformedRootedTree.Transform branchTransform)
           
 void setCalloutStroke(BasicStroke calloutStroke)
           
 void setDragRectangle(Rectangle2D dragRectangle)
           
 void setNodeBarPainter(NodeBarPainter nodeBarPainter)
           
 void setNodeLabelPainter(LabelPainter<Node> nodeLabelPainter)
           
 void setOrderBranchesOn(boolean orderBranchesOn)
           
 void setPreferredSize(Dimension dimension)
           
 void setRuler(double rulerHeight)
           
 void setScaleBarPainter(Painter<TreePane> scaleBarPainter)
           
 void setSelectedClade(Node selectedNode)
           
 void setSelectedNode(Node selectedNode)
           
 void setSelectedTip(Node selectedTip)
           
 void setSelectedTips(Node selectedNode)
           
 void setSelectionPaint(Paint selectionPaint)
           
 void setShowingTipCallouts(boolean showingTipCallouts)
           
 void setSize(Dimension dimension)
           
 void setSize(int width, int height)
           
 void setTipLabelPainter(LabelPainter<Node> tipLabelPainter)
           
 void setTransformBranchesOn(boolean transformBranchesOn)
           
 void setTree(RootedTree tree)
           
 void setTreeLayout(TreeLayout treeLayout)
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COLLAPSE_ATTRIBUTE_NAME

public final String COLLAPSE_ATTRIBUTE_NAME
See Also:
Constant Field Values
Constructor Detail

TreePane

public TreePane()
Method Detail

getTree

public RootedTree getTree()

setTree

public void setTree(RootedTree tree)

getTreeLayout

public TreeLayout getTreeLayout()

setTreeLayout

public void setTreeLayout(TreeLayout treeLayout)

setBranchDecorator

public void setBranchDecorator(Decorator branchDecorator)

setBranchColouringDecorator

public void setBranchColouringDecorator(String branchColouringAttribute,
                                        Decorator branchColouringDecorator)

getTreeBounds

public Rectangle2D getTreeBounds()

getTreeScale

public double getTreeScale()
This returns the scaling factor between the graphical image and the branch lengths of the tree

Returns:
the tree scale

painterChanged

public void painterChanged()
Specified by:
painterChanged in interface PainterListener

painterSettingsChanged

public void painterSettingsChanged()
Specified by:
painterSettingsChanged in interface PainterListener

getBranchStroke

public BasicStroke getBranchStroke()

setBranchStroke

public void setBranchStroke(BasicStroke stroke)

getCalloutStroke

public BasicStroke getCalloutStroke()

setCalloutStroke

public void setCalloutStroke(BasicStroke calloutStroke)

getSelectionPaint

public Paint getSelectionPaint()

setSelectionPaint

public void setSelectionPaint(Paint selectionPaint)

isTransformBranchesOn

public boolean isTransformBranchesOn()

setTransformBranchesOn

public void setTransformBranchesOn(boolean transformBranchesOn)

getBranchTransform

public TransformedRootedTree.Transform getBranchTransform()

setBranchTransform

public void setBranchTransform(TransformedRootedTree.Transform branchTransform)

isOrderBranchesOn

public boolean isOrderBranchesOn()

setOrderBranchesOn

public void setOrderBranchesOn(boolean orderBranchesOn)

getBranchOrdering

public SortedRootedTree.BranchOrdering getBranchOrdering()

setBranchOrdering

public void setBranchOrdering(SortedRootedTree.BranchOrdering branchOrdering)

getOriginalTree

public RootedTree getOriginalTree()

isShowingTipCallouts

public boolean isShowingTipCallouts()

setShowingTipCallouts

public void setShowingTipCallouts(boolean showingTipCallouts)

setSelectedNode

public void setSelectedNode(Node selectedNode)

setSelectedTip

public void setSelectedTip(Node selectedTip)

setSelectedClade

public void setSelectedClade(Node selectedNode)

setSelectedTips

public void setSelectedTips(Node selectedNode)

addSelectedNode

public void addSelectedNode(Node selectedNode)

addSelectedTip

public void addSelectedTip(Node selectedTip)

addSelectedClade

public void addSelectedClade(Node selectedNode)

addSelectedTips

public void addSelectedTips(Node selectedNode)

selectCladesFromSelectedNodes

public void selectCladesFromSelectedNodes()

selectTipsFromSelectedNodes

public void selectTipsFromSelectedNodes()

selectNodesFromSelectedTips

public void selectNodesFromSelectedTips()

selectAllTaxa

public void selectAllTaxa()

selectAllNodes

public void selectAllNodes()

clearSelection

public void clearSelection()

hasSelection

public boolean hasSelection()

collapseSelectedNodes

public void collapseSelectedNodes()

annotateSelectedNodes

public void annotateSelectedNodes(String name,
                                  Object value)

annotateSelectedTips

public void annotateSelectedTips(String name,
                                 Object value)

maintainAspectRatio

public boolean maintainAspectRatio()
Return whether the two axis scales should be maintained relative to each other

Returns:
a boolean

setTipLabelPainter

public void setTipLabelPainter(LabelPainter<Node> tipLabelPainter)

getTipLabelPainter

public Painter<Node> getTipLabelPainter()

setNodeLabelPainter

public void setNodeLabelPainter(LabelPainter<Node> nodeLabelPainter)

getNodeLabelPainter

public Painter<Node> getNodeLabelPainter()

setBranchLabelPainter

public void setBranchLabelPainter(LabelPainter<Node> branchLabelPainter)

getBranchLabelPainter

public Painter<Node> getBranchLabelPainter()

setNodeBarPainter

public void setNodeBarPainter(NodeBarPainter nodeBarPainter)

getNodeBarPainter

public Painter<Node> getNodeBarPainter()

setScaleBarPainter

public void setScaleBarPainter(Painter<TreePane> scaleBarPainter)

getScaleBarPainter

public Painter<TreePane> getScaleBarPainter()

setPreferredSize

public void setPreferredSize(Dimension dimension)
Overrides:
setPreferredSize in class JComponent

getHeightAt

public double getHeightAt(Graphics2D graphics2D,
                          Point2D point)

getNodeAt

public Node getNodeAt(Graphics2D g2,
                      Point point)

getNodesAt

public Set<Node> getNodesAt(Graphics2D g2,
                            Rectangle rect)

getSelectedNodes

public Set<Node> getSelectedNodes()

getSelectedTips

public Set<Node> getSelectedTips()

getDragRectangle

public Rectangle2D getDragRectangle()

setDragRectangle

public void setDragRectangle(Rectangle2D dragRectangle)

setRuler

public void setRuler(double rulerHeight)

scrollPointToVisible

public void scrollPointToVisible(Point point)

addTreeSelectionListener

public void addTreeSelectionListener(TreeSelectionListener treeSelectionListener)

removeTreeSelectionListener

public void removeTreeSelectionListener(TreeSelectionListener treeSelectionListener)

paint

public void paint(Graphics graphics)
Overrides:
paint in class JComponent

print

public int print(Graphics graphics,
                 PageFormat pageFormat,
                 int pageIndex)
          throws PrinterException
Specified by:
print in interface Printable
Throws:
PrinterException

drawTree

public void drawTree(Graphics2D g2,
                     double width,
                     double height)

addTreePaneListener

public void addTreePaneListener(TreePaneListener listener)

removeTreePaneListener

public void removeTreePaneListener(TreePaneListener listener)

fireTreePaneSettingsChanged

public void fireTreePaneSettingsChanged()

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Overrides:
setBounds in class Component

setBounds

public void setBounds(Rectangle rectangle)
Overrides:
setBounds in class Component

setSize

public void setSize(Dimension dimension)
Overrides:
setSize in class Component

setSize

public void setSize(int width,
                    int height)
Overrides:
setSize in class Component