Package org.woped.core.model.petrinet

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


     * Handles a click on any arc in any state
     */
    private void arcClicked(ArcModel arc) {

        if (arc.isActivated()) {
            AbstractPetriNetElementModel source = (AbstractPetriNetElementModel) getPetriNet().getElementContainer().getElementById(
                    arc.getSourceId());
            AbstractPetriNetElementModel target = (AbstractPetriNetElementModel) getPetriNet().getElementContainer().getElementById(
                    arc.getTargetId());

            OperatorTransitionModel tempOperator;

            // As a reminder, an arc is generally going from a place to a
            // transition or from a
            // transition to a place.
            // When pointing to a transition it is referencing a potential
            // provider of a token.
            // When pointing to a place that place is potential receiver for a
            // token.
            // First, we check if the origin of our clicked arc is a transition
            // (Note that we check for the operator type only as ordinary
            // transitions are not triggered
            // by clicking the arrow but by clicking the transition itself which
            // is handled in transitionClicked())
            if (source.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE) {
                tempOperator = (OperatorTransitionModel) source;
                if (tempOperator.isActivated()) {
                    if (tempOperator.getOperatorType() == OperatorTransitionModel.XOR_SPLIT_TYPE
                            || tempOperator.getOperatorType() == OperatorTransitionModel.XOR_SPLITJOIN_TYPE
                            || tempOperator.getOperatorType() == OperatorTransitionModel.ANDJOIN_XORSPLIT_TYPE) {
                        receiveTokens(arc);
                        if (tempOperator.getOperatorType() != OperatorTransitionModel.XOR_SPLITJOIN_TYPE) {
                            sendTokens(getPetriNet().getElementContainer().getIncomingArcs(tempOperator.getId()));
                        } else {
                            // Special code for splitjoin. We have to take the
                            // token from the center place
                            if (tempOperator.getCenterPlace() != null) {
                                // FIXME: Once implemented, this place will also
                                // have to remove weighted tokens
                                tempOperator.getCenterPlace().sendToken();
                            }
                        }
                    }
                }
            } else
                if (target.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE) {
                    tempOperator = (OperatorTransitionModel) target;
                    if (tempOperator.getOperatorType() == OperatorTransitionModel.XOR_JOIN_TYPE
                            || tempOperator.getOperatorType() == OperatorTransitionModel.XORJOIN_ANDSPLIT_TYPE
                            || tempOperator.getOperatorType() == OperatorTransitionModel.XOR_SPLITJOIN_TYPE) {
                        sendTokens(arc);
View Full Code Here


                            connectedNodes.addAll(wrongDirection);

                        }
                        Iterator<AbstractPetriNetElementModel> nodeIterator = connectedNodes.iterator();
                        while (nodeIterator.hasNext()) {
                            AbstractPetriNetElementModel target = nodeIterator.next();
                            // Use our node to index lookup table to
                            // find the RouteInfo object corresponding to the
                            // target
                            Integer targetIndex = nodeToIndex.get(target);
                            if (targetIndex != null) {
View Full Code Here

            receiveBackwardTokens(getPetriNet().getElementContainer().getIncomingArcs(transition.getId()));
            sendBackwardTokens(getPetriNet().getElementContainer().getOutgoingArcs(transition.getId()));
            actionPerformed = true;
        } else // if it is an arc ==> it is some kind of XOR-Operation
        {
            AbstractPetriNetElementModel source = (AbstractPetriNetElementModel) getPetriNet().getElementContainer().getElementById(
                    arc.getSourceId());
            AbstractPetriNetElementModel target = (AbstractPetriNetElementModel) getPetriNet().getElementContainer().getElementById(
                    arc.getTargetId());
            OperatorTransitionModel tempOperator;
            if (target.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE) {
                tempOperator = (OperatorTransitionModel) target;
                receiveBackwardTokens(arc);
                if (tempOperator.getOperatorType() != OperatorTransitionModel.XOR_SPLITJOIN_TYPE) {
                    sendBackwardTokens(getPetriNet().getElementContainer().getOutgoingArcs(tempOperator.getId()));
                    actionPerformed = true;
View Full Code Here

    // ! Append all objects to target that are not of TRANS_OPERATOR_TYPE
    private static void appendNonOperators(HashSet<AbstractPetriNetElementModel> target, Iterator<AbstractPetriNetElementModel> source) {
        while (source.hasNext()) {
            try {
                AbstractPetriNetElementModel element = source.next();
                if (element.getType() != AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE) {
                    target.add(element);
                }
            } catch (ClassCastException e) {
                // Ignore objects that are not of type AbstractElementModel
            }
View Full Code Here

          String ids = "";
          Iterator<AbstractPetriNetElementModel> i = m_editor
              .getModelProcessor().getElementContainer()
              .getRootElements().iterator();
          while (i.hasNext()) {
            AbstractPetriNetElementModel cur = (AbstractPetriNetElementModel) i
                .next();

            if (cur.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE) {
              OperatorTransitionModel operatorModel = (OperatorTransitionModel) cur;
              Iterator<AbstractPetriNetElementModel> simpleTransIter = operatorModel
                  .getSimpleTransContainer()
                  .getElementsByType(
                      AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE)
                  .values().iterator();
              while (simpleTransIter.hasNext()) {
                AbstractPetriNetElementModel simpleTransModel = (AbstractPetriNetElementModel) simpleTransIter
                    .next();
                if (simpleTransModel != null
                    && operatorModel
                        .getSimpleTransContainer()
                        .getElementById(
                            simpleTransModel
                                .getId())
                        .getType() == AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE) {
                  for (String v : content) {
                    if (v.equals(simpleTransModel.getId())) {
                      ids = ids + v + ",";
                      elements++;
                    }
                  }
                }
View Full Code Here

  public void mouseClicked(MouseEvent arg0) {
    // First, dehighlight all elements in the net
    Iterator<AbstractPetriNetElementModel> i = editor.getModelProcessor()
        .getElementContainer().getRootElements().iterator();
    while (i.hasNext()) {
      AbstractPetriNetElementModel current = (AbstractPetriNetElementModel) i.next();
      current.setHighlighted(false);
    }
    // Then, highlight all elements in the collection
    if (!elements.isEmpty()) {
      Iterator<AbstractPetriNetElementModel> iterCopy = elements.iterator();
      while (iterCopy.hasNext()) {
        AbstractPetriNetElementModel currentHigh = (AbstractPetriNetElementModel) iterCopy
            .next();
        currentHigh.setHighlighted(true);
      }
    }
    editor.getGraph().repaint();
  }
View Full Code Here

    private void updateStatistics(Iterator<AbstractPetriNetElementModel> i) {
        ArcConfiguration arcConfig = new ArcConfiguration();
        while (i.hasNext()) {
            try {
                AbstractPetriNetElementModel currentNode = i.next();
                NetAlgorithms.getArcConfiguration(currentNode, arcConfig);
                switch (currentNode.getType()) {
                case AbstractPetriNetElementModel.PLACE_TYPE:
                    m_places.add(currentNode);
                    if (arcConfig.m_numIncoming == 0) {
                        m_sourcePlaces.add(currentNode);
                    }
View Full Code Here

        if (m_transitions.size() == 0) {
            return;
        }

        // Add temporary transition t*, connecting sink to source
        AbstractPetriNetElementModel ttemp = addTStar();
        if (ttemp != null) {
            netElements.add(ttemp);
        }

        // First check for connectedness:
View Full Code Here

    public AbstractPetriNetElementModel addTStar() {
        if (!m_bBasicNetInfoAvailable) {
            calculateBasicNetInfo();
        }
        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
            // a unique source and a unique sink
            if ((m_sourcePlaces.size() == 1) && (m_sinkPlaces.size() == 1)) {
                AbstractPetriNetElementModel source = m_sourcePlaces.iterator().next();
                String sourceID = source.getId();
                AbstractPetriNetElementModel target = m_sinkPlaces.iterator().next();
                String targetID = target.getId();
                Object newEdge = m_currentEditor.getModelProcessor().createArc(tempID, sourceID);
                ttemp.getPort().addEdge(newEdge);
                source.getPort().addEdge(newEdge);
                newEdge = m_currentEditor.getModelProcessor().createArc(targetID, tempID);
                if (newEdge != null) {
                    ttemp.getPort().addEdge(newEdge);
                    target.getPort().addEdge(newEdge);
                }
                m_bBasicNetInfoAvailable = false;
            }
        }
        return ttemp;
View Full Code Here

        Set<Set<AbstractPetriNetElementModel>> result = new HashSet<Set<AbstractPetriNetElementModel>>();
        // Look for forward-branched places (conflicts)
        // and their follow-up transitions
        while (i.hasNext()) {
            // Determine the arc configuration of the current place
            AbstractPetriNetElementModel currentPlace = i.next();

            // Have a closer look at the follow-up transitions
            // Collect all affected nodes a priori just in case
            HashSet<AbstractPetriNetElementModel> violationGroup = new HashSet<AbstractPetriNetElementModel>();
            boolean violation = false;
            Set<AbstractPetriNetElementModel> compareSet = null;
            Set<AbstractPetriNetElementModel> successors = NetAlgorithms.getDirectlyConnectedNodes(currentPlace,
                    swapArcDirection ? NetAlgorithms.connectionTypeINBOUND : NetAlgorithms.connectionTypeOUTBOUND);
            for (Iterator<AbstractPetriNetElementModel> s = successors.iterator(); s.hasNext();) {
                AbstractPetriNetElementModel successor = s.next();
                Set<AbstractPetriNetElementModel> predecessors = NetAlgorithms.getDirectlyConnectedNodes(successor,
                        swapArcDirection ? NetAlgorithms.connectionTypeOUTBOUND : NetAlgorithms.connectionTypeINBOUND);
                if (compareSet == null) {
                    compareSet = predecessors;
                } else {
View Full Code Here

TOP

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

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.