Esempio n. 1
0
  protected void initializeEventHandlers() {
    // Add a FNode Selection Handler
    nodeSelectionHandler =
        new PNodeSelectionHandler(
            this, getCanvas().getLayer(), getNodeLayer(), getCanvas().getCamera());
    nodeSelectionHandler.setEventFilter(new PInputEventFilter(InputEvent.BUTTON1_MASK));
    // Add an FEdge Selection Handler
    edgeSelectionHandler =
        new PEdgeSelectionHandler(
            this, getCanvas().getLayer(), getEdgeLayer(), getCanvas().getCamera());
    edgeSelectionHandler.setEventFilter(new PInputEventFilter(InputEvent.BUTTON1_MASK));

    // Only allow panning via Middle Mouse button
    getCanvas().getPanEventHandler().setEventFilter(new PInputEventFilter(InputEvent.BUTTON2_MASK));

    PZoomEventHandler zoomer = new MyZoomEventHandler();
    zoomer.setMinScale(.15);
    zoomer.setMaxScale(7);
    getCanvas().setZoomEventHandler(zoomer);

    edgeHandler = new PEdgeHandler(this);
    getCanvas().addInputEventListener(edgeHandler);

    // add the tool tip handler
    toolTipHandler = new PToolTipHandler(getCanvas().getCamera());
    getCanvas().getCamera().addInputEventListener(toolTipHandler);
    // create the Squiggle handler
    squiggleEventHandler = new SquiggleEventHandler(squiggleLayer, getCanvas(), this);
    ContextMenuHelper ctxMenuHandler = new ContextMenuHelper(this);
    ctxMenuHandler.setEventFilter(new PInputEventFilter(InputEvent.BUTTON3_MASK));
    getCanvas().addInputEventListener(ctxMenuHandler);
  }
Esempio n. 2
0
 @Override
 public void mouseDragged(PInputEvent e) {
   // some node is under the mouse
   if (e.getPath().getNodeStackReference().size() > 1) return;
   e.getComponent().setInteracting(true);
   super.mouseDragged(e);
   if (original != null) doZoom(original, e);
 }