org.graffiti.plugins.views.defaults
Class GraffitiView

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.graffiti.plugin.view.AbstractView
                  extended by org.graffiti.plugins.views.defaults.GraffitiView
All Implemented Interfaces:
Autoscroll, ImageObserver, MenuContainer, Serializable, EventListener, AttributeConsumer, AttributeListener, EdgeListener, GraphListener, NodeListener, TransactionListener, View, View2D, Zoomable, DummySupportView

public class GraffitiView
extends AbstractView
implements View2D, GraphListener, AttributeListener, AttributeConsumer, NodeListener, EdgeListener, TransactionListener, DummySupportView

An implementation of org.graffiti.plugin.view.View2D, that displays a graph. Since it also shows changes in the graph it listens for changes in the graph, attributes, nodes and edges.

See Also:
JPanel, View2D, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
Component.BaselineResizeBehavior
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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 org.graffiti.plugin.view.View
NO_ZOOM
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GraffitiView()
          Constructs a new GraffitiView.
GraffitiView(Graph currentGraph)
          Constructs a new GraffitiView for the specified Graph.
 
Method Summary
 void addMessageListener(MessageListener ml)
          Adds a message listener to the view.
 void addMouseListener(MouseListener l)
           
 void addMouseMotionListener(MouseMotionListener l)
           
 void addViewForEdge(Edge edge)
          Adds a view for the given edge to this GraffitiView.
 void addViewForNode(Node node)
          Adds a view for the given Node to this GraffitiView.
 void close()
          Closes the current view.
 void completeRedraw()
          Instructs the view to do completely refresh its contents.
 boolean contains(int x, int y)
           
 boolean embedsInJScrollPane()
          See JScrollPane.
 Component findComponentAt(int x, int y)
           
 Component getComponentAt(int x, int y)
           
 CollectionAttribute getDirectedEdgeAttribute()
          Returns the attribute, which should be available in a directed edge object.
 CollectionAttribute getGraphAttribute()
          Returns the attribute, which should be available in a graph object.
 Graphics getGraphics()
           
 CollectionAttribute getNodeAttribute()
          Returns the attribute, which should be available in a node object.
 CollectionAttribute getUndirectedEdgeAttribute()
          Returns the attribute, which should be available in an undirected edge object.
 Viewport getViewport()
          
 void paint(Graphics g)
           
 void paintComponents(Graphics g)
           
 void postAttributeAdded(AttributeEvent e)
          Called after an attribute has been added.
 void postAttributeChanged(AttributeEvent e)
          Called after an attribute has been changed.
 void postAttributeRemoved(AttributeEvent e)
          Called after an attribute has been removed.
 void postDirectedChanged(EdgeEvent e)
          Called after the edge was set directed or undirected.
 void postEdgeAdded(GraphEvent e)
          Called after an edge has been added to the graph.
 void postEdgeRemoved(GraphEvent e)
          Called after an edge has been removed from the graph.
 void postEdgeReversed(EdgeEvent e)
          Called after the edge has been reversed.
 void postGraphCleared(GraphEvent e)
          Called after method clear() has been called on a graph.
 void postNodeAdded(GraphEvent e)
          Called after an edge has been added to the graph.
 void postNodeRemoved(GraphEvent e)
          Called after a node has been removed from the graph.
 void postSourceNodeChanged(EdgeEvent e)
          Called after the source node of an edge has changed.
 void postTargetNodeChanged(EdgeEvent e)
          Called after the target node of an edge has changed.
 void preSourceNodeChanged(EdgeEvent e)
          Called before a change of the source node of an edge takes place.
 void preTargetNodeChanged(EdgeEvent e)
          Called before a change of the target node of an edge takes place.
 void print(Graphics2D g, int width, int height)
           
 void removeMessageListener(MessageListener ml)
          Removes a message listener from the view.
 void removeMouseListener(MouseListener listener)
           
 void removeMouseMotionListener(MouseMotionListener l)
           
 void removeViewForEdge(Edge edge)
          Removes the view for the given edge from this GraffitiView.
 void removeViewForNode(Node node)
          Removes the view for the given Node from this GraffitiView.
 void repaint(GraphElement ge)
          Repaints the given graph element
 void setGraph(Graph g)
          Sets the graph this view displays.
 void setZoom(double factor)
          Sets the scale factor.
 void transactionFinished(TransactionEvent event)
          Called when a transaction has stopped.
 void transactionStarted(TransactionEvent e)
          Called when a transaction has started.
 void zoomToFitAfterRedraw()
           
 
