|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
beowulf.gui.DraggableContainer
beowulf.gui.JGraph
This class is a swing visualization of a beowulf.model.graph.GraphModel. It
is fairly customizable and handles drawing small and medium sized graphs at
reasonable speed. Care has been take to abstract out different parts of the
functionality and one can even respond to JGraph selection events.
Customization of the JGraph should begin with the development of a new subclass
of JNode and its appropriate factory. See JNode and JNodeFactory for more
details on how to achieve this. Any JGraph can have any JNodeFactory set in
order to manufacture JNodes.
JNodes are the GUI representation of the nodes in a Graph. The standard JNode
class simply draws a string onto the graphics context of the JGraph. The string
drawn is the result of calling .toString() on the node being represented.
Directed and undirected edges (and hence graphs) are handled fine. Self edges
and multiple edges between a pair of nodes will also be handled fine.
| Nested Class Summary |
| Nested classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
static int |
DIRECTED_GRAPH
Flag indicating the model is a directed graph. |
protected JNodeFactory |
factory
This is the factory which will produce JNodes, or GUI representations of nodes in the graph. |
static float |
HEAD
The size of the arrow that is drawn for directed edges. |
protected EventListenerList |
listenerList
This list contains references to all interested listeners. |
protected GraphModel |
model
Holds the graph model that this JGraph represents. |
protected Map |
nodeLookup
This Map will hold node->DraggableComponent translations. |
static int |
UNDIRECTED_GRAPH
Flag indicating the model is an undirected graph. |
| Fields inherited from class beowulf.gui.DraggableContainer |
currentComponent |
| Fields inherited from class javax.swing.JComponent |
accessibleContext, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
JGraph()
The basic constructor for JGraph. |
|
JGraph(GraphModel newModel)
This constructor takes in an existing GraphModel and uses it right away. |
|
JGraph(GraphModel newModel,
JNodeFactory newFactory)
This constructor takes in both an existing GraphModel and a JNodeFactory, used to create JNodes. |
|
JGraph(int graphType)
This constructor takes in a single int - one of the flags defined in this class indicating a directed or undirected graph. |
|
JGraph(int graphType,
JNodeFactory newFactory)
This constructor takes in both a graph type and a JNodeFactory used to create JNodes. |
|
JGraph(Vector nodeVector,
Vector edgeVector,
int graphType)
This constructor takes in a list of existing nodes and edges between them, as well as a graph type. |
|
JGraph(Vector nodeVector,
Vector edgeVector,
int graphType,
JNodeFactory newFactory)
This constructor takes in lists of existing nodes and edges, the graph type, and a new JNodeFactory. |
|
| Method Summary | |
void |
addGraphSelectionListener(GraphSelectionListener l)
This method adds a GraphSelectionListener as an interested listener of events to this JGraph. |
void |
edgeAdded(GraphEvent ge)
This method is called when an edge is added to a Graph. |
void |
edgeRemoved(GraphEvent ge)
This method is called when an edge is removed from a Graph. |
protected void |
fireNodeDeselected(Object source,
Object value)
This method must be called by all subclasses after a node is deselected. |
protected void |
fireNodeSelected(Object source,
Object value)
This method must be called any time a node is selected. |
JNodeFactory |
getJNodeFactory()
Returns the JNodeFactory. |
GraphModel |
getModel()
Returns the graph model. |
void |
nodeAdded(GraphEvent ge)
This method is called when a node is added to a Graph. |
void |
nodeRemoved(GraphEvent ge)
This method is called when a node is removed from a Graph. |
void |
paintComponent(Graphics g)
|
void |
removeGraphSelectionListener(GraphSelectionListener l)
This method removes the GraphSelectionListener as an interested listener of events to this JGraph. |
void |
setJNodeFactory(JNodeFactory newFactory)
Sets the JNodeFactory for this JGraph. |
void |
setModel(GraphModel newModel)
This method will replace the current model of this graph with the parameter. |
void |
valueChanged(DraggableComponentSelectionEvent dcse)
This method will be called whenever any DraggableContainers this object is listening to fire a DraggableComponent selection event. |
| Methods inherited from class beowulf.gui.DraggableContainer |
add, add, add, add, add, addDraggableComponentSelectionListener, fireComponentDeselected, fireComponentSelected, getCurrentComponent, mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased, removeDraggableComponentSelectionListener, setCurrentComponent, setLayout |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int DIRECTED_GRAPH
public static final int UNDIRECTED_GRAPH
public static final float HEAD
protected GraphModel model
protected Map nodeLookup
protected JNodeFactory factory
protected EventListenerList listenerList
| Constructor Detail |
public JGraph()
public JGraph(int graphType)
graphType - The type of graph (directed or undirected).
public JGraph(int graphType,
JNodeFactory newFactory)
graphType - The type of graph (directed or undirected).newFactory - The new JNodeFactory.public JGraph(GraphModel newModel)
newModel - The model to be represented by this JGraph.
public JGraph(GraphModel newModel,
JNodeFactory newFactory)
newModel - The model to be represented by this JGraph.newFactory - The new JNodeFactory.
public JGraph(Vector nodeVector,
Vector edgeVector,
int graphType)
nodeVector - The list of nodes.edgeVector - The list of edges.graphType - The graph type (directed or undirected).
public JGraph(Vector nodeVector,
Vector edgeVector,
int graphType,
JNodeFactory newFactory)
nodeVector - The list of nodes.edgeVector - The list of edges.graphType - The graph type (directed or undirected).newFactory - The new factory for this JGraph.| Method Detail |
public void addGraphSelectionListener(GraphSelectionListener l)
l - The graph selection listener to add.public void removeGraphSelectionListener(GraphSelectionListener l)
l - The graph selection listener to remove.
protected void fireNodeSelected(Object source,
Object value)
source - The graph on which the even occurred.value - The value of the node that was selected.
protected void fireNodeDeselected(Object source,
Object value)
source - The graph on which the even occurred.value - The value of the node that was deselected.public void setModel(GraphModel newModel)
newModel - The new graph model.public void setJNodeFactory(JNodeFactory newFactory)
newFactory - The new JNodeFactory.public GraphModel getModel()
public JNodeFactory getJNodeFactory()
public void nodeAdded(GraphEvent ge)
GraphListener
nodeAdded in interface GraphListenerge - The graph event containing all of the necessary data.public void nodeRemoved(GraphEvent ge)
GraphListener
nodeRemoved in interface GraphListenerge - The graph event containing all of the necessary data.public void edgeAdded(GraphEvent ge)
GraphListener
edgeAdded in interface GraphListenerge - The graph event containing all of the necessary data.public void edgeRemoved(GraphEvent ge)
GraphListener
edgeRemoved in interface GraphListenerge - The graph event containing all of the necessary data.public void valueChanged(DraggableComponentSelectionEvent dcse)
DraggableComponentSelectionListener
valueChanged in interface DraggableComponentSelectionListenerdcse - The generated event.public void paintComponent(Graphics g)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||