bpp-phyl3 3.0.0
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 override
 
std::string getName () const override
 
void setTree (const Tree &tree) override
 
double getWidth () const override
 
double getHeight () const override
 
void treeHasChanged () override
 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
 Plot the tree onto the specified device. More...
 
bool hasTree () const override
 
const Treetree () const override
 
const TreeTemplate< INode > & treeTemplate () const
 
Point2D< double > getNodePosition (int nodeId) const override
 Get the position of a node. More...
 
int getNodeAt (const Point2D< double > &position) const override
 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 (std::shared_ptr< const TreeDrawingSettings > tds) override
 Global drawing settings. More...
 
const TreeDrawingSettingsdisplaySettings () const override
 
double getXUnit () const override
 
double getYUnit () const override
 
void setXUnit (double xu) override
 Set the 'horizontal' expansion unit. More...
 
void setYUnit (double yu) override
 Set the 'vertical' expansion unit. More...
 
void collapseNode (int nodeId, bool yn) override
 Properties to draw. More...
 
bool isNodeCollapsed (int nodeId) const override
 
void addTreeDrawingListener (TreeDrawingListener *listener) override
 Add a drawing listener to this instance. More...
 
void removeTreeDrawingListener (TreeDrawingListener *listener) override
 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 std::shared_ptr< const TreeDrawingSettingsDEFAULT_SETTINGS = std::make_shared<const TreeDrawingSettings>()
 

Protected Member Functions

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
 

Protected Attributes

std::unique_ptr< TreeTemplate< INode > > tree_
 
double xUnit_
 
double yUnit_
 
std::shared_ptr< const TreeDrawingSettingssettings_
 
std::vector< TreeDrawingListener * > listeners_
 

Private Member Functions

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

Private Attributes

double totalDepth_
 
double numberOfLeaves_
 
short horOrientation_
 
short verOrientation_
 

Detailed Description

Cladogram representation of trees.

This representation is for trees without branch lengths.

Definition at line 34 of file CladogramPlot.h.

Constructor & Destructor Documentation

◆ CladogramPlot()

bpp::CladogramPlot::CladogramPlot ( )
inline

Definition at line 42 of file CladogramPlot.h.

Referenced by clone().

◆ ~CladogramPlot()

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

Definition at line 46 of file CladogramPlot.h.

Member Function Documentation

◆ addTreeDrawingListener()

void bpp::AbstractTreeDrawing::addTreeDrawingListener ( TreeDrawingListener listener)
inlineoverridevirtualinherited

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 281 of file AbstractTreeDrawing.h.

References bpp::AbstractTreeDrawing::listeners_.

◆ belongsTo()

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 47 of file AbstractTreeDrawing.cpp.

References bpp::Point2D< class >::getX(), bpp::Point2D< class >::getY(), and bpp::AbstractTreeDrawing::settings_.

Referenced by bpp::AbstractTreeDrawing::getNodeAt().

◆ clone()

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

Implements bpp::TreeDrawing.

Definition at line 48 of file CladogramPlot.h.

References CladogramPlot().

◆ collapseNode()

void bpp::AbstractTreeDrawing::collapseNode ( int  nodeId,
bool  yn 
)
inlineoverridevirtualinherited

Properties to draw.

Collapsing nodes

Implements bpp::TreeDrawing.

Definition at line 269 of file AbstractTreeDrawing.h.

References bpp::AbstractTreeDrawing::tree_.

◆ displaySettings()

const TreeDrawingSettings & bpp::AbstractTreeDrawing::displaySettings ( ) const
inlineoverridevirtualinherited

◆ drawAtBranch()

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 58 of file AbstractTreeDrawing.cpp.

References bpp::GraphicDevice::drawText(), bpp::NodeTemplate< NodeInfos >::getFather(), bpp::NodeTemplate< NodeInfos >::getInfos(), bpp::Node::hasFather(), bpp::AbstractTreeDrawing::xUnit_, and bpp::AbstractTreeDrawing::yUnit_.

◆ drawAtNode()

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 53 of file AbstractTreeDrawing.cpp.

References bpp::GraphicDevice::drawText(), bpp::NodeTemplate< NodeInfos >::getInfos(), bpp::AbstractTreeDrawing::xUnit_, and bpp::AbstractTreeDrawing::yUnit_.

