Package org.graphstream.ui.view

Examples of org.graphstream.ui.view.Camera


   * A key has been pressed.
   *
   * @param event  The event that generated the key.
   */
  public void keyPressed(KeyEvent event) {
    Camera camera = view.getCamera();

    if (event.getKeyCode() == KeyEvent.VK_PAGE_UP) {
      camera.setViewPercent(Math.max(0.0001f,
          camera.getViewPercent() * 0.9f));
    } else if (event.getKeyCode() == KeyEvent.VK_PAGE_DOWN) {
      camera.setViewPercent(camera.getViewPercent() * 1.1f);
    } else if (event.getKeyCode() == KeyEvent.VK_LEFT) {
      if ((event.getModifiers() & KeyEvent.ALT_MASK) != 0) {
        double r = camera.getViewRotation();
        camera.setViewRotation(r - 5);
      } else {
        double delta = 0;

        if ((event.getModifiers() & KeyEvent.SHIFT_MASK) != 0)
          delta = camera.getGraphDimension() * 0.1f;
        else
          delta = camera.getGraphDimension() * 0.01f;

        delta *= camera.getViewPercent();

        Point3 p = camera.getViewCenter();
        camera.setViewCenter(p.x - delta, p.y, 0);
      }
    } else if (event.getKeyCode() == KeyEvent.VK_RIGHT) {
      if ((event.getModifiers() & KeyEvent.ALT_MASK) != 0) {
        double r = camera.getViewRotation();
        camera.setViewRotation(r + 5);
      } else {
        double delta = 0;

        if ((event.getModifiers() & KeyEvent.SHIFT_MASK) != 0)
          delta = camera.getGraphDimension() * 0.1f;
        else
          delta = camera.getGraphDimension() * 0.01f;

        delta *= camera.getViewPercent();

        Point3 p = camera.getViewCenter();
        camera.setViewCenter(p.x + delta, p.y, 0);
      }
    } else if (event.getKeyCode() == KeyEvent.VK_UP) {
      double delta = 0;

      if ((event.getModifiers() & KeyEvent.SHIFT_MASK) != 0)
        delta = camera.getGraphDimension() * 0.1f;
      else
        delta = camera.getGraphDimension() * 0.01f;

      delta *= camera.getViewPercent();

      Point3 p = camera.getViewCenter();
      camera.setViewCenter(p.x, p.y + delta, 0);
    } else if (event.getKeyCode() == KeyEvent.VK_DOWN) {
      double delta = 0;

      if ((event.getModifiers() & KeyEvent.SHIFT_MASK) != 0)
        delta = camera.getGraphDimension() * 0.1f;
      else
        delta = camera.getGraphDimension() * 0.01f;

      delta *= camera.getViewPercent();

      Point3 p = camera.getViewCenter();
      camera.setViewCenter(p.x, p.y - delta, 0);
    }
  }
View Full Code Here

TOP

Related Classes of org.graphstream.ui.view.Camera

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.