Class VisualGraph<G>
- java.lang.Object
-
- com.googlecode.blaisemath.graph.view.VisualGraph<G>
-
- Type Parameters:
G- graphics canvas type
public class VisualGraph<G> extends Object
Combines aGraphLayoutManagerand aDelegatingNodeLinkGraphicto manage a graph and its node locations. The graph is maintained by the manager, and the visual elements by the graphic.- Author:
- Elisha Peterson
-
-
Field Summary
Fields Modifier and Type Field Description static com.googlecode.blaisemath.style.AttributeSetDEFAULT_EDGE_STYLEDefault graph edge stylestatic com.googlecode.blaisemath.style.AttributeSetDEFAULT_NODE_STYLEDefault graph node styleprotected PropertyChangeListenerlayoutListenerListens for changes from the layout
-
Constructor Summary
Constructors Constructor Description VisualGraph(com.google.common.graph.Graph graph)Construct adapter with the specified graph.VisualGraph(com.googlecode.blaisemath.graph.layout.GraphLayoutManager manager, @Nullable Supplier<com.googlecode.blaisemath.graphics.impl.DelegatingNodeLinkGraphic<Object,com.google.common.graph.EndpointPair<Object>,G>> graphicSupplier)Construct adapter with the specified manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.googlecode.blaisemath.coordinate.CoordinateManagergetCoordinateManager()Return the coordinate manager responsible for node locations.com.googlecode.blaisemath.graphics.Renderer<Shape,G>getEdgeRenderer()Return edge renderer.com.googlecode.blaisemath.style.ObjectStyler<com.google.common.graph.EndpointPair<Object>>getEdgeStyler()Return edge styler.com.google.common.graph.GraphgetGraph()Return the graph instance being visualized.com.googlecode.blaisemath.graphics.Renderer<com.googlecode.blaisemath.primitive.AnchoredText,G>getLabelRenderer()Return label renderer.com.googlecode.blaisemath.graph.layout.GraphLayoutManagergetLayoutManager()Return the layout manager responsible for updating positions.com.googlecode.blaisemath.graphics.Renderer<Point2D,G>getNodeRenderer()Return node renderer.com.googlecode.blaisemath.style.ObjectStyler<Object>getNodeStyler()Return node styler.com.googlecode.blaisemath.graphics.impl.DelegatingNodeLinkGraphicgetViewGraph()Return the graphic used for display.protected voidinitViewGraph()Initializes view graph for the graph in the graph manager.voidsetEdgeRenderer(com.googlecode.blaisemath.graphics.Renderer<Shape,G> renderer)Set edge renderer.voidsetEdgeStyler(com.googlecode.blaisemath.style.ObjectStyler<com.google.common.graph.EndpointPair<Object>> styler)Set edge styler.voidsetGraph(com.google.common.graph.Graph g)Set the graph instance being visualized.voidsetLabelRenderer(com.googlecode.blaisemath.graphics.Renderer<com.googlecode.blaisemath.primitive.AnchoredText,G> renderer)Set label renderer.voidsetLayoutManager(com.googlecode.blaisemath.graph.layout.GraphLayoutManager manager)Change the layout manager responsible for updating positions.voidsetNodeRenderer(com.googlecode.blaisemath.graphics.Renderer<Point2D,G> renderer)Set node renderer.voidsetNodeStyler(com.googlecode.blaisemath.style.ObjectStyler<Object> styler)Set node styler.
-
-
-
Field Detail
-
DEFAULT_NODE_STYLE
public static final com.googlecode.blaisemath.style.AttributeSet DEFAULT_NODE_STYLE
Default graph node style
-
DEFAULT_EDGE_STYLE
public static final com.googlecode.blaisemath.style.AttributeSet DEFAULT_EDGE_STYLE
Default graph edge style
-
layoutListener
protected final PropertyChangeListener layoutListener
Listens for changes from the layout
-
-
Constructor Detail
-
VisualGraph
public VisualGraph(com.google.common.graph.Graph graph)
Construct adapter with the specified graph.- Parameters:
graph- the graph to display
-
VisualGraph
public VisualGraph(com.googlecode.blaisemath.graph.layout.GraphLayoutManager manager, @Nullable Supplier<com.googlecode.blaisemath.graphics.impl.DelegatingNodeLinkGraphic<Object,com.google.common.graph.EndpointPair<Object>,G>> graphicSupplier)Construct adapter with the specified manager.- Parameters:
manager- a GraphLayoutManager with the graph to displaygraphicSupplier- optional, provides a way to override default creation of the view graph
-
-
Method Detail
-
initViewGraph
protected final void initViewGraph()
Initializes view graph for the graph in the graph manager. This includes setting up any styling appropriate for the graph, as well as updating the nodes and edges in the view graph.
-
getViewGraph
public com.googlecode.blaisemath.graphics.impl.DelegatingNodeLinkGraphic getViewGraph()
Return the graphic used for display.- Returns:
- the graphic
-
getLayoutManager
public com.googlecode.blaisemath.graph.layout.GraphLayoutManager getLayoutManager()
Return the layout manager responsible for updating positions.- Returns:
- layout manager
-
setLayoutManager
public final void setLayoutManager(com.googlecode.blaisemath.graph.layout.GraphLayoutManager manager)
Change the layout manager responsible for updating positions.- Parameters:
manager- layout manager
-
getCoordinateManager
public com.googlecode.blaisemath.coordinate.CoordinateManager getCoordinateManager()
Return the coordinate manager responsible for node locations.- Returns:
- coordinate manager
-
getGraph
public com.google.common.graph.Graph getGraph()
Return the graph instance being visualized.- Returns:
- the graph
-
setGraph
public void setGraph(com.google.common.graph.Graph g)
Set the graph instance being visualized.- Parameters:
g- the graph
-
getNodeStyler
public com.googlecode.blaisemath.style.ObjectStyler<Object> getNodeStyler()
Return node styler.- Returns:
- styler
-
setNodeStyler
public void setNodeStyler(com.googlecode.blaisemath.style.ObjectStyler<Object> styler)
Set node styler.- Parameters:
styler- object styler for nodes
-
getNodeRenderer
public com.googlecode.blaisemath.graphics.Renderer<Point2D,G> getNodeRenderer()
Return node renderer.- Returns:
- renderer
-
setNodeRenderer
public void setNodeRenderer(com.googlecode.blaisemath.graphics.Renderer<Point2D,G> renderer)
Set node renderer.- Parameters:
renderer- new renderer
-
getLabelRenderer
public com.googlecode.blaisemath.graphics.Renderer<com.googlecode.blaisemath.primitive.AnchoredText,G> getLabelRenderer()
Return label renderer.- Returns:
- renderer
-
setLabelRenderer
public void setLabelRenderer(com.googlecode.blaisemath.graphics.Renderer<com.googlecode.blaisemath.primitive.AnchoredText,G> renderer)
Set label renderer.- Parameters:
renderer- new renderer
-
getEdgeStyler
public com.googlecode.blaisemath.style.ObjectStyler<com.google.common.graph.EndpointPair<Object>> getEdgeStyler()
Return edge styler.- Returns:
- edge styler
-
setEdgeStyler
public void setEdgeStyler(com.googlecode.blaisemath.style.ObjectStyler<com.google.common.graph.EndpointPair<Object>> styler)
Set edge styler.- Parameters:
styler- edge styler
-
getEdgeRenderer
public com.googlecode.blaisemath.graphics.Renderer<Shape,G> getEdgeRenderer()
Return edge renderer.- Returns:
- renderer
-
-