bpp-phyl  2.1.0
 All Classes Namespaces Files Functions Variables Friends Pages
bpp::CladogramPlot Class Reference

Cladogram representation of trees. More...

#include <Bpp/Phyl/Graphics/CladogramPlot.h>

+ Inheritance diagram for bpp::CladogramPlot:
+ Collaboration diagram for bpp::CladogramPlot:

Public Member Functions

 CladogramPlot ()
 
virtual ~CladogramPlot ()
 
CladogramPlotclone () const
 
std::string getName () const
 
void setTree (const Tree *tree=0)
 
double getWidth () const
 
double getHeight () const
 
void treeHasChanged ()
 Method to implement to deal with redrawing when the underlying tree has been modified. More...
 
void setHorizontalOrientation (short orientation)
 
void setVerticalOrientation (short orientation)
 
short getHorizontalOrientation () const
 
short getVerticalOrientation () const
 
void plot (GraphicDevice &gDevice) const throw (Exception)
 Plot the tree onto the specified device. More...
 
bool hasTree () const
 
const TreeTemplate< INode > * getTree () const
 
Point2D< double > getNodePosition (int nodeId) const throw (NodeNotFoundException)
 Get the position of a node. More...
 
int getNodeAt (const Point2D< double > &position) const throw (NodeNotFoundException)
 Get the node corresponding to a position on the device. More...
 
bool belongsTo (const Point2D< double > &p1, const Point2D< double > &p2) const
 Utilitary function, telling if a point belongs to a specified area. More...
 
virtual void drawAtNode (GraphicDevice &gDevice, const INode &node, const std::string &text, double xOffset=0, double yOffset=0, short hpos=GraphicDevice::TEXT_HORIZONTAL_LEFT, short vpos=GraphicDevice::TEXT_VERTICAL_CENTER, double angle=0) const
 Draw some text at a particular node position. More...
 
virtual void drawAtBranch (GraphicDevice &gDevice, const INode &node, const std::string &text, double xOffset=0, double yOffset=0, short hpos=GraphicDevice::TEXT_HORIZONTAL_LEFT, short vpos=GraphicDevice::TEXT_VERTICAL_CENTER, double angle=0) const
 Draw some text at a particular branch position. More...
 
void setDisplaySettings (const TreeDrawingSettings *tds) throw (NullPointerException)
 Global drawing settings. More...
 
const TreeDrawingSettingsgetDisplaySettings () const
 
double getXUnit () const
 
double getYUnit () const
 
void setXUnit (double xu)
 Set the 'horizontal' expansion unit. More...
 
void setYUnit (double yu)
 Set the 'vertical' expansion unit. More...
 
void collapseNode (int nodeId, bool yn) throw (NodeNotFoundException, Exception)
 Properties to draw. More...
 
bool isNodeCollapsed (int nodeId) const throw (NodeNotFoundException, Exception)
 
void addTreeDrawingListener (TreeDrawingListener *listener) throw (Exception)
 Add a drawing listener to this instance. More...
 
void removeTreeDrawingListener (TreeDrawingListener *listener) throw (Exception)
 Remove a drawing listener from this instance. More...
 

Static Public Attributes

static short ORIENTATION_LEFT_TO_RIGHT = 1
 
static short ORIENTATION_RIGHT_TO_LEFT = 2
 
static short ORIENTATION_TOP_TO_BOTTOM = 3
 
static short ORIENTATION_BOTTOM_TO_TOP = 4
 
static const TreeDrawingSettings DEFAULT_SETTINGS
 

Protected Member Functions

TreeTemplate< INode > * getTree_ ()
 
const TreeTemplate< INode > * getTree_ () const
 
void fireBeforeTreeEvent_ (const DrawTreeEvent &event) const
 
void fireAfterTreeEvent_ (const DrawTreeEvent &event) const
 
void fireBeforeNodeEvent_ (const DrawINodeEvent &event) const
 
void fireAfterNodeEvent_ (const DrawINodeEvent &event) const
 
void fireBeforeBranchEvent_ (const DrawIBranchEvent &event) const
 
void fireAfterBranchEvent_ (const DrawIBranchEvent &event) const
 

Private Member Functions

void drawDendrogram_ (GraphicDevice &gDevice) const throw (Exception)
 
void recursivePlot_ (GraphicDevice &gDevice, INode &node, double x, double &y, double hDirection, double vDirection, unsigned int *tipCounter) const
 

Private Attributes

double totalDepth_
 
double numberOfLeaves_
 

Detailed Description

Cladogram representation of trees.

This representation is for trees without branch lengths.

Definition at line 72 of file CladogramPlot.h.

