Jpp
JMarkerAttributes.hh
Go to the documentation of this file.
1 #ifndef __JGIZMO__JMARKERATTRIBUTES__
2 #define __JGIZMO__JMARKERATTRIBUTES__
3 
4 #include <vector>
5 
6 #include "TAttMarker.h"
7 
9 
10 
11 /**
12  * \author mdejong
13  */
14 
15 namespace JGIZMO {}
16 namespace JPP { using namespace JGIZMO; }
17 
18 namespace JGIZMO {
19 
21  using JLANG::JPointer;
22 
23 
24  /**
25  * Auxiliary class to set marker attributes.
26  */
28  public JRewindableObjectIterator<TAttMarker>,
29  public std::vector <TAttMarker>
30  {
31  public:
32 
34 
35 
36  /**
37  * Constructor.
38  *
39  * \param size marker size
40  */
41  JMarkerAttributes(const Double_t size = 1.0) :
42  std::vector<TAttMarker>(),
43  index(0)
44  {
45  push_back(TAttMarker(kBlack, 20, 0.85 * size));
46  push_back(TAttMarker(kRed, 21, 0.70 * size));
47  push_back(TAttMarker(kBlue, 23, 0.75 * size));
48  push_back(TAttMarker(kGreen, 22, 0.75 * size));
49  push_back(TAttMarker(kMagenta, 34, 0.75 * size));
50  push_back(TAttMarker(kYellow, 29, 0.75 * size));
51  push_back(TAttMarker(kCyan, 33, 0.75 * size));
52 
53  push_back(TAttMarker(kBlack, 24, 0.85 * size));
54  push_back(TAttMarker(kRed, 25, 0.70 * size));
55  push_back(TAttMarker(kBlue, 32, 0.75 * size));
56  push_back(TAttMarker(kGreen, 26, 0.75 * size));
57  push_back(TAttMarker(kMagenta, 28, 0.75 * size));
58  push_back(TAttMarker(kYellow, 30, 0.75 * size));
59  push_back(TAttMarker(kCyan, 27, 0.75 * size));
60  }
61 
62 
63  /**
64  * Get reference to unique instance of this class object.
65  *
66  * \return reference to this class object
67  */
69  {
70  static JMarkerAttributes marker(1.0);
71 
72  return marker;
73  }
74 
75 
76  /**
77  * Set marker size.
78  *
79  * \param size marker size
80  */
81  void setMarkerSize(const Double_t size)
82  {
83  for (iterator i = this->begin(); i != this->end(); ++i) {
84  i->SetMarkerSize(i->GetMarkerSize() * size);
85  }
86  }
87 
88 
89  /**
90  * Rewind index.
91  */
92  virtual void rewind()
93  {
94  index = 0;
95  }
96 
97 
98  /**
99  * Check availability of next element.
100  *
101  * \return true if the iteration has more elements; else false
102  */
103  virtual bool hasNext()
104  {
105  return !this->empty();
106  }
107 
108 
109  /**
110  * Get next element.
111  *
112  * \return pointer to element
113  */
114  virtual const pointer_type& next()
115  {
116  static pointer_type ps;
117 
118  if (index < this->size()) {
119  ps.reset(&this->at(index));
120  }
121 
122  ++index;
123 
124  index = index%this->size();
125 
126  return ps;
127  }
128 
129 
130  /**
131  * Get marker attributes.
132  *
133  * \param index index
134  * \return marker attributes
135  */
136  const TAttMarker& get(unsigned int index)
137  {
138  return this->at(index%this->size());
139  }
140 
141 
142  private:
143  unsigned int index;
144  };
145 }
146 
147 #endif
JGIZMO::JMarkerAttributes::hasNext
virtual bool hasNext()
Check availability of next element.
Definition: JMarkerAttributes.hh:103
JObjectIterator.hh
std::vector
Definition: JSTDTypes.hh:12
JGIZMO::JMarkerAttributes::index
unsigned int index
Definition: JMarkerAttributes.hh:143
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
JLANG::JPointer
Template implementation of class that holds pointer to object(s).
Definition: JPointer.hh:22
JGIZMO::JMarkerAttributes::setMarkerSize
void setMarkerSize(const Double_t size)
Set marker size.
Definition: JMarkerAttributes.hh:81
JGIZMO::JMarkerAttributes::get
const TAttMarker & get(unsigned int index)
Get marker attributes.
Definition: JMarkerAttributes.hh:136
JGIZMO::JMarkerAttributes
Auxiliary class to set marker attributes.
Definition: JMarkerAttributes.hh:27
JGIZMO::JMarkerAttributes::next
virtual const pointer_type & next()
Get next element.
Definition: JMarkerAttributes.hh:114
JLANG::JRewindableObjectIterator
Interface for object iteration with rewinding.
Definition: JObjectIterator.hh:362
JGIZMO::JMarkerAttributes::rewind
virtual void rewind()
Rewind index.
Definition: JMarkerAttributes.hh:92
JGIZMO::JMarkerAttributes::pointer_type
JRewindableObjectIterator< TAttMarker >::pointer_type pointer_type
Definition: JMarkerAttributes.hh:33
JGIZMO
Auxiliary applications for use of ROOT and more.
Definition: JCanvas.hh:15
std
Definition: jaanetDictionary.h:36
JGIZMO::JMarkerAttributes::getInstance
static JMarkerAttributes & getInstance()
Get reference to unique instance of this class object.
Definition: JMarkerAttributes.hh:68
JGIZMO::JMarkerAttributes::JMarkerAttributes
JMarkerAttributes(const Double_t size=1.0)
Constructor.
Definition: JMarkerAttributes.hh:41