Package pal.gui
Class TreePainter
- java.lang.Object
-
- pal.gui.TreePainter
-
- All Implemented Interfaces:
Painter
- Direct Known Subclasses:
TreePainterCircular,TreePainterNormal
public abstract class TreePainter extends java.lang.Object implements Painter
A class that can paint a tree into a Graphics object.- Version:
- $Id: TreePainter.java,v 1.24 2003/08/16 23:48:26 matt Exp $
- Author:
- Alexei Drummond
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringattNamestatic java.awt.ColorBACKGROUNDstatic java.lang.StringBOOTSTRAP_ATTRIBUTE_NAMEstatic java.awt.ColorBOOTSTRAP_SUPPORT_COLOURstatic java.awt.FontDEFAULT_FONTstatic java.lang.StringDEFAULT_FONT_NAMEstatic intDEFAULT_FONT_SIZEstatic intDEFAULT_FONT_STYLEstatic java.awt.ColorFOREGROUNDstatic LabelDisplayerHILITED_LABEL_DISPLAYstatic java.awt.ColorNORMAL_LABEL_COLORstatic LabelDisplayerNORMAL_LABEL_DISPLAYprotected booleanshowingInternalLabelsdetermines whether internal nodes are labelledjava.lang.Stringtitle_PositionedNodetreeNode
-
Constructor Summary
Constructors Constructor Description TreePainter(Tree toDisplay, java.lang.String title, boolean showTitle)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoScale(java.awt.Graphics g, double xScale, int x, int y)voiddoTitle(java.awt.Graphics g, int x, int y)static voiddrawSymbol(java.awt.Graphics g, int x, int y, int width, int index)protected intgetBootstrapValue(PositionedNode node)Returns -1 if no trap value availableprotected java.awt.FontgetLabelFont()protected intgetLongestIdentifierPixelWidth(java.awt.FontMetrics fm)protected static doublegetMaxLeafTime(Node node)protected LabelDisplayergetNodeDisplay(Node n, LabelDisplayer defaultDisplay)protected java.lang.StringgetNodeName(Node node)intgetPenWidth()protected doublegetSizeOfScale(double target)TimeOrderCharacterDatagetTimeOrderCharacterData()java.lang.StringgetTitle()protected TreegetTree()booleanisShowingInternalLabels()booleanisShowingNodeHeights()booleanisShowTitle()booleanisUsingColor()booleanisUsingSymbols()voidsetAttributeName(java.lang.String name)voidsetColouriser(NameColouriser nc)voidsetLabelFont(java.awt.Font f)Set the font used to display labelsvoidsetLabelFontSize(int size)Set the font used to display labelsvoidsetLabelMapping(LabelMapping lp)voidsetMaxHeight(double maxHeight)sets the maximum height of plot.voidsetPenWidth(int p)voidsetShowingNodeHeights(boolean s)voidsetTimeOrderCharacterData(TimeOrderCharacterData tocd)voidsetTitle(java.lang.String title)voidsetTree(Tree tree)voidsetTreeImpl(Tree tree)may be implemented by sub classesvoidsetUsingColor(boolean use)voidsetUsingSymbols(boolean use)Sets whether the tree is painted with symbols.protected voidstandardTreePrep()Rotates the tree by leaf count, creates a positioned node version of the trees root and calculates postions and width and height information.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface pal.gui.Painter
getPreferredSize, paint, paint
-
-
-
-
Field Detail
-
BACKGROUND
public static final java.awt.Color BACKGROUND
-
FOREGROUND
public static final java.awt.Color FOREGROUND
-
NORMAL_LABEL_COLOR
public static final java.awt.Color NORMAL_LABEL_COLOR
-
NORMAL_LABEL_DISPLAY
public static final LabelDisplayer NORMAL_LABEL_DISPLAY
-
HILITED_LABEL_DISPLAY
public static final LabelDisplayer HILITED_LABEL_DISPLAY
-
BOOTSTRAP_SUPPORT_COLOUR
public static final java.awt.Color BOOTSTRAP_SUPPORT_COLOUR
-
BOOTSTRAP_ATTRIBUTE_NAME
public static final java.lang.String BOOTSTRAP_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
DEFAULT_FONT_SIZE
public static final int DEFAULT_FONT_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_FONT_STYLE
public static final int DEFAULT_FONT_STYLE
- See Also:
- Constant Field Values
-
DEFAULT_FONT_NAME
public static final java.lang.String DEFAULT_FONT_NAME
- See Also:
- Constant Field Values
-
DEFAULT_FONT
public static final java.awt.Font DEFAULT_FONT
-
treeNode
public PositionedNode treeNode
-
title_
public java.lang.String title_
-
attName
protected java.lang.String attName
-
showingInternalLabels
protected boolean showingInternalLabels
determines whether internal nodes are labelled
-
-
Constructor Detail
-
TreePainter
public TreePainter(Tree toDisplay, java.lang.String title, boolean showTitle)
- Parameters:
toDisplay- the tree being painted.title- the title of the tree.showTitle- true if a title is being displayed.nc- A name colouriser, may be null.
-
-
Method Detail
-
getBootstrapValue
protected int getBootstrapValue(PositionedNode node)
Returns -1 if no trap value available
-
standardTreePrep
protected void standardTreePrep()
Rotates the tree by leaf count, creates a positioned node version of the trees root and calculates postions and width and height information.
-
setMaxHeight
public final void setMaxHeight(double maxHeight)
sets the maximum height of plot. if this height is smaller than root height then only a proportion of tree is drawn.
-
setAttributeName
public final void setAttributeName(java.lang.String name)
-
setPenWidth
public final void setPenWidth(int p)
-
getPenWidth
public final int getPenWidth()
-
setTree
public final void setTree(Tree tree)
-
setTreeImpl
public void setTreeImpl(Tree tree)
may be implemented by sub classes
-
setUsingColor
public final void setUsingColor(boolean use)
-
isUsingColor
public final boolean isUsingColor()
-
setShowingNodeHeights
public final void setShowingNodeHeights(boolean s)
-
isShowingNodeHeights
public final boolean isShowingNodeHeights()
-
isShowingInternalLabels
public final boolean isShowingInternalLabels()
-
getTimeOrderCharacterData
public final TimeOrderCharacterData getTimeOrderCharacterData()
-
setTimeOrderCharacterData
public final void setTimeOrderCharacterData(TimeOrderCharacterData tocd)
-
isUsingSymbols
public final boolean isUsingSymbols()
-
setUsingSymbols
public final void setUsingSymbols(boolean use)
Sets whether the tree is painted with symbols. This can only be set to true of a TimeOrderCharacterData has been set.
-
getTree
protected final Tree getTree()
-
getSizeOfScale
protected final double getSizeOfScale(double target)
-
getMaxLeafTime
protected static final double getMaxLeafTime(Node node)
-
drawSymbol
public static final void drawSymbol(java.awt.Graphics g, int x, int y, int width, int index)
-
isShowTitle
public final boolean isShowTitle()
-
setColouriser
public final void setColouriser(NameColouriser nc)
-
setLabelMapping
public final void setLabelMapping(LabelMapping lp)
-
setTitle
public final void setTitle(java.lang.String title)
-
getNodeName
protected final java.lang.String getNodeName(Node node)
-
getTitle
public final java.lang.String getTitle()
-
doTitle
public final void doTitle(java.awt.Graphics g, int x, int y)
-
doScale
protected final void doScale(java.awt.Graphics g, double xScale, int x, int y)
-
getNodeDisplay
protected final LabelDisplayer getNodeDisplay(Node n, LabelDisplayer defaultDisplay)
-
getLongestIdentifierPixelWidth
protected final int getLongestIdentifierPixelWidth(java.awt.FontMetrics fm)
-
setLabelFont
public final void setLabelFont(java.awt.Font f)
Set the font used to display labels
-
setLabelFontSize
public final void setLabelFontSize(int size)
Set the font used to display labels
-
getLabelFont
protected final java.awt.Font getLabelFont()
-
-