#ifndef __JROOT__JLINEATTRIBUTES__ #define __JROOT__JLINEATTRIBUTES__ #include #include "TAttLine.h" #include "JLang/JObjectIterator.hh" /** * \author mdejong */ namespace JROOT {} namespace JPP { using namespace JROOT; } namespace JROOT { using JLANG::JRewindableObjectIterator; /** * Auxiliary class to set line attributes. */ class JLineAttributes : public JRewindableObjectIterator, public std::vector { public: typedef JRewindableObjectIterator::pointer_type pointer_type; /** * Constructor. * * \param width line width */ JLineAttributes(const Width_t width = 2) : std::vector(), index(0) { for (int i = 1; i <= 10; ++i) { push_back(TAttLine(kBlack, i, width)); } } /** * Get reference to unique instance of this class object. * * \return reference to this class object */ static JLineAttributes& getInstance() { static JLineAttributes line(2); return line; } /** * Set line width. * * \param width line width */ void setLineWidth(const Width_t width) { for (iterator i = this->begin(); i != this->end(); ++i) { i->SetLineWidth(width); } } /** * 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 line attributes. * * \param index index * \return line attributes */ const TAttLine& get(unsigned int index) { return this->at(index%this->size()); } private: unsigned int index; }; } #endif