public void mousePressed(MouseEvent e) {
    this.mousePoint = e.getPoint();

    Object topObject = null;
    PickedObjectList pickedObjects = this.wwd.getObjectsAtCurrentPosition();
    if (pickedObjects != null) topObject = pickedObjects.getTopObject();

    if (topObject instanceof ControlPointMarker) {
      this.activeControlPoint = (ControlPointMarker) topObject;
      this.activeAction = this.activeControlPoint.getType();

      setShowAnnotation(true);
      updateAnnotation(this.activeControlPoint.getPosition());

      // update controlPointIndex;
      int i = 0;
      for (Marker controlPoint : this.controlPoints) {
        if (controlPoint.equals(topObject)) break;
        i++;
      }
      this.activeControlPointIndex = i;
      e.consume();
    } else if (topObject == this.getPolygon()) {
      this.activeAction = MOVE_POLYGON_ACTION;

      // set the shape to be the "active control point"
      this.activeControlPointIndex = -1;

      setShowAnnotation(true);
      updateAnnotation(this.polygon.getReferencePosition());
      e.consume();
    }
  }
 private void mousePressedInIconsArea(MouseEvent e) {
   EditorMessageIconRenderer iconRenderer = getIconRendererUnderMouse(e);
   if (iconRenderer != null) {
     if (e.getButton() == MouseEvent.BUTTON3) {
       JPopupMenu popupMenu = iconRenderer.getPopupMenu();
       if (popupMenu != null && e.getID() == MouseEvent.MOUSE_PRESSED) {
         e.consume();
         Component component = e.getComponent();
         popupMenu.show(component == null ? myEditorComponent : component, e.getX(), e.getY());
       }
       return;
     }
     AnAction action = iconRenderer.getClickAction();
     if (e.getButton() == MouseEvent.BUTTON1 && action != null) {
       if (e.getID() == MouseEvent.MOUSE_CLICKED) {
         AnActionEvent actionEvent =
             new AnActionEvent(
                 e,
                 new LeftEditorHighlighterDataContext(myEditorComponent, iconRenderer.getNode()),
                 ICON_AREA,
                 action.getTemplatePresentation(),
                 ActionManager.getInstance(),
                 e.getModifiers());
         action.update(actionEvent);
         action.actionPerformed(actionEvent);
       }
       e.consume();
     }
   }
 }
 // Handle mouse actions
 public void mousePressed(MouseEvent mouseEvent) {
   if (this.isArmed() && this.isUseRubberBand() && mouseEvent.getButton() == MouseEvent.BUTTON1) {
     if ((mouseEvent.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) {
       if (!mouseEvent.isControlDown()) {
         this.setActive(true);
         measureTool.addControlPoint();
         if (measureTool.getControlPoints().size() == 1) {
           measureTool.addControlPoint(); // Simulate a second click
         }
         // Set the rubber band target to the last control point or the relevant control for
         // regular shapes.
         if (measureTool.isRegularShape()) {
           String initControl =
               measureTool.getShapeInitialControl(measureTool.getWwd().getCurrentPosition());
           rubberBandTarget = measureTool.getControlPoint(initControl);
         } else {
           rubberBandTarget =
               (MeasureTool.ControlPoint)
                   measureTool.getControlPoints().get(measureTool.getControlPoints().size() - 1);
         }
         measureTool.firePropertyChange(MeasureTool.EVENT_RUBBERBAND_START, null, null);
       }
     }
     mouseEvent.consume();
   } else if (!this.isArmed()
       && mouseEvent.getButton() == MouseEvent.BUTTON1
       && mouseEvent.isAltDown()) {
     if (!this.measureTool.isRegularShape()) {
       this.setMoving(true);
       this.movingTarget = this.lastPickedObject;
     }
     mouseEvent.consume();
   }
 }
    protected void processMouseMotionEvent(MouseEvent e) {
      super.processMouseMotionEvent(e);

      if (!isShowing()) return;

      if (MouseEvent.MOUSE_DRAGGED == e.getID() && myWasPressedOnMe) {
        myDragging = true;
        setCursor(getResizeCursor());
        myGlassPane.setCursor(getResizeCursor(), myListener);

        myPoint = SwingUtilities.convertPoint(this, e.getPoint(), ThreeComponentsSplitter.this);
        if (getOrientation()) {
          if (getHeight() > 0 || myDividerZone > 0) {
            if (myIsFirst) {
              setFirstSize(Math.max(getMinSize(myFirstComponent), myPoint.y));
            } else {
              setLastSize(
                  Math.max(
                      getMinSize(myLastComponent),
                      ThreeComponentsSplitter.this.getHeight() - myPoint.y - getDividerWidth()));
            }
          }
        } else {
          if (getWidth() > 0 || myDividerZone > 0) {
            if (myIsFirst) {
              setFirstSize(Math.max(getMinSize(myFirstComponent), myPoint.x));
            } else {
              setLastSize(
                  Math.max(
                      getMinSize(myLastComponent),
                      ThreeComponentsSplitter.this.getWidth() - myPoint.x - getDividerWidth()));
            }
          }
        }
        ThreeComponentsSplitter.this.doLayout();
      } else if (MouseEvent.MOUSE_MOVED == e.getID()) {
        if (myGlassPane != null) {
          if (isInside(e.getPoint())) {
            myGlassPane.setCursor(getResizeCursor(), myListener);
            e.consume();
          } else {
            myGlassPane.setCursor(null, myListener);
          }
        }
      }

      if (myWasPressedOnMe) {
        e.consume();
      }
    }
Example #5
0
    @Override
    public void mouseDrag(MouseEvent e, Point2D imagePoint, IcyCanvas canvas) {
      if (!isActiveFor(canvas)) return;

      ROI2D.this.beginUpdate();
      try {
        if (!e.isConsumed()) {
          // left button action
          if (EventUtil.isLeftMouseButton(e)) {
            // shift action
            if (EventUtil.isShiftDown(e)) {
              // over ROI --> delete ROI
              if (ROI2D.this.isOver(canvas, imagePoint)) {
                ROI2D.this.delete();
                e.consume();
              }
              // roi selected ?
              else if (ROI2D.this.selected) {
                // remove point at current position
                if (removePointAt(canvas, imagePoint)) e.consume();
              }
            }
            // normal action
            else {
              // roi focused ?
              if (ROI2D.this.focused) {
                final double dx = imagePoint.getX() - mousePos.getX();
                final double dy = imagePoint.getY() - mousePos.getY();

                ROI2D.this.translate(dx, dy);

                // consume event
                e.consume();
              }
              // roi selected ?
              else if (ROI2D.this.selected) {
                // add a new point
                if (addPointAt(imagePoint, EventUtil.isControlDown(e))) e.consume();
              }
            }
          }
        }
      } finally {
        ROI2D.this.endUpdate();
      }

      // update mouse position
      setMousePos(imagePoint);
    }
Example #6
0
  protected void visibleMouseEvent(MouseEvent e, Point tempPt) {
    super.visibleMouseEvent(e, tempPt);
    if (!isEnabled()) return;

    float curInterval = increment;

    if (e.isControlDown() != controlDown) {
      controlDown = e.isControlDown();
      startY = tempPt.y;
      startVal = getValue();
    }
    if (e.isControlDown()) {
      curInterval /= 5f;
    }

    if (mouseInside) {
      menu.setCursor(Cursor.N_RESIZE_CURSOR);
    }
    switch (e.getID()) {
      case (MouseEvent.MOUSE_PRESSED):
        if (mouseInside) {
          if (e.getClickCount() > 1) {
            setValue(defaultValue);
          }
          startY = tempPt.y;
          startVal = getValue();
          scrolling = true;
          nearestMenu.context.focus().setModalFocus(this.menu);
        }
        break;
      case (MouseEvent.MOUSE_DRAGGED):
        if (scrolling) {
          float dy = startY - tempPt.y;
          float dVal = dy * curInterval * scrollSpeed;
          value = startVal + dVal;
          setValue(value);
          e.consume();
        }
        break;
      case (MouseEvent.MOUSE_RELEASED):
        if (scrolling) {
          e.consume();
          scrolling = false;
          nearestMenu.context.focus().removeFromFocus(this.menu);
        }
        break;
    }
  }
Example #7
0
  /** 鼠标按下 */
  public void mousePressed(MouseEvent e) {

    int code = e.getButton();
    try {
      Screen.mouseDown[code] = true;
      Screen.mousePressed[this.pressedMouse] = code;
      this.pressedMouse++;
      if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) {
        leftClick(e);
      }
      if ((e.getModifiers() & InputEvent.BUTTON2_MASK) != 0) {
        middleClick(e);
      }
      if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) {
        rightClick(e);
      }
      if (mouseMap.size() > 0) {
        Action action = (Action) mouseMap.get(String.valueOf(code));
        if (action != null) {
          action.press();
        }
      }
      mouseDown(e);
      e.consume();
    } catch (Exception ex) {
      pressedMouse = 0;
    }
  }
