cz.cuni.amis.pogamut.episodic.visualizer
Class VisualizationRenderer

Package class diagram package VisualizationRenderer
java.lang.Object
  extended by cz.cuni.amis.pogamut.episodic.visualizer.VisualizationRenderer

public class VisualizationRenderer
extends Object

VisualizationRenderer is responsible for actual visualization itself. It draws the visualization window and controls it. It does not know almost anything about the nodes it is visualizing. All it does is provide a group of functions for adding and manipulating with graph representations of memory. All its methods are called from VisualizationCreator class only.

The only knowlegde about the memory it has are: the index of schema bag visualization graph, so that custom detail about selected counts can be displayed upon request; some information about node and edges type so that different edges and labels can be filtered out and so that tree layout of the graphs is generated correctly without the object nodes connecting several trees together.

Author:
Michal Cermak (based on Jung examples by Tom Nelson)

Nested Class Summary
 class VisualizationRenderer.AdditionalInfo
          This structure holds an additional info about all vertices in all the graphs.
 class VisualizationRenderer.GraphChooser
          Listener attached to the combobox choosing the graph that should be displayed in a visualization window.
 class VisualizationRenderer.HideEdge
          Class holding information about an edge that is not part of the tree structures.
 class VisualizationRenderer.ObjectVertex
          Class holding information about vertex representing an object node.
protected  class VisualizationRenderer.PopupGraphMousePlugin
          Listener object that is responsible for making popup window visible upon right-click.
 
Field Summary
protected  int graph_index
          Index of a graph that is currently displayed in the visualizer window.
protected  Map<Integer,String> graph_names
          Names of graphs that are used to populate the graph chooser combo box in a visualization window.
protected  Map<Integer,edu.uci.ics.jung.graph.Graph<Integer,Integer>> graphs
          Actual graph structures holding the visualized representation of all structures in memory.
protected  Map<Integer,Integer> lastNonObjectNode
           
protected  Integer lastSchemaEpisodeNode
           
protected  Map<Integer,edu.uci.ics.jung.algorithms.layout.Layout<Integer,Integer>> layouts
          Layouts for all the graphs in a visualizer structure.
 
Constructor Summary
VisualizationRenderer()
          Construtor of a renderer.
 
Method Summary
 boolean addEdge(int index, int id, EdgeType type, int v1, int v2, String label, Color c)
          Adds a new edge into a specified graph.
 boolean addEdge(int index, int id, int v1, int v2, String label, Color c)
          Adds a new edge into a specified graph.
 boolean addGraph(int index, String label, Dimension dim)
          Adds a new graph to the list of graphs that can be displayed by the visualizer and adds a new item to the combobox.
 void addVertex(int index, int id, double x, double y, String label, Color c)
          Adds a new vertex to the specified graph while setting some other info and positioning the vertex on a given position.
 void addVertex(int index, int id, double x, double y, String label, Color c, VertexType type)
          Adds a new vertex to the specified graph while setting some other info and positioning the vertex on a given position.
 void addVertex(int index, int id, String label)
          Adds a new vertex to the specified graph.
 void addVertex(int index, int id, String label, Color c, VertexType type)
          Adds a new vertex to the specified graph while setting some other info.
 boolean clearGraph(int index)
           
 void createTreeLayout(int index)
          Creates tree layout of a given graph using algorithm for finding a minimum spanning tree.
 void positionObjectNodes(int y)
          Updates the positions of object nodes on the visible display so they are always displayed on the screen as the user scrolls across the graph.
 void removeEdge(int index, int id)
          Deletes a given edge from specified graph.
 boolean removeGraph(int index)
          Deletes a specified graph from list of possibly visualized graphs.
 void setEdgeTooltip(int id, String tip)
          Sets a text that should be displayed when mouse is hovering over an edge.
 void setSchemaMessageCommand(ISchemaMessageCommand command, int schemaGraph)
          Sets the schemaGraph index and SchemaMessageCommand class so that count info can be displayed correctly.
 void setVertexDetail(int id, String tip)
          Sets a text that should be displayed when additional info is displayed after right clicking on the specified vertex.
 void setVertexLocation(int graph, int id, double x, double y)
          Position an existing vertex to a specified location.
 void setVertexSaturation(int id, double saturation)
          Set the saturation of a vertex based on its score.
 void setVertexTooltip(int id, String tip)
          Sets a text that should be displayed when mouse is hovering over a vertex.
 void updateTime(String time)
          Refreshes the time information displayed on visualized graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

