Exemplo n.º 1
0
  /** Pastes Items from the Clipboard on the Board */
  public void paste() {

    ComponentSelection clipboardContent = (ComponentSelection) tbe.getClipboard().getContents(this);

    if ((clipboardContent != null)
        && (clipboardContent.isDataFlavorSupported(ComponentSelection.itemFlavor))) {

      Object[] tempItems = null;
      try {
        tempItems =
            board.cloneItems(clipboardContent.getTransferData(ComponentSelection.itemFlavor));
      } catch (UnsupportedFlavorException e1) {

        e1.printStackTrace();
      }
      ItemComponent[] items = new ItemComponent[tempItems.length];
      for (int i = 0; i < tempItems.length; i++) {
        items[i] = (ItemComponent) tempItems[i];
      }
      PasteCommand del = new PasteCommand(items);
      ArrayList<Command> actCommands = new ArrayList<Command>();
      actCommands.add(del);
      tbe.addCommands(actCommands);
      board.addItem(items);
    }
  }
Exemplo n.º 2
0
 /**
  * Add/Remove a Point to/from an Arrow
  *
  * @param b boolean, true = add, false = remove
  */
 public void addRemovePoint(boolean b) {
   if (board.getSelectionCount() == 1 && board.getSelectionCell() instanceof ArrowItem) {
     MoveCommand mc = new MoveCommand(board.getSelectedItems());
     ArrowItem a = (ArrowItem) board.getSelectionCell();
     if (b) {
       a.addPoint();
     } else {
       a.removePoint();
     }
     WorkingView.this.refresh();
     board.setSelectionCell(a);
     setTool(cursorTool, cursorButton);
     board.addItem(a);
     mc.setMoveEnd(board.getSelectedItems());
     ArrayList<Command> actCommands = new ArrayList<Command>();
     actCommands.add(mc);
     tbe.addCommands(actCommands);
   }
 }