bpp-phyl  2.2.0
bpp::AbstractTreeDrawing Class Referenceabstract

Partial implementation of the TreeDrawing interface. More...

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

+ Inheritance diagram for bpp::AbstractTreeDrawing:
+ Collaboration diagram for bpp::AbstractTreeDrawing:

Public Member Functions

 AbstractTreeDrawing ()
 
 AbstractTreeDrawing (const AbstractTreeDrawing &atd)
 
AbstractTreeDrawingoperator= (const AbstractTreeDrawing &atd)
 
virtual ~AbstractTreeDrawing ()
 
bool hasTree () const
 
const TreeTemplate< INode > * getTree () const
 
void setTree (const Tree *tree)
 
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...
 
virtual void treeHasChanged ()=0
 Method to implement to deal with redrawing when the underlying tree has been modified. More...
 
TreeDrawingclone () const =0
 
virtual std::string getName () const =0
 
virtual double getWidth () const =0
 
virtual double getHeight () const =0
 
virtual void plot (GraphicDevice &gDevice) const =0 throw (Exception)
 Plot the tree onto the specified device. More...
 

Static Public Attributes

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 Attributes

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

Detailed Description

Partial implementation of the TreeDrawing interface.

This basic implementation uses a dedicated NodeInfo structure in combination with the NodeTemplate class. This structures stores the current coordinates of all nodes, so that it is easy to annotate the tree drawing.:if expand("%") == ""|browse confirm w|else|confirm w|endif

Definition at line 155 of file AbstractTreeDrawing.h.

Constructor & Destructor Documentation

◆ AbstractTreeDrawing() [1/2]

bpp::AbstractTreeDrawing::AbstractTreeDrawing ( )
inline

Definition at line 166 of file AbstractTreeDrawing.h.

◆ AbstractTreeDrawing() [2/2]

bpp::AbstractTreeDrawing::AbstractTreeDrawing ( const AbstractTreeDrawing atd)
inline

Definition at line 168 of file AbstractTreeDrawing.h.

References listeners_.

◆ ~AbstractTreeDrawing()

virtual bpp::AbstractTreeDrawing::~AbstractTreeDrawing ( )
inlinevirtual

Definition at line 203 of file AbstractTreeDrawing.h.

References listeners_.

Member Function Documentation

◆ addTreeDrawingListener()

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

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 listeners_.

◆ belongsTo()

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

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.

◆ clone()

TreeDrawing* bpp::TreeDrawing::clone ( ) const
pure virtualinherited

Implemented in bpp::CladogramPlot, and bpp::PhylogramPlot.

◆ collapseNode()

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

Properties to draw.

Collapsing nodes

Implements bpp::TreeDrawing.

Definition at line 293 of file AbstractTreeDrawing.h.

References tree_.

◆ 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
virtual

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(), and bpp::Node::hasFather().

◆ 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
virtual

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().

◆ fireAfterBranchEvent_()

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

◆ fireAfterNodeEvent_()

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

◆ fireAfterTreeEvent_()

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

Definition at line 338 of file AbstractTreeDrawing.h.

References listeners_.

◆ fireBeforeBranchEvent_()

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

◆ fireBeforeNodeEvent_()

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

◆ fireBeforeTreeEvent_()

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

Definition at line 331 of file AbstractTreeDrawing.h.

References listeners_.

◆ getDisplaySettings()

const TreeDrawingSettings& bpp::AbstractTreeDrawing::getDisplaySettings ( ) const
inlinevirtual

Implements bpp::TreeDrawing.

Definition at line 283 of file AbstractTreeDrawing.h.

References settings_.

◆ getHeight()

virtual double bpp::TreeDrawing::getHeight ( ) const
pure virtualinherited
Returns
The total height of the drawing, in Y units.

Implemented in bpp::CladogramPlot, and bpp::PhylogramPlot.

◆ getName()

virtual std::string bpp::TreeDrawing::getName ( ) const
pure virtualinherited
Returns
A string describing this drawing algorithm.

Implemented in bpp::CladogramPlot, and bpp::PhylogramPlot.

◆ getNodeAt()

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

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().