Constructor & Destructor Documentation

bpp::CladogramPlot::CladogramPlot ( )
inline

Definition at line 80 of file CladogramPlot.h.

Referenced by clone().

virtual bpp::CladogramPlot::~CladogramPlot ( )
inlinevirtual

Definition at line 84 of file CladogramPlot.h.

Member Function Documentation

void bpp::AbstractTreeDrawing::addTreeDrawingListener ( TreeDrawingListener listener) throw (Exception)
inlinevirtualinherited

Add a drawing listener to this instance.

Parameters
listenera pointer toward an object implementing the TreeDrawingListener interface. This object will then be owned by the class and copied and deleted if/when needed, unless it is autonomous.
See Also
TreeDrawingListener

Implements bpp::TreeDrawing.

Definition at line 305 of file AbstractTreeDrawing.h.

References bpp::AbstractTreeDrawing::listeners_, bpp::AbstractTreeDrawing::listeners_, bpp::AbstractTreeDrawing::listeners_, and bpp::AbstractTreeDrawing::listeners_.

bool AbstractTreeDrawing::belongsTo ( const Point2D< double > &  p1,
const Point2D< double > &  p2 
) const
inherited

Utilitary function, telling if a point belongs to a specified area.

This method is used internally to get a node coordinates.

Parameters
p1Point to look for.
p2Second point defining the center of the area.
Returns
True if p1 belongs to the area defined by p2.

Definition at line 86 of file AbstractTreeDrawing.cpp.

References bpp::Point2D< T >::getX(), bpp::Point2D< T >::getX(), bpp::Point2D< T >::getX(), bpp::Point2D< T >::getX(), bpp::Point2D< T >::getY(), bpp::Point2D< T >::getY(), bpp::Point2D< T >::getY(), and bpp::Point2D< T >::getY().

CladogramPlot* bpp::CladogramPlot::clone ( ) const
inlinevirtual

Implements bpp::TreeDrawing.

Definition at line 86 of file CladogramPlot.h.

References CladogramPlot().

void bpp::AbstractTreeDrawing::collapseNode ( int  nodeId,
bool  yn 
) throw (NodeNotFoundException, Exception)
inlinevirtualinherited

Properties to draw.

Collapsing nodes

Implements bpp::TreeDrawing.

Definition at line 293 of file AbstractTreeDrawing.h.

References bpp::AbstractTreeDrawing::tree_, and bpp::AbstractTreeDrawing::tree_.

void AbstractTreeDrawing::drawAtBranch ( GraphicDevice gDevice,
const INode node,
const std::string &  text,
double  xOffset = 0,
double  yOffset = 0,
short  hpos = GraphicDevice::TEXT_HORIZONTAL_LEFT,
short  vpos = GraphicDevice::TEXT_VERTICAL_CENTER,
double  angle = 0 
) const
virtualinherited

Draw some text at a particular branch position.

Parameters
gDeviceThe GraphicDevice object on which to draw.
nodeThe node of interest.
textThe text to draw.
xOffsetHorizontal offset.
yOffsetVertical offset.
hposThe way the text should be aligned horizontally (see GraphicDevice).
vposThe way the text should be aligned vertically (see GraphicDevice).
angleThe rotation value of the text.

Definition at line 97 of file AbstractTreeDrawing.cpp.

References bpp::NodeTemplate< NodeInfos >::getFather(), bpp::NodeTemplate< NodeInfos >::getInfos(), bpp::NodeTemplate< NodeInfos >::getInfos(), and bpp::Node::hasFather().

void AbstractTreeDrawing::drawAtNode ( GraphicDevice gDevice,
const INode node,
const std::string &  text,
double  xOffset = 0,
double  yOffset = 0,
short  hpos = GraphicDevice::TEXT_HORIZONTAL_LEFT,
short  vpos = GraphicDevice::TEXT_VERTICAL_CENTER,
double  angle = 0 
) const
virtualinherited

Draw some text at a particular node position.

Parameters
gDeviceThe GraphicDevice object on which to draw.
nodeThe node of interest.
textThe text to draw.
xOffsetHorizontal offset.
yOffsetVertical offset.
hposThe way the text should be aligned horizontally (see GraphicDevice).
vposThe way the text should be aligned vertically (see GraphicDevice).
angleThe rotation value of the text.

Definition at line 92 of file AbstractTreeDrawing.cpp.

References bpp::NodeTemplate< NodeInfos >::getInfos(), and bpp::NodeTemplate< NodeInfos >::getInfos().

void CladogramPlot::drawDendrogram_ ( GraphicDevice gDevice) const throw (Exception)
privatevirtual