Methods inherited from class org.graffiti.plugin.view.AbstractView
autoresize, autoscroll, getAutoscrollInsets, getComponentElementMap, getComponentForElement, getGrid, getId, getViewComponent, getViewName, getZoom, getZoomTransform, postInEdgeAdded, postInEdgeRemoved, postOutEdgeAdded, postOutEdgeRemoved, postUndirectedEdgeAdded, postUndirectedEdgeRemoved, preAttributeAdded, preAttributeChanged, preAttributeRemoved, preDirectedChanged, preEdgeAdded, preEdgeRemoved, preEdgeReversed, preGraphCleared, preInEdgeAdded, preInEdgeRemoved, preNodeAdded, preNodeRemoved, preOutEdgeAdded, preOutEdgeRemoved, preUndirectedEdgeAdded, preUndirectedEdgeRemoved, setAttributeComponentManager, setGrid, setId, supportsGrid
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, getComponent, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.graffiti.plugin.view.View
getComponentElementMap, getComponentForElement, getGrid, getId, getViewComponent, getViewName, setAttributeComponentManager, setGrid, setId, supportsGrid
 
Methods inherited from interface org.graffiti.event.GraphListener
preEdgeAdded, preEdgeRemoved, preGraphCleared, preNodeAdded, preNodeRemoved
 
Methods inherited from interface org.graffiti.event.NodeListener
postInEdgeAdded, postInEdgeRemoved, postOutEdgeAdded, postOutEdgeRemoved, postUndirectedEdgeAdded, postUndirectedEdgeRemoved, preInEdgeAdded, preInEdgeRemoved, preOutEdgeAdded, preOutEdgeRemoved, preUndirectedEdgeAdded, preUndirectedEdgeRemoved
 
Methods inherited from interface org.graffiti.event.EdgeListener
preDirectedChanged, preEdgeReversed
 
Methods inherited from interface org.graffiti.event.AttributeListener
preAttributeAdded, preAttributeChanged, preAttributeRemoved
 
Methods inherited from interface java.awt.dnd.Autoscroll
autoscroll, getAutoscrollInsets
 
Methods inherited from interface org.graffiti.plugin.view.Zoomable
getZoom, getZoomTransform
 

Constructor Detail

GraffitiView

public GraffitiView()
Constructs a new GraffitiView. The graph is initialized with an instance of the default implementation.


GraffitiView

public GraffitiView(Graph currentGraph)
Constructs a new GraffitiView for the specified Graph.

Parameters:
currentGraph - the Graph for which to construct the new GraffitiView.
Method Detail

getComponentAt

public Component getComponentAt(int x,
                                int y)
Overrides:
getComponentAt in class Container
See Also:
Container.getComponentAt(int, int)

getUndirectedEdgeAttribute

public CollectionAttribute getUndirectedEdgeAttribute()
Description copied from interface: org.graffiti.attributes.AttributeConsumer
Returns the attribute, which should be available in an undirected edge object. May return null.

Specified by:
getUndirectedEdgeAttribute in interface AttributeConsumer
Returns:
DOCUMENT ME!
See Also:
AttributeConsumer.getUndirectedEdgeAttribute()

getDirectedEdgeAttribute

public CollectionAttribute getDirectedEdgeAttribute()
Description copied from interface: org.graffiti.attributes.AttributeConsumer
Returns the attribute, which should be available in a directed edge object. May return null.

Specified by:
getDirectedEdgeAttribute in interface AttributeConsumer
Returns:
DOCUMENT ME!
See Also:
AttributeConsumer.getDirectedEdgeAttribute()

setGraph

public void setGraph(Graph g)
Sets the graph this view displays.

Specified by:
setGraph in interface View
Specified by:
setGraph in class AbstractView
Parameters:
g - graph this view should display.

getGraphAttribute

public CollectionAttribute getGraphAttribute()
Description copied from interface: org.graffiti.attributes.AttributeConsumer
Returns the attribute, which should be available in a graph object. May return null.

Specified by:
getGraphAttribute in interface AttributeConsumer
Returns:
DOCUMENT ME!
See Also:
AttributeConsumer.getGraphAttribute()

getGraphics

public Graphics getGraphics()
Overrides:
getGraphics in class JComponent
See Also:
JComponent.getGraphics()

getNodeAttribute

public CollectionAttribute getNodeAttribute()
Description copied from interface: org.graffiti.attributes.AttributeConsumer
Returns the attribute, which should be available in a node object. May return null.

Specified by:
getNodeAttribute in interface AttributeConsumer
Returns:
DOCUMENT ME!
See Also:
AttributeConsumer.getNodeAttribute()

addMessageListener

public void addMessageListener(MessageListener ml)
Adds a message listener to the view.

