Package org.woped.core.model.petrinet

Examples of org.woped.core.model.petrinet.TransitionModel


    Vector<ResourceClassModel> roles = ((PetriNetModelProcessor) (parentEditor
        .getModelProcessor())).getRoles();
    ((PetriNetModelProcessor) (getModelProcessor())).setRoles(roles);

    Map<String, AbstractPetriNetElementModel> transitions;
    TransitionModel trans;
    if (!(transitions = container.getElementsByType(2)).isEmpty()) {
      Iterator<AbstractPetriNetElementModel> iterTrans = transitions.values().iterator();
      while (iterTrans.hasNext()) {
        trans = (TransitionModel) iterTrans.next();
        if (trans.isIncommingTarget())
          createArc(this.m_subprocessInput.getId(), trans.getId());
        if (trans.isOutgoingSource())
          createArc(trans.getId(), this.m_subprocessOutput.getId());

      }
    }
    // Restore original "edited" status of parent editor
    // because creation of source and target places should not
View Full Code Here


      if (toDelete[i] instanceof ArcModel) {
        allPorts.add(toDelete[i]);
        getModelProcessor().removeArc(((ArcModel) toDelete[i]).getId());
      } else if (toDelete[i] instanceof TriggerModel) {
        TransitionModel owner = (TransitionModel) getModelProcessor()
            .getElementContainer().getElementById(
                ((TriggerModel) toDelete[i]).getOwnerId());
        if (owner != null && owner.getToolSpecific().getTrigger() != null) {
          if (owner.getToolSpecific().getTrigger().getTriggertype() == TriggerModel.TRIGGER_RESOURCE
              && owner.getToolSpecific().getTransResource() != null) {
            owner.getToolSpecific().removeTransResource();
          }
          owner.getToolSpecific().removeTrigger();
        }
        allPorts.add(toDelete[i]);
      } else if (toDelete[i] instanceof TransitionResourceModel) {
        TransitionModel owner = (TransitionModel) getModelProcessor()
            .getElementContainer().getElementById(
                ((TransitionResourceModel) toDelete[i])
                    .getOwnerId());
        if (owner != null) {
          owner.getToolSpecific().removeTransResource();
        }
        allPorts.add(toDelete[i]);
      } else if (toDelete[i] instanceof NameModel) {
        allPorts.add(toDelete[i]);
      } else if (toDelete[i] instanceof GroupModel) {
View Full Code Here

      // 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
View Full Code Here

        Iterator<AbstractPetriNetElementModel> iterPlace = sa.getPlaces().iterator();

        LowLevelPetriNet lNet = new LowLevelPetriNet();
        Set<AbstractPetriNetElementModel> successors;
        Set<AbstractPetriNetElementModel> predecessors;
        TransitionModel tm;
        PlaceModel pm;

        // loop over all places
        while (iterPlace.hasNext()) {
            pm = (PlaceModel) iterPlace.next();
            lNet.getPlaceNode(new PlaceNode(pm.getTokenCount(), pm.getVirtualTokenCount(), pm.getId(), pm
                    .getNameValue(), makeOriginId(pm.getId())));
        }

        // loops over all transitions and set predecessors and successors
        while (iterTransition.hasNext()) {
          AbstractPetriNetElementModel trans = iterTransition.next();
          AbstractPetriNetElementModel opTrans = null;
          tm = (TransitionModel) trans;
            successors = NetAlgorithms.getDirectlyConnectedNodes(tm, NetAlgorithms.connectionTypeOUTBOUND);
            predecessors = NetAlgorithms.getDirectlyConnectedNodes(tm, NetAlgorithms.connectionTypeINBOUND);
            ModelElementContainer mec;
            AbstractPetriNetElementModel elem = null;
            Iterator<ModelElementContainer> ownerIterator = trans.getOwningContainersIterator();
            while (ownerIterator.hasNext()) {
              mec = ownerIterator.next();
              elem = mec.getOwningElement();
              if (elem != null && elem.getType() == TransitionModel.TRANS_OPERATOR_TYPE) {
                opTrans = (TransitionModel)elem;
                break;
              }
            }
        
            // add current transition node
            TransitionNode tNode;
            if (opTrans != null && opTrans.getType() == TransitionModel.TRANS_OPERATOR_TYPE) {
              tNode = lNet.getTransitionNode(new TransitionNode(tm.getId(), tm.getNameValue(),
                    makeOriginId(tm.getId()), ((OperatorTransitionModel)opTrans).getOperatorType()));
            }
            else {
              tNode = lNet.getTransitionNode(new TransitionNode(tm.getId(), tm.getNameValue(),
                    makeOriginId(tm.getId()), OperatorTransitionModel.TRANS_SIMPLE_TYPE));
            }

            // add predecessor of current transition node
            for (AbstractPetriNetElementModel predecessor : predecessors) {
                lNet.getPlaceNode(
View Full Code Here

    if (cell instanceof GroupModel) {
      cell = ((GroupModel) cell).getMainElement();
    }
   
    if (cell instanceof TransitionModel) {
      TransitionModel trans = (TransitionModel) cell;
      int opType = trans.getToolSpecific().getOperatorType();
      if (opType == OperatorTransitionModel.XOR_SPLIT_TYPE
          || opType == OperatorTransitionModel.XOR_SPLITJOIN_TYPE
          || opType == OperatorTransitionModel.ANDJOIN_XORSPLIT_TYPE) {
        return true;
      }
View Full Code Here

                    /* CREATING A SUBPROCESS */
                    modElement = new SubProcessModel(map);
                } else if (map.getType() == AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE && map.getOperatorType() == -1)
                {
                    /* CREATING A SIMPLE TRANSITION */
                    modElement = new TransitionModel(map);
                } else if (map.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE)
                {
                    /* CREATING A AALST TRANSITION */
                  switch (map.getOperatorType())
                  {
View Full Code Here

                    if ((operator.getOperatorType() == OperatorTransitionModel.XOR_SPLIT_TYPE)
                            || (operator.getOperatorType() == OperatorTransitionModel.ANDJOIN_XORSPLIT_TYPE)) {
                        if (transition.isActivated()) {
                            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);
                                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();
                                            virtualTransition.setNameValue(XorName);
                                            RemoteControl.addFollowingItem(virtualTransition);                                           
                                            tokenGameStats.numActiveTransitions++;                                                                           
                                            virtualTransition = null;
                                            XorName = "";
                                        }
View Full Code Here

                }
            // Update net status
            // and trigger redraw

            // Track the "walked way" by get out the transition's ID of the Choice-Box
            TransitionModel helpTransitionReference;
            for (int i = 0; i < RemoteControl.getFollowingActivatedTransitions().size(); i++) {
                helpTransitionReference = RemoteControl.getFollowingActivatedTransitions().get(i);
                if (arc.getId().equals(helpTransitionReference.getId())) {
                    RemoteControl.addHistoryItem(helpTransitionReference);
                }
            }
            checkNet();
View Full Code Here

    /*
     * Disables all Transitions. Set each transition inactive and not firing. Used on stop.
     */
    private void resetTransitionStatus() {
        Iterator<String> eleIter = allTransitions.keySet().iterator();
        TransitionModel transition;
        // Iterate over all Transitions
        while (eleIter.hasNext()) {
            transition = (TransitionModel) allTransitions.get(eleIter.next());
            if (transition.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE) {
                // When starting a new token game we have to reset all center
                // places that
                // may contain tokens
                OperatorTransitionModel tempOperator = (OperatorTransitionModel) transition;
                if (tempOperator.getCenterPlace() != null) {
View Full Code Here

        /**
     * 
     */
        public void mouseReleased(MouseEvent e) {
            Vector<Object> allCells = getGraph().getAllCellsForLocation(e.getPoint().x, e.getPoint().y);
            TransitionModel transition = findTransitionInCell(allCells);
            PlaceModel place = findPlaceInCell(allCells);
            ArcModel arc = findArcInCell(allCells);
            if (transition != null && transition.isActivated()) {
                transitionClicked(transition, e);
            } else
                if (arc != null && arc.isActivated()) {
                    arcClicked(arc);
                } else
View Full Code Here

TOP

Related Classes of org.woped.core.model.petrinet.TransitionModel

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.