Package org.woped.core.model

Examples of org.woped.core.model.CreationMap


    AbstractPetriNetElementModel sourceModel = sourceKeyIterator.next();
    setSubprocessInput(sourceModel);

    // Check whether the source element already exists
    if (container.getElementById(sourceModel.getId()) == null) {
      CreationMap sourceCreationMap = sourceModel.getCreationMap();
      if (((EditorVC) parentEditor).isCopyFlag() == false) {     
      container.getArcMap().clear();
      container.getIdMap().clear();
      }
      sourceCreationMap.setPosition(10, 160);
      sourceCreationMap.setReadOnly(true);
      sourceCreationMap.setNamePosition(30, 200);
      sourceCreationMap.setEditOnCreation(false);
      sourceCreationMap.setUpperElement(sourceModel);
      createElement(sourceCreationMap, true, true);
    } else {
      container.getElementById(sourceModel.getId()).setNameValue(
          getSubprocessInput().getNameValue());
      container.getElementById(sourceModel.getId()).setReadOnly(true);
    }

    // Get list of output nodes
    Set<AbstractPetriNetElementModel> targets = NetAlgorithms
        .getDirectlyConnectedNodes(model,
            NetAlgorithms.connectionTypeOUTBOUND);
    Iterator<AbstractPetriNetElementModel> targetKeyIterator = targets.iterator();
    AbstractPetriNetElementModel targetModel = targetKeyIterator.next();
    setSubprocessOutput(targetModel);
    // Check whether the target element already exists
    if (container.getElementById(targetModel.getId()) == null) {
      CreationMap targetCreationMap = targetModel.getCreationMap();
      targetCreationMap.setPosition(520, 160);
      targetCreationMap.setReadOnly(true);
      targetCreationMap.setNamePosition(540, 200);
      targetCreationMap.setEditOnCreation(false);
      targetCreationMap.setUpperElement(targetModel);
      createElement(targetCreationMap, true, true);

    } else {
      container.getElementById(targetModel.getId()).setNameValue(
          getSubprocessOutput().getNameValue());
View Full Code Here


        (int) p.getY(), doNotEdit);
  }

  public GraphCell createElement(int type, int additionalType, int x, int y,
      boolean doNotEdit) {
    CreationMap map = CreationMap.createMap();
    map.setType(type);
    if (doNotEdit) {
      map.setEditOnCreation(false);
    }
    if (type == OperatorTransitionModel.TRANS_OPERATOR_TYPE) {
      map.setOperatorType(additionalType);
    }
    if (x != -1 && y != -1) {
      map.setPosition(x, y);
    }
    return createElement(map, true, doNotEdit);
  }
View Full Code Here

   * @param targetId
   * @return
   */
  public ArcModel createArc(String sourceId, String targetId) {

    CreationMap map = CreationMap.createMap();
    map.setArcSourceId(sourceId);
    map.setArcTargetId(targetId);
    return createArc(map, true);

  }
