Bridges-Java-2.2  2.2.0
Bridges(JavaAPI)
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
bridges.base.ADTVisualizer< K, E > Class Template Reference

Public Member Functions

 ADTVisualizer ()
 
void setTitle (String titl)
 
void setDescription (String descr)
 
 ADTVisualizer (ArrayElement< E >[] elementArray)
 
 ADTVisualizer (Object type)
 
void validateType (Object type)
 
String getVisualizerType ()
 
void setVisualizerType (String visualizerType)
 
String getGraphAdjList_Representation (GraphAdjList< K, E > graph)
 
String getGraphAdjMatrix_Representation (GraphAdjMatrix< K, E > graph)
 
String getSLRepresentation (SLelement< E > first_element)
 
String getDLRepresentation (DLelement< E > first_element)
 
String getArrayRepresentation (Element< E >[] el_array, int size)
 
String getTreeRepresentation (TreeElement< E > root)
 
String generateJSON_Array (Element< E >[] el_array, int size)
 
String generateJSON_SLL (LinkedList< SLelement< E >> nodes, LinkedList< SLelement< E >> links)
 
String generateJSON_DLL (LinkedList< DLelement< E >> nodes, LinkedList< DLelement< E >> links)
 
String generateJSON_Graph (LinkedList< Element< E >> nodes, LinkedList< Element< E >> links_src, LinkedList< Element< E >> links_dest)
 
boolean visualizeJSON ()
 
void setVisualizeJSON (boolean flag)
 
String build_JSON (StringBuilder nodes_JSON, StringBuilder links_JSON)
 
String build_JSON (String tree_json)
 

Static Public Member Functions

static StringBuilder trimComma (StringBuilder in)
 

Public Attributes

String visualizerType
 
final Map< String, String > adt_names
 
Element< E >[] elementArray
 

Protected Attributes

int arrayIndex
 
boolean json_flag = false
 

Detailed Description

The Bridges object uses this class to keep track of the Visualization representation prior to passing the information to the Bridges Server.

An end user will generally not need to interact directly with this class.

Constructor & Destructor Documentation

constructor using the superclass Object when using this constructor the default ADT structure is graph

Exceptions
Exception
bridges.base.ADTVisualizer< K, E >.ADTVisualizer ( ArrayElement< E >[]  elementArray)

Constructor allow visulizations of an array.

Parameters
adtArraythe array of elements to visualize
bridges.base.ADTVisualizer< K, E >.ADTVisualizer ( Object  type)

Any other object type sent to the ADTVisualizer will throw an exception example sending a String will throw an error

Parameters
typean object
Exceptions
Exceptionto indicate that an invalid object was sent to the ADTVisualizer

Member Function Documentation

String bridges.base.ADTVisualizer< K, E >.build_JSON ( StringBuilder  nodes_JSON,
StringBuilder  links_JSON 
)

This method builds the JSON string

Parameters
nodes_JSONthe string builder object of existing nodes
links_JSONthe string builder object of existing links between the nodes
Returns
ADT's JSON
String bridges.base.ADTVisualizer< K, E >.build_JSON ( String  tree_json)
String bridges.base.ADTVisualizer< K, E >.generateJSON_Array ( Element< E >[]  el_array,
int  size 
)

Generating the JSON string for an array of elements

Parameters
elementarray (Element<E>[])
size(size of array)
Returns
JSON string
String bridges.base.ADTVisualizer< K, E >.generateJSON_DLL ( LinkedList< DLelement< E >>  nodes,
LinkedList< DLelement< E >>  links 
)

This method creates the JSON for a doubly linked list

Parameters
nodes- this is the Linked list of DLelements
links- this is the list containing the links
Returns
returns the JSON string for the current ADT
String bridges.base.ADTVisualizer< K, E >.generateJSON_Graph ( LinkedList< Element< E >>  nodes,
LinkedList< Element< E >>  links_src,
LinkedList< Element< E >>  links_dest 
)

This method builds the JSON for the Binary Tree

