bpp-phyl  2.2.0
TreeDrawingListener.h
Go to the documentation of this file.
1 //
2 // File: TreeDrawingListener.h
3 // Created by: Julien Dutheil
4 // Created on: Tue May 18 10:33 2010
5 //
6 
7 /*
8 Copyright or © or Copr. Bio++ Development Team, (2010)
9 
10 This software is a computer program whose purpose is to provide
11 graphic components to develop bioinformatics applications.
12 
13 This software is governed by the CeCILL license under French law and
14 abiding by the rules of distribution of free software. You can use,
15 modify and/ or redistribute the software under the terms of the CeCILL
16 license as circulated by CEA, CNRS and INRIA at the following URL
17 "http://www.cecill.info".
18 
19 As a counterpart to the access to the source code and rights to copy,
20 modify and redistribute granted by the license, users are provided only
21 with a limited warranty and the software's author, the holder of the
22 economic rights, and the successive licensors have only limited
23 liability.
24 
25 In this respect, the user's attention is drawn to the risks associated
26 with loading, using, modifying and/or developing or reproducing the
27 software by the user in light of its specific status of free software,
28 that may mean that it is complicated to manipulate, and that also
29 therefore means that it is reserved for developers and experienced
30 professionals having in-depth computer knowledge. Users are therefore
31 encouraged to load and test the software's suitability as regards their
32 requirements in conditions enabling the security of their systems and/or
33 data to be ensured and, more generally, to use and operate it in the
34 same conditions as regards security.
35 
36 The fact that you are presently reading this means that you have had
37 knowledge of the CeCILL license and that you accept its terms.
38 */
39 
40 #ifndef _TREEDRAWINGLISTENER_H_
41 #define _TREEDRAWINGLISTENER_H_
42 
43 #include "TreeDrawing.h"
44 
45 #include <Bpp/Clonable.h>
46 
47 namespace bpp {
48 
56  public virtual Clonable
57 {
58 public:
59 #ifndef NO_VIRTUAL_COV
61 #else
62  Clonable*
63 #endif
64  clone() const = 0;
65 
66  virtual void beforeDrawTree(const DrawTreeEvent& event) = 0;
67  virtual void afterDrawTree(const DrawTreeEvent& event) = 0;
68  virtual void beforeDrawNode(const DrawNodeEvent& event) = 0;
69  virtual void afterDrawNode(const DrawNodeEvent& event) = 0;
70  virtual void beforeDrawBranch(const DrawBranchEvent& event) = 0;
71  virtual void afterDrawBranch(const DrawBranchEvent& event) = 0;
72 
77  virtual bool isAutonomous() const = 0;
78 
79  virtual bool isEnabled() const = 0;
80  virtual void enable(bool tf) = 0;
81 };
82 
83 
88  public virtual TreeDrawingListener
89 {
90 private:
92  bool enabled_;
93 
94 public:
95  TreeDrawingListenerAdapter(bool autonomous) : autonomous_(autonomous), enabled_(true) {}
96 
97 public:
98  void beforeDrawTree(const DrawTreeEvent& event) {}
99  void afterDrawTree(const DrawTreeEvent& event) {}
100  void beforeDrawNode(const DrawNodeEvent& event) {}
101  void afterDrawNode(const DrawNodeEvent& event) {}
102  void beforeDrawBranch(const DrawBranchEvent& event) {}
103  void afterDrawBranch(const DrawBranchEvent& event) {}
104  bool isAutonomous() const { return autonomous_; }
105  bool isEnabled() const { return enabled_; }
106  void enable(bool tf) { enabled_ = tf; }
107 };
108 
109 
110 
116 {
117 private:
119 
120 public:
121  NodesIdTreeDrawingListener(const TreeDrawingSettings* settings, bool autonomous = false) :
122  TreeDrawingListenerAdapter(autonomous),
123  settings_(settings)
124  {}
125 
128  settings_(lntdl.settings_) {}
129 
131  {
132  TreeDrawingListenerAdapter::operator=(lntdl);
133  settings_ = lntdl.settings_;
134  return *this;
135  }
136 
138 
139 public :
140  void afterDrawNode(const DrawNodeEvent& event);
141 
142 };
143 
144 
150 {
151 private:
153 
154 public:
155  LeafNamesTreeDrawingListener(const TreeDrawingSettings* settings, bool autonomous = false) :
156  TreeDrawingListenerAdapter(autonomous),
157  settings_(settings)
158  {}
159 
162  settings_(lntdl.settings_)
163  {}
164 
166  {
167  TreeDrawingListenerAdapter::operator=(lntdl);
168  settings_ = lntdl.settings_;
169  return *this;
170  }
171 
173 
174 public :
175  void afterDrawNode(const DrawNodeEvent& event);
176 
177 };
178 
179 
189 {
190 private:
192 
193 public:
194  BranchLengthsTreeDrawingListener(const TreeDrawingSettings* settings, bool autonomous = false) :
195  TreeDrawingListenerAdapter(autonomous),
196  settings_(settings)
197  {}
198 
201  settings_(lntdl.settings_)
202  {}
203 
205  {
206  TreeDrawingListenerAdapter::operator=(lntdl);
207  settings_ = lntdl.settings_;
208  return *this;
209  }
210 
212 
213 public :
214  void afterDrawBranch(const DrawBranchEvent& event);
215 
216 };
217 
218 
228 {
229 private:
231 
232 public:
233  BootstrapValuesTreeDrawingListener(const TreeDrawingSettings* settings, bool autonomous = false) :
234  TreeDrawingListenerAdapter(autonomous),
235  settings_(settings)
236  {}
237 
240  settings_(lntdl.settings_) {}
241 
243  {
244  TreeDrawingListenerAdapter::operator=(lntdl);
245  settings_ = lntdl.settings_;
246  return *this;
247  }
248 
250 
251 public :
252  void afterDrawBranch(const DrawBranchEvent& event);
253 
254 };
255 
256 
266 {
267 
268 public:
269  LabelInnerNodesTreeDrawingListener(bool autonomous = false) :
270  TreeDrawingListenerAdapter(autonomous) {}
271 
273 
274 public :
275  void afterDrawNode(const DrawNodeEvent& event);
276 
277 };
278 
279 
280 
288 {
289 public:
290  LabelCollapsedNodesTreeDrawingListener(bool autonomous = false) :
291  TreeDrawingListenerAdapter(autonomous) {}
292 
294 
295 public :
296  void afterDrawNode(const DrawNodeEvent& event);
297 
298 };
299 
300 } //end of namespace bpp
301 
302 #endif //_TREEDRAWINGLISTENER_H_
303 
BootstrapValuesTreeDrawingListener & operator=(const BootstrapValuesTreeDrawingListener &lntdl)
virtual bool isEnabled() const =0
LabelCollapsedNodesTreeDrawingListener * clone() const
LabelInnerNodesTreeDrawingListener * clone() const
LabelInnerNodesTreeDrawingListener(bool autonomous=false)
BootstrapValuesTreeDrawingListener(const TreeDrawingSettings *settings, bool autonomous=false)
A TreeDrawingListener implementation that write the bootstrap values of inner nodes.
void afterDrawNode(const DrawNodeEvent &event)
virtual void beforeDrawTree(const DrawTreeEvent &event)=0
void afterDrawBranch(const DrawBranchEvent &event)
BootstrapValuesTreeDrawingListener * clone() const
bool isAutonomous() const
Tells if the listener is autonomous. If so, it will never be hard-copied or deleted.
void afterDrawBranch(const DrawBranchEvent &event)
BranchLengthsTreeDrawingListener(const BranchLengthsTreeDrawingListener &lntdl)
const TreeDrawingSettings * settings_
void afterDrawNode(const DrawNodeEvent &event)
virtual void enable(bool tf)=0
virtual void afterDrawBranch(const DrawBranchEvent &event)=0
BranchLengthsTreeDrawingListener * clone() const
NodesIdTreeDrawingListener(const TreeDrawingSettings *settings, bool autonomous=false)
void afterDrawBranch(const DrawBranchEvent &event)
virtual void beforeDrawNode(const DrawNodeEvent &event)=0
LeafNamesTreeDrawingListener(const TreeDrawingSettings *settings, bool autonomous=false)
const TreeDrawingSettings * settings_
BranchLengthsTreeDrawingListener(const TreeDrawingSettings *settings, bool autonomous=false)
LabelCollapsedNodesTreeDrawingListener(bool autonomous=false)
BootstrapValuesTreeDrawingListener(const BootstrapValuesTreeDrawingListener &lntdl)
A set of options to tune the display of a TreeDrawing object.
Definition: TreeDrawing.h:61
void beforeDrawNode(const DrawNodeEvent &event)
NodesIdTreeDrawingListener & operator=(const NodesIdTreeDrawingListener &lntdl)
A TreeDrawingListener implementation that write the branch lengths of inner nodes.
void afterDrawNode(const DrawNodeEvent &event)
LeafNamesTreeDrawingListener(const LeafNamesTreeDrawingListener &lntdl)
Event class used by TreeDrawing classes.
Definition: TreeDrawing.h:124
virtual bool isAutonomous() const =0
Tells if the listener is autonomous. If so, it will never be hard-copied or deleted.
An empty implementation of the TreeDrawingListener interface.
Interface allowing to capture drawing events.
LeafNamesTreeDrawingListener & operator=(const LeafNamesTreeDrawingListener &lntdl)
virtual void afterDrawTree(const DrawTreeEvent &event)=0
A TreeDrawingListener implementation that write the names of inner nodes.
const TreeDrawingSettings * settings_
void beforeDrawTree(const DrawTreeEvent &event)
Event class used by TreeDrawing classes.
Definition: TreeDrawing.h:165
A TreeDrawingListener implementation that write leaf names.
void afterDrawNode(const DrawNodeEvent &event)
virtual void beforeDrawBranch(const DrawBranchEvent &event)=0
virtual void afterDrawNode(const DrawNodeEvent &event)=0
NodesIdTreeDrawingListener * clone() const
void afterDrawTree(const DrawTreeEvent &event)
LeafNamesTreeDrawingListener * clone() const
void afterDrawNode(const DrawNodeEvent &event)
NodesIdTreeDrawingListener(const NodesIdTreeDrawingListener &lntdl)
BranchLengthsTreeDrawingListener & operator=(const BranchLengthsTreeDrawingListener &lntdl)
A TreeDrawingListener implementation that writes nodes id.
void beforeDrawBranch(const DrawBranchEvent &event)
TreeDrawingListener * clone() const =0
Event class used by TreeDrawing classes.
Definition: TreeDrawing.h:211
A TreeDrawingListener implementation that label the collapsed nodes.