9 namespace datastructure {
26 vector<TreeElement*> children;
74 return (n >= children.size() || n < 0 ) ?
nullptr : children.at(n);
87 return (n >= children.size() || n < 0) ?
nullptr : children.at(n);
95 children.push_back(child);
117 if ((index < children.size()) && index >= 0) {
118 children[index] = kid;
119 this->
links.erase(children[index]);
137 virtual const string getDataStructureRepresentation()
const override final {
156 string json_str =
"", children =
"", link_props =
"", elem_rep =
"";
162 t_str = elem_rep.substr(1, elem_rep.size() - 2);
163 json_str += t_str +
COMMA;
165 if (root->children.size())
167 for (
int k = 0; k < root->children.size(); k++) {
168 if (root->children[k] == NULL) {
188 json_str +=
"linkProperties" +
COLON +
"{}" +
COMMA;
190 json_str += preOrder(root->children[k]);
195 json_str = json_str.substr(0, json_str.size() - 1);
197 if (root->children.size())
This is the fundamental building block for all data structures in BRIDGES.
Definition: Element.h:52
This is the superclass of all data structure types in BRIDGES.
Definition: DataStructure.h:73
double getThickness() const
Get the link thickness.
Definition: LinkVisualizer.h:100
const string COLON
Definition: DataStructure.h:51
const string OPEN_BOX
Definition: DataStructure.h:54
const vector< TreeElement * > & getChildren() const
Get the children of this node.
Definition: TreeElement.h:61
TreeElement(const E &e=E(), const string &lab=string())
Construct a TreeElement from given values.
Definition: TreeElement.h:38
void setChild(const size_t &index, TreeElement *kid)
Sets child at index to "kid".
Definition: TreeElement.h:108
vector< TreeElement * > & getChildren()
Get the children of this node.
Definition: TreeElement.h:52
const string CLOSE_CURLY
Definition: DataStructure.h:53
This class can be used to create tree elements, derived from Element.
Definition: TreeElement.h:24
TreeElement * getChild(const int &n)
Gets the nth child of this node.
Definition: TreeElement.h:73
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
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
const string CLOSE_BOX
Definition: DataStructure.h:55
const string getCSSRepresentation() const
Definition: Color.h:404
This class maintains the visual properties of links within data structures.
Definition: LinkVisualizer.h:26
virtual const string getDStype() const override
Get the data structure name.
Definition: TreeElement.h:45
unordered_map< Element *, LinkVisualizer > links
Definition: Element.h:95
const TreeElement * getChild(const int &n) const
Gets the nth child of this node - constant version.
Definition: TreeElement.h:86
const string COMMA
Definition: DataStructure.h:50
const string QUOTE
Definition: DataStructure.h:49
void addChild(TreeElement *child)
Adds a child to children.
Definition: TreeElement.h:94
std::string JSONencode(const T &d)
Definition: JSONutil.h:37
LinkVisualizer * getLinkVisualizer(const Element *el)
Returns the LinkVisualizer of element.
Definition: Element.h:165