/**
   * Defaults to typical marquee behaviour when the marquee palette button is selected. Otherwise,
   * if there is nothing under the mouse upon a mouse press a new net element will be added. If
   * there is a vertex or condition under the mouse this method will not be invoked , relying
   * instead on the default behaviour of {@link BasicMarqueeHandler}, which is typically to begin a
   * select/drag operation on the element. If there is a valid outgoing flow under the mouse, this
   * is a trigger to begin drawing a flow relation.
   */
  public void mousePressed(MouseEvent event) {
    if (SwingUtilities.isRightMouseButton(event)
        || paletteBar.getState() == Palette.SelectionState.MARQUEE) {
      super.mousePressed(event);
      return;
    }

    State oldState = state;
    switch (oldState) {
      case ABOVE_VERTEX:
        {
          state = State.DRAGGING_VERTEX;
          break;
        }
      case ABOVE_OUTGOING_PORT:
        {
          state = State.DRAWING_FLOW_RELATION;
          getNet().setCursor(CursorFactory.getCustomCursor(CursorFactory.HIDDEN));
          break;
        }
      case ABOVE_CANVAS:
        {
          Point2D snapPoint = getNearestSnapPoint(event.getPoint());
          state = State.ABOVE_VERTEX;
          switch (paletteBar.getState()) {
            case CONDITION:
              {
                NetCellFactory.insertCondition(getNet(), snapPoint);
                break;
              }
            case ATOMIC_TASK:
              {
                NetCellFactory.insertAtomicTask(getNet(), snapPoint);
                break;
              }
            case MULTIPLE_ATOMIC_TASK:
              {
                NetCellFactory.insertMultipleAtomicTask(getNet(), snapPoint);
                break;
              }
            case COMPOSITE_TASK:
              {
                NetCellFactory.insertCompositeTask(getNet(), snapPoint);
                break;
              }
            case MULTIPLE_COMPOSITE_TASK:
              {
                NetCellFactory.insertMultipleCompositeTask(getNet(), snapPoint);
                break;
              }
          }
          break;
        }
    }
    doStateTransitionProcessing(event.getPoint(), oldState, state);
  }
 private void matchCursorTo(int cursorType) {
   getNet().setCursor(CursorFactory.getCustomCursor(cursorType));
   paletteBar.refreshSelected();
 }