Example #8
0
  public void mouseClicked(MouseEvent e) {
    int x;
    int y;

    e.consume();

    if (mouseEventsEnabled) {

      x = Math.round(e.getX() / scale);
      y = Math.round(e.getY() / scale);

      // allow for the canvas margin
      y -= margin;

      // System.out.println("Mouse Click: (" + x + ", " + y + ")");

      if (e.getClickCount() < 2) {
        if (nativeSelectItem(x, y)) {
          parentFTAFrame.updateFrame();
        }
      } else {
        if (nativeSelectItem(x, y)) {
          parentFTAFrame.updateFrame();
        }

        editSelected();
        parentFTAFrame.updateFrame();
      }

      if (focusEventsEnabled) {
        // tell the main Canvas to point to this coordinate
        parentFTAFrame.setCanvasFocus(x, y);
      }
    }
  }
  public void mouseReleased(MouseEvent e) {
    logger.fine("Event: mouseReleased");
    // handling click in mouseReleased rather than in mouseClicked
    // provides better interaction. If mouse was slightly moved
    // between pressed and released events, the event clicked
    // is not triggered.
    // The behavior is not tested on Linux.

    // first stop the timer and select the node:
    stopTimerForDelayedSelection();
    c.extendSelection(e);
    // Right mouse <i>press</i> is <i>not</i> a popup trigger for Windows.
    // Only Right mouse release is a popup trigger!
    // OK, but Right mouse <i>press</i> <i>is</i> a popup trigger on Linux.
    c.showPopupMenu(e);
    if (e.isConsumed()) {
      return;
    }

    if (e.getModifiers() == MouseEvent.BUTTON1_MASK) {
      // FIXME Dimitry: Double Click comes after Plain Click combining (un)folding with editing
      //            if (e.getClickCount() % 2 == 0) {
      //                c.doubleClick(e);
      //            } else {
      c.plainClick(e);
      //            }
      e.consume();
    }
  }
  /**
   * Defaults to typical marquee behaviour unless a flow relation is being drawn. In that case, each
   * drag event will redraw a line from the mouse cursor to the source port. If there is a valid
   * incoming port under the mouse, this will also be highlighted to identify that a valid flow may
   * be drawn upon a mouse release event.
   */
  public void mouseDragged(MouseEvent event) {
    if (paletteBar.getState() == Palette.SelectionState.MARQUEE) {
      super.mouseDragged(event);
      return;
    }

    if (state == State.DRAWING_FLOW_RELATION) {
      if (sourcePort != null) {
        setCurrentPoint(getNet().snap(event.getPoint()));
        paintPotentialFlow();
        PortView portUnderMouse = getPortViewAt(event.getPoint());
        if (portUnderMouse != null
            && portUnderMouse != sourcePort
            && connectionAllowable(sourcePort, portUnderMouse)
            && acceptsIncomingFlows(portUnderMouse)) {
          if (portUnderMouse != targetPort) {
            targetPort = portUnderMouse;
            getOverlay().setTarget(net.toScreen(targetPort.getBounds()));
          }
        }
        if (portUnderMouse == null) {
          targetPort = null;
          getOverlay().setTarget(null);
        }
      }
      event.consume();
    }
  }
 @Override
 protected void processMouseEvent(MouseEvent e) {
   if (UIUtil.isActionClick(e, MouseEvent.MOUSE_PRESSED) && isOnNextStepButton(e)) {
     e.consume();
   }
   super.processMouseEvent(e);
 }
  /**
   * check the modifiers. If accepted, use the mouse drag motion to rotate the graph in the master
   * view
   */
  public void mouseDragged(MouseEvent e) {
    if (down == null) return;
    VisualizationViewer vv = (VisualizationViewer) e.getSource();
    boolean accepted = checkModifiers(e);
    if (accepted) {
      if (vv instanceof SatelliteVisualizationViewer) {
        VisualizationViewer vvMaster = ((SatelliteVisualizationViewer) vv).getMaster();

        MutableTransformer modelTransformerMaster = vvMaster.getLayoutTransformer();

        // rotate
        vv.setCursor(cursor);
        // I want to compute rotation based on the view coordinates of the
        // lens center in the satellite view.
        // translate the master view center to layout coords, then translate
        // that point to the satellite view's view coordinate system....
        Point2D center = vv.transform(vvMaster.inverseTransform(vvMaster.getCenter()));
        Point2D q = down;
        Point2D p = e.getPoint();
        Point2D v1 = new Point2D.Double(center.getX() - p.getX(), center.getY() - p.getY());
        Point2D v2 = new Point2D.Double(center.getX() - q.getX(), center.getY() - q.getY());
        double theta = angleBetween(v1, v2);
        modelTransformerMaster.rotate(-theta, vvMaster.inverseViewTransform(vvMaster.getCenter()));
        down.x = e.getX();
        down.y = e.getY();
      }
      e.consume();
    }
  }
