quoggles
Class QGraphMouse

java.lang.Object
  |
  +--quoggles.QGraphMouse
All Implemented Interfaces:
java.util.EventListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

public class QGraphMouse
extends java.lang.Object
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

Implements actions resulting from mouse events.


Field Summary
private  boolean dragged
          Used for dragging purposes: true iff user drags
private  javax.swing.JComponent draggedComp
          Used for dragging purposes: component currently dragged
private  java.awt.geom.Point2D dragPoint1
          Used for dragging purposes
private  java.awt.geom.Point2D dragPoint2
          Used for dragging purposes
private  boolean dragSecondPoint
          Used for dragging purposes
private  javax.swing.border.Border emptyBorder
          Empty (i.e. invisible) border
private  javax.swing.JComponent ghostComp
          Used for dragging purposes: Show "virtual component" at mouse pos
private  javax.swing.border.Border markBorder
          Border used to highlight boxes
private  java.util.Collection markedBoxReps
          Collection of all currently marked BoxRepresentations
private  java.util.Map markedCopyOrigMap
          Maps copied marked nodes to their originals
private  org.graffiti.graph.Graph markedSubGraph
          The induced subgraph of the marked nodes
private  QMain qMain
          Used to communicate between the individual parts of the system
private  java.awt.Point relDrag
          Used for dragging purposes
private  java.util.Map relDragMap
          Saves all relative drag positions for all marked boxes
private  java.awt.geom.Point2D selRectPt1
          Marks a corner of the selection rectangle
private  java.awt.geom.Point2D selRectPt2
          Marks a corner of the selection rectangle
private  java.util.Collection showOrderComps
          Components used to show the order of IO of marked sub graph
 
Constructor Summary
QGraphMouse(QMain q)
          Constructor.
 
Method Summary
 org.graffiti.graph.Graph getMarkedSubGraph()
          Returns the currently marked sub graph.
private  void markBoxRep(BoxRepresentation boxRep)
          Do something to highlight the boxRep.
private  void markedBoxRepsChanged()
          Takes care to display / save order of IO for marked sub query.
 void mouseClicked(java.awt.event.MouseEvent e)
          If double clicked on an icon, adds the corresponding box (uses the functionality of mousePressed, mouseDragged and mouseReleased).
 void mouseDragged(java.awt.event.MouseEvent e)
          Moves curently dragged component according to the mouse movement.
 void mouseEntered(java.awt.event.MouseEvent e)
          Empty.
 void mouseExited(java.awt.event.MouseEvent e)
          Empty.
 void mouseMoved(java.awt.event.MouseEvent e)
          Empty except followMode is switched on.
 void mousePressed(java.awt.event.MouseEvent e)
          As it might be the start of a drag, set all relevant flags and fields.
 void mouseReleased(java.awt.event.MouseEvent e)
          Calls checkConnections(true) if it succeeds a drag operation and removes any visible "virtual component".
private  void moveBoxRepresentation(BoxRepresentation rep, java.awt.Point newPos)
          Calculate the next possible position for the given box representation starting at the given position.
 void moveBoxRepresentation(BoxRepresentation rep, java.awt.Point newPos, boolean freePlacement)
          If last parameter is false: Calculate the next possible position for the given box representation starting at the given position.
private  void moveOneOneConn(java.awt.Point pt, boolean freePlacement)
          Equivalent of moveBoxRepresentation for OneOneConnector_Boxes
 void reset()
           
private  void unMarkBoxRep(BoxRepresentation boxRep)
          Remove anything that highlighted the boxRep.
private  void unMarkBoxRep(BoxRepresentation boxRep, boolean inform)
          Remove anything that highlighted the boxRep.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

qMain

private QMain qMain
Used to communicate between the individual parts of the system


relDrag

private java.awt.Point relDrag
Used for dragging purposes


draggedComp

private javax.swing.JComponent draggedComp
Used for dragging purposes: component currently dragged


ghostComp

private final javax.swing.JComponent ghostComp
Used for dragging purposes: Show "virtual component" at mouse pos


dragged

private boolean dragged
Used for dragging purposes: true iff user drags


dragPoint1

private java.awt.geom.Point2D dragPoint1
Used for dragging purposes


dragPoint2

