if(!pressed) return;
// process drag rect
if(dragRectStartPoint != null) {
dragRectEndPoint = cursor;
Bounds dragRectBounds = new Bounds(dragRectStartPoint,dragRectEndPoint);
tempSelection.clear();
for(SNode node : context.getDocument().getCurrentPage().getNodes()) {
if(dragRectBounds.intersects(node.getTransformedBounds())) {
if(!tempSelection.contains(node)) {
tempSelection.add(node);
}
}
}
context.getDocument().setDirty(true);
context.redraw();
return;
}
// process handle if handle has been selected.
if(selectedHandle != null) {
double nx = cursor.getX();
double ny = cursor.getY();
SketchDocument doc = context.getDocument();
if(doc.isSnapGrid()) {
nx = ((int)(nx/doc.getGridWidth()))*doc.getGridWidth();
ny = ((int)(ny/doc.getGridHeight()))*doc.getGridHeight();
}
if(selectedHandle instanceof MouseEventHandle) {
((MouseEventHandle)selectedHandle).mouseDragged(nx, ny, event.isShiftPressed(), cursor);
} else {
selectedHandle.setX(nx,event.isShiftPressed());
selectedHandle.setY(ny,event.isShiftPressed());
selectedHandle.setXY(nx,ny,event.isShiftPressed());
}
context.getDocument().setDirty(true);
context.redraw();
return;
}
// do nothing if no selection
if(context.getSelection().isEmpty()) return;
// move selected nodes
moved = true;
boolean hsnap = false;
boolean vsnap = false;
//snap with other nodes first
if(context.getDocument().isSnapNodeBounds()) {
for(SNode node : context.getDocument().getCurrentPage().getNodes()) {
if(!context.getSelection().contains(node)) {
if(snapHorizontalBounds(cursor, node.getTransformedBounds())) {
hsnap = true;
}
if(snapVerticalBounds(cursor, node.getTransformedBounds())) {
vsnap = true;
}
}
}
}
//snap with doc bounds next if not already snapped
if(context.getDocument().isSnapDocBounds()) {
Bounds docBounds = new Bounds(0,0,context.getDocument().getWidth(),context.getDocument().getHeight());
if(!hsnap) {
hsnap = snapHorizontalBounds(cursor, docBounds);
}
if(!vsnap) {
vsnap = snapVerticalBounds(cursor,docBounds);