Package org.woped.core.model

Examples of org.woped.core.model.ArcModel


    for(String key:origMap.keySet()){
      // Number of children
      outboundLines.put(key, origMap.get(key).size() - 1);
      // Adds itself as a parent reference for its children
      for(String subkey:origMap.get(key).keySet()){
        ArcModel arc = mec.getArcMap().get(subkey);
        if(arc == null) continue;
        String childKey = arc.getTargetId();
       
        if(inboundLines.containsKey(childKey))
          inboundLines.put(childKey, inboundLines.get(childKey) + 1);
        else
          inboundLines.put(childKey, 1);
View Full Code Here


        multipleSelected = true;
      }
      else if (selectedCell instanceof ArcModel)
      {
        arcSelected = true;
        ArcModel a = (ArcModel)selectedCell;
        if (a.isXORsplit(editor.getModelProcessor()))
        {
          xorArcSelected = true;
        }
        if (((ArcModel) selectedCell).isRoute())
        {
View Full Code Here

   */
  public LinearPathDescriptor(Map<String, Map<String,Object>> idMap, Map<String,ArcModel> arcMap){
    for(String key:idMap.keySet()){
      ArrayList<String> children = new ArrayList<String>();
      for(String subkey:idMap.get(key).keySet()){
        ArcModel arc = arcMap.get(subkey);
        if(arc == null) continue;
        arcs.add(arc);
        children.add(arc.getTargetId());
      }
      pathMap.put(key, children);
    }
  }
View Full Code Here

    }
     
   
    for(String key:idMap.keySet()){
      for(String subkey:idMap.get(key).keySet()){
        ArcModel arc = arcMap.get(subkey);
        if(arc == null) continue;
        g.addEdge(idToVertex.get(arc.getSourceId()), idToVertex.get(arc.getTargetId()));
      }
    }
   
    rpst = new RPST<DirectedEdge,Vertex>(g);
   
View Full Code Here

    private void importArcs(Arc[] arcs, int editorIndex) throws Exception
    {
        AbstractPetriNetElementModel currentSourceModel = null;
        AbstractPetriNetElementModel currentTargetModel = null;
        ArcModel arc = null;
        CreationMap map;
        for (int i = 0; i < arcs.length; i++)
        {
            currentSourceModel = (AbstractPetriNetElementModel) getEditor()[editorIndex].getModelProcessor().getElementContainer().getElementById(arcs[i].getSource());
            currentTargetModel = (AbstractPetriNetElementModel) getEditor()[editorIndex].getModelProcessor().getElementContainer().getElementById(arcs[i].getTarget());
            String tempID;

            if (ConfigurationManager.getConfiguration().isImportToolspecific())
            {
                if (currentTargetModel == null && currentSourceModel != null)
                {
                    if (arcs[i].getTarget().indexOf(OperatorTransitionModel.INNERID_SEPERATOR) != 0)
                    {
                        tempID = arcs[i].getTarget().substring(0, arcs[i].getTarget().indexOf(OperatorTransitionModel.INNERID_SEPERATOR));
                    } else
                    {
                        tempID = arcs[i].getTarget().substring(0, arcs[i].getTarget().indexOf(OperatorTransitionModel.INNERID_SEPERATOR_OLD));
                    }
                    if (isOperator(getEditor()[editorIndex].getModelProcessor(), tempID))
                    {
                        map = CreationMap.createMap();
                        map.setArcSourceId(arcs[i].getSource());
                        map.setArcTargetId(tempID);
                        arc = (ArcModel)getEditor()[editorIndex].create(map);
                    }
                }
                if (currentSourceModel == null && currentTargetModel != null)
                {
                    if (arcs[i].getSource().indexOf(OperatorTransitionModel.INNERID_SEPERATOR) != 0)
                    {
                        tempID = arcs[i].getSource().substring(0, arcs[i].getSource().indexOf(OperatorTransitionModel.INNERID_SEPERATOR));
                    } else
                    {
                        tempID = arcs[i].getSource().substring(0, arcs[i].getSource().indexOf(OperatorTransitionModel.INNERID_SEPERATOR_OLD));
                    }

                    if (isOperator(getEditor()[editorIndex].getModelProcessor(), tempID))
                    {
                        map = CreationMap.createMap();
                        map.setArcSourceId(tempID);
                        map.setArcTargetId(arcs[i].getTarget());
                        arc = (ArcModel)getEditor()[editorIndex].create(map);
                    }
                }
                if (currentTargetModel != null && currentSourceModel != null)
                {
                    map = CreationMap.createMap();
                    map.setArcSourceId(arcs[i].getSource());
                    map.setArcTargetId(arcs[i].getTarget());
                    arc = (ArcModel)getEditor()[editorIndex].create(map);
                }
            } else
            {
                map = CreationMap.createMap();
                map.setArcSourceId(arcs[i].getSource());
                map.setArcTargetId(arcs[i].getTarget());
                arc = (ArcModel)getEditor()[editorIndex].create(map);
            }
            if (arcs[i].isSetGraphics() && arc != null)
            {
                for (int j = 0; j < arcs[i].getGraphics().getPositionArray().length; j++)
                {
                    arc.addPoint(new Point2D.Double(arcs[i].getGraphics().getPositionArray(j).getX(), arcs[i].getGraphics().getPositionArray(j).getY()));
                }
            }
            LoggerManager.debug(Constants.FILE_LOGGER, " ... Arc (ID:" + arcs[i].getId() + "( " + arcs[i].getSource() + " -> " + arcs[i].getTarget() + ") created");
        }
    }
View Full Code Here

    else
    {
      editor = (EditorVC) getMediator().getUi().getEditorFocus();
    }
    Object cell;
    ArcModel anArc;
    Iterator<String> anIter;
    if (editor != null)
    {
      CreationMap map = CreationMap.createMap();
      if (editor.getLastMousePosition() != null)
      {
        map.setPosition((int)(editor.getLastMousePosition().getX() / editor.getGraph().getScale()),
                (int)(editor.getLastMousePosition().getY() / editor.getGraph().getScale()));               
      }

      switch (event.getOrder())
      {
      // Petrinet
      case AbstractViewEvent.ADD_PLACE:
        map.setType(AbstractPetriNetElementModel.PLACE_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_TRANSITION:
        map.setType(AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_ANDJOIN:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.AND_JOIN_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_ANDSPLIT:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.AND_SPLIT_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_ANDSPLITJOIN:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.AND_SPLITJOIN_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_XORJOIN:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.XOR_JOIN_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_XORSPLIT:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.XOR_SPLIT_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_XORSPLITJOIN:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.XOR_SPLITJOIN_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_ANDJOINXORSPLIT:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.ANDJOIN_XORSPLIT_TYPE);
        editor.create(map);
        break;
      case AbstractViewEvent.ADD_XORJOINANDSPLIT:
        map.setType(AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE);
        map.setOperatorType(OperatorTransitionModel.XORJOIN_ANDSPLIT_TYPE);
        editor.create(map);
        break;
      // General
      case AbstractViewEvent.RENAME:
        cell = editor.getGraph().getSelectionCell();
        if (cell instanceof TriggerModel)
        {
          cell = ((TriggerModel) cell).getParent();
        }
        if (cell instanceof GroupModel)
        {
          cell = ((GroupModel) cell).getMainElement();
        }
        editor.edit(cell);
        break;
      case AbstractViewEvent.REMOVE:
        editor.deleteSelection();
        break;
      case AbstractViewEvent.CUT:
        editor.cutSelection();
        break;
      case AbstractViewEvent.COPY:
        editor.copySelection();
        break;
      case AbstractViewEvent.PASTE:
        editor.paste();
        break;
      case AbstractViewEvent.PASTE_AT:
        editor.pasteAtMousePosition();
        break;
      case AbstractViewEvent.REDO:
        editor.redo();
        break;
      case AbstractViewEvent.UNDO:
        editor.undo();
        break;
      case AbstractViewEvent.UNGROUP:
        editor.getGraph().ungroupSelection();
        break;
      case AbstractViewEvent.GROUP:
        editor.getGraph().groupSelection();
        break;
      case AbstractViewEvent.OPEN_PROPERTIES:
        cell = editor.getGraph().getSelectionCell();
        AbstractPetriNetElementModel element = null;

        if (cell instanceof ArcModel && ((ArcModel) cell).isXORsplit(editor.getModelProcessor()))
        {
          new ArcPropertyEditor((JFrame) getMediator().getUi(), (Point)editor.getLastMousePosition(), (ArcModel) cell, editor);
        }

        if (cell instanceof TriggerModel)
        {
          cell = ((TriggerModel) cell).getParent();
        }
        if (cell instanceof GroupModel)
        {
          element = ((GroupModel) cell).getMainElement();
        }
        else if (cell instanceof AbstractPetriNetElementModel)
        {
          element = (AbstractPetriNetElementModel) cell;
        }
        if (element != null)
        {
          if (element instanceof TransitionModel)
          {
            new TransitionPropertyEditor((JFrame) getMediator()
                .getUi(), (Point)editor.getLastMousePosition(), (TransitionModel)element, editor);

          }
          if (element instanceof PlaceModel)
          {
            new PlacePropertyEditor((JFrame) getMediator().getUi(), (Point)editor.getLastMousePosition(), (PlaceModel)element, editor);
          }
        }
        break;
      case AbstractViewEvent.ADD_POINT:
        editor.addPointToSelectedArc();
        break;
      case AbstractViewEvent.REMOVE_POINT:
        editor.removeSelectedPoint();
        break;
      case AbstractViewEvent.ADD_EXT_TRIGGER:
        cell = editor.getGraph().getSelectionCell();
        removeResources(editor, cell);
        editor.createTrigger(getCreateTriggerMap(editor.getGraph().getSelectionCell(),
            TriggerModel.TRIGGER_MESSAGE));
        break;
      case AbstractViewEvent.ADD_RES_TRIGGER:
        editor.createTrigger(getCreateTriggerMap(editor.getGraph().getSelectionCell(),
            TriggerModel.TRIGGER_RESOURCE));
        break;
      case AbstractViewEvent.ADD_TIME_TRIGGER:
        cell = editor.getGraph().getSelectionCell();
        removeResources(editor, cell);
        editor.createTrigger(getCreateTriggerMap(editor.getGraph().getSelectionCell(),
            TriggerModel.TRIGGER_TIME));
        break;
      case AbstractViewEvent.REMOVE_TRIGGER:
        cell = editor.getGraph().getSelectionCell();
        removeResources(editor, cell);
        if (cell instanceof GroupModel)
        {
          cell = ((GroupModel) cell).getMainElement();
        }
        if (cell instanceof TransitionModel)
        {
          editor.deleteCell(((TransitionModel) cell).getToolSpecific().getTrigger(), true);
        }
        break;
      case AbstractViewEvent.ADD_SUBPROCESS:
        editor.createElement(AbstractPetriNetElementModel.SUBP_TYPE, -1, editor.getLastMousePosition(), false);
        break;
      case AbstractViewEvent.ROUTING_ACTIVE:
        cell = editor.getGraph().getSelectionCell();
        ((ArcModel) cell).setRoute(true);
        editor.getGraph().connect(((ArcModel) cell), true);
        break;
      case AbstractViewEvent.ROUTING_DEACTIVE:
        cell = editor.getGraph().getSelectionCell();
        ((ArcModel) cell).setRoute(false);
        editor.getGraph().connect(((ArcModel) cell), true);
        break;
      case AbstractViewEvent.ROUTING_ALL_ACTIVE:
        anIter = editor.getModelProcessor().getElementContainer().getArcMap().keySet().iterator();

        while (anIter.hasNext())
        {
          anArc = editor.getModelProcessor().getElementContainer().getArcById(anIter.next());
          anArc.setRoute(true);
          editor.getGraph().connect(anArc, true);
        }
        editor.updateNet();
        break;
      case AbstractViewEvent.ROUTING_ALL_DEACTIVE:
        anIter = editor.getModelProcessor().getElementContainer().getArcMap().keySet().iterator();
        while (anIter.hasNext())
        {
          anArc = editor.getModelProcessor().getElementContainer().getArcById(anIter.next());
          anArc.setRoute(false);
          editor.getGraph().connect(anArc, true);
        }
        editor.updateNet();
        break;
      case AbstractViewEvent.ADD_TOKEN:
View Full Code Here

        }
        getGraphLayoutCache().insertGroup(group, new Object[] { element, ((AbstractPetriNetElementModel) element).getNameModel() });
      }
      for (Iterator<ArcModel> iter = processor.getElementContainer().getArcMap().values().iterator(); iter.hasNext();)
      {
        ArcModel arc = iter.next();                   
        connect(arc, true);
      }
    }
View Full Code Here

      }
    }

    // rotate arcpoints
    Iterator<String> arcsIter = mec.getArcMap().keySet().iterator();
    ArcModel arc;
    while (arcsIter.hasNext()) {
      arc = mec.getArcById(arcsIter.next());
      if (arc != null) {
        for (Point2D p : arc.getPoints()) {
          p.setLocation(p.getY(), p.getX());
        }
      }
    }
    if (negX < 0 || negY < 0) {
View Full Code Here

   * @param moveY the value to move all elements up or down
   * @param mec the ModelElementContainer with all elements which have to been moved
   */
  private void moveAllElements(int moveX, int moveY, ModelElementContainer mec) {
    AbstractPetriNetElementModel element;
    ArcModel arc;
    for (String elementId : mec.getIdMap().keySet()) {
      element = mec.getElementById(elementId);
      if (element != null) {
        // move element
        element.setPosition(element.getX() + moveX, element.getY() + moveY);

        // move element�s name
        element.getNameModel().setPosition(element.getNameModel().getX() + moveX,
            element.getNameModel().getY() + moveY);

        // move triggers and resources (if existing)
        if (element instanceof TransitionModel) {
          TransitionModel tm = (TransitionModel) element;

          if (tm.hasTrigger()) {
            TriggerModel trigMod = tm.getToolSpecific().getTrigger();
            trigMod.setPosition(trigMod.getX() + moveX, trigMod.getY() + moveY);
          }
          if (tm.hasResource()) {
            TransitionResourceModel transRes = tm.getToolSpecific().getTransResource();
            transRes.setPosition(transRes.getX() + moveX, transRes.getY() + moveY);
          }
        }
      }
    }
    // move arcs
    for (String arcId : mec.getArcMap().keySet()) {
      arc = mec.getArcById(arcId);
      if (arc != null) {
        for (Point2D p : arc.getPoints()) {
          p.setLocation(p.getX() + moveX, p.getY() + moveY);
        }
      }
    }
  }
View Full Code Here

        this.arcCounter = 0;
        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());

            if (currentTargetModel.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE)
              connectedTransitions.add(currentTargetModel);
            else if (currentSourceModel.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE)
              connectedTransitions.add(currentSourceModel);
            else
            {
                initArc(iNet.addNewArc(), currentArc, null);
            }
        }
     
        Iterator<AbstractPetriNetElementModel> currentTransition = connectedTransitions.iterator();
        while (currentTransition.hasNext())
        {
          OperatorTransitionModel currentConnectedModel = (OperatorTransitionModel)currentTransition.next();
          Iterator<String> innerArcIter = currentConnectedModel.getSimpleTransContainer().getArcMap().keySet().iterator();
          while (innerArcIter.hasNext())
          {
            ArcModel currentInnerArc = (ArcModel) currentConnectedModel.getSimpleTransContainer().getArcMap().get(innerArcIter.next());

            ArcModel currentOuterArc = null;
            if (elementContainer.getElementById(currentInnerArc.getSourceId())!=null)
            {
              currentOuterArc = elementContainer.findArc(currentInnerArc.getSourceId(),
                  currentConnectedModel.getId());
            }
View Full Code Here

TOP

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

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.