Specified by:
addMessageListener in interface View
Overrides:
addMessageListener in class AbstractView
Parameters:
ml - a message listener
Throws:
IllegalArgumentException - DOCUMENT ME!

addMouseListener

public void addMouseListener(MouseListener l)
Overrides:
addMouseListener in class Component
See Also:
Component.addMouseListener(java.awt.event.MouseListener)

removeMouseListener

public void removeMouseListener(MouseListener listener)
Overrides:
removeMouseListener in class Component

addMouseMotionListener

public void addMouseMotionListener(MouseMotionListener l)
Overrides:
addMouseMotionListener in class Component
See Also:
Component.addMouseMotionListener(java.awt.event.MouseMotionListener)

removeMouseMotionListener

public void removeMouseMotionListener(MouseMotionListener l)
Overrides:
removeMouseMotionListener in class Component

close

public void close()
Closes the current view.

Specified by:
close in interface View
Overrides:
close in class AbstractView

completeRedraw

public void completeRedraw()
Description copied from interface: org.graffiti.plugin.view.View
Instructs the view to do completely refresh its contents.

Specified by:
completeRedraw in interface View
See Also:
View.completeRedraw()

contains

public boolean contains(int x,
                        int y)
Overrides:
contains in class JComponent
See Also:
JComponent.contains(int, int)

findComponentAt

public Component findComponentAt(int x,
                                 int y)
Overrides:
findComponentAt in class Container
See Also:
Container.findComponentAt(int, int)

paint

public void paint(Graphics g)
Overrides:
paint in class JComponent
See Also:
JComponent.paint(java.awt.Graphics)

paintComponents

public void paintComponents(Graphics g)
Overrides:
paintComponents in class Container
See Also:
Container.paintComponents(java.awt.Graphics)

postAttributeAdded

public void postAttributeAdded(AttributeEvent e)
Called after an attribute has been added.

Specified by:
postAttributeAdded in interface AttributeListener
Overrides:
postAttributeAdded in class AbstractView
Parameters:
e - the AttributeEvent detailing the changes.

postAttributeChanged

public void postAttributeChanged(AttributeEvent e)
Called after an attribute has been changed.

Specified by:
postAttributeChanged in interface AttributeListener
Overrides:
postAttributeChanged in class AbstractView
Parameters:
e - the AttributeEvent detailing the changes.

postAttributeRemoved

public void postAttributeRemoved(AttributeEvent e)
Called after an attribute has been removed.

Specified by:
postAttributeRemoved in interface AttributeListener
Overrides:
postAttributeRemoved in class AbstractView
Parameters:
e - the AttributeEvent detailing the changes.

postDirectedChanged

public void postDirectedChanged(EdgeEvent e)
Called after the edge was set directed or undirected.

Specified by:
postDirectedChanged in interface EdgeListener
Overrides:
postDirectedChanged in class AbstractView
Parameters:
e - the EdgeEvent detailing the changes.

addViewForEdge

public void addViewForEdge(Edge edge)
Adds a view for the given edge to this GraffitiView. The edge may be part of the graph or not.

Specified by:
addViewForEdge in interface DummySupportView
Parameters:
edge - any Edge

postEdgeAdded

public void postEdgeAdded(GraphEvent e)
Called after an edge has been added to the graph.

Specified by:
postEdgeAdded in interface GraphListener
Overrides:
postEdgeAdded in class AbstractView
Parameters:
e - the GraphEvent detailing the changes.

removeViewForEdge

public void removeViewForEdge(Edge edge)
Removes the view for the given edge from this GraffitiView.

Specified by:
removeViewForEdge in interface DummySupportView
Parameters:
edge - any Edge

postEdgeRemoved

public void postEdgeRemoved(GraphEvent e)
Called after an edge has been removed from the graph.

Specified by:
postEdgeRemoved in interface GraphListener
Overrides:
postEdgeRemoved in class AbstractView
Parameters:
e - the GraphEvent detailing the changes.

postEdgeReversed

public void postEdgeReversed(EdgeEvent e)
Called after the edge has been reversed.

Specified by:
postEdgeReversed in interface EdgeListener
Overrides:
postEdgeReversed in class AbstractView
Parameters:
e - the EdgeEvent detailing the changes.

postGraphCleared

public void postGraphCleared(GraphEvent e)
Called after method clear() has been called on a graph. No other events (like remove events) are generated.

Specified by:
postGraphCleared in interface GraphListener
Overrides:
postGraphCleared in class AbstractView
Parameters:
e - the GraphEvent detailing the changes.

addViewForNode

public void addViewForNode(Node node)
Adds a view for the given Node to this GraffitiView. The Node may be in the graph or not.

