handler.setCurrentState(EditState.MOVING);
if (!isValid(handler, e, eventType))
throw new IllegalArgumentException("Not valid state", new Exception()); //$NON-NLS-1$
EditBlackboard editBlackboard2 = handler.getEditBlackboard(handler.getEditLayer());
editBlackboard2.startBatchingEvents();
try {
if (tracker == null) {
handler.lock(this);
Point closestPoint = editBlackboard2.overVertex(Point.valueOf(e.x, e.y),
PreferenceUtil.instance().getVertexRadius(), false);
Map<EditGeom, Boolean> changedStatus=new HashMap<EditGeom, Boolean>();
for( EditGeom geom : editBlackboard2.getGeoms() ) {
changedStatus.put(geom, geom.isChanged());
}
IEditValidator validator = validatorFactory.get(handler, e, eventType);
// If at the start the geometry isn't valid then who are we to complain?
if( validator.isValid(handler, e, eventType)!=null ){
validator=null;
}
tracker = new PositionTracker(closestPoint, handler.getMouseTracker()
.getDragStarted(), getPointsToMove(handler, editBlackboard2),
changedStatus, validator);
handler.getBehaviours().add(tracker);
if (isSnappingValid() && PreferenceUtil.instance().getSnapBehaviour()!=SnapBehaviour.GRID ) {
drawSnapArea = new DrawSnapAreaCommand(tracker);
handler.getContext().getViewportPane().addDrawCommand(drawSnapArea);
}
}
if (tracker.lastPoint == null) {
tracker.lastPoint = handler.getMouseTracker().getDragStarted();
}
Point point = Point.valueOf(e.x, e.y);
int deltaX = point.getX() - tracker.lastPoint.getX(), deltaY = point.getY()
- tracker.lastPoint.getY();
doMove(deltaX, deltaY, handler, editBlackboard2, tracker.selection);
tracker.lastPoint = point;
return null;
} finally {
editBlackboard2.fireBatchedEvents();
handler.repaint();
}
}