private java.awt.geom.Point2D dragPoint2
Used for dragging purposes


dragSecondPoint

private boolean dragSecondPoint
Used for dragging purposes


selRectPt1

private java.awt.geom.Point2D selRectPt1
Marks a corner of the selection rectangle


selRectPt2

private java.awt.geom.Point2D selRectPt2
Marks a corner of the selection rectangle


relDragMap

private java.util.Map relDragMap
Saves all relative drag positions for all marked boxes


emptyBorder

private final javax.swing.border.Border emptyBorder
Empty (i.e. invisible) border


markBorder

private final javax.swing.border.Border markBorder
Border used to highlight boxes


markedBoxReps

private java.util.Collection markedBoxReps
Collection of all currently marked BoxRepresentations


markedSubGraph

private org.graffiti.graph.Graph markedSubGraph
The induced subgraph of the marked nodes


markedCopyOrigMap

private java.util.Map markedCopyOrigMap
Maps copied marked nodes to their originals


showOrderComps

private java.util.Collection showOrderComps
Components used to show the order of IO of marked sub graph

Constructor Detail

QGraphMouse

public QGraphMouse(QMain q)
Constructor.

Parameters:
q - main component used for communication.
Method Detail

getMarkedSubGraph

public org.graffiti.graph.Graph getMarkedSubGraph()
Returns the currently marked sub graph.

Returns:
the currently marked sub graph

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
If double clicked on an icon, adds the corresponding box (uses the functionality of mousePressed, mouseDragged and mouseReleased). If double clicked on a box representation, removes this box.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseClicked(java.awt.event.MouseEvent)

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Moves curently dragged component according to the mouse movement. More precisely, a "virtual component" is moved and the real component snaps to the next possible position (if there is one).

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
See Also:
MouseMotionListener.mouseDragged(java.awt.event.MouseEvent)

moveOneOneConn

private void moveOneOneConn(java.awt.Point pt,
                            boolean freePlacement)
Equivalent of moveBoxRepresentation for OneOneConnector_Boxes

Parameters:
pt -
freePlacement -

moveBoxRepresentation

public void moveBoxRepresentation(BoxRepresentation rep,
                                  java.awt.Point newPos,
                                  boolean freePlacement)
If last parameter is false: Calculate the next possible position for the given box representation starting at the given position. Snaps the component to this position. This method is quite expensive (at least with this rather quadratic implementation). If last parameter is true, the box is just moved according to the mouse pointer's position.

Parameters:
rep -
newPos -
freePlacement -

moveBoxRepresentation

private void moveBoxRepresentation(BoxRepresentation rep,
                                   java.awt.Point newPos)
Calculate the next possible position for the given box representation starting at the given position. Snaps the component to this position. This method is quite expensive (at least with this rather quadratic implementation).

Parameters:
rep -
newPos -

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Empty except followMode is switched on.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
See Also:
MouseMotionListener.mouseMoved(java.awt.event.MouseEvent)

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
As it might be the start of a drag, set all relevant flags and fields. If pressed on a "red sign", start a 1-1-connector there.

Specified by:
mousePressed in interface java.awt.event.MouseListener
See Also:
MouseListener.mousePressed(java.awt.event.MouseEvent)

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Calls checkConnections(true) if it succeeds a drag operation and removes any visible "virtual component". Resets all flags etc. indicating a drag.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseReleased(java.awt.event.MouseEvent)

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Empty.

Specified by:
mouseEntered in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseEntered(java.awt.event.MouseEvent)

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Empty.

Specified by:
mouseExited in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseExited(java.awt.event.MouseEvent)

unMarkBoxRep

private void unMarkBoxRep(BoxRepresentation boxRep,
                          boolean inform)
Remove anything that highlighted the boxRep. The given boolean value specifies whether or not the markedBoxRepsChanged mthod is called.

Parameters:
boxRep -

unMarkBoxRep

private void unMarkBoxRep(BoxRepresentation boxRep)
Remove anything that highlighted the boxRep.

Parameters:
boxRep -

markBoxRep

private void markBoxRep(BoxRepresentation boxRep)
Do something to highlight the boxRep.

Parameters:
boxRep -

markedBoxRepsChanged

private void markedBoxRepsChanged()
Takes care to display / save order of IO for marked sub query.


reset

public void reset()