Package org.woped.core.model.petrinet

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


    // creating a new ModelElement through Factory
    if (map.isValid()) {
      if (map.getId() == null) {
        map.setId(getNewElementId(map.getType()));
      }
      AbstractPetriNetElementModel anElement = ModelElementFactory
          .createModelElement(map);
      getElementContainer().addElement(anElement);

      if (map.getType() == AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE
          || map.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE
View Full Code Here


   * @return ArcModel
   */
  public ArcModel createArc(String id, Object sourceId, Object targetId,
      Point2D[] points, boolean transformOperators) {

    AbstractPetriNetElementModel sourceModel = getElementContainer()
        .getElementById(sourceId);
    AbstractPetriNetElementModel targetModel = getElementContainer()
        .getElementById(targetId);

    if ((sourceModel == null) || (targetModel == null)) {
      return null;
    }

    // if the id isn't set or the id set already belongs to an existing arc
    // then fetch a new one
    if (id == null | this.getElementContainer().getArcById(id) != null) {
      id = getNexArcId();
    }

    // if aalst source or target -> update Model
    ArcModel displayedArc = ModelElementFactory.createArcModel(id,
        (DefaultPort) sourceModel.getChildAt(0),
        (DefaultPort) targetModel.getChildAt(0));
    displayedArc.setPoints(points);
    insertArc(displayedArc, transformOperators);
    return displayedArc;
  }
View Full Code Here

    insertArc(displayedArc, transformOperators);
    return displayedArc;
  }

  public void insertArc(ArcModel arc, boolean transformOperators) {
    AbstractPetriNetElementModel sourceModel = getElementContainer()
        .getElementById(arc.getSourceId());
    AbstractPetriNetElementModel targetModel = getElementContainer()
        .getElementById(arc.getTargetId());
    getElementContainer().addReference(arc);

    /* IF transform Operators into classic petrinet */
    if (transformOperators) {
      OperatorTransitionModel operatorModel;
      /* IF THE SOURCE IS AN OPERATOR */
      if (sourceModel.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE) {

        // storing the source as operator
        operatorModel = (OperatorTransitionModel) sourceModel;
        // put the Target in the SimpleContainer of the operator
        operatorModel.addElement(getElementContainer().getElementById(
            targetModel.getId()));

        LoggerManager
            .debug(Constants.CORE_LOGGER,
                "Connection from Aalst Model detected... resolve Inner-Transitions ...");

        // Register new outgoing connection with the operator.
        // This will generate all the necessary inner arcs
        operatorModel.registerOutgoingConnection(this, targetModel);

        LoggerManager.debug(Constants.CORE_LOGGER,
            "... Inner-Transition resolving completed");
      }
      /* IF OPERATOR IS TARGET */
      else if (targetModel.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE) {

        LoggerManager
            .debug(Constants.CORE_LOGGER,
                "Connection to Aalst Model detected... resolve Inner-Transitions ...");
        // stor the target as operatorModel
        operatorModel = (OperatorTransitionModel) getElementContainer()
            .getElementById(targetModel.getId());

        // add the source to the SimpleTransContainer
        operatorModel.addElement(getElementContainer().getElementById(
            sourceModel.getId()));

View Full Code Here

  public void removeArc(Object id) {

    ArcModel arcToDelete = getElementContainer().getArcById(id);
    if (arcToDelete != null) {
      AbstractPetriNetElementModel sourceElement = getElementContainer()
          .getElementById(arcToDelete.getSourceId());
      AbstractPetriNetElementModel targetElement = getElementContainer()
          .getElementById(arcToDelete.getTargetId());

      if (sourceElement.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE) {
        OperatorTransitionModel currentOperator = (OperatorTransitionModel) sourceElement;
        // Register the removal of an outgoing arc
        currentOperator.registerOutgoingConnectionRemoval(this,
            targetElement);

        currentOperator.getSimpleTransContainer()
            .removeSourceArcsFromElement(arcToDelete.getTargetId());

        // Each inner transition container contains a local copy of each
        // element connecting to an operator
        // We have to remove this local copy
        currentOperator.getSimpleTransContainer().removeElement(
            targetElement.getId());

      } else if (targetElement.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE) {
        OperatorTransitionModel currentOperator = (OperatorTransitionModel) targetElement;
        // Register the removal of an incoming arc
        currentOperator.registerIncomingConnectionRemoval(this,
            sourceElement);

        currentOperator.getSimpleTransContainer()
            .removeTargetArcsFromElement(arcToDelete.getSourceId());

        // Each inner transition container contains a local copy of each
        // element connecting to an operator
        // We have to remove this local copy
        currentOperator.getSimpleTransContainer().removeElement(
            sourceElement.getId());

        LoggerManager.debug(Constants.CORE_LOGGER,
            "INNER ARC TO SOURCE deleted");
      }

      // remove element from the subprocess model
      if (targetElement.getType() == AbstractPetriNetElementModel.SUBP_TYPE) {
        ((SubProcessModel) targetElement).getSimpleTransContainer()
            .removeElement(sourceElement.getId());
      }

      if (sourceElement.getType() == AbstractPetriNetElementModel.SUBP_TYPE) {
        ((SubProcessModel) sourceElement).getSimpleTransContainer()
            .removeElement(targetElement.getId());
      }

      getElementContainer().removeArc(arcToDelete);
    }
View Full Code Here

  public String getNewElementId(int elementType) {
    String id = null;

    String prefix = "";
    AbstractPetriNetElementModel owningElement = getElementContainer()
        .getOwningElement();
    if (owningElement != null) {
      prefix = owningElement.getId()
          + OperatorTransitionModel.INNERID_SEPERATOR;
    }

    switch (elementType) {
    case AbstractPetriNetElementModel.SUBP_TYPE:
View Full Code Here

   * @author <a href="mailto:b.joerger@gmx.de">Benjamin Joerger</a>
   */
  public void resetRGHighlightAndVTokens() {
    for (Iterator<AbstractPetriNetElementModel> iter = getElementContainer()
        .getRootElements().iterator(); iter.hasNext();) {
      AbstractPetriNetElementModel current = (AbstractPetriNetElementModel) iter.next();
      current.setRGHighlighted(false);
      if (current instanceof PlaceModel) {
        ((PlaceModel) current).resetVirtualTokens();
      }
    }
  }
View Full Code Here

          // part of the inner
          // workings of an XOR split-join)
          // Create the element using the element factory and the
          // already configured creation map and add it to the model
          // element container
          AbstractPetriNetElementModel element = ModelElementFactory
              .createModelElement(map);
          currentContainer.addElement(element);
        }
        doNOTcreate = false;
        LoggerManager.debug(Constants.FILE_LOGGER, "   ... Place (ID:"
View Full Code Here

          // Now, instead of the transition, an operator is created
          // for each of those inner transitions
          // and all but the first such instance are discarded here
          // because an element
          // with the same id already exists at this point
          AbstractPetriNetElementModel element = processor.createElement(map);
          currentContainer.addElement(element);
          LoggerManager.debug(Constants.FILE_LOGGER,
              " ... Transition (ID:" + map.getId() + ")imported");
          // increaseCurrent();

          if (element.getType() == AbstractPetriNetElementModel.SUBP_TYPE) {
            // The element we just created is a sub-process element
            // Get the corresponding page from the PNML document
            // and restore the sub-process elements by recursively
            // calling importNet()
            Page pages[] = currentNet.getPageArray();
            if (pages != null) {
              for (int currentPage = 0; currentPage < pages.length; ++currentPage) {
                if (pages[currentPage].getId().equals(
                    element.getId())) {
                  // Only one sub-process net per page may be
                  // defined for now
                  // Ignore the rest
                  NetType subProcessNets[] = pages[currentPage]
                      .getNetArray();
View Full Code Here

      private boolean readOnly;
      private Color readOnlyColor = new Color(225, 225, 225);
      private Color highLightedColor = new Color(255, 0, 0, 128);
      private Color HighLightedRGColor = new Color(188,235,253);
      public PetriNetElementRenderer(Object cell) {
        AbstractPetriNetElementModel model = (AbstractPetriNetElementModel) cell;
        readOnly = model.isReadOnly();
      }
View Full Code Here

    // So we will be using it here to instantiate the serialized arcs
    PetriNetModelProcessor processor = new PetriNetModelProcessor();
    processor.setElementContainer(currentContainer);

    for (int i = 0; i < arcs.length; i++) {
      AbstractPetriNetElementModel currentSourceModel = null;
      AbstractPetriNetElementModel currentTargetModel = null;
      ArcModel arc = null;

      try {
        currentSourceModel = (AbstractPetriNetElementModel) currentContainer
            .getElementById(arcs[i].getSource());
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.