◆ getNodePosition()

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

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(), and bpp::NodeTemplate< NodeInfos >::getInfos().

◆ getTree()

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

Implements bpp::TreeDrawing.

Definition at line 219 of file AbstractTreeDrawing.h.

References tree_.

◆ getTree_() [1/2]

TreeTemplate<INode>* bpp::AbstractTreeDrawing::getTree_ ( )
inlineprotected

◆ getTree_() [2/2]

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

Definition at line 329 of file AbstractTreeDrawing.h.

References tree_.

◆ getWidth()

virtual double bpp::TreeDrawing::getWidth ( ) const
pure virtualinherited
Returns
The total width of the drawing, in X units.

Implemented in bpp::CladogramPlot, and bpp::PhylogramPlot.

◆ getXUnit()

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

Implements bpp::TreeDrawing.

Definition at line 285 of file AbstractTreeDrawing.h.

References xUnit_.

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

◆ getYUnit()

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

Implements bpp::TreeDrawing.

Definition at line 287 of file AbstractTreeDrawing.h.

References yUnit_.

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

◆ hasTree()

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

Implements bpp::TreeDrawing.

Definition at line 212 of file AbstractTreeDrawing.h.

References tree_.

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

◆ isNodeCollapsed()

bool bpp::AbstractTreeDrawing::isNodeCollapsed ( int  nodeId) const
throw (NodeNotFoundException,
Exception
)
inlinevirtual

Implements bpp::TreeDrawing.

Definition at line 299 of file AbstractTreeDrawing.h.

References tree_.

◆ operator=()

AbstractTreeDrawing& bpp::AbstractTreeDrawing::operator= ( const AbstractTreeDrawing atd)
inline

Definition at line 184 of file AbstractTreeDrawing.h.

References listeners_, settings_, tree_, xUnit_, and yUnit_.

◆ plot()

virtual void bpp::TreeDrawing::plot ( GraphicDevice &  gDevice) const
throw (Exception
)
pure virtualinherited

Plot the tree onto the specified device.

Parameters
gDeviceAn object implementing the GraphicDevice interface.

Implemented in bpp::AbstractDendrogramPlot.

◆ removeTreeDrawingListener()

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

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 listeners_.

◆ setDisplaySettings()

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

Global drawing settings.

Implements bpp::TreeDrawing.

Definition at line 278 of file AbstractTreeDrawing.h.

References settings_.

◆ setTree()

void bpp::AbstractTreeDrawing::setTree ( const Tree tree)
inlinevirtual
Parameters
treeA pointer toward the tree to associate with this drawing.

Implements bpp::TreeDrawing.

Reimplemented in bpp::CladogramPlot, and bpp::PhylogramPlot.

Definition at line 221 of file AbstractTreeDrawing.h.

References tree_, and treeHasChanged().

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

◆ setXUnit()

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

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 xUnit_.

◆ setYUnit()

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

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 yUnit_.

◆ treeHasChanged()

virtual void bpp::AbstractTreeDrawing::treeHasChanged ( )
pure virtual

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

Implemented in bpp::CladogramPlot, and bpp::PhylogramPlot.

Referenced by setTree().

Member Data Documentation

◆ DEFAULT_SETTINGS

const TreeDrawingSettings AbstractTreeDrawing::DEFAULT_SETTINGS
static

Definition at line 373 of file AbstractTreeDrawing.h.

◆ listeners_

◆ settings_

const TreeDrawingSettings* bpp::AbstractTreeDrawing::settings_
private

Definition at line 162 of file AbstractTreeDrawing.h.

Referenced by getDisplaySettings(), operator=(), and setDisplaySettings().

◆ tree_

std::auto_ptr<TreeTemplate<INode> > bpp::AbstractTreeDrawing::tree_
private

◆ xUnit_

double bpp::AbstractTreeDrawing::xUnit_
private

Definition at line 160 of file AbstractTreeDrawing.h.

Referenced by getXUnit(), operator=(), and setXUnit().

◆ yUnit_

double bpp::AbstractTreeDrawing::yUnit_
private

Definition at line 161 of file AbstractTreeDrawing.h.

Referenced by getYUnit(), operator=(), and setYUnit().


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