Bridges-C++  3.4.4
Bridges(C++ API)
ElementVisualizer.h
Go to the documentation of this file.
1 #ifndef ELVIS_H
2 #define ELVIS_H
3 
4 #include "Color.h"
5 #include <cmath>
6 
7 namespace bridges {
8  namespace datastructure {
32  public:
33  /*
34  * @brief specifies the default color ("steelblue")
35  * @return the default color
36  */
37  static const Color DEFAULT_COLOR() {
38  return Color("steelblue");
39  }
40  /*
41  * @brief specifies the default shape (CIRCLE)
42  * @return the default shape
43  */
44  static constexpr Shape DEFAULT_SHAPE () {
45  return CIRCLE;
46  }
47  /*
48  * @brief specifies the default size (10.0)
49  * @return the default size
50  */
51  static constexpr double DEFAULT_SIZE () {
52  return 10.;
53  }
54  private:
55  Color color = DEFAULT_COLOR();
56  double size = DEFAULT_SIZE();
57  Shape shape = DEFAULT_SHAPE();
58  double locationX = INFINITY, locationY = INFINITY; // location of element
59  public:
69  const double& sz = DEFAULT_SIZE(),
70  const Shape& shp = DEFAULT_SHAPE())
71  : color(hue), size(sz), shape(shp) {}
79  void setSize(const double& sz) {
80  (sz < 0.001 || 200. < sz)
81  ? throw "Invalid Size Value.. " + to_string(sz) +
82  " Must be in the [0.001,199.0] range"
83  : size = sz;
84  }
86  double getSize() const {
87  return size;
88  }
94  void setColor(const Color& col) {
95  color = col;
96  }
102  void setColor(const string& col) {
103  color = Color(col);
104  }
105 
110  Color getColor() const {
111  return color;
112  }
113 
121  void setOpacity(double opacity) {
122  if (opacity >= 0.0 && opacity <= 1.0)
123  color.setAlpha( (int) (opacity * 255.));
124  }
125 
131  double getOpacity() {
132  return color.getAlpha() / 255.;
133  }
140  void setShape(const Shape& shp) {
141  shape = shp;
142  }
147  Shape getShape() const {
148  return shape;
149  }
157  void setLocation(const double& locX, const double& locY) {
158  locationX = locX;
159  locationY = locY;
160  }
161 
166  double getLocationX() const {
167  return locationX;
168  }
173  double getLocationY() const {
174  return locationY;
175  }
176  };//end of ElementVisualizer class
177  }
178 }//end of bridges namespace
179 #endif
This class represents Color, and supports rgba, hexadecimal and named color values.
Definition: Color.h:50
int getAlpha() const
Definition: Color.h:286
void setAlpha(int a)
Definition: Color.h:326
This class maintains the visual properties of the a Bridges element.
Definition: ElementVisualizer.h:31
void setColor(const string &col)
Set the color to a named color.
Definition: ElementVisualizer.h:102
void setSize(const double &sz)
Definition: ElementVisualizer.h:79
void setOpacity(double opacity)
Set opacity of element.
Definition: ElementVisualizer.h:121
void setShape(const Shape &shp)
Set the shape of the element.
Definition: ElementVisualizer.h:140
Shape getShape() const
Return the shape of the element.
Definition: ElementVisualizer.h:147
double getSize() const
Definition: ElementVisualizer.h:86
double getLocationY() const
get Y coordinate of element location
Definition: ElementVisualizer.h:173
Color getColor() const
Return the element color.
Definition: ElementVisualizer.h:110
static const Color DEFAULT_COLOR()
Definition: ElementVisualizer.h:37
ElementVisualizer(const Color &hue=DEFAULT_COLOR(), const double &sz=DEFAULT_SIZE(), const Shape &shp=DEFAULT_SHAPE())
Definition: ElementVisualizer.h:68
double getLocationX() const
get X coordinate of element location
Definition: ElementVisualizer.h:166
void setColor(const Color &col)
Set the color to "col".
Definition: ElementVisualizer.h:94
static constexpr Shape DEFAULT_SHAPE()
Definition: ElementVisualizer.h:44
void setLocation(const double &locX, const double &locY)
Definition: ElementVisualizer.h:157
double getOpacity()
Get opacity of element.
Definition: ElementVisualizer.h:131
static constexpr double DEFAULT_SIZE()
Definition: ElementVisualizer.h:51
Shape
Definition: ElementVisualizer.h:10
@ DIAMOND
Definition: ElementVisualizer.h:10
@ CIRCLE
Definition: ElementVisualizer.h:10
@ SQUARE
Definition: ElementVisualizer.h:10
@ STAR
Definition: ElementVisualizer.h:10
@ WYE
Definition: ElementVisualizer.h:10
@ TRIANGLE
Definition: ElementVisualizer.h:10
@ CROSS
Definition: ElementVisualizer.h:10
these methods convert byte arrays in to base64 codes and are used in BRIDGES to represent the color a...
Definition: alltypes.h:4