Example #13
0
 public void mousePressed(MouseEvent e) {
   mouseX = e.getX();
   mouseY = e.getY();
   // consume this event so that it will not be processed
   // in the default manner
   e.consume();
 }
Example #14
0
  /**
   * If the user double clicks on any part of this FigNode, pass it down to one of the internal
   * Figs. This allows the user to initiate direct text editing.
   *
   * <p>{@inheritDoc}
   */
  @Override
  public void mouseClicked(MouseEvent me) {
    if (!readyToEdit) {
      Object owner = getOwner();
      if (Model.getFacade().isAModelElement(owner)
          && !Model.getModelManagementHelper().isReadOnly(owner)) {
        readyToEdit = true;
      } else {

        return;
      }
    }
    if (me.isConsumed()) {
      return;
    }
    if (me.getClickCount() >= 2
        && !(me.isPopupTrigger() || me.getModifiers() == InputEvent.BUTTON3_MASK)) {
      if (getOwner() == null) {
        return;
      }
      Fig f = hitFig(new Rectangle(me.getX() - 2, me.getY() - 2, 4, 4));
      if (f instanceof MouseListener) {
        ((MouseListener) f).mouseClicked(me);
      }
    }
    me.consume();
  }
      @Override
      public void mouseDragged(MouseEvent e) {
        if (!myDragging) return;
        MouseEvent event = SwingUtilities.convertMouseEvent(e.getComponent(), e, MyDivider.this);
        final ToolWindowAnchor anchor = myInfo.getAnchor();
        final Point point = event.getPoint();
        final Container windowPane = InternalDecorator.this.getParent();
        myLastPoint = SwingUtilities.convertPoint(MyDivider.this, point, windowPane);
        myLastPoint.x = Math.min(Math.max(myLastPoint.x, 0), windowPane.getWidth());
        myLastPoint.y = Math.min(Math.max(myLastPoint.y, 0), windowPane.getHeight());

        final Rectangle bounds = InternalDecorator.this.getBounds();
        if (anchor == ToolWindowAnchor.TOP) {
          InternalDecorator.this.setBounds(0, 0, bounds.width, myLastPoint.y);
        } else if (anchor == ToolWindowAnchor.LEFT) {
          InternalDecorator.this.setBounds(0, 0, myLastPoint.x, bounds.height);
        } else if (anchor == ToolWindowAnchor.BOTTOM) {
          InternalDecorator.this.setBounds(
              0, myLastPoint.y, bounds.width, windowPane.getHeight() - myLastPoint.y);
        } else if (anchor == ToolWindowAnchor.RIGHT) {
          InternalDecorator.this.setBounds(
              myLastPoint.x, 0, windowPane.getWidth() - myLastPoint.x, bounds.height);
        }
        InternalDecorator.this.validate();
        e.consume();
      }
