Beispiel #1
0
  public void mouseWheelMoved(MouseWheelEvent e) {
    if (isOSX) {
      return;
    }
    int notches = e.getWheelRotation();

    if (false) {
      if (notches < 0) {
        child.zoomToCursor(child.getPctZoom() * 21 / 20, e.getPoint());
      } else {
        child.zoomToCursor(child.getPctZoom() * 20 / 21, e.getPoint());
      }

      Component comp = container.getParent().getParent();
      if (comp instanceof MainPanel) ((MainPanel) comp).updateZoomCombo();
    }

    boolean horizontalScroll =
        ((e.getModifiers() & ActionEvent.SHIFT_MASK) == ActionEvent.SHIFT_MASK)
            || ((e.getModifiers() & ActionEvent.META_MASK) == ActionEvent.META_MASK);

    Rectangle r = container.getViewport().getViewRect();
    int newx = Math.min((int) r.getMinX() + (horizontalScroll ? notches : 0), 0);
    int newy = Math.min((int) r.getMinY() + (horizontalScroll ? 0 : notches), 0);
    scrollTo(newx, newy);
  }
  @Override
  public void mouseWheelMoved(MouseWheelEvent e) {
    super.mouseWheelMoved(e);

    int v = e.getWheelRotation() > 0 ? 1 : -1;

    float zoomFact = 1.05f;
    double cx = camera.pos.getX();
    double cy = camera.pos.getY();

    cx -= e.getPoint().x;
    cy -= e.getPoint().y;

    if (v < 0) {
      camera.scale *= zoomFact;
      cx *= zoomFact;
      cy *= zoomFact;
    } else {
      camera.scale /= zoomFact;
      cx /= zoomFact;
      cy /= zoomFact;
    }

    cx += e.getPoint().x;
    cy += e.getPoint().y;

    camera.pos.set(cx, cy);
    camera.proot.updateThis();
  }
Beispiel #3
0
    public void mouseWheelMoved(MouseWheelEvent e) {
      int amount = e.getWheelRotation();

      Point2D p = new Point2D.Double(e.getPoint().getX(), e.getPoint().getY());

      if (amount > 0) zoomOut(p);
      if (amount < 0) zoomIn(p);
    }
Beispiel #4
0
  /**
   * This mouse wheel listener reacts when a scroll is carried out over the tab strip and scrolls
   * one tab/down or up, selecting it immediately.
   */
  @Override
  public void mouseWheelMoved(MouseWheelEvent wev) {
    // Ensure the cursor is over the tab strip
    if (super.indexAtLocation(wev.getPoint().x, wev.getPoint().y) < 0) return;

    // Get currently selected tab
    int newTab = super.getSelectedIndex() + wev.getWheelRotation();

    // Ensure the new tab index is sound
    newTab = newTab < 0 ? 0 : newTab;
    newTab = newTab >= super.getTabCount() ? super.getTabCount() - 1 : newTab;

    // select new tab
    super.setSelectedIndex(newTab);
  }
