Esempio n. 1
0
 /**
  * Determines whether or not the given mouse event is actually a popup trigger.
  *
  * @param aPoint the <em>corrected</em> mouse position, where the popup is to be shown, cannot be
  *     <code>null</code>;
  * @param aEvent the mouse event that could be a popup trigger, cannot be <code>null</code>.
  */
 private boolean handlePopupTrigger(final Point aPoint, final MouseEvent aEvent) {
   final boolean popupTrigger = isCursorPopupTrigger(aEvent);
   if (popupTrigger) {
     JPopupMenu contextMenu = createCursorPopup(aPoint, aEvent.getLocationOnScreen());
     if (contextMenu != null) {
       contextMenu.show(aEvent.getComponent(), aEvent.getX(), aEvent.getY());
       // Mark the event as consumed...
       aEvent.consume();
     }
   }
   return popupTrigger;
 }
Esempio n. 2
0
  /**
   * @param aEvent
   * @param aStartPoint
   */
  protected void handleZoomRegion(final MouseEvent aEvent, final Point aStartPoint) {
    // For now, disabled by default as it isn't 100% working yet...
    if (Boolean.FALSE.equals(Boolean.valueOf(System.getProperty("zoomregionenabled", "false")))) {
      return;
    }

    final JComponent source = (JComponent) aEvent.getComponent();
    final boolean dragging = (aEvent.getID() == MouseEvent.MOUSE_DRAGGED);

    final GhostGlassPane glassPane =
        (GhostGlassPane) SwingUtilities.getRootPane(source).getGlassPane();

    Rectangle viewRect;
    final JScrollPane scrollPane =
        SwingComponentUtils.getAncestorOfClass(JScrollPane.class, source);
    if (scrollPane != null) {
      final JViewport viewport = scrollPane.getViewport();
      viewRect = SwingUtilities.convertRectangle(viewport, viewport.getVisibleRect(), glassPane);
    } else {
      viewRect = SwingUtilities.convertRectangle(source, source.getVisibleRect(), glassPane);
    }

    final Point start = SwingUtilities.convertPoint(source, aStartPoint, glassPane);
    final Point current = SwingUtilities.convertPoint(source, aEvent.getPoint(), glassPane);

    if (dragging) {
      if (!glassPane.isVisible()) {
        glassPane.setVisible(true);
        glassPane.setRenderer(new RubberBandRenderer(), start, current, viewRect);
      } else {
        glassPane.updateRenderer(start, current, viewRect);
      }

      glassPane.repaintPartially();
    } else
    /* if ( !dragging ) */
    {
      // Fire off a signal to the zoom controller to do its job...
      this.controller.getZoomController().zoomRegion(aStartPoint, aEvent.getPoint());

      glassPane.setVisible(false);
    }
  }
Esempio n. 3
0
 /**
  * Sets the current mouse cursor.
  *
  * @param aMouseCursor a mouse cursor, can be <code>null</code> to use the default cursor.
  */
 protected final void setMouseCursor(final MouseEvent aEvent, final java.awt.Cursor aMouseCursor) {
   aEvent.getComponent().setCursor(aMouseCursor);
 }
Esempio n. 4
0
 /**
  * @param aEvent
  * @return
  */
 protected final MouseEvent convertEvent(final MouseEvent aEvent) {
   JComponent view = SwingComponentUtils.getDeepestComponentAt(aEvent);
   return SwingUtilities.convertMouseEvent(aEvent.getComponent(), aEvent, view);
 }