Example #16
0
 public void mouseReleased(MouseEvent e) {
   for (int i = 0; i < iconRect.length; i++) {
     if (isMouseOverIcon[i]) {
       e.consume();
     }
   }
 }
 public void mouseEvt(MouseEvent evt) {
   if (evt.isPopupTrigger()) {
     propDialog.setVisible(true);
     propDialog.toFront();
     evt.consume();
   }
 }
 @Override
 public void mousePressed(MouseEvent e) {
   if (buttonVisible) {
     buttonPressed = true;
     e.consume();
   }
 }
Example #19
0
    protected void updateFocus(MouseEvent e, Point2D imagePoint, IcyCanvas canvas) {
      final boolean focused = isOver(canvas, imagePoint);

      ROI2D.this.setFocused(focused);
      // no need to go further as we can have only one selected instance
      if (focused) e.consume();
    }
  @Override
  protected void processMouseEvent(MouseEvent e) {
    switch (e.getID()) {
      case MouseEvent.MOUSE_PRESSED:
      case MouseEvent.MOUSE_RELEASED:
      case MouseEvent.MOUSE_CLICKED:
        if (isInFoldingArea(e)) {
          mousePressedInFoldingArea(e);
        } else if (isInTextArea(e)) {
          mousePressedInTextArea(e);
        } else {
          mousePressedInIconsArea(e);
        }
        if (!e.isConsumed()
            && e.getButton() == MouseEvent.BUTTON3
            && e.getID() == MouseEvent.MOUSE_PRESSED) {
          DefaultActionGroup actionGroup =
              ActionUtils.getDefaultGroup(MPSActions.EDITOR_LEFTPANEL_GROUP);
          if (actionGroup != null) {
            ActionPopupMenu popupMenu =
                ActionManager.getInstance()
                    .createActionPopupMenu(ActionPlaces.EDITOR_POPUP, actionGroup);
            popupMenu.getComponent().show(e.getComponent(), e.getX(), e.getY());
            e.consume();
          }
        }
    }

    // suppressing future event processig in case event was consumed by one of LeftHighlighter
    // elements
    if (!e.isConsumed()) {
      super.processMouseEvent(e);
    }
  }