◆ drawDendrogram_()

◆ fireAfterBranchEvent_()

void bpp::AbstractTreeDrawing::fireAfterBranchEvent_ ( const DrawIBranchEvent event) const
inlineprotectedinherited

◆ fireAfterNodeEvent_()

void bpp::AbstractTreeDrawing::fireAfterNodeEvent_ ( const DrawINodeEvent event) const
inlineprotectedinherited

◆ fireAfterTreeEvent_()

void bpp::AbstractTreeDrawing::fireAfterTreeEvent_ ( const DrawTreeEvent event) const
inlineprotectedinherited

◆ fireBeforeBranchEvent_()

void bpp::AbstractTreeDrawing::fireBeforeBranchEvent_ ( const DrawIBranchEvent event) const
inlineprotectedinherited

◆ fireBeforeNodeEvent_()

void bpp::AbstractTreeDrawing::fireBeforeNodeEvent_ ( const DrawINodeEvent event) const
inlineprotectedinherited

◆ fireBeforeTreeEvent_()

void bpp::AbstractTreeDrawing::fireBeforeTreeEvent_ ( const DrawTreeEvent event) const
inlineprotectedinherited

◆ getHeight()

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

Implements bpp::TreeDrawing.

Definition at line 56 of file CladogramPlot.h.

References numberOfLeaves_.

Referenced by recursivePlot_().

◆ getHorizontalOrientation()

short bpp::AbstractDendrogramPlot::getHorizontalOrientation ( ) const
inlineinherited

◆ getName()

std::string bpp::CladogramPlot::getName ( ) const
inlineoverridevirtual
Returns
A string describing this drawing algorithm.

Implements bpp::TreeDrawing.

Definition at line 51 of file CladogramPlot.h.

◆ getNodeAt()

int AbstractTreeDrawing::getNodeAt ( const Point2D< double > &  position) const
overridevirtualinherited

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 33 of file AbstractTreeDrawing.cpp.

References bpp::AbstractTreeDrawing::belongsTo(), and bpp::AbstractTreeDrawing::tree_.

◆ getNodePosition()

Point2D< double > AbstractTreeDrawing::getNodePosition ( int  nodeId) const
overridevirtualinherited

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 20 of file AbstractTreeDrawing.cpp.

References bpp::TextTools::toString(), and bpp::AbstractTreeDrawing::tree_.

◆ getVerticalOrientation()

short bpp::AbstractDendrogramPlot::getVerticalOrientation ( ) const
inlineinherited

◆ getWidth()

double bpp::CladogramPlot::getWidth ( ) const
inlineoverridevirtual
Returns
The total width of the drawing, in X units.

Implements bpp::TreeDrawing.

Definition at line 55 of file CladogramPlot.h.

References totalDepth_.

Referenced by drawDendrogram_().

◆ getXUnit()

double bpp::AbstractTreeDrawing::getXUnit ( ) const
inlineoverridevirtualinherited

◆ getYUnit()

double bpp::AbstractTreeDrawing::getYUnit ( ) const
inlineoverridevirtualinherited
Returns
The vertical unit length.

Implements bpp::TreeDrawing.

Definition at line 263 of file AbstractTreeDrawing.h.

References bpp::AbstractTreeDrawing::yUnit_.

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

◆ hasTree()

bool bpp::AbstractTreeDrawing::hasTree ( ) const
inlineoverridevirtualinherited

◆ isNodeCollapsed()

bool bpp::AbstractTreeDrawing::isNodeCollapsed ( int  nodeId) const
inlineoverridevirtualinherited

Implements bpp::TreeDrawing.

Definition at line 275 of file AbstractTreeDrawing.h.

References bpp::AbstractTreeDrawing::tree_.

◆ plot()

void AbstractDendrogramPlot::plot ( GraphicDevice gDevice) const
virtualinherited

Plot the tree onto the specified device.

Parameters
gDeviceAn object implementing the GraphicDevice interface.

Implements bpp::TreeDrawing.

Definition at line 15 of file AbstractDendrogramPlot.cpp.

References bpp::AbstractTreeDrawing::displaySettings(), bpp::AbstractDendrogramPlot::drawDendrogram_(), and bpp::GraphicDevice::setCurrentPointSize().

