Package CH.ifa.draw.framework

Examples of CH.ifa.draw.framework.Figure


   */
  public boolean canCopy()
  {
    for (FigureEnumeration fe = workspaceView.selectionElements(); fe.hasMoreElements();)
    {
      Figure next = fe.nextFigure();

      if (next instanceof NodeFigure || next instanceof TextElementFigure || next instanceof SocketFigure || next instanceof ParamFigure)
        return true;
    }

View Full Code Here


   */
  public boolean canDelete()
  {
    for (FigureEnumeration fe = workspaceView.selectionElements(); fe.hasMoreElements();)
    {
      Figure next = fe.nextFigure();

      if (next instanceof NodeFigure)
      {
        if (! socketsAndParamsOnly)
          return true;
View Full Code Here

      // Socket that contains the selected parameters
      NodeSocket paramHolder = null;

      for (FigureEnumeration fe = workspaceView.selectionElements(); fe.hasMoreElements();)
      {
        Figure next = fe.nextFigure();

        if (next instanceof NodeFigure)
        {
          NodeFigure nodeFigure = (NodeFigure) next;
          nodeFigure.encodeGeometry();

          Node node = nodeFigure.getNode();

          // Remember that we have copied this one
          copiedSourceNodes.add(node);

          // Clone the node and add it to the process
          node = (Node) node.clone();
          process.addNode(node);

          copyFlavor = ClientFlavors.PROCESS_ITEM;
        }

        else if (next instanceof TextElementFigure)
        {
          TextElementFigure textElementFigure = (TextElementFigure) next;
          textElementFigure.encodeGeometry();

          TextElement textElement = textElementFigure.getTextElement();

          // Clone the element and add it to the process
          textElement = (TextElement) textElement.clone();
          process.addTextElement(textElement);

          copyFlavor = ClientFlavors.PROCESS_ITEM;
        }

        else if (next instanceof SocketFigure)
        {
          SocketFigure socketFigure = (SocketFigure) next;
          socketFigure.encodeGeometry();

          NodeSocket socket = socketFigure.getNodeSocket();

          if (socketHolder == null)
          {
            socketHolder = new ActivityNodeImpl();
            socketHolder.setName("NodeDummy");
            process.addNode(socketHolder);
          }

          // Clone the socketand add it to the dummy node
          socket = (NodeSocket) socket.clone();
          socketHolder.addSocket(socket);

          copyFlavor = ClientFlavors.NODE_SOCKETS;
        }

        else if (next instanceof ParamFigure)
        {
          ParamFigure paramFigure = (ParamFigure) next;

          NodeParam param = paramFigure.getNodeParam();

          if (paramHolder == null)
          {
            if (socketHolder == null)
            {
              socketHolder = new ActivityNodeImpl();
              socketHolder.setName("NodeDummy");
              process.addNode(socketHolder);
            }

            paramHolder = new NodeSocketImpl();
            paramHolder.setName("SocketDummy");
            socketHolder.addSocket(paramHolder);
          }

          // Clone the socket and add it to the dummy node
          param = (NodeParam) param.clone();
          paramHolder.addParam(param, - 1);

          copyFlavor = ClientFlavors.NODE_PARAMS;
        }
      }

      // When copying a link, we perform the following steps:
      // 1. Encode the geometry
      // 2. Generate reference names from the actual object references
      //    (e. g. node names for control links, parameter names for data links etc.)
      // 3. Clone the object
      // 4. Add the cloned object to the dummy process
      // 5. Re-establish the object references (now based on the elements of the dummy process)
      //    If this fails, the object will be removed from the dummy process again.

      StandardMsgContainer msgContainer = ModelConnector.getInstance().getMsgContainer();
      msgContainer.clearMsgs();

      for (FigureEnumeration fe = workspaceView.selectionElements(); fe.hasMoreElements();)
      {
        Figure next = fe.nextFigure();

        if (next instanceof FlowConnection)
        {
          FlowConnection flowConnection = (FlowConnection) next;
View Full Code Here

  /**
   * Deletes the current selection.
   */
  public void delete()
  {
    Figure selection = null;

    // Delete all elements, try to determine which element to select after the delete.
    // E. g. when deleting a node socket, the node it belongs to will be selected.
    boolean hasSelected = false;
    for (FigureEnumeration fe = workspaceView.selectionElements(); fe.hasMoreElements();)
    {
      Figure next = fe.nextFigure();

      if (!hasSelected)
      {
        if (next instanceof ProcessElementContainer)
        {
View Full Code Here

    NamedObjectCollectionUtil.createUniqueNames(source.getControlLinkList(), target.getControlLinkList());

    // Update the reference names according to the changed object names
    source.maintainReferences(ModelObject.SYNC_LOCAL_REFNAMES);

    Figure firstFigure = null;

    // Add the nodes to the target process
    for (Iterator it = source.getNodes(); it.hasNext();)
    {
      Node node = (Node) it.next();

      target.addNode(node);

      // Rebuild the references after adding the object to the target
      node.maintainReferences(ModelObject.SYNC_GLOBAL_REFNAMES);

      NodeFigure nodeFigure = drawing.createNodeFigure(node);
      if (nodeFigure == null)
      {
        target.removeNode(node);
        continue;
      }

      if (firstFigure == null)
        firstFigure = nodeFigure;

      workspaceView.add(nodeFigure);
      workspaceView.addToSelection(nodeFigure);

      // Position the new node within the process drawing so that it doesn't hide an existing figure
      ModelerUtil.preventOverlap(drawing, nodeFigure);
    }

    // Add the text elements to the target process
    for (Iterator it = source.getTextElements(); it.hasNext();)
    {
      TextElement textElement = (TextElement) it.next();

      target.addTextElement(textElement);

      // Rebuild the references after adding the object to the target
      textElement.maintainReferences(ModelObject.SYNC_GLOBAL_REFNAMES);

      TextElementFigure textElementFigure = drawing.createTextElementFigure(textElement);
      if (textElementFigure == null)
      {
        target.removeTextElement(textElement);
        continue;
      }

      if (firstFigure == null)
        firstFigure = textElementFigure;

      workspaceView.add(textElementFigure);
      workspaceView.addToSelection(textElementFigure);

      // Position the new element within the process drawing so that it doesn't hide an existing figure
      ModelerUtil.preventOverlap(drawing, textElementFigure);
    }

    // Add the control links
    for (Iterator it = source.getControlLinks(); it.hasNext();)
    {
      ControlLink link = (ControlLink) it.next();

      target.addControlLink(link);

      // Determine the reference names after adding the object to the target
      link.maintainReferences(ModelObject.SYNC_LOCAL_REFNAMES);

      FlowConnection flowConnection = drawing.createFlowConnection(link);
      if (flowConnection == null)
      {
        target.removeControlLink(link);
        continue;
      }

      workspaceView.add(flowConnection);
      workspaceView.addToSelection(flowConnection);
    }

    // Add the data links
    for (Iterator it = source.getDataLinks(); it.hasNext();)
    {
      DataLink link = (DataLink) it.next();

      target.addDataLink(link);

      // Determine the reference names after adding the object to the target
      link.maintainReferences(ModelObject.SYNC_LOCAL_REFNAMES);

      ParamConnection paramConnection = drawing.createParamConnection(link);
      if (paramConnection == null)
      {
        target.removeDataLink(link);
        continue;
      }

      workspaceView.add(paramConnection);
      workspaceView.addToSelection(paramConnection);
    }

    if (firstFigure != null)
    {
      // Get the bounding rectangle
      Rectangle rect = new Rectangle(firstFigure.displayBox());

      // Enlarge by 100 pixel to prevent it from hanging in the corners
      rect.grow(50, 50);

      workspaceView.scrollRectToVisible(rect);
View Full Code Here

    if (workspaceView.selectionCount() == 1)
    {
      FigureEnumeration fe = workspaceView.selectionElements();
      if (fe.hasMoreElements())
      {
        Figure selection = fe.nextFigure();
        if (selection instanceof MultiSocketNodeFigure)
        {
          // Get the node figure to add the sockets to
          MultiSocketNodeFigure nodeFigure = (MultiSocketNodeFigure) selection;
          MultiSocketNode targetNode = (MultiSocketNode) nodeFigure.getNode();
View Full Code Here

    if (workspaceView.selectionCount() == 1)
    {
      FigureEnumeration fe = workspaceView.selectionElements();
      if (fe.hasMoreElements())
      {
        Figure figure = fe.nextFigure();
        if (figure instanceof SocketFigure)
        {
          // Get the node figure to add the sockets to
          SocketFigure socketFigure = (SocketFigure) figure;
          NodeSocket targetSocket = socketFigure.getNodeSocket();
View Full Code Here

    if (workspaceView.selectionCount() == 1)
    {
      FigureEnumeration fe = workspaceView.selectionElements();
      if (fe.hasMoreElements())
      {
        Figure selection = fe.nextFigure();
        if (selection instanceof PlaceholderNodeFigure)
        {
          // Get the node figure to add the sockets to
          PlaceholderNodeFigure nodeFigure = (PlaceholderNodeFigure) selection;
          nodeFigure.assignPlaceholderReference(source.toString());
View Full Code Here

  {
    List li = new ArrayList();

    for (FigureEnumeration fe = figures(); fe.hasMoreElements();)
    {
      Figure f = fe.nextFigure();
      li.add(f);
    }

    return li;
  }
View Full Code Here

  {
    List li = new ArrayList();

    for (FigureEnumeration fe = figures(); fe.hasMoreElements();)
    {
      Figure f = fe.nextFigure();

      if (f instanceof NodeFigure)
      {
        li.add(f);
      }
View Full Code Here

TOP

Related Classes of CH.ifa.draw.framework.Figure

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.