Class ModelVisualizer
-
- All Implemented Interfaces:
public class ModelVisualizerUnified visualizer for both Network and LayeredNetwork models using the JUNG library.
This visualizer accepts either a Network or LayeredNetwork object and provides appropriate visual styling for each model type:
- White shapes (except Sink which is black)
- 9 node types: Source, Sink, Queue, Delay, Fork, Join, ClassSwitch, Cache, Router
- Sugiyama-style left-to-right hierarchical layout
- Solid black edges
- Red shapes (yellow when selected)
- 4 node types: Host (triangle), Task (parallelogram), Entry (rectangle), Activity (circle)
- 4-level hierarchical layout (Host→Task→Entry→Activity)
- 6 edge styles: solid (hierarchy), dashed (sync), dot-dashed (async), dotted (forwarding)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumModelVisualizer.NodeTypeUnified node type enumeration covering both Network and LayeredNetwork elements.
public enumModelVisualizer.EdgeTypeUnified edge type enumeration covering both Network and LayeredNetwork relationships.
public classModelVisualizer.ModelVertexUnified wrapper class for graph vertices representing model elements.
public classModelVisualizer.ModelEdgeUnified wrapper class for graph edges representing relationships.
-
Field Summary
Fields Modifier and Type Field Description public Graph<ModelVisualizer.ModelVertex, ModelVisualizer.ModelEdge>graph
-
Constructor Summary
Constructors Constructor Description ModelVisualizer(Network model)Creates a visualizer for a Network model. ModelVisualizer(LayeredNetwork model)Creates a visualizer for a LayeredNetwork model.
-
Method Summary
Modifier and Type Method Description Graph<ModelVisualizer.ModelVertex, ModelVisualizer.ModelEdge>getGraph()Returns the underlying JUNG graph. Graph<ModelVisualizer.ModelVertex, ModelVisualizer.ModelEdge>buildGraph()Builds a JUNG graph from the underlying model. voidshow()Displays the graph in a JFrame window with default settings. voidshow(String title)Displays the graph with a custom title. voidshow(String title, int width, int height)Displays the graph with custom title and dimensions. voidshow(String title, int width, int height, boolean showToolbars)Displays the graph with custom title, dimensions, and toolbar visibility. voidshowWithLayout(Layout<ModelVisualizer.ModelVertex, ModelVisualizer.ModelEdge> layout, String title, int width, int height, boolean showToolbars)Displays the graph using the specified layout with optional toolbars. Layout<ModelVisualizer.ModelVertex, ModelVisualizer.ModelEdge>createHierarchicalLayout(int width, int height)Creates a hierarchical layout appropriate for the model type. Layout<ModelVisualizer.ModelVertex, ModelVisualizer.ModelEdge>createHierarchicalLayout(int width, int height, double vSpaceFactor)Creates a hierarchical layout with vertical spacing factor. Function<ModelVisualizer.ModelVertex, Paint>getVertexPaintTransformer(Array<ModelVisualizer.ModelVertex> selectedVertex, Array<int> colorTheme)Returns a transformer for vertex fill colors based on color theme. Function<ModelVisualizer.ModelVertex, Paint>getVertexOutlineTransformer()Returns a transformer for vertex outline colors. Function<ModelVisualizer.ModelVertex, Shape>getVertexShapeTransformer()Returns a transformer for vertex shapes based on node type. Function<ModelVisualizer.ModelEdge, Paint>getEdgePaintTransformer()Returns a transformer for edge colors. Function<ModelVisualizer.ModelEdge, Stroke>getEdgeStrokeTransformer()Returns a transformer for edge strokes based on edge type. static voidsetBackgroundImage(VisualizationViewer<out Object, out Object> vv, BufferedImage img)Sets a background image for the visualization viewer. static voidclearBackgroundImage(VisualizationViewer<out Object, out Object> vv)Clears the background image from the visualization viewer. -
-
Constructor Detail
-
ModelVisualizer
ModelVisualizer(Network model)
Creates a visualizer for a Network model.- Parameters:
model- the Network to visualize
-
ModelVisualizer
ModelVisualizer(LayeredNetwork model)
Creates a visualizer for a LayeredNetwork model.- Parameters:
model- the LayeredNetwork to visualize
-
-
Method Detail
-
getGraph
Graph<ModelVisualizer.ModelVertex, ModelVisualizer.ModelEdge> getGraph()
Returns the underlying JUNG graph.
-
buildGraph
Graph<ModelVisualizer.ModelVertex, ModelVisualizer.ModelEdge> buildGraph()
Builds a JUNG graph from the underlying model.
- Returns:
the constructed JUNG graph
-
show
void show()
Displays the graph in a JFrame window with default settings.
-
show
void show(String title)
Displays the graph with a custom title.
- Parameters:
title- the window title
-
show
void show(String title, int width, int height)
Displays the graph with custom title and dimensions.
- Parameters:
title- the window titlewidth- the window widthheight- the window height
-
show
void show(String title, int width, int height, boolean showToolbars)
Displays the graph with custom title, dimensions, and toolbar visibility.
- Parameters:
title- the window titlewidth- the window widthheight- the window heightshowToolbars- if true, show toolbars; if false, show only the graph image
-
showWithLayout
void showWithLayout(Layout<ModelVisualizer.ModelVertex, ModelVisualizer.ModelEdge> layout, String title, int width, int height, boolean showToolbars)
Displays the graph using the specified layout with optional toolbars.
-
createHierarchicalLayout
Layout<ModelVisualizer.ModelVertex, ModelVisualizer.ModelEdge> createHierarchicalLayout(int width, int height)
Creates a hierarchical layout appropriate for the model type.
-
createHierarchicalLayout
Layout<ModelVisualizer.ModelVertex, ModelVisualizer.ModelEdge> createHierarchicalLayout(int width, int height, double vSpaceFactor)
Creates a hierarchical layout with vertical spacing factor.
-
getVertexPaintTransformer
Function<ModelVisualizer.ModelVertex, Paint> getVertexPaintTransformer(Array<ModelVisualizer.ModelVertex> selectedVertex, Array<int> colorTheme)
Returns a transformer for vertex fill colors based on color theme. Theme 0=Color, 1=Multicolor, 2=Greyscale, 3=Black/White
-
getVertexOutlineTransformer
Function<ModelVisualizer.ModelVertex, Paint> getVertexOutlineTransformer()
Returns a transformer for vertex outline colors.
-
getVertexShapeTransformer
Function<ModelVisualizer.ModelVertex, Shape> getVertexShapeTransformer()
Returns a transformer for vertex shapes based on node type.
-
getEdgePaintTransformer
Function<ModelVisualizer.ModelEdge, Paint> getEdgePaintTransformer()
Returns a transformer for edge colors.
-
getEdgeStrokeTransformer
Function<ModelVisualizer.ModelEdge, Stroke> getEdgeStrokeTransformer()
Returns a transformer for edge strokes based on edge type.
-
setBackgroundImage
static void setBackgroundImage(VisualizationViewer<out Object, out Object> vv, BufferedImage img)
Sets a background image for the visualization viewer.
-
clearBackgroundImage
static void clearBackgroundImage(VisualizationViewer<out Object, out Object> vv)
Clears the background image from the visualization viewer.
-
-
-
-