Beispiel #5
0
  /**
   * Handle the case where a plot implements the {@link Zoomable} interface.
   *
   * @param zoomable the zoomable plot.
   * @param e the mouse wheel event.
   */
  private void handleZoomable(Zoomable zoomable, MouseWheelEvent e) {
    // don't zoom unless the mouse pointer is in the plot's data area
    ChartRenderingInfo info = this.chartPanel.getChartRenderingInfo();
    PlotRenderingInfo pinfo = info.getPlotInfo();
    Point2D p = this.chartPanel.translateScreenToJava2D(e.getPoint());
    if (!pinfo.getDataArea().contains(p)) {
      return;
    }

    Plot plot = (Plot) zoomable;
    // do not notify while zooming each axis
    boolean notifyState = plot.isNotify();
    plot.setNotify(false);
    int clicks = e.getWheelRotation();
    double zf = 1.0 + this.zoomFactor;
    if (clicks < 0) {
      zf = 1.0 / zf;
    }
    if (chartPanel.isDomainZoomable()) {
      zoomable.zoomDomainAxes(zf, pinfo, p, true);
    }
    if (chartPanel.isRangeZoomable()) {
      zoomable.zoomRangeAxes(zf, pinfo, p, true);
    }
    plot.setNotify(notifyState); // this generates the change event too
  }
 @Override
 public void mouseWheelMoved(MouseWheelEvent e) {
   int rotation = -e.getWheelRotation();
   if (rotation < 0) {
     MainCycle.drawPanel.setBackground(MyMouseClickListener.pickAColor(e.getPoint()));
     MainCycle.drawPanel.repaint();
   }
 }
 /**
  * Overrides method from MouseWheelListener to ensure that the screen is scaled suitably when
  * zooming in and out. Method will capture the number of notches the mouse wheel was moved by, and
  * then invoke scaleScreen. Positive inputs (scroll down) decrease the scale of the screen, and
  * negative inputs (scroll up) increase it.
  */
 @Override
 public void mouseWheelMoved(MouseWheelEvent e) {
   Point mousePos =
       SwingUtilities.convertPoint(
           this, e.getPoint(), this); // get current mouse position relative to this pane
   int wheelMovedBy = e.getWheelRotation(); // number of notches moved in the mouse wheel
   scaleScreen(wheelMovedBy);
 }
 public void mouseWheelMoved(MouseWheelEvent e) {
   Point p = e.getPoint();
   boolean zoomIn = (e.getWheelRotation() < 0);
   if (isInNavigationImage(p)) {
     if (zoomIn) {
       navZoomFactor = 1.0 + zoomIncrement;
     } else {
       navZoomFactor = 1.0 - zoomIncrement;
     }
     zoomNavigationImage();
   } else if (isInImage(p)) {
     if (zoomIn) {
       zoomFactor = 1.0 + zoomIncrement;
     } else {
       zoomFactor = 1.0 - zoomIncrement;
     }
     zoomImage();
   }
 }
Beispiel #9
0
  /**
   * It zooms in and out as the user uses the mousewheel. The mouse stays pointing in the same map
   * coordinates
   *
   * @param ev
   */
  private void handleMouseWheelEvent(MouseWheelEvent ev) {
    if (this.IsRendering()) {
      return;
    }
    double zoomFactor = 0.5;
    int clicks = ev.getWheelRotation();
    // -ve means wheel moved up, +ve means down
    int sign = (clicks > 0 ? -1 : 1);

    zoomFactor = sign * zoomFactor / 2;

    Point2D mouseMapPointPos = this.getPointInMap(ev.getPoint());

    ReferencedEnvelope env = this.getDisplayArea();

    double width = env.getSpan(0);
    double height = env.getSpan(1);
    double newWidth = width - (width * zoomFactor);
    double newHeight = height - (height * zoomFactor);

    double centerX = env.getMedian(0);
    double centerY = env.getMedian(1);

    double distanceMouseCenterAlongX = mouseMapPointPos.getX() - centerX;
    double distanceMouseCenterAlongY = mouseMapPointPos.getY() - centerY;
    centerX += distanceMouseCenterAlongX * zoomFactor;
    centerY += distanceMouseCenterAlongY * zoomFactor;

    double newMinX = centerX - newWidth / 2;
    double newMinY = centerY - newHeight / 2;
    double newMaxX = centerX + newWidth / 2;
    double newMaxY = centerY + newHeight / 2;
    env =
        new ReferencedEnvelope(
            newMinX, newMaxX, newMinY, newMaxY, env.getCoordinateReferenceSystem());

    this.setDisplayArea(env);
    // this.refresh();
  }
  @Override
  public void mouseWheelMoved(MouseWheelEvent evt) {
    Point current = evt.getPoint();
    Rectangle bound = viewer.getViewportBounds();

    double dx = current.x - bound.width / 2;
    double dy = current.y - bound.height / 2;

    Dimension oldMapSize = viewer.getTileFactory().getMapSize(viewer.getZoom());

    viewer.setZoom(viewer.getZoom() + evt.getWheelRotation());

    Dimension mapSize = viewer.getTileFactory().getMapSize(viewer.getZoom());

    Point2D center = viewer.getCenter();

    double dzw = (mapSize.getWidth() / oldMapSize.getWidth());
    double dzh = (mapSize.getHeight() / oldMapSize.getHeight());

    double x = center.getX() + dx * (dzw - 1);
    double y = center.getY() + dy * (dzh - 1);

    viewer.setCenter(new Point2D.Double(x, y));
  }