Example #21
0
  public void mouseDragged(MouseEvent e) { // called during motion with buttons down

    ball.LaunchBall();

    e.consume();
    repaint();
  }
 @Override
 public void mouseClicked(MouseEvent e) {
   JTable table = (JTable) e.getSource();
   Point point = e.getPoint();
   int clickedRow = table.rowAtPoint(point);
   int clickedCol = table.columnAtPoint(point);
   if ((clickedCol == -1) || (clickedRow == -1)) {
     return;
   }
   if (table.getValueAt(clickedRow, clickedCol) instanceof StringUrl) {
     // retrieve the link to go to
     String sUrl = ((StringUrl) table.getValueAt(clickedRow, clickedCol)).getUrl();
     URL url;
     try {
       url = new URL(sUrl);
       log.debug("showing url for " + url);
       HtmlBrowser.URLDisplayer.getDefault().showURL(url);
       // prevent this from getting called again as it works it's way up the component stack
       e.consume();
     } catch (MalformedURLException ex) {
       StatusBar.getInstance()
           .setStatusText("\"" + sUrl + "\" is not a valid URL. Cannot open in browser.");
       log.warn(
           "\""
               + sUrl
               + "\" is not a valid URL. Cannot open in browser.\n\n"
               + ex.getLocalizedMessage());
     }
   }
 }
 public void mouseReleased(MouseEvent mouseEvent) {
   if (this.isArmed() && this.isUseRubberBand() && mouseEvent.getButton() == MouseEvent.BUTTON1) {
     if (this.isUseRubberBand() && measureTool.getPositions().size() == 1)
       measureTool.removeControlPoint();
     this.setActive(false);
     rubberBandTarget = null;
     // Disarm after second control point of a line or regular shape
     autoDisarm();
     mouseEvent.consume();
     measureTool.firePropertyChange(MeasureTool.EVENT_RUBBERBAND_STOP, null, null);
   } else if (this.isMoving() && mouseEvent.getButton() == MouseEvent.BUTTON1) {
     this.setMoving(false);
     this.movingTarget = null;
     mouseEvent.consume();
   }
 }
 @Override
 public final void mouseDragged(MouseEvent e) {
   if (start == null) {
     mousePressed(e);
   }
   mouseDragInProgress((GMouseEvent) e, start);
   e.consume();
 }
 @Override
 public final void mousePressed(MouseEvent e) {
   GMouseEvent gme = (GMouseEvent) e;
   start = gme.getGraphicLocation();
   mouseDragInitiated(gme, start);
   e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
   e.consume();
 }
 @Override
 public void mouseClicked(MouseEvent evt) {
   if (evt.getClickCount() == 2) {
     multicaster.trackDoubleClick(
         new Point(evt.getX(), evt.getY()), evt.getModifiersEx(), getView());
   }
   evt.consume();
 }
  public void mouseMoved(MouseEvent e) { // called during motion when no buttons are down

    mx = e.getX();
    my = e.getY();
    Graphics g = getGraphics();
    if (m_state == 0) showTooltip(g);
    e.consume();
  }
 @Override
 public void mouseReleased(MouseEvent e) {
   if (buttonPressed) {
     buttonPressed = false;
     changeFitMode();
     e.consume();
   }
 }
 private void mousePressedInTextArea(MouseEvent e) {
   if (e.isConsumed()) return;
   AbstractLeftColumn column = getTextColumnByX(e.getX());
   if (column != null) {
     column.mousePressed(e);
     e.consume();
   }
 }
    public void mouseClicked(MouseEvent e) {
      if (e.getClickCount() == 2) {
        actionListener.actionPerformed(
            new ActionEvent(this, ActionEvent.ACTION_PERFORMED, actionCommand));

        e.consume();
      }
    }