snap.ui.diagram
Class DiagramPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--snap.ui.diagram.DiagramPanel
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, GraphChangeEventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable

public class DiagramPanel
extends javax.swing.JComponent
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.ActionListener, GraphChangeEventListener

DiagramPanel is the component object used to display layout information such as visualization icons and their associated connections. This object encapsulates all the necessary component objects for layout design including the dialog windows. It extends JComponent and implements MouseListener, MouseMotionListener and ActionListener to allow for mouse controls and actions. It also contains the actions for adding, editing, and deleting layout components.

Author:
Nathan Conklin - nathan@conklinfamily.net, Matt Clement - macleme2@vt.edu, Kiran Indukuri - kindukur@vt.edu, Chris North - north@cs.vt.edu
See Also:
Serialized Form

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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DiagramPanel(snap.Snap snap)
          Class constructor
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent actionEvent)
          Handles all actions and events related to the drawing of a layout sent by way of mouse events or through other method calls.
 void graphChanged(snap.graph.GraphChangeEvent gce)
           
 void mouseClicked(java.awt.event.MouseEvent mouseEvent)
          Interprets mouse clicked events and determines the appropriate UI related actions to perform.
 void mouseDragged(java.awt.event.MouseEvent mouseEvent)
          Handles the continuous drawing and animation of a temporary connection as a result of mouse dragged events.
 void mouseEntered(java.awt.event.MouseEvent mouseEvent)
          Handles the mouseEntered event.
 void mouseExited(java.awt.event.MouseEvent mouseEvent)
          Handles the mouseExited event.
 void mouseMoved(java.awt.event.MouseEvent mouseEvent)
          Handles all mouse moved events, but particularly is involved with the continuous drawing and animation of a new Link as a result of these mouse moved events.
 void mousePressed(java.awt.event.MouseEvent mouseEvent)
          Initiates the sequence of events to manage the popup menus as a result of mouse pressed events and establishes a current visualization otherwise.
 void mouseReleased(java.awt.event.MouseEvent mouseEvent)
          Initiates the sequence of events to manage the popup menus as a result of mouse release events.
 void paintComponent(java.awt.Graphics g)
          Handles the repainting of all the visualizations and connections currently being displayed in the layout.
 void removeLink(snap.ui.diagram.Link link)
          Removes the link from the UI and from the CoordinationGraph
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DiagramPanel

public DiagramPanel(snap.Snap snap)
Class constructor

Parameters:
snap - the snap parent object
Method Detail

paintComponent

public void paintComponent(java.awt.Graphics g)
Handles the repainting of all the visualizations and connections currently being displayed in the layout.

Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
g - the graphics context to use for painting

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent mouseEvent)
Interprets mouse clicked events and determines the appropriate UI related actions to perform. If a link is in the process of being created, this method helps regulate that process and is responsible for initiating the connection completion sequence when the process is complete.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
mouseEvent - the mouse event to be handled

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent mouseEvent)
Handles the continuous drawing and animation of a temporary connection as a result of mouse dragged events. It also ensures that the visualizations are drawn on top of the connections to present the correct visual appearance.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
mouseEvent - the mouse event to be handled

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent mouseEvent)
Handles all mouse moved events, but particularly is involved with the continuous drawing and animation of a new Link as a result of these mouse moved events.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Parameters:
mouseEvent - the mouse event to be handled

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent mouseEvent)
Initiates the sequence of events to manage the popup menus as a result of mouse release events.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
mouseEvent - the mouse event to be handled

mousePressed

public void mousePressed(java.awt.event.MouseEvent mouseEvent)
Initiates the sequence of events to manage the popup menus as a result of mouse pressed events and establishes a current visualization otherwise.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
mouseEvent - the mouse event to be handled

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent mouseEvent)
Handles the mouseEntered event. Retained as part of implementations.

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Parameters:
mouseEvent - the mouse event thrown

mouseExited

public void mouseExited(java.awt.event.MouseEvent mouseEvent)
Handles the mouseExited event. Retained as part of implementations.

Specified by:
mouseExited in interface java.awt.event.MouseListener
Parameters:
mouseEvent - the mouse event thrown

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent actionEvent)
Handles all actions and events related to the drawing of a layout sent by way of mouse events or through other method calls. These atomic events make up the basic operations that can be performed. Iterpretation of the events to determine not only the type of event that was sent, but where the event originated is pivotal to the operation of this method.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
actionEvent - the event to process

graphChanged

public void graphChanged(snap.graph.GraphChangeEvent gce)
Specified by:
graphChanged in interface GraphChangeEventListener

removeLink

public void removeLink(snap.ui.diagram.Link link)
Removes the link from the UI and from the CoordinationGraph