Parameters
nodes- list of the tree nodes
links- list of the tree links
Returns
complete JSON string for the current ADT This method builds the JSON for the Graph ADT
Parameters
nodes- list of the tree nodes
links- list of the tree links
Returns
complete JSON string for the current ADT
String bridges.base.ADTVisualizer< K, E >.generateJSON_SLL ( LinkedList< SLelement< E >>  nodes,
LinkedList< SLelement< E >>  links 
)

Generating the JSON string given a set of nodes and links for the singly linked list

Parameters
nodes
links
datastructure type
Returns
string
String bridges.base.ADTVisualizer< K, E >.getArrayRepresentation ( Element< E >[]  el_array,
int  size 
)
String bridges.base.ADTVisualizer< K, E >.getDLRepresentation ( DLelement< E >  first_element)

This method returns the JSON string of a doubly linked list

Parameters
e
Returns
String bridges.base.ADTVisualizer< K, E >.getGraphAdjList_Representation ( GraphAdjList< K, E >  graph)

This method creates a JSON representation of the graph - Adjacency List Representation.

Parameters
Hashmap<String,SLelement<E>represents the list of vertices each of which is a singly linked list.
Returns
- this method returns the JSON string
String bridges.base.ADTVisualizer< K, E >.getGraphAdjMatrix_Representation ( GraphAdjMatrix< K, E >  graph)

This method creates a JSON representation of the graph - Adjacency Matrix

Parameters
e- is the starting element(node)
Returns
- this method returns the JSON
String bridges.base.ADTVisualizer< K, E >.getSLRepresentation ( SLelement< E >  first_element)
String bridges.base.ADTVisualizer< K, E >.getTreeRepresentation ( TreeElement< E >  root)

This method returns the JSON string representation of the tree made by using preorder traversal

Parameters
e
Returns
String bridges.base.ADTVisualizer< K, E >.getVisualizerType ( )

This method returns the visualizer type as a string

Returns
one the of the strings represented in ADTVisualizer.ADT_TYPE that represents the type of Bridges Visualization (e.g. "graph", "llist", etc.)
void bridges.base.ADTVisualizer< K, E >.setDescription ( String  descr)
Parameters
descrdescription to annotate the visualization;
void bridges.base.ADTVisualizer< K, E >.setTitle ( String  titl)
Parameters
titletitle used in the visualization;
void bridges.base.ADTVisualizer< K, E >.setVisualizeJSON ( boolean  flag)
Parameters
setthe flag to output the JSON
void bridges.base.ADTVisualizer< K, E >.setVisualizerType ( String  visualizerType)

This method sets the visualizer type

Parameters
visualizerTypea string in ADTVisualizer.ADT_TYPE representing the type of Bridges Visualization (e.g. "graph", "llist", etc.)
Exceptions
Exception
static StringBuilder bridges.base.ADTVisualizer< K, E >.trimComma ( StringBuilder  in)
static
void bridges.base.ADTVisualizer< K, E >.validateType ( Object  type)

Validates whether the "type" is recognized by ADTVisualizer.

Parameters
typean object to check whether ADTVisualizer will accept as a valid type
boolean bridges.base.ADTVisualizer< K, E >.visualizeJSON ( )
Parameters
checkif the flag to output the JSON is set

Member Data Documentation

final Map<String, String> bridges.base.ADTVisualizer< K, E >.adt_names
Initial value:
=
new HashMap <String, String>(){
private static final long serialVersionUID = 1L;
{
put("Array", "Array");
put("SinglyLinkedList", "SinglyLinkedList");
put("DoublyLinkedList", "DoublyLinkedList");
put("GraphAdjacencyList","GraphAdjacencyList");
put("GraphAdjacencyMatrix","GraphAdjacencyMatrix");
put("ArrayStack","Array");
put("ArrayQueue","Array");
put("LinkedListStack","SinglyLinkedList");
put("LinkedListQueue","SinglyLinkedList");
put("Tree","Tree");
put("BinaryTree","BinaryTree");
put("BinarySearchTree","BinarySearchTree");
put("AVLTree","AVLTree");
}
}
int bridges.base.ADTVisualizer< K, E >.arrayIndex
protected
Element<E> [] bridges.base.ADTVisualizer< K, E >.elementArray
boolean bridges.base.ADTVisualizer< K, E >.json_flag = false
protected
String bridges.base.ADTVisualizer< K, E >.visualizerType

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