graphs

protected Map<Integer,edu.uci.ics.jung.graph.Graph<Integer,Integer>> graphs
Actual graph structures holding the visualized representation of all structures in memory. Each time different graph is displayed, other graphs are still part of visualizer, are just not displayed for a while.


layouts

protected Map<Integer,edu.uci.ics.jung.algorithms.layout.Layout<Integer,Integer>> layouts
Layouts for all the graphs in a visualizer structure. Each time a different graph is visualized, the relevant layout has to be used so that the visualization is user-friendly and readable.


graph_names

protected Map<Integer,String> graph_names
Names of graphs that are used to populate the graph chooser combo box in a visualization window.


lastSchemaEpisodeNode

protected Integer lastSchemaEpisodeNode

lastNonObjectNode

protected Map<Integer,Integer> lastNonObjectNode

graph_index

protected int graph_index
Index of a graph that is currently displayed in the visualizer window.

Constructor Detail

VisualizationRenderer

public VisualizationRenderer()
Construtor of a renderer. All window objects are created here.

Method Detail

setSchemaMessageCommand

public void setSchemaMessageCommand(ISchemaMessageCommand command,
                                    int schemaGraph)
Sets the schemaGraph index and SchemaMessageCommand class so that count info can be displayed correctly.

Parameters:
command - Reference to a SchemaMessageCommand class providing text to be displayed for selected nodes when popup window with actual schema count is invoked.
schemaGraph - Index of a graph visualizing schema bag, so the renderer will know when to use schemaMessageCommand to retrieve the info text and when to use inner AdditionalInfo class.

updateTime

public void updateTime(String time)
Refreshes the time information displayed on visualized graph.

Parameters:
time - String with time information to be displayed in a visualizer window.

positionObjectNodes

public void positionObjectNodes(int y)
Updates the positions of object nodes on the visible display so they are always displayed on the screen as the user scrolls across the graph.

Parameters:
time - String with time information to be displayed in a visualizer window.

addVertex

public void addVertex(int index,
                      int id,
                      String label)
Adds a new vertex to the specified graph.

Parameters:
index - Index of a graph the vertex should be added to.
id - Unique ID of a new vertex.
label - String that will be used as vertex label.

addVertex

public void addVertex(int index,
                      int id,
                      String label,
                      Color c,
                      VertexType type)
Adds a new vertex to the specified graph while setting some other info.

Parameters:
index - Index of a graph the vertex should be added to.
id - Unique ID of a new vertex.
label - String that will be used as vertex label.
color - Color of a new vertex.
type - VertexType of a new vertex.

addVertex

public void addVertex(int index,
                      int id,
                      double x,
                      double y,
                      String label,
                      Color c)
Adds a new vertex to the specified graph while setting some other info and positioning the vertex on a given position.

The position can change if createTreeLayout method is invoked for the given graph.

Parameters:
index - Index of a graph the vertex should be added to.
id - Unique ID of a new vertex.
x - Horizontal coordinate of a new vertex.
y - Vertical coordinate of a new vertex.
label - String that will be used as vertex label.
color - Color of a new vertex.

addVertex

public void addVertex(int index,
                      int id,
                      double x,
                      double y,
                      String label,
                      Color c,
                      VertexType type)
Adds a new vertex to the specified graph while setting some other info and positioning the vertex on a given position.

The position can change if createTreeLayout method is invoked for the given graph.

Parameters:
index - Index of a graph the vertex should be added to.
id - Unique ID of a new vertex.
x - Horizontal coordinate of a new vertex.
y - Vertical coordinate of a new vertex.
label - String that will be used as vertex label.
color - Color of a new vertex.
type - VertexType of a new vertex.

