Bridges-C++  3.4.5-dev1-6-g935685a
Bridges(C++ API)
USState.h
Go to the documentation of this file.
1 #ifndef STATE_H
2 #define STATE_H
3 
4 #include "USCounty.h"
5 #include "../Color.h"
6 
7 #include <string>
8 #include <unordered_map>
9 
10 using std::string;
11 
12 
13 namespace bridges {
14  namespace dataset {
15  /*
16  * @brief This object stores US State and links to information
17  *
18  * This object is used alongside with the USMap object. Each state
19  * has a stroke color and fill color and list of counties of type County
20  *
21  * See tutorial at https://bridgesuncc.github.io/tutorials/Map.html
22  *
23  * @author Kalpathi Subramanian, Erik Saule
24  * @date Last modified Dec 29, 2024
25  */
26  class USState {
27  string name;
28  datastructure::Color stroke_color;
29  bool view_counties; // flag to visualize county boundaries
30  float stroke_width; // boundary color
31  datastructure::Color fill_color; // fill color of state
32  unordered_map<string, USCounty> counties; // holds county info
33 
34  public:
35  USState() = default;
36 
37  USState(string st) {
38  name = st;
39  stroke_color = datastructure::Color("red");
40  view_counties = true;
41  stroke_width = 2.;
42  fill_color = datastructure::Color("blue");
43  }
52  unordered_map<string, USCounty> getCounties() const {
53  return counties;
54  }
68  unordered_map<string, USCounty>& accessCounties() {
69  return counties;
70  }
71 
77  void setCounties(unordered_map<string, USCounty> & c) {
78  counties = c;
79  }
80 
81  // getters, setters
82  string getStateName() const {
83  return name;
84  }
85  void setStateName(string n) {
86  name = n;
87  }
88 
90  return stroke_color;
91  }
93  stroke_color = c;
94  }
95 
97  return fill_color;
98  }
100  fill_color = c;
101  }
102 
103  float getStrokeWidth() const {
104  return stroke_width;
105  }
106  void setStrokeWidth(float width) {
107  stroke_width = width;
108  }
109 
113  bool getViewCountiesFlag() const {
114  return view_counties;
115  }
116  void setViewCountiesFlag(bool flag) {
117  view_counties = flag;
118  }
119  };
120  };
121 };
122 #endif
Definition: USState.h:26
unordered_map< string, USCounty > & accessCounties()
obtain reference to the county data for that state
Definition: USState.h:68
unordered_map< string, USCounty > getCounties() const
obtain a copy of the county data for that state
Definition: USState.h:52
void setFillColor(datastructure::Color c)
Definition: USState.h:99
void setStrokeWidth(float width)
Definition: USState.h:106
void setStateName(string n)
Definition: USState.h:85
USState(string st)
Definition: USState.h:37
void setStrokeColor(datastructure::Color c)
Definition: USState.h:92
void setCounties(unordered_map< string, USCounty > &c)
sets the counties for this state
Definition: USState.h:77
string getStateName() const
Definition: USState.h:82
float getStrokeWidth() const
Definition: USState.h:103
void setViewCountiesFlag(bool flag)
Definition: USState.h:116
datastructure::Color getStrokeColor() const
Definition: USState.h:89
datastructure::Color getFillColor() const
Definition: USState.h:96
bool getViewCountiesFlag() const
this flag lets you turn on/off counties as needed
Definition: USState.h:113
This class represents Color, and supports rgba, hexadecimal and named color values.
Definition: Color.h:50
Support for drawing Bar charts.
Definition: alltypes.h:4