View Full Code Here

    /* delta for Position */
    int deltaX = 20, deltaY = 20;

    /* insert elements */
    CreationMap sourceMap, tempMap = null, currentArcMap;
    HashMap<String, Object> correctedSourceId = new HashMap<String, Object>();
    HashMap<String, Object> correctedTargetId = new HashMap<String, Object>();
    Point currentPosition;
    Point middleOfSelection = null;

    AbstractPetriNetElementModel tempElement;
    String oldElementId;
    Vector<Object> toSelectElements = new Vector<Object>();
    Iterator<String> eleIter = pasteElements.keySet().iterator();

    boolean originalName = true;
    String originalNameStr = null;

    while (eleIter.hasNext()) {
      sourceMap = pasteElements.get(eleIter.next());
      tempMap = (CreationMap) sourceMap.clone();
      // position for element
      currentPosition = sourceMap.getPosition();

      // set new delta values if a mouse position is given
      if (points.length > 0 && middleOfSelection == null) {
        middleOfSelection = getMiddleOfSelection(pasteElements);

        deltaX = (int) points[0].getX() - middleOfSelection.x
            - tempMap.getSize().getX1() / 2;
        deltaY = (int) points[0].getY() - middleOfSelection.y
            - tempMap.getSize().getX2() / 2;
      }

      // set new position
      tempMap.setPosition(currentPosition.x + deltaX, currentPosition.y
          + deltaY);
      // position for name
      currentPosition = (Point) sourceMap.getNamePosition().clone();
      tempMap.setNamePosition(currentPosition.x + deltaX,
          currentPosition.y + deltaY);

      // position for trigger
      if ((currentPosition = sourceMap.getTriggerPosition()) != null) {
        tempMap.setTriggerPosition(currentPosition.x + deltaX,
            currentPosition.y + deltaY);
      }

      // copy in another frame than the source frame
      if (this != m_clipboard.getM_sourceEditor()) {
        // determine middle of selected elements
        if (middleOfSelection == null) {
          middleOfSelection = getMiddleOfSelection(pasteElements);
        }

        // position for element
        if (points.length > 0) {
          currentPosition = new Point(
              (int) (((int) points[0].getX() / 2)
                  - tempMap.getSize().getX1() / 2
                  + tempMap.getPosition().getX() - middleOfSelection.x),
              (int) (((int) points[0].getY() / 2)
                  - tempMap.getSize().getX2() / 2
                  + tempMap.getPosition().getY() - middleOfSelection.y));
        } else {
          currentPosition = new Point(
              (int) ((getEditorPanel().getWidth() / 2) - tempMap.getSize().getX1()
                  / 2 + tempMap.getPosition().getX() - middleOfSelection.x),
              (int) ((getEditorPanel().getHeight() / 2)
                  - tempMap.getSize().getX2() / 2
                  + tempMap.getPosition().getY() - middleOfSelection.y));

        }
        tempMap.setPosition(currentPosition.x, currentPosition.y);

        // position for name
        if (isRotateSelected()) {
          tempMap.setNamePosition(currentPosition.x
              + tempMap.getSize().getX1(), currentPosition.y - 1);
        } else {
          tempMap.setNamePosition(currentPosition.x - 1,
              currentPosition.y + tempMap.getSize().getX2());
        }

        if (isRotateSelected()) {
          tempMap.setTriggerPosition(currentPosition.x - 20,
              currentPosition.y + 7);
        } else {
          tempMap.setTriggerPosition(currentPosition.x + 7,
              currentPosition.y - 20);

        }

      }

      // keep the sourceMapID
      oldElementId = sourceMap.getId();
      originalNameStr = sourceMap.getName();
      originalName = isOriginalName(originalNameStr, oldElementId);
      tempMap.setEditOnCreation(false);
      tempMap.setReadOnly(false);
      // set ID to null, to get new ID
      tempMap.setId(null);
      // get tempGroupModel with new ID
      GroupModel tempGroupModel = (GroupModel) (create(tempMap));
      // get form the group an AbstractElementModel (extends GraphCell)

      tempElement = tempGroupModel.getMainElement();
      // check if tempElement TransitionModel (PetriNetModelElement)

      if (tempElement instanceof TransitionModel) {
        // GroupModel currentTrans = (GroupModel) (create(currentMap));
        // new element exactly transitionModel
        TransitionModel tempTrans = (TransitionModel) tempElement;
        // copy time
        if ((sourceMap.getTransitionTime() != -1)
            && (sourceMap.getTransitionTimeUnit() != -1)) {
          tempTrans.getToolSpecific().setTime(
              sourceMap.getTransitionTime());
          tempTrans.getToolSpecific().setTimeUnit(
              sourceMap.getTransitionTimeUnit());
        }
        // copy trigger model
        CreationMap map = tempTrans.getCreationMap();
        if (sourceMap.getTriggerType() != -1) {
          if (map != null) {

            map.setTriggerType(sourceMap.getTriggerType());
            createTriggerForPaste(map, tempTrans);
            Point p = tempTrans.getPosition();
            // Why deleteCell?
            // deleteCell(tempTrans.getToolSpecific().getTrigger(),
            // true);
            map.setTriggerPosition(p.x, p.y);
            // copy resource model
            if ((sourceMap.getResourceOrgUnit() != null)
                && sourceMap.getResourceRole() != null) {
              map.setResourceOrgUnit(sourceMap
                  .getResourceOrgUnit());
              map.setResourceRole(sourceMap.getResourceRole());
            }
          }

        } else
          map.setType(1);

      }
      /* change arc source/target */
      Iterator<String> arcIter = pasteArcs.keySet().iterator();
      while (arcIter.hasNext()) {
        currentArcMap = pasteArcs.get(arcIter.next());
        if ((this.getEditorPanel().getContainer().getActionMap()
            .get(currentArcMap.getArcSourceId()) != null)
            || ((currentArcMap.getArcSourceId()
                .equals(oldElementId)) && (!correctedSourceId
                .containsKey(currentArcMap.getArcId())))) {
          currentArcMap.setArcSourceId(tempElement.getId());
          correctedSourceId.put(currentArcMap.getArcId(), null);
        }
        if ((currentArcMap.getArcTargetId().equals(oldElementId))
            && (!correctedTargetId.containsKey(currentArcMap
                .getArcId()))) {
          currentArcMap.setArcTargetId(tempElement.getId());
          correctedTargetId.put(currentArcMap.getArcId(), null);
        }
      }
      /* */
      if (originalName)
        tempElement.setNameValue(tempElement.getId());
      else
        tempElement.setNameValue(originalNameStr);
      toSelectElements.add(tempElement.getParent());
    }

    /* insert arcs */
    Iterator<String> arcIter = pasteArcs.keySet().iterator();
    ArcModel tempArc;
    Point2D point;
    CreationMap cmap = CreationMap.createMap();
    while (arcIter.hasNext()) {
      currentArcMap = pasteArcs.get(arcIter.next());
      if ((currentArcMap.getArcSourceId() != null)
          && (currentArcMap.getArcTargetId()) != null) {

        cmap.setArcSourceId(currentArcMap.getArcSourceId());
        cmap.setArcTargetId(currentArcMap.getArcTargetId());
        tempArc = createArc(cmap, true);
       
        // It is possible that an arc could not be created, because either its source
        // or target element are missing. Simply ignore the arc in this case
        if (tempArc == null)
View Full Code Here

  private Point getMiddleOfSelection(Map<String, CreationMap> maps) {
    int minX = 999999, minY = 999999, maxX = -1, maxY = -1;

    Iterator<String> eleIterTemp = maps.keySet().iterator();
    CreationMap iterMap;
    while (eleIterTemp.hasNext()) {
      iterMap = maps.get(eleIterTemp.next());

      minX = Math.min(minX, iterMap.getPosition().x);
      minY = Math.min(minY, iterMap.getPosition().y);
      maxX = Math.max(maxX, iterMap.getPosition().x);
      maxY = Math.max(maxY, iterMap.getPosition().y);
    }
    return new Point((maxX + minX) / 2, (maxY + minY) / 2);
  }
View Full Code Here

                             * chosen by the user, it will be identified by its ID as Arc and the depending Arc will be taken instead to be occured
                             */
                            while (outArcs.hasNext()) {
                                ID = outArcs.next(); // get the Arc's ID
                                // Use a new CreationMap with the arcs id to create the virtual transition
                                CreationMap map = CreationMap.createMap();
                                map.setId(ID);
                                virtualTransition = new TransitionModel(map);
                                helpPlace = getPetriNet().getElementContainer().getElementById(
                                        getPetriNet().getElementContainer().getArcById(ID).getTargetId());
                                XorName = transition.getNameValue() + " -> (" + helpPlace.getNameValue() + ")";
                                virtualTransition.setNameValue(XorName);
                                RemoteControl.addFollowingItem(virtualTransition);
                                tokenGameStats.numActiveTransitions++;                                                               
                                virtualTransition = null;
                                XorName = "";
                            }

                            setOutgoingArcsActive(transition.getId(), true);
                        }
                    } else
                        if ((operator.getOperatorType() == OperatorTransitionModel.XOR_JOIN_TYPE)
                                || (operator.getOperatorType() == OperatorTransitionModel.XORJOIN_ANDSPLIT_TYPE)) {
                            if (transition.getNumIncomingActivePlaces() > 0) {
                                String XorName, ID;
                                Iterator<String> inArcs = incomingArcs.keySet().iterator();
                                TransitionModel virtualTransition; // needed to build virtual Transitions.
                                AbstractPetriNetElementModel helpPlace;
                                // ArcModel activeArc;

                                /*
                                 * In this while-loop, Virtual Transitions will be build which represent the Arcs in the OccurenceList. If a virtual Transition
                                 * is chosen by the user, it will be identified by its ID as Arc and the depending Arc will be taken instead to be occured
                                 */
                                setIncomingArcsActive(transition.getId(), true);
                                while (inArcs.hasNext()) {
                                    ID = inArcs.next(); // Get Arcs ID
                                    // List all activated Arcs in the occur List
                                    if (getPetriNet().getElementContainer().getArcById(ID).isActivated()) {
                                        // Use a new CreationMap with the arcs id to create the virtual transition
                                        CreationMap map = CreationMap.createMap();
                                        map.setId(ID);
                                        virtualTransition = new TransitionModel(map);
                                        helpPlace = getPetriNet().getElementContainer().getElementById(
                                                getPetriNet().getElementContainer().getArcById(ID).getSourceId());
                                        XorName = "(" + helpPlace.getNameValue() + ")-> " + transition.getNameValue();
                                        virtualTransition.setNameValue(XorName);
                                        RemoteControl.addFollowingItem(virtualTransition);
                                        tokenGameStats.numActiveTransitions++;                                                                       
                                        virtualTransition = null;
                                        XorName = "";
                                    }
                                }
                            }
                        } else
                            if (operator.getOperatorType() == OperatorTransitionModel.XOR_SPLITJOIN_TYPE) {
                                // This is the XOR split-join combination type.
                                // Check whether the center place already contains (a) token(s)
                                if ((operator.getCenterPlace() != null)
                                        && (operator.getCenterPlace().getVirtualTokenCount() > 0)) {

                                    String XorName, ID;
                                    Iterator<String> outArcs = outgoingArcs.keySet().iterator();
                                    TransitionModel virtualTransition; // needed to build virtual Transitions.
                                    AbstractPetriNetElementModel helpPlace;

                                    /*
                                     * In this while-loop, Virtual Transitions will be build which represent the Arcs in the OccurenceList. If a virtual
                                     * Transition is chosen by the user, it will be identified by its ID as Arc and the depending Arc will be taken instead to
                                     * be occured
                                     */
                                    while (outArcs.hasNext()) {
                                        ID = outArcs.next(); // get the Arc's ID
                                        // Use a new CreationMap with the arcs id to create the virtual transition
                                        CreationMap map = CreationMap.createMap();
                                        map.setId(ID);
                                        virtualTransition = new TransitionModel(map);

                                        virtualTransition.setId(ID); // set HelpTransition's ID to Arc's ID
                                        helpPlace = getPetriNet().getElementContainer().getElementById(
                                                getPetriNet().getElementContainer().getArcById(ID).getTargetId());
                                        XorName = transition.getNameValue() + " -> (" + helpPlace.getNameValue() + ")";
                                        virtualTransition.setNameValue(XorName);
                                        RemoteControl.addFollowingItem(virtualTransition);                                       
                                        tokenGameStats.numActiveTransitions++;                                                                       
                                        virtualTransition = null;
                                        XorName = "";
                                    }

                                    setOutgoingArcsActive(transition.getId(), true);
                                }
                                // There must at least be one token at the input side for
                                // the transition to be
                                // activated
                                if (transition.getNumIncomingActivePlaces() > 0) {
                                    String XorName, ID;
                                    Iterator<String> inArcs = incomingArcs.keySet().iterator();
                                    TransitionModel virtualTransition; // needed to build virtual Transitions.
                                    AbstractPetriNetElementModel helpPlace;
                                    // ArcModel activeArc;

                                    /*
                                     * In this while-loop, Virtual Transitions will be build which represent the Arcs in the OccurenceList. If a virtual
                                     * Transition is chosen by the user, it will be identified by its ID as Arc and the depending Arc will be taken instead to
                                     * be occured
                                     */
                                    setIncomingArcsActive(transition.getId(), true);
                                    while (inArcs.hasNext()) {
                                        ID = inArcs.next(); // Get Arcs ID
                                        // List all activated Arcs in the occur List
                                        if (getPetriNet().getElementContainer().getArcById(ID).isActivated()) {
                                            // Use a new CreationMap with the arcs id to create the virtual transition
                                            CreationMap map = CreationMap.createMap();
                                            map.setId(ID);
                                            virtualTransition = new TransitionModel(map);
                                            helpPlace = getPetriNet().getElementContainer().getElementById(
                                                    getPetriNet().getElementContainer().getArcById(ID).getSourceId());
                                            XorName = "(" + helpPlace.getNameValue() + ")-> "
                                                    + transition.getNameValue();
View Full Code Here

        return HEIGHT;
    }
   
    public CreationMap getCreationMap()
    {
        CreationMap map = super.getCreationMap();
        if (hasTrigger())
        {
            map.setTriggerType(getToolSpecific().getTrigger().getTriggertype());
            map.setTriggerPosition(new Point(getToolSpecific().getTrigger().getPosition()));
        }
        else
          // If no trigger exists, our creation map must reflect this
          // (there might have been a trigger before which was removed
          // during editing)
          map.setTriggerType(-1);
        if (hasResource())
        {
            map.setResourceOrgUnit(getToolSpecific().getTransResource().getTransOrgUnitName());
            map.setResourceRole(getToolSpecific().getTransResource().getTransRoleName());
            map.setResourcePosition(new Point(getToolSpecific().getTransResource().getPosition()));
        }
        else
        {
          // If no resource org unit exists, our creation map must reflect this
          // (there might have been a resource unit before which was removed
          // during editing)
          map.setResourceOrgUnit(null);
          map.setResourceRole(null);
          map.setResourcePosition(null);
        }
        // Extract transition service time and transition service
        // time unit
        map.setTransitionTime(getToolSpecific().getTime());
        map.setTransitionTimeUnit(getToolSpecific().getTimeUnit());
      
        return map;
    }
View Full Code Here

    // copy elements

    Map<?, ?> idMap = container.getIdMap();
    Iterator<?> keyIterator = idMap.keySet().iterator();
    CreationMap currentArcMapSub;
    AbstractPetriNetElementModel newElementSub = null;
    while (keyIterator.hasNext()) {

      AbstractPetriNetElementModel currentElementSub = (AbstractPetriNetElementModel) container
          .getElementById(keyIterator.next());

      if (!currentElementSub.isReadOnly()) {
        CreationMap newMapSub = (CreationMap) currentElementSub
            .getCreationMap().clone();
        // newMap.setId("copyof_" + newMap.getId());
        String[] splitName = newMapSub.getId().split(
            SUBELEMENT_SEPERATOR);
        if (splitName.length > 1)
          newMapSub.setId(super.getId() + SUBELEMENT_SEPERATOR
              + splitName[splitName.length - 1]);
        newMapSub.setName(newMapSub.getId());
        newElementSub = ModelElementFactory
            .createModelElement(newMapSub);
       
        if (currentElementSub instanceof TransitionModel) {
          TransitionModel newTransitionSub = (TransitionModel) newElementSub;
          newTransitionSub
              .setToolSpecific(((TransitionModel) currentElementSub)
                  .getToolSpecific());

          newContainer.addElement(newTransitionSub);

        } else

          newContainer.addElement(newElementSub);
      }
    }
    /* insert arc source/target */
    Iterator<?> arcIterSub = container.getArcMap().keySet().iterator();
    CreationMap cMapSub = CreationMap.createMap();
    String originalElementId;
    String[] splitedSourceId, splitedTargetId;
    while (arcIterSub.hasNext()) {
      currentArcMapSub = container.getArcMap().get((arcIterSub.next()))
          .getCreationMap();
      originalElementId = currentArcMapSub.getName();
      splitedSourceId = currentArcMapSub.getArcSourceId().split(
          SUBELEMENT_SEPERATOR);
      splitedTargetId = currentArcMapSub.getArcTargetId().split(
          SUBELEMENT_SEPERATOR);

      String newSourceName ;
      String newTargetName ;
     
      if ((splitedSourceId.length > 1) && (splitedTargetId.length > 1)) {
        newTargetName =super.getId() + SUBELEMENT_SEPERATOR
        + splitedTargetId[splitedTargetId.length - 1];
        newSourceName = super.getId() + SUBELEMENT_SEPERATOR
        + splitedSourceId[splitedSourceId.length - 1];
        cMapSub.setArcSourceId(newSourceName);
        cMapSub.setArcTargetId(newTargetName);
        processor.createArc(newSourceName,
            newTargetName);
      }
      else if ((splitedSourceId.length <= 1) && (splitedTargetId.length > 1)) {
        newTargetName =super.getId() + SUBELEMENT_SEPERATOR
        + splitedTargetId[splitedTargetId.length - 1];
        cMapSub.setArcTargetId(newTargetName);
        ((TransitionModel) newContainer.getElementById(newTargetName)).setIncommingTarget(true);
        processor.createArc(originalElementId,
            cMapSub.getArcTargetId());
      }
      else if ((splitedSourceId.length > 1) && (splitedTargetId.length <= 1)) {
        newSourceName = super.getId() + SUBELEMENT_SEPERATOR
        + splitedSourceId[splitedSourceId.length - 1];
        cMapSub.setArcSourceId(newSourceName);
        ((TransitionModel) newContainer.getElementById(newSourceName)).setOutgoingSource(true);
      }
    }
    /* insert arcs */
    return newContainer;
View Full Code Here

        AbstractPetriNetElementModel ttemp = null;
        // Create transition 't*'
        Iterator<AbstractPetriNetElementModel> i = m_transitions.iterator();
        AbstractPetriNetElementModel transitionTemplate = ((i.hasNext()) ? (AbstractPetriNetElementModel) i.next() : null);
        if (transitionTemplate != null) {
            CreationMap tempMap = transitionTemplate.getCreationMap();
            tempMap.setType(AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE);
            String tempID = "t*";
            tempMap.setName(tempID);
            tempMap.setId(tempID);
            tempMap.setEditOnCreation(false);
            ttemp = m_currentEditor.getModelProcessor().createElement(tempMap);

            // Now connect the new transition 't*' to
            // the source and the target
            // For this to be possible, we will need
View Full Code Here

        return "Place\nID: " + getId() + "\nName: " + getNameValue() + "\nTokens: " + getVirtualTokenCount();
    }

    public CreationMap getCreationMap()
    {
        CreationMap map = super.getCreationMap();
        // Tokens
        if (getTokenCount() > 0) map.setTokens(getTokenCount());

        return map;
    }
View Full Code Here

TOP

Related Classes of org.woped.core.model.CreationMap

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.