#ifndef __JROOT__JMARKERATTRIBUTES__ #define __JROOT__JMARKERATTRIBUTES__ #include #include "TAttMarker.h" #include "JLang/JObjectIterator.hh" /** * \author mdejong */ namespace JROOT {} namespace JPP { using namespace JROOT; } namespace JROOT { using JLANG::JRewindableObjectIterator; /** * Auxiliary class to set marker attributes. */ class JMarkerAttributes : public JRewindableObjectIterator, public std::vector { public: typedef JRewindableObjectIterator::pointer_type pointer_type; /** * Constructor. * * \param size marker size */ JMarkerAttributes(const Double_t size = 1.0) : std::vector(), index(0) { push_back(TAttMarker(kBlack, 20, 0.85 * size)); push_back(TAttMarker(kRed, 21, 0.70 * size)); push_back(TAttMarker(kBlue, 23, 0.75 * size)); push_back(TAttMarker(kGreen, 22, 0.75 * size)); push_back(TAttMarker(kMagenta, 34, 0.75 * size)); push_back(TAttMarker(kYellow, 29, 0.75 * size)); push_back(TAttMarker(kCyan, 33, 0.75 * size)); push_back(TAttMarker(kOrange, 47, 0.75 * size)); push_back(TAttMarker(kPink, 41, 0.75 * size)); push_back(TAttMarker(kViolet, 43, 0.75 * size)); push_back(TAttMarker(kBlack, 24, 0.85 * size)); push_back(TAttMarker(kRed, 25, 0.70 * size)); push_back(TAttMarker(kBlue, 32, 0.75 * size)); push_back(TAttMarker(kGreen, 26, 0.75 * size)); push_back(TAttMarker(kMagenta, 28, 0.75 * size)); push_back(TAttMarker(kYellow, 30, 0.75 * size)); push_back(TAttMarker(kCyan, 27, 0.75 * size)); push_back(TAttMarker(kOrange, 46, 0.75 * size)); push_back(TAttMarker(kPink, 40, 0.75 * size)); push_back(TAttMarker(kViolet, 42, 0.75 * size)); } /** * Get reference to unique instance of this class object. * * \return reference to this class object */ static JMarkerAttributes& getInstance() { static JMarkerAttributes marker(1.0); return marker; } /** * Set marker size. * * \param size marker size */ void setMarkerSize(const Double_t size) { for (iterator i = this->begin(); i != this->end(); ++i) { i->SetMarkerSize(i->GetMarkerSize() * size); } } /** * Rewind index. */ virtual void rewind() override { index = 0; } /** * Check availability of next element. * * \return true if the iteration has more elements; else false */ virtual bool hasNext() override { return !this->empty(); } /** * Get next element. * * \return pointer to element */ virtual const pointer_type& next() override { static pointer_type ps; if (index < this->size()) { ps.reset(&this->at(index)); } ++index; index = index%this->size(); return ps; } /** * Get marker attributes. * * \param index index * \return marker attributes */ const TAttMarker& get(unsigned int index) { return this->at(index%this->size()); } private: unsigned int index; }; } #endif