Bridges-C++  3.1.1
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 {
29  public:
30  static const Color DEFAULT_COLOR() {
31  return Color("steelblue");
32  }
33  static constexpr Shape DEFAULT_SHAPE () {
34  return CIRCLE;
35  }
36  static constexpr double DEFAULT_SIZE () {
37  return 10.;
38  }
39  private:
40  Color color = DEFAULT_COLOR();
41  double size = DEFAULT_SIZE();
42  Shape shape = DEFAULT_SHAPE();
43  double locationX = INFINITY, locationY = INFINITY; // location of element
44  public:
54  const double& sz = DEFAULT_SIZE(),
55  const Shape& shp = DEFAULT_SHAPE())
56  : color(hue), size(sz), shape(shp) {}
64  void setSize(const double& sz) {
65  (sz < 1 || 50 < sz)
66  ? throw "Invalid Size Value.. " + to_string(sz) +
67  " Must be in the [1.0,50.0] range"
68  : size = sz;
69  }
71  double getSize() const {
72  return size;
73  }
79  void setColor(const Color& col) {
80  color = col;
81  }
87  void setColor(const string& col) {
88  color = Color(col);
89  }
90 
95  Color getColor() const {
96  return color;
97  }
98 
104  void setOpacity(double opacity) {
105  if (opacity >= 0.0 && opacity <= 1.0)
106  color.setAlpha( (int) (opacity * 255.));
107  }
108 
114  double getOpacity() {
115  return color.getAlpha() / 255.;
116  }
122  void setShape(const Shape& shp) {
123  shape = shp;
124  }
129  Shape getShape() const {
130  return shape;
131  }
139  void setLocation(const double& locX, const double& locY) {
140  locationX = locX;
141  locationY = locY;
142  }
143 
147  double getLocationX() const {
148  return locationX;
149  }
153  double getLocationY() const {
154  return locationY;
155  }
156  };//end of ElementVisualizer class
157  }
158 }//end of bridges namespace
159 #endif
int getAlpha() const
Definition: Color.h:287
static constexpr double DEFAULT_SIZE()
Definition: ElementVisualizer.h:36
double getLocationY() const
Definition: ElementVisualizer.h:153
double getLocationX() const
Definition: ElementVisualizer.h:147
Definition: ElementVisualizer.h:10
Definition: ElementVisualizer.h:10
void setOpacity(double opacity)
Definition: ElementVisualizer.h:104
Definition: ElementVisualizer.h:10
This class maintains the visual properties of the a Bridges element.
Definition: ElementVisualizer.h:28
void setAlpha(int a)
Definition: Color.h:327
void setColor(const Color &col)
Set the color to "col".
Definition: ElementVisualizer.h:79
double getOpacity()
Get opacity of element.
Definition: ElementVisualizer.h:114
This class represents Color, and supports rgba, hexadecimal and named color values.
Definition: Color.h:51
void setLocation(const double &locX, const double &locY)
Definition: ElementVisualizer.h:139
these methods convert byte arrays in to base64 codes and are used in BRIDGES to represent the color a...
Definition: alltypes.h:4
void setSize(const double &sz)
Definition: ElementVisualizer.h:64
static constexpr Shape DEFAULT_SHAPE()
Definition: ElementVisualizer.h:33
ElementVisualizer(const Color &hue=DEFAULT_COLOR(), const double &sz=DEFAULT_SIZE(), const Shape &shp=DEFAULT_SHAPE())
Definition: ElementVisualizer.h:53
double getSize() const
Definition: ElementVisualizer.h:71
Color getColor() const
Definition: ElementVisualizer.h:95
Definition: ElementVisualizer.h:10
Shape
Definition: ElementVisualizer.h:10
void setColor(const string &col)
Set the color to a named color.
Definition: ElementVisualizer.h:87
Definition: ElementVisualizer.h:10
void setShape(const Shape &shp)
Set the shape of the element.
Definition: ElementVisualizer.h:122
Shape getShape() const
Return the shape of the element.
Definition: ElementVisualizer.h:129
Definition: ElementVisualizer.h:10
static const Color DEFAULT_COLOR()
Definition: ElementVisualizer.h:30
Definition: ElementVisualizer.h:10