Implements bpp::AbstractDendrogramPlot.

Definition at line 72 of file CladogramPlot.cpp.

void bpp::AbstractTreeDrawing::fireAfterBranchEvent_ ( const DrawIBranchEvent event) const
inlineprotectedinherited
void bpp::AbstractTreeDrawing::fireAfterNodeEvent_ ( const DrawINodeEvent event) const
inlineprotectedinherited
void bpp::AbstractTreeDrawing::fireAfterTreeEvent_ ( const DrawTreeEvent event) const
inlineprotectedinherited
void bpp::AbstractTreeDrawing::fireBeforeBranchEvent_ ( const DrawIBranchEvent event) const
inlineprotectedinherited
void bpp::AbstractTreeDrawing::fireBeforeTreeEvent_ ( const DrawTreeEvent event) const
inlineprotectedinherited
const TreeDrawingSettings& bpp::AbstractTreeDrawing::getDisplaySettings ( ) const
inlinevirtualinherited

Implements bpp::TreeDrawing.

Definition at line 283 of file AbstractTreeDrawing.h.

References bpp::AbstractTreeDrawing::settings_.

double bpp::CladogramPlot::getHeight ( ) const
inlinevirtual
Returns
The total height of the drawing, in Y units.

Implements bpp::TreeDrawing.

Definition at line 94 of file CladogramPlot.h.

References numberOfLeaves_.

Referenced by recursivePlot_(), and recursivePlot_().

short bpp::AbstractDendrogramPlot::getHorizontalOrientation ( ) const
inlineinherited
std::string bpp::CladogramPlot::getName ( ) const
inlinevirtual
Returns
A string describing this drawing algorithm.

Implements bpp::TreeDrawing.

Definition at line 89 of file CladogramPlot.h.

int AbstractTreeDrawing::getNodeAt ( const Point2D< double > &  position) const throw (NodeNotFoundException)
virtualinherited

Get the node corresponding to a position on the device.

Parameters
positionA position in the coordinates system of the last GraphicDevice used.
Returns
The corresponding node identifier if available.
Exceptions
NodeNotFoundExceptionIf the node does not correspond to a node in the tree.

Implements bpp::TreeDrawing.

Definition at line 70 of file AbstractTreeDrawing.cpp.

References bpp::Node::getId(), and bpp::NodeTemplate< NodeInfos >::getInfos().

Point2D< double > AbstractTreeDrawing::getNodePosition ( int  nodeId) const throw (NodeNotFoundException)
virtualinherited

Get the position of a node.

Parameters
nodeIdThe identifier of the node.
Returns
The localization of the node using the coordinate system of the last GraphicDevice used.
Exceptions
NodeNotFoundExceptionIf the node does not correspond to a node in the tree.

Implements bpp::TreeDrawing.

Definition at line 55 of file AbstractTreeDrawing.cpp.

References bpp::Node::getId(), bpp::NodeTemplate< NodeInfos >::getInfos(), and bpp::TextTools::toString().

const TreeTemplate<INode>* bpp::AbstractTreeDrawing::getTree ( ) const
inlinevirtualinherited
Returns
A pointer toward the tree associated to this drawing.

Implements bpp::TreeDrawing.

Definition at line 219 of file AbstractTreeDrawing.h.

References bpp::AbstractTreeDrawing::tree_.

const TreeTemplate<INode>* bpp::AbstractTreeDrawing::getTree_ ( ) const
inlineprotectedinherited

Definition at line 329 of file AbstractTreeDrawing.h.

References bpp::AbstractTreeDrawing::tree_.

short bpp::AbstractDendrogramPlot::getVerticalOrientation ( ) const
inlineinherited
double bpp::CladogramPlot::getWidth ( ) const
inlinevirtual
Returns
The total width of the drawing, in X units.

Implements bpp::TreeDrawing.

Definition at line 93 of file CladogramPlot.h.

References totalDepth_.

double bpp::AbstractTreeDrawing::getXUnit ( ) const
inlinevirtualinherited
Returns
The horizontal unit length.

Implements bpp::TreeDrawing.

Definition at line 285 of file AbstractTreeDrawing.h.

References bpp::AbstractTreeDrawing::xUnit_.

Referenced by bpp::PhylogramPlot::recursivePlot_(), and recursivePlot_().

double bpp::AbstractTreeDrawing::getYUnit ( ) const
inlinevirtualinherited
bool bpp::AbstractTreeDrawing::hasTree ( ) const
inlinevirtualinherited
Returns
'True' if a tree is attached to this instance.

Implements bpp::TreeDrawing.

Definition at line 212 of file AbstractTreeDrawing.h.

