Point2D ptMouseTrns, ptAnchor;
Rectangle2D dndCurrentRect;
int i;
Receiver rcv;
List dndColl;
PerformableEdit edit;
if( !dndDragging ) { // test if mouse move was sufficient
if( ptDeltaMouse.getX()*ptDeltaMouse.getX()+ptDeltaMouse.getY()*ptDeltaMouse.getY() <= 25.0 ) return;
}
dndColl = doc.getSelectedReceivers().getAll();
if( !dndDragging ) {
dndDragging = true;
dndRecentRect = getUnionRect( dndColl );
dndAnchorRef.clear();
for( i = 0; i < dndColl.size(); i++ ) {
rcv = (Receiver) dndColl.get( i );
dndAnchorRef.put( rcv, rcv.getAnchor() );
}
}
// ptMouseTrns = screenToVirtual( ptDeltaMouse );
final Point2D ptTrns1 = screenToVirtual( dndFirstEvent.getPoint() );
final Point2D ptTrns2 = screenToVirtual( e.getPoint() );
ptMouseTrns = new Point2D.Double( ptTrns2.getX() - ptTrns1.getX(),
ptTrns2.getY() - ptTrns1.getY() );
for( i = 0; i < dndColl.size(); i++ ) {
rcv = (Receiver) dndColl.get( i );
ptAnchor = (Point2D) dndAnchorRef.get( rcv );
if( ptAnchor != null ) {
// XXX need to exclude our own anchor in the snap method() !
// rcv.setAnchor( snap( new Point2D.Double(
// Math.max( 0.0, Math.min( 1.0, ptAnchor.getX() + ptMouseTrns.getX() )),
// Math.max( 0.0, Math.min( 1.0, ptAnchor.getY() + ptMouseTrns.getY() ))), true ));
ptAnchor = new Point2D.Double(
Math.max( -1.0, Math.min( 1.0, ptAnchor.getX() + ptMouseTrns.getX() )),
Math.max( -1.0, Math.min( 1.0, ptAnchor.getY() + ptMouseTrns.getY() )));
edit = new EditSetReceiverAnchor( this, doc, rcv, ptAnchor );
//System.out.println( "ptDeltaMouse = " + ptDeltaMouse + "; ptMouseTrns = " + ptMouseTrns + "; ptAnchor = " + ptAnchor );
doc.getUndoManager().addEdit( edit.perform() );
}
}
dndCurrentRect = getUnionRect( dndColl );
updateReceiverShapes();
efficientUpdateAndRepaint( dndRecentRect, dndCurrentRect, true );