public void mouseDragged(MouseEvent e) { if (e.getModifiersEx() == MouseEvent.BUTTON1_DOWN_MASK) { if (RockEditDisplay.HotObject.ROCK.equals(hot.what)) { // move a rock final Point2D wc = getWc(e, tmp); int idx = PositionSet.findRockIndexTouchingRockAtPos(rocks, wc, hot.idx); if (idx >= 0) { log.debug("new position blocked"); } else { rocks.getRock(hot.idx).setLocation(wc); rocks.notifyChange(); log.debug("relocated"); } } if (RockEditDisplay.HotObject.SPEED.equals(hot.what)) { // change the speed of a rock final Point2D wc = getWc(e, tmp); panel.setSpeedSpot(hot.idx, wc); } } }
public void mouseClicked(MouseEvent e) { log.info("" + hot.idx); if (e.getButton() == MouseEvent.BUTTON1) { int mask = 1 << hot.idx; if (e.isShiftDown()) { int old = panel.getSelectedMask(); if ((mask & old) == 0) mask |= old; else mask = ~mask & old; } panel.setSelectedMask(mask); } }