Exemplo n.º 1
0
  /**
   * Defaults to typical marquee behaviour unless a flow relation is being drawn. In that case, each
   * drag event will redraw a line from the mouse cursor to the source port. If there is a valid
   * incoming port under the mouse, this will also be highlighted to identify that a valid flow may
   * be drawn upon a mouse release event.
   */
  public void mouseDragged(MouseEvent event) {
    if (paletteBar.getState() == Palette.SelectionState.MARQUEE) {
      super.mouseDragged(event);
      return;
    }

    if (state == State.DRAWING_FLOW_RELATION) {
      if (sourcePort != null) {
        setCurrentPoint(getNet().snap(event.getPoint()));
        paintPotentialFlow();
        PortView portUnderMouse = getPortViewAt(event.getPoint());
        if (portUnderMouse != null
            && portUnderMouse != sourcePort
            && connectionAllowable(sourcePort, portUnderMouse)
            && acceptsIncomingFlows(portUnderMouse)) {
          if (portUnderMouse != targetPort) {
            targetPort = portUnderMouse;
            getOverlay().setTarget(net.toScreen(targetPort.getBounds()));
          }
        }
        if (portUnderMouse == null) {
          targetPort = null;
          getOverlay().setTarget(null);
        }
      }
      event.consume();
    }
  }
Exemplo n.º 2
0
 protected void paintPort(PortView port, boolean show) {
   if (port != null) {
     Rectangle2D portBounds = net.toScreen(port.getBounds());
     getOverlay().setMouseOverPort(show ? portBounds : null);
     getOverlay().setScale(getNet().getScale());
     net.repaint(
         (int) portBounds.getX() - 1,
         (int) portBounds.getY() - 1,
         (int) portBounds.getWidth() + 2,
         (int) portBounds.getHeight() + 2);
   }
 }