@Override
public void mousePressed(Canvas canvas, Graphics g, MouseEvent e) {
Project proj = canvas.getProject();
Selection sel = proj.getSelection();
Circuit circuit = canvas.getCircuit();
start = Location.create(e.getX(), e.getY());
curDx = 0;
curDy = 0;
moveGesture = null;
// if the user clicks into the selection,
// selection is being modified
Collection<Component> in_sel = sel.getComponentsContaining(start, g);
if (!in_sel.isEmpty()) {
if ((e.getModifiers() & InputEvent.SHIFT_MASK) == 0) {
setState(proj, MOVING);
proj.repaintCanvas();
return;
} else {
Action act = SelectionActions.drop(sel, in_sel);
if (act != null) {
proj.doAction(act);
}
}
}
// if the user clicks into a component outside selection, user
// wants to add/reset selection
Collection<Component> clicked = circuit.getAllContaining(start, g);
if (!clicked.isEmpty()) {
if ((e.getModifiers() & InputEvent.SHIFT_MASK) == 0) {
if (sel.getComponentsContaining(start).isEmpty()) {
Action act = SelectionActions.dropAll(sel);
if (act != null) {