5 #include <unordered_set> 6 #include <unordered_map> 17 namespace datastructure {
19 template <
typename K,
typename E1,
typename E2>
class GraphAdjList;
54 template <
typename K,
typename E1,
typename E2>
friend class GraphAdjList;
56 template <
typename K>
friend class Array;
57 template <
typename K>
friend class Array1D;
58 template <
typename K>
friend class Array2D;
59 template <
typename K>
friend class Array3D;
69 static const unordered_map<const Shape, const string, hash<int>>& ShapeNames() {
71 static std::unordered_map<const Shape, const string, hash<int>> sn = {
95 unordered_map<Element*, LinkVisualizer>
links;
105 explicit Element(
const E& val = E(),
const string& lab =
string()) :
106 label(lab), value(val) {
117 : label(e.label), value(e.value), elvis(new
ElementVisualizer(*(e.elvis))), links(e.links) {
121 this->label = e.label;
122 this->value = e.value;
123 *(this->elvis) = *(e.elvis);
124 this->links = e.
links;
128 E& operator= (E
const& e) {
166 if (links.find(const_cast<Element*>(el)) != links.end()) {
167 return &(links.at(const_cast<Element*>(el)));
170 cerr <<
"Element " << label <<
" not linked to Element " 171 << el->
getLabel() <<
", returning NULL" << endl;
184 return const_cast<Element*
> (
this)->getLinkVisualizer(el);
274 const string& src,
const string& dest) {
double getLocationY() const
get Y coordinate of element location
Definition: ElementVisualizer.h:173
double getLocationX() const
get X coordinate of element location
Definition: ElementVisualizer.h:166
void setSize(const double &sz)
Sets size of the element.
Definition: Element.h:297
void setValue(const E &val)
Sets generic object to "val".
Definition: Element.h:229
This is the fundamental building block for all data structures in BRIDGES.
Definition: Element.h:52
static const string getLinkRepresentation(const LinkVisualizer &lv, const string &src, const string &dest)
Definition: Element.h:273
Element(const E &val=E(), const string &lab=string())
Definition: Element.h:105
Definition: ElementVisualizer.h:10
Definition: ElementVisualizer.h:10
double getThickness() const
Get the link thickness.
Definition: LinkVisualizer.h:100
void setOpacity(double opacity)
Set opacity of element.
Definition: ElementVisualizer.h:121
E & getValue()
Gets the object held in the generic object E.
Definition: Element.h:220
const string COLON
Definition: DataStructure.h:51
E const & getValue() const
Gets the object held in the generic object E.
Definition: Element.h:210
This class provides methods to represent adjacency list based graphs.
Definition: Element.h:19
Shape getShape() const
Returns the shape of the element.
Definition: Element.h:370
string const & getLabel() const
Gets the label of this element.
Definition: Element.h:191
Definition: ElementVisualizer.h:10
This class maintains the visual properties of the a Bridges element.
Definition: ElementVisualizer.h:31
The foundation of BRIDGES array types. It is not meant to be used directly by students.
Definition: Array.h:21
const string OPEN_BOX
Definition: DataStructure.h:54
void setOpacity(double opacity)
Set opacity of element - use the 4th color component.
Definition: Element.h:341
void setColor(const Color &col)
Set the color to "col".
Definition: ElementVisualizer.h:94
const string CLOSE_CURLY
Definition: DataStructure.h:53
double getOpacity()
Get opacity of element.
Definition: ElementVisualizer.h:131
virtual const string getElementRepresentation() const
Gets the JSON string of the element representation.
Definition: Element.h:238
This class represents Color, and supports rgba, hexadecimal and named color values.
Definition: Color.h:51
Color getColor() const
Return the link color.
Definition: LinkVisualizer.h:124
void setShape(const Shape &shp)
Set the shape of the element.
Definition: Element.h:360
LinkVisualizer * getLinkVisualizer(const Element *el) const
Returns the LinkVisualizer of element.
Definition: Element.h:183
void setLocation(const double &locX, const double &locY)
Definition: ElementVisualizer.h:157
these methods convert byte arrays in to base64 codes and are used in BRIDGES to represent the color a...
Definition: alltypes.h:4
const string OPEN_CURLY
Definition: DataStructure.h:52
void setColor(const Color &col)
Set the color of the Element.
Definition: Element.h:314
const string CLOSE_BOX
Definition: DataStructure.h:55
void setLocation(const double &locX, const double &locY)
Sets the location attributes of an element.
Definition: Element.h:379
double getSize() const
Get element size.
Definition: Element.h:306
Color getColor() const
Get the current color of the element.
Definition: Element.h:332
void setSize(const double &sz)
Definition: ElementVisualizer.h:79
const string getCSSRepresentation() const
Definition: Color.h:404
A BRIDGES array type.
Definition: Array2D.h:43
const ElementVisualizer * getVisualizer() const
Get the element visualizer object - constant version.
Definition: Element.h:152
A BRIDGES 1D array type.
Definition: Array1D.h:53
A BRIDGES array type.
Definition: Array3D.h:43
double getSize() const
Definition: ElementVisualizer.h:86
void setLabel(const string &lab)
Sets label of this element.
Definition: Element.h:200
This class provides methods to represent adjacency matrix based graphs.
Definition: Element.h:20
This class maintains the visual properties of links within data structures.
Definition: LinkVisualizer.h:26
string getLabel() const
Return the link label.
Definition: LinkVisualizer.h:69
Color getColor() const
Return the element color.
Definition: ElementVisualizer.h:110
Definition: ElementVisualizer.h:10
Shape
Definition: ElementVisualizer.h:10
double getOpacity()
Definition: Element.h:350
ElementVisualizer * getVisualizer()
Get the element visualizer object.
Definition: Element.h:144
unordered_map< Element *, LinkVisualizer > links
Definition: Element.h:95
Definition: ElementVisualizer.h:10
double getLocationY() const
Gets the Y coordinate of the location.
Definition: Element.h:394
void setShape(const Shape &shp)
Set the shape of the element.
Definition: ElementVisualizer.h:140
const string COMMA
Definition: DataStructure.h:50
Shape getShape() const
Return the shape of the element.
Definition: ElementVisualizer.h:147
double getLocationX() const
Gets the X coordinate of the location.
Definition: Element.h:387
const string QUOTE
Definition: DataStructure.h:49
Element(const Element &e)
Definition: Element.h:116
void setColor(const string col)
Set the color by name.
Definition: Element.h:323
virtual ~Element()
Definition: Element.h:136
Definition: ElementVisualizer.h:10
Definition: ElementVisualizer.h:10
std::string JSONencode(const T &d)
Definition: JSONutil.h:37
LinkVisualizer * getLinkVisualizer(const Element *el)
Returns the LinkVisualizer of element.
Definition: Element.h:165