Package org.woped.core.model.petrinet

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


    private void saveModelElementContainer(NetType iNet, ModelElementContainer elementContainer)
    {
        Iterator<AbstractPetriNetElementModel> root2Iter = elementContainer.getRootElements().iterator();
        while (root2Iter.hasNext())
        {
            AbstractPetriNetElementModel currentModel = (AbstractPetriNetElementModel) root2Iter.next();
            /* ##### PLACES ##### */
            if (currentModel.getType() == AbstractPetriNetElementModel.PLACE_TYPE)
            {
                initPlace(iNet.addNewPlace(), (PlaceModel) currentModel);
            } else if (currentModel.getType() == AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE)
            /* ##### TRANSITION ##### */
            {
                initTransition(iNet.addNewTransition(), (TransitionModel) currentModel, null);

            } else if (currentModel.getType() == AbstractPetriNetElementModel.SUBP_TYPE)
            {
                // A sub-process is a reference transition with an associated page
              // First, generate the transition itself
                initTransition(iNet.addNewTransition(), (TransitionModel) currentModel, null);
                // Create the page and add the sub-net to it
                // by calling ourselves recursively
                Page newPage = iNet.addNewPage();
                // Associate the new page with the ID of the sub-process model
                // so it can be assigned back later on when importing the net
                newPage.setId(currentModel.getId());
                // Create a new XMLBean representing the sub-net
                NetType newNet = newPage.addNewNet();
               
                ModelElementContainer subProcessContainer =                
                  ((SubProcessModel)currentModel).getSimpleTransContainer();
               
                EditorLayoutInfo subProcessLayout =subProcessContainer.getEditorLayoutInfo();
                if (subProcessLayout!=null)
                {
                  // This sub-process model stores some information about
                  // the layout of the subprocessor editor
                  // Convert it to XMLBeans information and store it
                  NetToolspecificType subPToolSpec = newNet.addNewToolspecific();
                 
                  subPToolSpec.setTool("WoPeD");
                  subPToolSpec.setVersion("1.0");
                  // graphics
                  GraphicsSimpleType iGraphicsNet = subPToolSpec.addNewBounds();
                  if (subProcessLayout.getSavedSize() != null)
                  {
                    DimensionType dim = iGraphicsNet.addNewDimension();
                    dim.setX(new BigDecimal(subProcessLayout.getSavedSize().getWidth()));
                    dim.setY(new BigDecimal(subProcessLayout.getSavedSize().getHeight()));
                  }
                  if (subProcessLayout.getSavedLocation() != null)
                  {
                    PositionType location = iGraphicsNet.addNewPosition();
                    location.setX(new BigDecimal(subProcessLayout.getSavedLocation().getX()));
                    location.setY(new BigDecimal(subProcessLayout.getSavedLocation().getY()));
                  }
                  // Store the width of the tree view
                  subPToolSpec.setTreeWidthRight(subProcessLayout.getTreeViewWidthRight());
                  subPToolSpec.setOverviewPanelVisible(subProcessLayout.getOverviewPanelVisible());
                  subPToolSpec.setTreeHeightOverview(subProcessLayout.getTreeHeightOverview());
                  subPToolSpec.setTreePanelVisible(subProcessLayout.getTreePanelVisible());
                }
               
                // Call ourselves recursively to store the sub-process net
                saveModelElementContainer(newNet, subProcessContainer);
            } else if (currentModel.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE)
            {
              // Special handling code for operators:
              // Instead of the operator itself, the inner transitions and places
              // will be written to the PNML file
              // Their location (screen coordinates) are those of the original operator
              // (and also have to be because the operator screen location is not stored separately
              // but restored from its replacement elements)

                LoggerManager.debug(Constants.FILE_LOGGER, "   ... Setting InnerTtransitions for Operator (ID:" + currentModel.getId() + ")");
                OperatorTransitionModel operatorModel = (OperatorTransitionModel) currentModel;
                Iterator<AbstractPetriNetElementModel> simpleTransIter = operatorModel.getSimpleTransContainer().getElementsByType(AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE).values().iterator();
                while (simpleTransIter.hasNext())
                {
                    AbstractPetriNetElementModel simpleTransModel = (AbstractPetriNetElementModel) simpleTransIter.next();
                    if (simpleTransModel != null // Sometimes the iterator
                            // returns null...
                            && operatorModel.getSimpleTransContainer().getElementById(simpleTransModel.getId()).getType() == AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE)
                    {
                        initTransition(iNet.addNewTransition(), (TransitionModel) operatorModel.getSimpleTransContainer().getElementById(simpleTransModel.getId()), operatorModel);
                    }

                }
                if (operatorModel.getCenterPlace() != null)
                {
                    PlaceType iCenterPlace = initPlace(iNet.addNewPlace(), operatorModel.getCenterPlace());
                    initToolspecific(iCenterPlace.addNewToolspecific(), operatorModel.getCenterPlace(), operatorModel.getId(), operatorModel.getOperatorType());
                }
                LoggerManager.debug(Constants.FILE_LOGGER, "   ... InnerTtransitions set.");
            }
            for (int i = 0; i < statusBars.length; i++)
                statusBars[i].nextStep();
        }
        /* ##### ARCS ##### */
       
        // When iterating through our arcs, we remember all
        // transitions that are either source or destination of
        // any arc we encounter
        // Instead of serializing the arc itself, we serialize
        // the "inner arcs" of all such transitions
        // To sort out duplicates, we create a set
        Set<AbstractPetriNetElementModel> connectedTransitions = new HashSet<AbstractPetriNetElementModel>()
        Iterator<String> arcIter = elementContainer.getArcMap().keySet().iterator();
        while (arcIter.hasNext())
        {
            ArcModel currentArc = elementContainer.getArcById(arcIter.next());
            AbstractPetriNetElementModel currentTargetModel = (AbstractPetriNetElementModel) elementContainer.getElementById(currentArc.getTargetId());
            AbstractPetriNetElementModel currentSourceModel = (AbstractPetriNetElementModel) elementContainer.getElementById(currentArc.getSourceId());
            // Remember either source or target if it is a transition
            // Please note that one special condition of petri nets is that
            // a transition is never directly connected to another transition
            // so either source or target may be a transition, never both
            if (currentTargetModel.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE)
              connectedTransitions.add(currentTargetModel);
            else if (currentSourceModel.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE)
              connectedTransitions.add(currentSourceModel);
            else
            {
              // The current arc is not connected to any transition
              // We do not need to take care of any inner arcs
View Full Code Here


    int numNodes = mec.getRootElements().size();
   
    nodeArray = new Node[numNodes];
    int nextIdx = 0;
   
    AbstractPetriNetElementModel source = (AbstractPetriNetElementModel)qualanService.getSourcePlaces().iterator().next();
    sourcePlace = new Node(source.getId(), source.getNameValue());
    sourcePlace.setType(Node.TYPE_PLACE);
   
    AbstractPetriNetElementModel sink = (AbstractPetriNetElementModel)qualanService.getSinkPlaces().iterator().next();
    sinkPlace = new Node(sink.getId(), sink.getNameValue());
    sinkPlace.setType(Node.TYPE_PLACE);
   
    initNodeArray();
   
    nodeArray[nextIdx] = sourcePlace;
View Full Code Here

    if (mec.getTargetElements(n.getId()).size() > 1)
      n.setFork(true);
   
    while (postNodes.hasNext()){
      AbstractPetriNetElementModel currentPlace = (AbstractPetriNetElementModel) postNodes.next();

      int nodeIdx = getNodeIdx(currentPlace.getId());
      Node postNode = null;
      if (nodeIdx >= nodeArray.length){
        String id = currentPlace.getId();
        if (id.equals(sinkPlace.getId())){
          postNode = sinkPlace;
        } else {
          postNode = new Node(id, currentPlace.getNameValue());
          switch (currentPlace.getType()){
          case AbstractPetriNetElementModel.PLACE_TYPE:
            postNode.setType(Node.TYPE_PLACE);
            break;
          case AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE:
            postNode.setType(Node.TYPE_TRANS_SIMPLE);
            postNode.setTime(((TransitionModel)currentPlace).getToolSpecific().getTime());
            postNode.setTimeUnit(getTimeUnitConst(((TransitionModel)currentPlace).getToolSpecific().getTimeUnit()));
            int type = ((OperatorTransitionModel)currentPlace).getOperatorType();
            if ((type == OperatorTransitionModel.AND_JOIN_TYPE) || (type == OperatorTransitionModel.AND_SPLITJOIN_TYPE) || (type == OperatorTransitionModel.ANDJOIN_XORSPLIT_TYPE)){
              postNode.setAndJoin(true);
              postNode.setType(Node.TYPE_AND_JOIN);             
            }
            if ((type == OperatorTransitionModel.AND_SPLIT_TYPE) || (type == OperatorTransitionModel.AND_SPLITJOIN_TYPE) || (type == OperatorTransitionModel.XORJOIN_ANDSPLIT_TYPE)){
              postNode.setAndSplit(true);
              postNode.setType(Node.TYPE_AND_SPLIT);             
            }
            if ((type == OperatorTransitionModel.XOR_JOIN_TYPE) || (type == OperatorTransitionModel.XOR_SPLITJOIN_TYPE) || (type == OperatorTransitionModel.XORJOIN_ANDSPLIT_TYPE)){
              postNode.setType(Node.TYPE_XOR_JOIN);
            }
            if ((type == OperatorTransitionModel.XOR_SPLIT_TYPE) || (type == OperatorTransitionModel.XOR_SPLITJOIN_TYPE) || (type == OperatorTransitionModel.ANDJOIN_XORSPLIT_TYPE)){
              postNode.setType(Node.TYPE_XOR_SPLIT);
            }
            break;
          case AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE:
            postNode.setType(Node.TYPE_TRANS_SIMPLE);
            postNode.setTime(((TransitionModel)currentPlace).getToolSpecific().getTime());
            postNode.setTimeUnit(getTimeUnitConst(((TransitionModel)currentPlace).getToolSpecific().getTimeUnit()));
            break;
          case AbstractPetriNetElementModel.SUBP_TYPE:
            postNode.setType(Node.TYPE_SUBP);
            postNode.setTime(((TransitionModel)currentPlace).getToolSpecific().getTime());
            postNode.setTimeUnit(getTimeUnitConst(((TransitionModel)currentPlace).getToolSpecific().getTimeUnit()));
            break;
          default:
            postNode.setType(0);
          }
        }

        nodeIdx = findNextFreeIndex();
        nodeArray[nodeIdx] = postNode;
      }

      try{
        double p = (mec.findArc(n.getId(), currentPlace.getId())).getProbability();
       
        // Kompatibilit�t zu alten Netzen
        if (p == 0.0) p = 1.0;
       
        Arc a = new Arc(nodeArray[nodeIdx], p);
        a.setSource(n);
        n.getSuccessor().add(a);
      } catch(Exception e){
        e.printStackTrace();
      }
    }
   
    while (preNodes.hasNext()){
      AbstractPetriNetElementModel currentNode = (AbstractPetriNetElementModel) preNodes.next();

      int nodeIdx = getNodeIdx(currentNode.getId());
      if (nodeIdx >= nodeArray.length){
        Node preNode = new Node(currentNode.getId(), currentNode.getNameValue());
        switch (currentNode.getType()){
        case AbstractPetriNetElementModel.PLACE_TYPE:
          preNode.setType(Node.TYPE_PLACE);
          break;
        case AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE:
          preNode.setType(Node.TYPE_TRANS_SIMPLE);
          preNode.setTime(((TransitionModel)currentNode).getToolSpecific().getTime());
          break;
        case AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE:
          preNode.setType(Node.TYPE_TRANS_SIMPLE);
          preNode.setTime(((TransitionModel)currentNode).getToolSpecific().getTime());
          break;
        case AbstractPetriNetElementModel.SUBP_TYPE:
          preNode.setType(Node.TYPE_SUBP);
          preNode.setTime(((TransitionModel)currentNode).getToolSpecific().getTime());
          break;
        default:
          preNode.setType(0);
        }
        nodeIdx = findNextFreeIndex();
        nodeArray[nodeIdx] = preNode;
      }
     
      try{
        double p = (mec.findArc(currentNode.getId(), n.getId())).getProbability();
        Arc a = new Arc(nodeArray[nodeIdx], p);
        a.setSource(a.getTarget());
        a.setTarget(n);
        n.getPredecessor().add(a);
       
View Full Code Here

   */
  public SimGraph(IEditor editor) {
    this.mec = editor.getModelProcessor().getElementContainer();
    IQualanalysisService qualanService = QualAnalysisServiceFactory.createNewQualAnalysisService(editor);   
    buildGraph();   
    AbstractPetriNetElementModel el = (AbstractPetriNetElementModel) qualanService.getSinkPlaces().iterator().next();
    sink = Nodes.get(el.getId());
    el = (AbstractPetriNetElementModel) qualanService.getSourcePlaces().iterator().next();
    source = Nodes.get(el.getId());       
  }
View Full Code Here

    return n;
  }

  void buildGraph() {
    // first run through all elements creates the map with all SimNodes
    AbstractPetriNetElementModel el = null;
    SimNode node = null;
    for (Iterator<?> i = mec
        .getElementsByType(AbstractPetriNetElementModel.PLACE_TYPE).values()
        .iterator(); i.hasNext();) {
      el = (AbstractPetriNetElementModel) i.next();
      Nodes.put(el.getId(), createSimNode(el));
    }
    allTrans = mec.getElementsByType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
    allTrans.putAll(mec.getElementsByType(AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE));
    allTrans.putAll(mec.getElementsByType(AbstractPetriNetElementModel.SUBP_TYPE));   
    for (Iterator<AbstractPetriNetElementModel> i = allTrans.values().iterator(); i.hasNext();) {
      el = (AbstractPetriNetElementModel) i.next();
      node = createSimNode(el);
      Nodes.put(el.getId(), node);     
      addResource(el, node);     
    }
   
    // second run through all elements creates the arc with probability and
    // pre and post SimNodes
View Full Code Here

  public void createArcPrePostNode() {
    for (SimNode n : Nodes.values()) {
      for (Iterator<?> target = mec.getTargetElements(n.getid()).values()
          .iterator(); target.hasNext();) {
        AbstractPetriNetElementModel postNode = (AbstractPetriNetElementModel) target
            .next();
        double p = (mec.findArc(n.getid(), postNode.getId()))
            .getProbability();
        if (p == 0.0)
          p = 1;
        SimArc arc = new SimArc(n, Nodes.get(postNode.getId()), p);
        n.getarcOut().add(arc);
      }
      for (Iterator<?> source = mec.getSourceElements(n.getid()).values()
          .iterator(); source.hasNext();) {
        AbstractPetriNetElementModel preNode = (AbstractPetriNetElementModel) source
            .next();
        SimArc arc = new SimArc(n, Nodes.get(preNode.getId()));
        n.getarcIn().add(arc);
      }
    }
  }
View Full Code Here

                {
                    m_selection[0] = ((GroupModel) m_selection[0]).getMainElement();
                }
                if (m_selection[0] instanceof AbstractPetriNetElementModel)
                {
                    AbstractPetriNetElementModel element = (AbstractPetriNetElementModel) m_selection[0];

                    if (element instanceof PlaceModel)
                    {
                        //logger.info("Changing PlaceModel");
                        // OLDUserInterface.getInstance().getActiveEditor().getGraph().getGraphLayoutCache().valueForCellChanged(((PlaceModel)element).getNameModel(),
View Full Code Here

   * hierarchies
   *
   */
   private void gettingElements(HashMap<String, SGYElement> vertices) {
    HashMap<String, SGYElement> potentialSources;
    AbstractPetriNetElementModel ele;
    ArcModel arc;
    String sSource, sTarget;
    ModelElementContainer mec = editor.getModelProcessor()
        .getElementContainer();

    // getting Elements and Arcs
    for (String elementId : mec.getIdMap().keySet()) {
      ele = mec.getElementById(elementId);
      selectElements.add(ele.getParent());
      if (lineType != 2) {
        if (ele instanceof TransitionModel) {
          TransitionModel transitionModel = (TransitionModel) ele;
          if (transitionModel.hasTrigger()) {
            lineType = 1;
          }
          if (transitionModel.hasResource()) {
            lineType = 2;
          }
        }
      }
      vertices.put(ele.getId(), new SGYElement(ele));
    }

    // building relationships, defines the source
    potentialSources = (HashMap<String, SGYElement>) vertices.clone();
    for (String arcId : mec.getArcMap().keySet()) {
View Full Code Here

   * calculates the size of the model basing on model-position and
   * -width/-height
   */
  private void calculateModelSize() {
    ModelElementContainer elements = editor.getModelProcessor().getElementContainer();
    AbstractPetriNetElementModel element = null;

    modelSize = new Dimension(100, 100);

    for (String elementId : elements.getIdMap().keySet()) {
      element = elements.getElementById(elementId);
      int elementNameWidth = element.getNameModel().getNameValue()
          .length() * 7;
      // TODO: The best would be taking the size of the blue box itself
      if (element.getX() + element.getWidth() + elementNameWidth > modelSize.width) {
        modelSize.width = element.getX() + element.getWidth()
            + elementNameWidth;
      }
      if (element.getY() + element.getHeight() > modelSize.height) {
        modelSize.height = element.getY() + element.getHeight();
      }
    }
    // Adding some offset for editor-frame, statusbar, scrollbar, etc.
    modelSize.width += 60;
    modelSize.height += 120;
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.