Beispiel #11
0
 @Override
 public void mouseWheelMoved(MouseWheelEvent e) {
   Point2D point = e.getPoint();
   panel.zoom(point, -e.getWheelRotation());
 }
  public void mouseWheelMoved(MouseWheelEvent e) {
    if (enabled && !readOnly) {
      if (timer != null && timer.isRunning()) {
        timer.stop();
      }
      if (enableMouseWheel) {
        int count = 1;
        MouseWheelEvent e2;

        long lastEventTime = e.getWhen();
        int steps = 0;
        int r;

        // This cycle is to determine multiple clicks like double wheel, triple wheel event etc.
        // We go through the vector of events and check whether there are events corresponding to
        // multiple events.
        for (int i = 0; i < events.size() && events.get(i) instanceof MouseWheelEvent; i++) {
          e2 = (MouseWheelEvent) events.get(i);

          // The events are considered to be a multiple click when:
          // 1. Coordinates are equal
          // 2. Modifiers are equal
          // 3. Both events are wheel up or down
          // 4. Delay between two subsequent clicks is lower than given number of miliseconds
          r = e2.getWheelRotation();
          if (e2.getX() == e.getX()
              && e2.getY() == e.getY()
              && e2.getModifiers() == e.getModifiers()
              && (lastEventTime - e2.getWhen() < mouseMultiDelay)
              && e2.getID() == e.getID()
              && ((r > 0 && e.getWheelRotation() > 0) || (r < 0 && e.getWheelRotation() < 0))) {
            count++;
            lastEventTime = e2.getWhen();
            steps += Math.abs(r);
          } else {
            break;
          }
        }

        steps += Math.abs(e.getWheelRotation());

        // Generate the command string
        String s =
            "Mouse "
                + (e.getWheelRotation() > 0
                    ? MouseCommand.MOUSE_WHEEL_DOWN
                    : MouseCommand.MOUSE_WHEEL_UP);

        // Insert modifiers if there are any
        String modifiers = parser.modifiersToString(e.getModifiers());
        if (modifiers.length() > 0) {
          s += " " + MouseCommand.PARAM_MODIFIER + "=" + modifiers;
        }

        // Generate the count parameter
        if (count > 1) {
          s += " " + MouseCommand.PARAM_COUNT + "=" + Math.abs(steps);
        }

        // This will determine whether this event is preceded by a mouse move command with the same
        // coordinates.
        // It will be replaced if yes.
        boolean replaceLastMove = false;
        if (enableMouseMoves) {
          if (events.size() > 0 && events.get(events.size() - 1) instanceof MouseEvent) {
            MouseEvent me = (MouseEvent) events.get(events.size() - 1);
            if (me.getID() == MouseEvent.MOUSE_MOVED
                && e.getX() == me.getX()
                && e.getY() == me.getY()) {
              replaceLastMove = true;
            }
          }
        }

        // Generate coordinates
        s += " " + MouseCommand.PARAM_TO + "=" + parser.pointToString(e.getPoint());

        // Insert the command to the current editor
        insertLine(s, count > 1 || replaceLastMove, true, false);
        dragInProgress = false;
      }
      insertEvent(e);
    }
  }
 /*
  * Zoom in/out proportional to the number of clicks of the mouse wheel.
  */
 public void mouseWheelMoved(MouseWheelEvent e) {
   double f = e.getWheelRotation() * 0.2;
   zoom(f, e.getPoint());
 }
 @Override
 public void mouseWheelMoved(MouseWheelEvent e) {
   mUIModel.zoomAt(-e.getWheelRotation(), e.getPoint());
 }