Esempio n. 1
0
 /**
  * Scales the view about the center of the canvas.
  *
  * @param scale the amount to scale
  */
 private void scaleViewAboutPoint(double scale) {
   Rectangle canvasBounds = graph.getCanvas().getBounds();
   graph
       .getCanvas()
       .getCamera()
       .scaleViewAboutPoint(scale, canvasBounds.getCenterX(), canvasBounds.getCenterY());
 }
Esempio n. 2
0
 /**
  * Controls which direction to pan the canvas.
  *
  * @param dir integer representing the direction to pan
  */
 private void pan(int dir) {
   int amount = 15;
   if (dir == LEFT) {
     graph.getCanvas().getCamera().translateView(-amount, 0);
   } else if (dir == RIGHT) {
     graph.getCanvas().getCamera().translateView(amount, 0);
   } else if (dir == UP) {
     graph.getCanvas().getCamera().translateView(0, -amount);
   } else if (dir == DOWN) {
     graph.getCanvas().getCamera().translateView(0, amount);
   }
 }
Esempio n. 3
0
  /** {@inheritDoc} */
  public void keyReleased(PInputEvent event) {

    if (event.getKeyCode() == KeyEvent.VK_SHIFT) {
      press[0] = false;
    }

    if (event.getKeyCode() == KeyEvent.VK_UP) {
      press[1] = false;
    }

    if (event.getKeyCode() == KeyEvent.VK_DOWN) {
      press[2] = false;
    }

    if (event.getKeyCode() == KeyEvent.VK_R) {
      press[3] = false;
    }

    if (event.getKeyCode() == KeyEvent.VK_CONTROL) {
      press[4] = false;
    }

    if (event.getKeyCode() == KeyEvent.VK_C) {
      press[5] = false;
    }

    if (event.getKeyCode() == KeyEvent.VK_LEFT) {
      press[6] = false;
    }

    if (event.getKeyCode() == KeyEvent.VK_RIGHT) {
      press[7] = false;
    }

    if (event.getKeyCode() == KeyEvent.VK_V) {
      press[8] = false;
    }

    if (event.getKeyCode() == KeyEvent.VK_O) {
      press[9] = false;
    }

    if (event.getKeyCode() == KeyEvent.VK_D) {
      press[10] = false;
    }

    if (!press[0] || !press[10]) {
      GraphBuilder.setDeleteMode(false);
    }
  }
Esempio n. 4
0
  /** {@inheritDoc} */
  public void keyPressed(PInputEvent event) {

    if (event.getKeyCode() == KeyEvent.VK_SHIFT) {
      press[0] = true;
    }

    if (event.getKeyCode() == KeyEvent.VK_UP) {
      press[1] = true;
    }

    if (event.getKeyCode() == KeyEvent.VK_DOWN) {
      press[2] = true;
    }

    if (event.getKeyCode() == KeyEvent.VK_R) {
      press[3] = true;
    }

    if (event.getKeyCode() == KeyEvent.VK_CONTROL) {
      press[4] = true;
    }

    if (event.getKeyCode() == KeyEvent.VK_C) {
      press[5] = true;
    }

    if (event.getKeyCode() == KeyEvent.VK_LEFT) {
      press[6] = true;
    }

    if (event.getKeyCode() == KeyEvent.VK_RIGHT) {
      press[7] = true;
    }

    if (event.getKeyCode() == KeyEvent.VK_V) {
      press[8] = true;
    }

    if (event.getKeyCode() == KeyEvent.VK_O) {
      press[9] = true;
    }

    if (event.getKeyCode() == KeyEvent.VK_D) {
      press[10] = true;
    }

    if (press[0] && press[1]) {
      zoomIn();
    } else if (press[1]) {
      pan(UP);
    }
    if (press[0] && press[2]) {
      zoomOut();
    } else if (press[2]) {
      pan(DOWN);
    }
    if (press[0] && press[8]) {
      graph.switchCanvas();
    }
    if (press[0] && press[3]) {
      if (graph.getCurOp().equals("efg")) {
        graph.resetEFGView();
      } else {
        graph.resetTestView();
      }
    }
    if (press[4] && press[5]) {
      System.exit(0);
    }
    if (press[6]) {
      pan(LEFT);
    }
    if (press[7]) {
      pan(RIGHT);
    }
    if (press[4] && press[9]) {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              GUIBuilder.createAndShowGUI();
            }
          });
      graph.setVisible(false);
      graph.dispose();
    }
    if (press[0] && press[10]) {
      GraphBuilder.setDeleteMode(true);
    }
  }