/** * MouseListener method for mouseUp events. Depending on the kind of event the appropriate hook * method is called (popupMenuUp for popup trigger, doubleMouseClick for a double click, and * mouseUp() and mouseClick() for normal mouse clicks). * * @param e MouseEvent which should be interpreted * @param x x coordinate of the MouseEvent * @param y y coordinate of the MouseEvent */ public void mouseUp(MouseEvent e, int x, int y) { if (e.isPopupTrigger()) { handlePopupMenu(e, x, y); } else if (e.getClickCount() == 2) { handleMouseDoubleClick(e, x, y); } else { super.mouseUp(e, x, y); handleMouseUp(e, x, y); handleMouseClick(e, x, y); } }
/** * MouseListener method for mouseDown events. If the popup trigger has been activated, then the * appropriate hook method is called. * * @param e MouseEvent which should be interpreted * @param x x coordinate of the MouseEvent * @param y y coordinate of the MouseEvent */ public void mouseDown(MouseEvent e, int x, int y) { // isPopupTrigger() at mouseDown() is only notified at UNIX systems if (e.isPopupTrigger()) { handlePopupMenu(e, x, y); } else { super.mouseDown(e, x, y); handleMouseDown(e, x, y); } }
/** * Hook method which can be overriden by subclasses to provide specialised behaviour in the event * of a popup trigger. */ protected void handlePopupMenu(MouseEvent e, int x, int y) { Figure figure = drawing().findFigure(e.getX(), e.getY()); if (figure != null) { Object attribute = figure.getAttribute(Figure.POPUP_MENU); if (attribute == null) { figure = drawing().findFigureInside(e.getX(), e.getY()); } if (figure != null) { showPopupMenu(figure, e.getX(), e.getY(), e.getComponent()); } } }
/** * MouseListener method for mouseDrag events. Usually, mouse drags are ignored for popup menus or * double clicks. * * @param e MouseEvent which should be interpreted * @param x x coordinate of the MouseEvent * @param y y coordinate of the MouseEvent */ public void mouseDrag(MouseEvent e, int x, int y) { if (!e.isPopupTrigger()) { super.mouseDrag(e, x, y); } }