References bpp::AbstractTreeDrawing::tree_.

Referenced by setTree(), bpp::PhylogramPlot::treeHasChanged(), and treeHasChanged().

bool bpp::AbstractTreeDrawing::isNodeCollapsed ( int  nodeId) const throw (NodeNotFoundException, Exception)
inlinevirtualinherited
void AbstractDendrogramPlot::plot ( GraphicDevice gDevice) const throw (Exception)
virtualinherited

Plot the tree onto the specified device.

Parameters
gDeviceAn object implementing the GraphicDevice interface.

Implements bpp::TreeDrawing.

Definition at line 50 of file AbstractDendrogramPlot.cpp.

void bpp::AbstractTreeDrawing::removeTreeDrawingListener ( TreeDrawingListener listener) throw (Exception)
inlinevirtualinherited

Remove a drawing listener from this instance.

Parameters
listenera pointer toward an object implementing the TreeDrawingListener interface. If the listener is autonomous, it will be deleted.

Implements bpp::TreeDrawing.

Definition at line 312 of file AbstractTreeDrawing.h.

References bpp::AbstractTreeDrawing::listeners_, bpp::AbstractTreeDrawing::listeners_, bpp::AbstractTreeDrawing::listeners_, and bpp::AbstractTreeDrawing::listeners_.

void bpp::AbstractTreeDrawing::setDisplaySettings ( const TreeDrawingSettings tds) throw (NullPointerException)
inlinevirtualinherited

Global drawing settings.

Implements bpp::TreeDrawing.

Definition at line 278 of file AbstractTreeDrawing.h.

References bpp::AbstractTreeDrawing::settings_.

void bpp::AbstractDendrogramPlot::setHorizontalOrientation ( short  orientation)
inlineinherited
void CladogramPlot::setTree ( const Tree tree = 0)
virtual
Parameters
treeA pointer toward the tree to associate with this drawing.

Reimplemented from bpp::AbstractTreeDrawing.

Definition at line 65 of file CladogramPlot.cpp.

References bpp::TreeTemplateTools::getDepth(), bpp::AbstractTreeDrawing::hasTree(), bpp::AbstractTreeDrawing::setTree(), and totalDepth_.

void bpp::AbstractDendrogramPlot::setVerticalOrientation ( short  orientation)
inlineinherited
void bpp::AbstractTreeDrawing::setXUnit ( double  xu)
inlinevirtualinherited

Set the 'horizontal' expansion unit.

The effect of this expansion factor depends on the implementation of the interface.

Parameters
xuThe horizontal unit length.

Implements bpp::TreeDrawing.

Definition at line 289 of file AbstractTreeDrawing.h.

References bpp::AbstractTreeDrawing::xUnit_.

void bpp::AbstractTreeDrawing::setYUnit ( double  yu)
inlinevirtualinherited

Set the 'vertical' expansion unit.

The effect of this expansion factor depends on the implementation of the interface.

Parameters
yuThe vertical unit length.

Implements bpp::TreeDrawing.

Definition at line 291 of file AbstractTreeDrawing.h.

References bpp::AbstractTreeDrawing::yUnit_.

void bpp::CladogramPlot::treeHasChanged ( )
inlinevirtual

Method to implement to deal with redrawing when the underlying tree has been modified.

Implements bpp::AbstractTreeDrawing.

Definition at line 96 of file CladogramPlot.h.

References bpp::TreeTemplateTools::getDepth(), bpp::AbstractTreeDrawing::getTree_(), bpp::AbstractTreeDrawing::hasTree(), numberOfLeaves_, and totalDepth_.

Member Data Documentation

const TreeDrawingSettings AbstractTreeDrawing::DEFAULT_SETTINGS
staticinherited

Definition at line 373 of file AbstractTreeDrawing.h.

double bpp::CladogramPlot::numberOfLeaves_
private

Definition at line 77 of file CladogramPlot.h.

Referenced by getHeight(), and treeHasChanged().

short AbstractDendrogramPlot::ORIENTATION_BOTTOM_TO_TOP = 4
staticinherited

Definition at line 84 of file AbstractDendrogramPlot.h.

short AbstractDendrogramPlot::ORIENTATION_RIGHT_TO_LEFT = 2
staticinherited

Definition at line 82 of file AbstractDendrogramPlot.h.

short AbstractDendrogramPlot::ORIENTATION_TOP_TO_BOTTOM = 3
staticinherited
double bpp::CladogramPlot::totalDepth_
private

Definition at line 76 of file CladogramPlot.h.

Referenced by getWidth(), recursivePlot_(), setTree(), and treeHasChanged().


The documentation for this class was generated from the following files: