ca.sqlpower.architect.swingui
Class Relationship.RelationshipDecorationMover

java.lang.Object
  extended by javax.swing.event.MouseInputAdapter
      extended by ca.sqlpower.architect.swingui.Relationship.RelationshipDecorationMover
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, javax.swing.event.MouseInputListener
Enclosing class:
Relationship

protected static class Relationship.RelationshipDecorationMover
extends javax.swing.event.MouseInputAdapter

The RelationshipDecorationMover responds to mouse events on the relationship by moving either the PK or FK connection point so it is near the mouse's current position. It ceases this activity when a mouse button is released.

The normal way to create a RelationshipDecorationMover is like this:

  new RelationshipDecorationMover(myRelationship, <true|false>);
 
note that no reference to the object is saved; it will cleanly dispose itself when a mouse button is lifted and hence become eligible for garbage collection.


Field Summary
protected  boolean movingPk
           
protected  Relationship r
           
protected  java.awt.Point startingFk
           
protected  java.awt.Point startingPk
           
 
Constructor Summary
Relationship.RelationshipDecorationMover(Relationship r, boolean movePk)
           
 
Method Summary
protected  void cleanup()
           
 void mouseDragged(java.awt.event.MouseEvent e)
          Forwards to mouseMoved(java.awt.event.MouseEvent).
 void mouseMoved(java.awt.event.MouseEvent e)
          Moves either the PK or FK decoration (depending on the movingPk flag) so it is as close to the mouse pointer as possible, while still being attached to an edge of the parent (for PK) or child (for FK) table.
 void mouseReleased(java.awt.event.MouseEvent e)
          Cleans up this mover (it will no longer track mouse motion, and will become eligible for garbage collection unless this instance's creator saved a reference).
protected  java.awt.Point translatePoint(java.awt.Point p)
          Translates the given point from Relationship coordinates into PKTable or FKTable coordinates, with the help of the Relationship's UI delegate (which ensures the decoration still lines up with the table's edge, and that it faces the right way, and that it snaps to a straight line when close).
 
Methods inherited from class javax.swing.event.MouseInputAdapter
mouseClicked, mouseEntered, mouseExited, mousePressed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

r

protected Relationship r

startingPk

protected java.awt.Point startingPk

startingFk

protected java.awt.Point startingFk

movingPk

protected boolean movingPk
Constructor Detail

Relationship.RelationshipDecorationMover

public Relationship.RelationshipDecorationMover(Relationship r,
                                                boolean movePk)
Method Detail

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Moves either the PK or FK decoration (depending on the movingPk flag) so it is as close to the mouse pointer as possible, while still being attached to an edge of the parent (for PK) or child (for FK) table.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Overrides:
mouseMoved in class javax.swing.event.MouseInputAdapter

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Forwards to mouseMoved(java.awt.event.MouseEvent).

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Overrides:
mouseDragged in class javax.swing.event.MouseInputAdapter

translatePoint

protected java.awt.Point translatePoint(java.awt.Point p)
Translates the given point from Relationship coordinates into PKTable or FKTable coordinates, with the help of the Relationship's UI delegate (which ensures the decoration still lines up with the table's edge, and that it faces the right way, and that it snaps to a straight line when close). Whether the PK or FK table is the target depends on the state of the movingPk property.


mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Cleans up this mover (it will no longer track mouse motion, and will become eligible for garbage collection unless this instance's creator saved a reference).

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Overrides:
mouseReleased in class javax.swing.event.MouseInputAdapter

cleanup

protected void cleanup()


Copyright © 2003-2007 SQL Power Group Inc. www.sqlpower.ca