org.grinvin.list

Class GraphViewPanel

Implemented Interfaces:
ComponentListener, EmbeddingListener, EventListener, GraphListener, Observer

public class GraphViewPanel
extends JPanel
implements ComponentListener, EmbeddingListener, GraphListener, Observer

Provides a view of the Graph. TODO: clean this up, refactor common code with GraphPanel

Field Summary

protected Color
backgroundColor
Panel background color.
protected GraphContext
context
protected EmbeddingView
embedding
protected GraphView
graph
protected Guides
guides
Current Guides object for this panel.
protected Renderer
renderer
protected double
scale

Constructor Summary

GraphViewPanel(EmbeddingView embedding, Renderer renderer, GraphContext context, double scale)
Create a new graph panel with given peer.

Method Summary

void
componentHidden(ComponentEvent e)
void
componentMoved(ComponentEvent e)
void
componentResized(ComponentEvent e)
Recenters the drawing when the component changes size.
void
componentShown(ComponentEvent e)
void
dimensionChanged(int oldDimension)
void
edgeAdded(Edge edge)
void
edgeChanged(Edge edge)
void
edgeRemoved(Edge edge)
void
edgeRestored(Edge edge)
void
embeddingChanged()
void
graphChanged()
protected void
paintBackground(Graphics2D g2)
Paint a background overlay.
protected void
paintEdges(Graphics2D g2)
Paint all edges of the graph using the current renderer.
protected void
paintVertices(Graphics2D g2)
Paint all vertices of the graph using the current vertex renderer.
void
update(Observable o, Object arg)
void
vertexAdded(Vertex vertex)
void
vertexChanged(Vertex vertex)
void
vertexCoordinatesChanged(Vertex vertex)
void
vertexRemoved(Vertex vertex)
void
vertexRestored(Vertex vertex)
protected @Override
void paintComponent(Graphics g)
Paints the graph on the panel using the current renderer.

Field Details

backgroundColor

protected Color backgroundColor
Panel background color.

context

protected GraphContext context

embedding

protected EmbeddingView embedding

graph

protected GraphView graph

guides

protected Guides guides
Current Guides object for this panel.

renderer

protected Renderer renderer

scale

protected double scale

Constructor Details

GraphViewPanel

public GraphViewPanel(EmbeddingView embedding,
                      Renderer renderer,
                      GraphContext context,
                      double scale)
Create a new graph panel with given peer. The panel is given a preferred size large enough to display the coordinate range (-1.1,-1.1)-(1.1,1.1).
Parameters:
embedding - Embedding displayed in this panel. The peer of this embedding should be of type GraphModel.
renderer - Renderer for this panel.
context - Graph context for this panel.
scale - Number of pixels corresponding to a unit length in the embedding.

Method Details

componentHidden

public void componentHidden(ComponentEvent e)

componentMoved

public void componentMoved(ComponentEvent e)

componentResized

public void componentResized(ComponentEvent e)
Recenters the drawing when the component changes size.

componentShown

public void componentShown(ComponentEvent e)

dimensionChanged

public void dimensionChanged(int oldDimension)
Specified by:
dimensionChanged in interface EmbeddingListener

edgeAdded

public void edgeAdded(Edge edge)
Specified by:
edgeAdded in interface GraphListener

edgeChanged

public void edgeChanged(Edge edge)
Specified by:
edgeChanged in interface GraphListener

edgeRemoved

public void edgeRemoved(Edge edge)
Specified by:
edgeRemoved in interface GraphListener

edgeRestored

public void edgeRestored(Edge edge)
Specified by:
edgeRestored in interface GraphListener

embeddingChanged

public void embeddingChanged()
Specified by:
embeddingChanged in interface EmbeddingListener

graphChanged

public void graphChanged()
Specified by:
graphChanged in interface GraphListener

paintBackground

protected void paintBackground(Graphics2D g2)
Paint a background overlay. See GraphViewPanel for the order in which the various paint methods are executed.

This implementation is delegates to the current guides object.


paintEdges

protected void paintEdges(Graphics2D g2)
Paint all edges of the graph using the current renderer.

See GraphViewPanel for the order in which the various paint methods are executed.


paintVertices

protected void paintVertices(Graphics2D g2)
Paint all vertices of the graph using the current vertex renderer.

See GraphViewPanel for the order in which the various paint methods are executed.


update

public void update(Observable o,
                   Object arg)

vertexAdded

public void vertexAdded(Vertex vertex)
Specified by:
vertexAdded in interface GraphListener

vertexChanged

public void vertexChanged(Vertex vertex)
Specified by:
vertexChanged in interface GraphListener

vertexCoordinatesChanged

public void vertexCoordinatesChanged(Vertex vertex)
Specified by:
vertexCoordinatesChanged in interface EmbeddingListener

vertexRemoved

public void vertexRemoved(Vertex vertex)
Specified by:
vertexRemoved in interface GraphListener

vertexRestored

public void vertexRestored(Vertex vertex)
Specified by:
vertexRestored in interface GraphListener

void paintComponent

protected @Override void paintComponent(Graphics g)
Paints the graph on the panel using the current renderer. Paints background, edges and then vertices.