Esempio n. 1
0
  public void onClick(InputEventInfo ev) {
    super.onClick(ev);

    final JFileChooser fc = new JFileChooser();
    fc.setFileFilter(new ImageFileFilter());
    int returnVal =
        fc.showOpenDialog(
            CCanvasController.canvasdb.get(CCanvasController.getCurrentUUID()).getComponent());

    if (returnVal == JFileChooser.APPROVE_OPTION) {
      File file = fc.getSelectedFile();
      Networking.send(
          CImageController.getImageTransferPacket(
              Calico.uuid(),
              CCanvasController.getCurrentUUID(),
              BubbleMenu.lastOpenedPosition.x,
              BubbleMenu.lastOpenedPosition.y,
              file));
    }
    //		if (this.uuid != 0l && new_uuid != 0l &&
    // CGroupController.groupdb.get(new_uuid).getParentUUID() == 0l)
    //		{
    //			CGroupController.move_start(new_uuid);
    //			CGroupController.move_end(new_uuid, ev.getX(), ev.getY());
    //		}
  }
 public void onClick(InputEventInfo ev) {
   // confirm with the user?
   // get the canvas ID
   long canvasClicked = CCanvasController.getCanvasAtPoint(PieMenu.lastOpenedPosition);
   CGrid.getInstance().deleteCanvas(canvasClicked);
   CCanvasController.lock_canvas(
       canvasClicked, false, "clean canvas action", (new Date()).getTime());
 }
 /**
  * Discern whether teh scrap <code>groupId</code> exists in the currently displayed canvas (if
  * any).
  */
 private boolean isCurrentlyDisplayed(long groupId) {
   if (!CanvasPerspective.getInstance().isActive()) {
     return false;
   }
   return (CGroupController.groupdb.get(groupId).getCanvasUID()
       == CCanvasController.getCurrentUUID());
 }
 public void onClick(InputEventInfo ev) {
   // confirm with the user?
   // get the canvas ID
   long canvasClicked = CCanvasController.getCanvasAtPoint(PieMenu.lastOpenedPosition);
   if (canvasClicked != 0l) {
     CGrid.canvasAction = CGrid.CUT_CANVAS;
     CGrid.getInstance().drawSelectedCell(canvasClicked, ev.getX(), ev.getY());
   }
 }
Esempio n. 5
0
  public void delete() {
    // Remove all elements
    ComposableElementController.no_notify_removeAllElements(this.uuid);

    // remove from canvas
    CCanvasController.no_notify_delete_child_connector(this.canvasUID, this.uuid);

    // Remove from groups
    CGroupController.no_notify_delete_child_connector(this.getAnchorUUID(TYPE_HEAD), uuid);
    CGroupController.no_notify_delete_child_connector(this.getAnchorUUID(TYPE_TAIL), uuid);

    if (CCanvasController.canvas_has_child_connector_node(this.canvasUID, uuid)) {
      // This line is not thread safe so must invokeLater to prevent eraser artifacts.
      /*SwingUtilities.invokeLater(
      		new Runnable() { public void run() { removeFromParent(); } }
      );*/
      CalicoDraw.removeNodeFromParent(this);
      // removeFromParent();
    }
  }
Esempio n. 6
0
  public void actionMouseClicked(InputEventInfo event) {
    if (event.getAction() == InputEventInfo.ACTION_PRESSED) {
      super.onMouseDown();
    } else if (event.getAction() == InputEventInfo.ACTION_RELEASED && isPressed) {
      // Networking.send(CalicoPacket.getPacket(NetworkCommand.CANVAS_REDO, cuid));
      Calico.logger.debug("Pressed Color button " + color.toString());
      CalicoDataStore.PenColor = color;
      CalicoDataStore.LastDrawingColor = color;

      if (CalicoDataStore.Mode != CInputMode.ARROW) CalicoDataStore.set_Mode(CInputMode.EXPERT);
      CCanvasController.redrawMenuBars();
      isPressed = false;
    }
  }
    private void positionLeft(PNode node, double width, double height) {
      double x =
          X_MARGIN
              + CalicoOptions.menu.menubar.defaultIconDimension
              + (CalicoOptions.menu.menubar.iconBuffer * 2);
      double y = Y_MARGIN;

      peers.clear();
      PBounds bounds = new PBounds(x, y, width, height);

      CCanvas canvas = CCanvasController.canvasdb.get(CCanvasController.getCurrentUUID());
      if (canvas != null) {
        canvas.getCamera().findIntersectingNodes(bounds, peers);
        peers.remove(node);
        for (int i = (peers.size() - 1); i >= 0; i--) {
          PNode peer = (PNode) peers.get(i);
          if ((peer instanceof PCamera)
              || (peer instanceof BubbleMenuContainer)
              || !peer.getVisible()) {
            peers.remove(i);
          } else {
            while (peer != null) {
              if ((peer instanceof BubbleMenuContainer) || (peer == node) || !peer.getVisible()) {
                peers.remove(i);
                break;
              }
              peer = peer.getParent();
            }
          }
        }

        for (Object peer : peers) {
          PBounds peerArea = ((PNode) peer).getBounds();
          if (peerArea.intersects(bounds)) {
            double unobstructedPosition = peerArea.getY() + peerArea.getHeight() + Y_MARGIN;
            if (unobstructedPosition > y) {
              y = unobstructedPosition;
              bounds.setOrigin(x, y);
            }
          }
        }
      }

      node.setBounds(bounds);
    }
    private void positionRight(PNode node, double width, double height) {
      double x =
          CalicoDataStore.ScreenWidth
              - (X_MARGIN
                  + (CalicoOptions.menu.menubar.defaultIconDimension
                      + (CalicoOptions.menu.menubar.iconBuffer * 2))
                  + width);
      double y = Y_MARGIN;

      peers.clear();
      PBounds bounds = new PBounds(x, y, width, height);

      CCanvas canvas = CCanvasController.canvasdb.get(CCanvasController.getCurrentUUID());
      if (canvas != null) {
        canvas.getCamera().findIntersectingNodes(bounds, peers);
        peers.remove(node);
        for (int i = (peers.size() - 1); i >= 0; i--) {
          PNode peer = (PNode) peers.get(i);
          if ((peer instanceof PCamera) || peer.isDescendentOf(node)) {
            peers.remove(i);
          }
        }

        for (Object peer : peers) {
          PBounds peerArea = ((PNode) peer).getBounds();
          if (peerArea.intersects(bounds)) {
            double unobstructedPosition = peerArea.getX() - (X_MARGIN + width);
            if (unobstructedPosition < x) {
              x = unobstructedPosition;
              bounds.setOrigin(x, y);
            }
          }
        }
      }

      node.setBounds(bounds);
    }
 /**
  * Notify the <code>CCanvasController</code> that some change has been made to <code>canvasId
  * </code>.
  */
 public void notifyContentChanged(long canvasId) {
   CCanvasController.notifyContentChanged(this, canvasId);
 }
 private IntentionalInterfacesCanvasContributor() {
   CCanvasController.addContentContributor(this);
 }