◆ recursivePlot_()

◆ removeTreeDrawingListener()

void bpp::AbstractTreeDrawing::removeTreeDrawingListener ( TreeDrawingListener listener)
inlineoverridevirtualinherited

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 288 of file AbstractTreeDrawing.h.

References bpp::TreeDrawingListener::isAutonomous(), and bpp::AbstractTreeDrawing::listeners_.

◆ setDisplaySettings()

void bpp::AbstractTreeDrawing::setDisplaySettings ( std::shared_ptr< const TreeDrawingSettings tds)
inlineoverridevirtualinherited

Global drawing settings.

Implements bpp::TreeDrawing.

Definition at line 253 of file AbstractTreeDrawing.h.

References bpp::AbstractTreeDrawing::settings_.

◆ setHorizontalOrientation()

void bpp::AbstractDendrogramPlot::setHorizontalOrientation ( short  orientation)
inlineinherited

◆ setTree()

void CladogramPlot::setTree ( const Tree tree)
overridevirtual
Parameters
treeA tree to associate with this drawing. The object will be copied.

Reimplemented from bpp::AbstractTreeDrawing.

Definition at line 30 of file CladogramPlot.cpp.

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

◆ setVerticalOrientation()

void bpp::AbstractDendrogramPlot::setVerticalOrientation ( short  orientation)
inlineinherited

◆ setXUnit()

void bpp::AbstractTreeDrawing::setXUnit ( double  xu)
inlineoverridevirtualinherited

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 265 of file AbstractTreeDrawing.h.

References bpp::AbstractTreeDrawing::xUnit_.

◆ setYUnit()

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

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 267 of file AbstractTreeDrawing.h.

References bpp::AbstractTreeDrawing::yUnit_.

◆ tree()

const Tree & bpp::AbstractTreeDrawing::tree ( ) const
inlineoverridevirtualinherited
Returns
A pointer toward the tree associated to this drawing.

Implements bpp::TreeDrawing.

Definition at line 178 of file AbstractTreeDrawing.h.

References bpp::AbstractTreeDrawing::hasTree(), and bpp::AbstractTreeDrawing::tree_.

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

◆ treeHasChanged()

void bpp::CladogramPlot::treeHasChanged ( )
inlineoverridevirtual

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

Implements bpp::AbstractTreeDrawing.

Definition at line 58 of file CladogramPlot.h.

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

◆ treeTemplate()

const TreeTemplate< INode > & bpp::AbstractTreeDrawing::treeTemplate ( ) const
inlineinherited

Member Data Documentation

◆ DEFAULT_SETTINGS

shared_ptr< const TreeDrawingSettings > AbstractTreeDrawing::DEFAULT_SETTINGS = std::make_shared<const TreeDrawingSettings>()
staticinherited

Definition at line 359 of file AbstractTreeDrawing.h.

◆ horOrientation_

short bpp::AbstractDendrogramPlot::horOrientation_
privateinherited

◆ listeners_

◆ numberOfLeaves_

double bpp::CladogramPlot::numberOfLeaves_
private

Definition at line 39 of file CladogramPlot.h.

Referenced by getHeight(), and treeHasChanged().

◆ ORIENTATION_BOTTOM_TO_TOP

short AbstractDendrogramPlot::ORIENTATION_BOTTOM_TO_TOP = 4
staticinherited

Definition at line 49 of file AbstractDendrogramPlot.h.

◆ ORIENTATION_LEFT_TO_RIGHT

◆ ORIENTATION_RIGHT_TO_LEFT

short AbstractDendrogramPlot::ORIENTATION_RIGHT_TO_LEFT = 2
staticinherited

Definition at line 47 of file AbstractDendrogramPlot.h.

◆ ORIENTATION_TOP_TO_BOTTOM

short AbstractDendrogramPlot::ORIENTATION_TOP_TO_BOTTOM = 3
staticinherited

◆ settings_

◆ totalDepth_

double bpp::CladogramPlot::totalDepth_
private

Definition at line 38 of file CladogramPlot.h.

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

◆ tree_

◆ verOrientation_

short bpp::AbstractDendrogramPlot::verOrientation_
privateinherited

◆ xUnit_

◆ yUnit_


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