Package edu.umd.cs.piccolo

Examples of edu.umd.cs.piccolo.PCamera


   * The mouse wheel is used to zoom in and out of the viewport and center on
   * the (x,y) position the mouse is currently on.
   */
  @Override
  public void mouseWheelRotated(PInputEvent e) {
    PCamera lc = svWindow.canvas.getCamera();
    double sf = SVWindow.SCALING_FACTOR;

    if (e.getWheelRotation() < 0) {
      sf = 1 / sf;
    }
    lc.scaleViewAboutPoint(lc.getScale() / sf, e.getPosition().getX(), e
        .getPosition().getY());
  }
View Full Code Here


    // Add a Scrollpane to be able to scroll within the canvas
    PScrollPane scrollPane = new PScrollPane(canvas);
    getContentPane().add(scrollPane);
    scrollPane.setWheelScrollingEnabled(false);
    PCamera lc = canvas.getCamera();
    lc.scaleViewAboutPoint(initialScalingfactor, 0, 0);

    // Disable the default event handlers and add our own.
    addWindowListener(svEventHandler);
    canvas.removeInputEventListener(canvas.getPanEventHandler());
    canvas.removeInputEventListener(canvas.getZoomEventHandler());
View Full Code Here

      // all the way around.
      int wmargin = width / 2;
      int hmargin = height / 2;
      double scalefactor = Math.min(winSizeX / (2.0 * wmargin + width),
                                    winSizeY / (2.0 * hmargin + height));
      PCamera lc = canvas.getCamera();
      lc.scaleView(scalefactor / lc.getViewScale());
      lc.animateViewToPanToBounds(new Rectangle(x1 - hmargin, y1 - hmargin,
                                                2 * wmargin + width,
                                                2 * hmargin + height), 0);
    }
  }
View Full Code Here

    int rotationAmount = event.getWheelRotation() * -1;

    double scaleDelta = 1 + (0.2 * rotationAmount);

    PCamera camera = event.getCamera();
    double currentScale = camera.getViewScale();
    double newScale = currentScale * scaleDelta;

    if (newScale < WorldSky.MIN_ZOOM_SCALE) {
      scaleDelta = WorldSky.MIN_ZOOM_SCALE / currentScale;
    }
View Full Code Here

   */
  protected void dragActivityStep(PInputEvent aEvent) {
    if (!getAutopan())
      return;

    PCamera c = aEvent.getCamera();
    PBounds b = c.getBoundsReference();
    Point2D l = aEvent.getPositionRelativeTo(c);
    int outcode = b.outcode(l);
    PDimension delta = new PDimension();

    if ((outcode & Rectangle.OUT_TOP) != 0) {
      delta.height = validatePanningSpeed(-1.0
          - (0.5 * Math.abs(l.getY() - b.getY())));
    } else if ((outcode & Rectangle.OUT_BOTTOM) != 0) {
      delta.height = validatePanningSpeed(1.0 + (0.5 * Math.abs(l.getY()
          - (b.getY() + b.getHeight()))));
    }

    if ((outcode & Rectangle.OUT_RIGHT) != 0) {
      delta.width = validatePanningSpeed(1.0 + (0.5 * Math.abs(l.getX()
          - (b.getX() + b.getWidth()))));
    } else if ((outcode & Rectangle.OUT_LEFT) != 0) {
      delta.width = validatePanningSpeed(-1.0
          - (0.5 * Math.abs(l.getX() - b.getX())));
    }

    c.localToView(delta);

    if (delta.width != 0 || delta.height != 0) {
      if (isInverted) {
        c.translateView(-1 * delta.width, -1 * delta.height);
      } else {
        c.translateView(delta.width, delta.height);
      }
    }
   
    // Loop through selected objects, compensate for camera panning
    // so that objects will remain stationary relative to cursor
View Full Code Here

TOP

Related Classes of edu.umd.cs.piccolo.PCamera

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.