setVertexLocation

public void setVertexLocation(int graph,
                              int id,
                              double x,
                              double y)
Position an existing vertex to a specified location.

Parameters:
graph - Index of a graph the vertex belongs to.
id - ID of a vertex that is supposed to be moved.
x - New X coordination.
y - New Y coordination.

addEdge

public boolean addEdge(int index,
                       int id,
                       int v1,
                       int v2,
                       String label,
                       Color c)
Adds a new edge into a specified graph. Edge will be connecting specified vertices. No edge is added if there already exists an edge between specified the vertices.

Parameters:
index - Index of a graph the edge should be added to.
id - Unique ID of a new edge.
v1 - ID of a vertex on one end of this edge.
v2 - ID of a vertex on the other end of this edge.
label - Label of a new edge.
c - Color of the new edge.
Returns:
Returns true if new edge was added to the graph. Returns false if an edge already existed between the specified vertices.

addEdge

public boolean addEdge(int index,
                       int id,
                       EdgeType type,
                       int v1,
                       int v2,
                       String label,
                       Color c)
Adds a new edge into a specified graph. Edge will be connecting specified vertices. No edge is added if there already exists an edge between specified the vertices.

Parameters:
index - Index of a graph the edge should be added to.
id - Unique ID of a new edge.
type - EdgeType of a new edge.
v1 - ID of a vertex on one end of this edge.
v2 - ID of a vertex on the other end of this edge.
label - Label of a new edge.
c - Color of the new edge.
Returns:
Returns true if new edge was added to the graph. Returns false if an edge already existed between the specified vertices.

removeEdge

public void removeEdge(int index,
                       int id)
Deletes a given edge from specified graph.

Parameters:
index - Index of a graph containing the edge that should be removed.
id - ID of an edge that should be removed.

setVertexDetail

public void setVertexDetail(int id,
                            String tip)
Sets a text that should be displayed when additional info is displayed after right clicking on the specified vertex.

Parameters:
id - ID of a vertex with the new detailed info.
tip - Text containing detialed info of a vertex.

setVertexSaturation

public void setVertexSaturation(int id,
                                double saturation)
Set the saturation of a vertex based on its score. This way it should be easy to differentiate between vertices with high and low score values.

Parameters:
id - ID of a vertex with newly specified saturation.
saturation - Saturation value. One means is normal color. Zero means gray color.

setVertexTooltip

public void setVertexTooltip(int id,
                             String tip)
Sets a text that should be displayed when mouse is hovering over a vertex.

Parameters:
id - ID of a vertex with the new tooltip.
tip - Text containing a tooltip for a vertex.

setEdgeTooltip

public void setEdgeTooltip(int id,
                           String tip)
Sets a text that should be displayed when mouse is hovering over an edge.

Parameters:
id - ID of a edge with the new tooltip.
tip - Text containing a tooltip for an edge.

addGraph

public boolean addGraph(int index,
                        String label,
                        Dimension dim)
Adds a new graph to the list of graphs that can be displayed by the visualizer and adds a new item to the combobox. This graph will be empty but it will be possible to add new vertices and edges to it from now on.

Parameters:
index - Index of a new graph. If the index is not unique the new graph will not be added.
label - Name of the new graph to be displayed in a combobox.
dim - Dimension of a view window.
Returns:
Returns true if new graph was successfully added, false otherwise.

removeGraph

public boolean removeGraph(int index)
Deletes a specified graph from list of possibly visualized graphs. This method is called during memory reorganization phase, so that chronobags can be heavily altered are displayed from scratch.

Parameters:
index - Index of a graph that is to be removed.
Returns:
Returns true if graph was deleted. Returns false if graph with no such index existed.

clearGraph

public boolean clearGraph(int index)

createTreeLayout

public void createTreeLayout(int index)
Creates tree layout of a given graph using algorithm for finding a minimum spanning tree.

For the algorithm to work, graph has to be a forest, so sequence nodes and object vertices are removed from graph first and returned back after the new layout is created.

Parameters:
index - Index of a graph that should have the tree layout.


Copyright © 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.