Bridges-Java  3.4.2
Bridges(Java API)
Public Member Functions | List of all members
bridges.base.TreeElement< E > Class Template Reference
Inheritance diagram for bridges.base.TreeElement< E >:
bridges.base.Element< E > bridges.base.DataStruct bridges.base.BinTreeElement< E > bridges.base.BSTElement< K, E > bridges.base.AVLTreeElement< K, E > bridges.base.KdTreeElement< K, E >

Detailed Description

This class extends Element to represent general trees with arbitrary number of children.

TreeElement nodes can have an arbitrary number of child nodes(held in in a vector in the order in which they were added). The visualization of trees assumes that the children are drawn in order from left to right.

Tree Elements have labels (string) that are displayed on the visualization. Elements take an generic object E as a user defined parameter, which can be any native type or object.

Elements contain a visualizer (ElementVisualizer) object for setting visual attributes (color, shape, opacity, size), necessary for displaying them in a web browser.

Elements also have a LinkVisualizer object that is used when they are linked to another element, appropriate for setting link attributes, between parent and child nodes.

Parameters
EThe generic parameter object that is part of this element, representing application specific data.
See also
Example tutorial at https://bridgesuncc.github.io/tutorials/Tree.html
Author
Kalpathi Subramanian
Date
6/22/16, 5/17/17, 7/14/19

Public Member Functions

 TreeElement ()
 
 TreeElement (E e)
 
 TreeElement (String label, E e)
 
String getDataStructType ()
 
void addChild (TreeElement< E > child)
 
int getNumberOfChildren ()
 
void setChild (int index, TreeElement< E > child)
 
TreeElement< E > getChild (int index)
 
String getDataStructureRepresentation ()
 
- Public Member Functions inherited from bridges.base.Element< E >
 Element ()
 Element constructor. More...
 
 Element (E val)
 the constructor of Element More...
 
 Element (String label, E val)
 Constructor of Element. More...
 
 Element (Element< E > original)
 performing deep copy of an element when needed More...
 
String getIdentifier ()
 
void setSize (double sz)
 
void setColor (Color col)
 
Color getColor ()
 
void setOpacity (float opacity)
 
double getOpacity ()
 
void setShape (String aShape)
 
ElementVisualizer getVisualizer ()
 
void setVisualizer (ElementVisualizer visualizer)
 
LinkVisualizer getLinkVisualizer (Element< E > el)
 Returns the Element's link visualizer object. More...
 
String getClassName ()
 
int compareTo (Element< E > e1)
 
boolean equals (Element< E > e1)
 
String getElementRepresentation ()
 
String getLinkRepresentation (LinkVisualizer lv, String src, String dest)
 
String getLabel ()
 
void setLabel (String label)
 
getValue ()
 
void setValue (E value)
 
double getSize ()
 
void setColor (String col)
 Change the element color. More...
 
String getShape ()
 
void setLocation (double locX, double locY)
 Set the location attributes of an element. More...
 
double getLocationX ()
 
double getLocationY ()
 
String toString ()
 

Additional Inherited Members

- Protected Member Functions inherited from bridges.base.Element< E >
void setLinkVisualizer (Element< E > el)
 Sets the link from this element to a new incoming element. More...
 
void removeLinkVisualizer (Element< E > el)
 Removes the link from this element to a new incoming element. More...
 
void validateVal (E value)
 
- Protected Attributes inherited from bridges.base.DataStruct
String QUOTE = "\""
 
- Package Attributes inherited from bridges.base.DataStruct
String COMMA = ","
 
String COLON = ":"
 
String OPEN_CURLY = "{"
 
String CLOSE_CURLY = "}"
 
String OPEN_PAREN = "("
 
String CLOSE_PAREN = ")"
 
String OPEN_BOX = "["
 
String CLOSE_BOX = "]"
 
- Static Package Attributes inherited from bridges.base.Element< E >
static Integer ids = 0
 

Constructor & Destructor Documentation

◆ TreeElement() [1/3]

Constructs an empty TreeElement with first two children set to null.

◆ TreeElement() [2/3]

Constructs a TreeElement holding an object "e" with first two children set to null.

Parameters
ethe generic object that TreeElement will hold

◆ TreeElement() [3/3]

bridges.base.TreeElement< E >.TreeElement ( String  label,
e 
)

Constructs a TreeElement with label set to "label", holding an object "e".

Parameters
labelthe label of TreeElement that shows up on the Bridges visualization
ethe generic object that TreeElement will hold

Member Function Documentation

◆ addChild()

void bridges.base.TreeElement< E >.addChild ( TreeElement< E >  child)

Adds a child to the node

◆ getChild()

TreeElement<E> bridges.base.TreeElement< E >.getChild ( int  index)

gets a child at a particular index

Parameters
indexinto the list of children
Returns
child to be returned

◆ getDataStructType()

String bridges.base.TreeElement< E >.getDataStructType ( )

This method gets the data structure type

Returns
The date structure type as a string

Reimplemented from bridges.base.Element< E >.

Reimplemented in bridges.base.KdTreeElement< K, E >, bridges.base.BSTElement< K, E >, bridges.base.BinTreeElement< E >, and bridges.base.AVLTreeElement< K, E >.

◆ getDataStructureRepresentation()

String bridges.base.TreeElement< E >.getDataStructureRepresentation ( )

Get hierarchical JSON of the tree representation

Returns
the JSON string

Reimplemented from bridges.base.Element< E >.

◆ getNumberOfChildren()

int bridges.base.TreeElement< E >.getNumberOfChildren ( )

Returns the number of children at this node

Returns
number of children

◆ setChild()

void bridges.base.TreeElement< E >.setChild ( int  index,
TreeElement< E >  child 
)

adds a child to the node - will be added at the next open position

Parameters
[in]indexwhich child to set
[in]childchild to be added

The documentation for this class was generated from the following file: