/** Check the state of the keys and buttons and set the selection accordingly. */ @Override public void mouseReleased(MouseEvent e) { if (e.getButton() != MouseEvent.BUTTON1) return; if (mousePos == null || mousePosStart == null) return; // injected release from outside // disable the selection rect Rectangle r; if (!lassoMode) { nc.requestClearRect(); r = getSelectionRectangle(); lasso = rectToPolygon(r); } else { nc.requestClearPoly(); lasso.addPoint(mousePos.x, mousePos.y); r = lasso.getBounds(); } mousePosStart = null; mousePos = null; if ((e.getModifiersEx() & MouseEvent.BUTTON3_DOWN_MASK) == 0) { selectionEndedListener.selectionEnded(r, e); } }