Specified by:
addViewForNode in interface DummySupportView
Parameters:
node - any Node

postNodeAdded

public void postNodeAdded(GraphEvent e)
Called after an edge has been added to the graph.

Specified by:
postNodeAdded in interface GraphListener
Overrides:
postNodeAdded in class AbstractView
Parameters:
e - the GraphEvent detailing the changes.

removeViewForNode

public void removeViewForNode(Node node)
Removes the view for the given Node from this GraffitiView.

Specified by:
removeViewForNode in interface DummySupportView
Parameters:
node - any Node

postNodeRemoved

public void postNodeRemoved(GraphEvent e)
Called after a node has been removed from the graph. All edges incident to this node have already been removed (preEdgeRemoved and postEdgeRemoved have been called).

Specified by:
postNodeRemoved in interface GraphListener
Overrides:
postNodeRemoved in class AbstractView
Parameters:
e - the GraphEvent detailing the changes.

postSourceNodeChanged

public void postSourceNodeChanged(EdgeEvent e)
Called after the source node of an edge has changed.

Specified by:
postSourceNodeChanged in interface EdgeListener
Overrides:
postSourceNodeChanged in class AbstractView
Parameters:
e - the EdgeEvent detailing the changes.

postTargetNodeChanged

public void postTargetNodeChanged(EdgeEvent e)
Called after the target node of an edge has changed.

Specified by:
postTargetNodeChanged in interface EdgeListener
Overrides:
postTargetNodeChanged in class AbstractView
Parameters:
e - the EdgeEvent detailing the changes.

preSourceNodeChanged

public void preSourceNodeChanged(EdgeEvent e)
Called before a change of the source node of an edge takes place.

Specified by:
preSourceNodeChanged in interface EdgeListener
Overrides:
preSourceNodeChanged in class AbstractView
Parameters:
e - the EdgeEvent detailing the changes.

preTargetNodeChanged

public void preTargetNodeChanged(EdgeEvent e)
Called before a change of the target node of an edge takes place.

Specified by:
preTargetNodeChanged in interface EdgeListener
Overrides:
preTargetNodeChanged in class AbstractView
Parameters:
e - the EdgeEvent detailing the changes.

removeMessageListener

public void removeMessageListener(MessageListener ml)
Removes a message listener from the view.

Specified by:
removeMessageListener in interface View
Overrides:
removeMessageListener in class AbstractView
Parameters:
ml - a message listener
Throws:
IllegalArgumentException - DOCUMENT ME!

repaint

public void repaint(GraphElement ge)
Repaints the given graph element

Specified by:
repaint in interface View
Parameters:
ge - theGraphElement to repaint.

transactionFinished

public void transactionFinished(TransactionEvent event)
Called when a transaction has stopped.

Specified by:
transactionFinished in interface TransactionListener
Overrides:
transactionFinished in class AbstractView
Parameters:
event - the EdgeEvent detailing the changes.

transactionStarted

public void transactionStarted(TransactionEvent e)
Description copied from class: org.graffiti.plugin.view.AbstractView
Called when a transaction has started.

Specified by:
transactionStarted in interface TransactionListener
Overrides:
transactionStarted in class AbstractView
Parameters:
e - the EdgeEvent detailing the changes.
See Also:
TransactionListener.transactionStarted(org.graffiti.event.TransactionEvent)

setZoom

public void setZoom(double factor)
Sets the scale factor. Should call ViewportEventDispatcher.onViewportChange(Viewport) on the ZoomEventDispatcher returned by MainFrame.getViewportEventDispatcher(). Do not call setZoom from within an implementation of ViewportListener.onViewportChange(Viewport), as it may cause a deadlock. An actual change of the zoom is not guaranteed. The Zoomable may arbitrarily restrict the values.

Specified by:
setZoom in interface Zoomable
Overrides:
setZoom in class AbstractView
Parameters:
factor - the zoom factor to set. Smaller values yield in the display of a greater area with fewer details ("a view from greater distance"). 1.0 is the default value. Must be a finite value greater than 0.0.

embedsInJScrollPane

public boolean embedsInJScrollPane()
See JScrollPane.

Specified by:
embedsInJScrollPane in interface View
Returns:
true.

getViewport

public Viewport getViewport()

Specified by:
getViewport in interface View2D

zoomToFitAfterRedraw

public void zoomToFitAfterRedraw()
Specified by:
zoomToFitAfterRedraw in interface View2D

print

public void print(Graphics2D g,
                  int width,
                  int height)
Specified by:
print in interface View2D


Generated at 2012-05-30 11:01:25 PM CEST