Examples of ArcModel


Examples of org.woped.core.model.ArcModel

   *
   * @param map
   * @return
   */
  public ArcModel createArc(CreationMap map, boolean insertIntoCache) {
    ArcModel arc = null;
    String sourceId = map.getArcSourceId();
    String targetId = map.getArcTargetId();
    List<?> points = map.getArcPoints();
    Point2D[] pointArray = new Point2D[points.size()];
    for (int i = 0; i < points.size(); i++) {
      if (points.get(i) instanceof Point2D) {
        pointArray[i] = (Point2D) points.get(i);
      } else if (points.get(i) instanceof IntPair) {
        pointArray[i] = new Point2D.Double(
            ((IntPair) points.get(i)).getX1(),
            ((IntPair) points.get(i)).getX2());
      }
    }

    // CHECK if connection is valid
    if (getGraph().isValidConnection(
        getModelProcessor().getElementContainer().getElementById(
            sourceId),
        getModelProcessor().getElementContainer().getElementById(
            targetId))) {
      if (!getModelProcessor().getElementContainer().hasReference(
          sourceId, targetId)) {
        arc = getModelProcessor().createArc(map.getArcId(), sourceId,
            targetId, pointArray, true);
        getGraph().connect(arc, insertIntoCache);
        // Manually copy arc points
        for (int i = 0; i < pointArray.length; ++i) {
          addPointToArc(arc, pointArray[i]);
        }
        // Copy probability state of the creation map
        arc.setProbability(map.getArcProbability());
        arc.setDisplayOn(map.getDisplayArcProbability());
        // If there is a label position, copy it
        if (map.getArcLabelPosition() != null) {
          arc.setLabelPosition(new Point2D.Double(map
              .getArcLabelPosition().getX(), map
              .getArcLabelPosition().getY()));
        }
      } else {
        LoggerManager.debug(Constants.EDITOR_LOGGER,
View Full Code Here

Examples of org.woped.core.model.ArcModel

   * Remove the Point closest to the Mouse Position of the currently selected
   * Arc.
   */
  public void removeSelectedPoint() {
    Point2D l = m_lastMousePosition;
    ArcModel arc = (ArcModel) getGraph().getFirstCellForLocation(l.getX(),
        l.getY());
    arc.removePoint(l);
    getGraph().getModel().insert(new Object[] { arc }, null, null, null,
        null);
  }
View Full Code Here

Examples of org.woped.core.model.ArcModel

        currentElement = getModelProcessor().getElementContainer()
            .getElementById(
                ((TriggerModel) currentElement).getOwnerId());
      }
      if (currentElement instanceof ArcModel) {
        ArcModel tempArc = (ArcModel) currentElement;
        clipboardArcs.add(tempArc);
      }     
      if (currentElement instanceof AbstractPetriNetElementModel) {
        AbstractPetriNetElementModel tempElement = (AbstractPetriNetElementModel) currentElement;
        // copy the element
View Full Code Here

Examples of org.woped.core.model.ArcModel

      toSelectElements.add(tempElement.getParent());
    }

    /* insert arcs */
    Iterator<String> arcIter = pasteArcs.keySet().iterator();
    ArcModel tempArc;
    Point2D point;
    CreationMap cmap = CreationMap.createMap();
    while (arcIter.hasNext()) {
      currentArcMap = pasteArcs.get(arcIter.next());
      if ((currentArcMap.getArcSourceId() != null)
          && (currentArcMap.getArcTargetId()) != null) {

        cmap.setArcSourceId(currentArcMap.getArcSourceId());
        cmap.setArcTargetId(currentArcMap.getArcTargetId());
        tempArc = createArc(cmap, true);
       
        // It is possible that an arc could not be created, because either its source
        // or target element are missing. Simply ignore the arc in this case
        if (tempArc == null)
          continue;
       
        for (short k = 0; k < currentArcMap.getArcPoints().size(); k++) {

          IntPair ip = (IntPair) currentArcMap.getArcPoints().get(k);
          point = new Point2D.Double(ip.getX1() + deltaX, ip.getX2()
              + deltaY);

          tempArc.addPoint(point);
        }

        toSelectElements.add(tempArc);
      }
    }
View Full Code Here

Examples of org.woped.core.model.ArcModel

     */
    private void setIncomingArcsActive(Object transitionId, boolean active) {
        Iterator<String> incomingArcsIter = getPetriNet().getElementContainer().getIncomingArcs(transitionId).keySet()
                .iterator();
        while (incomingArcsIter.hasNext()) {
            ArcModel arc = getPetriNet().getElementContainer().getArcById(incomingArcsIter.next());
            if (active) {
                PlaceModel place = (PlaceModel) getPetriNet().getElementContainer().getElementById(arc.getSourceId());
                if (place.getVirtualTokenCount() > 0) {
                    arc.setActivated(true);
                    // TODO: check weight
                }
            } else {
                arc.setActivated(false);
            }
        }
    }
View Full Code Here

Examples of org.woped.core.model.ArcModel

        Map<String, ArcModel> arcsFromPlaces = getRootOwningContainer().getIncomingArcs(getId());
     
        Iterator<String> incomingArcsIter = arcsFromPlaces.keySet().iterator();
        int activePlaces = 0;
        while (incomingArcsIter.hasNext()) {
            ArcModel arc = getRootOwningContainer().getArcById(incomingArcsIter.next());
            try {
                PlaceModel place = (PlaceModel) getRootOwningContainer().getElementById(arc.getSourceId());
                if (place != null && place.getVirtualTokenCount() > 0) {
                    // TODO: when ARC WEIGTH implemented check tokens >= weigth
                    activePlaces++;
                }
            } catch (ClassCastException cce) {
                LoggerManager.warn(Constants.CORE_LOGGER, "TokenGame: Source not a Place. Ignore arc: "
                        + arc.getId());
            }
        }
        return activePlaces;
   
View Full Code Here

Examples of org.woped.core.model.ArcModel

     */
        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
                    if (place != null && place.isActivated()) {
                        // If an active place has been clicked there is only one reasonable explanation for this:
                        // It is a sink place of a sub-process
View Full Code Here

Examples of org.woped.core.model.ArcModel

            sinkTStarMap.setArcTargetId(tStar.getId());
            sinkTStarMap.setEditOnCreation(false);
            List<Point> sinkTStarPointList = new ArrayList<Point>();
            sinkTStarPointList.add(sinkArcPoint);
            sinkTStarMap.setArcPoints(sinkTStarPointList);
            ArcModel sinkTStarArc = createArc(sinkTStarMap, true);
            tStarComponents[1] = sinkTStarArc;

            CreationMap tStarSourceMap = CreationMap.createMap();
            tStarSourceMap.setArcSourceId(tStar.getId());
            tStarSourceMap.setArcTargetId(source.getId());
            tStarSourceMap.setEditOnCreation(false);
            List<Point> tStarSourcePointList = new ArrayList<Point>();
            tStarSourcePointList.add(sourceArcPoint);
            tStarSourceMap.setArcPoints(tStarSourcePointList);
            ArcModel tStarSourceArc = createArc(tStarSourceMap, true);
            tStarComponents[2] = tStarSourceArc;
            editor.getGraph().setEnabled(false);
        }
    }
View Full Code Here

Examples of org.woped.core.model.ArcModel

        editor.getGraph().getModel().remove(allDeletedObjects.toArray());
        editor.updateNet();
    }

    public ArcModel createArc(CreationMap map, boolean insertIntoCache) {
        ArcModel arc = null;
        String sourceId = map.getArcSourceId();
        String targetId = map.getArcTargetId();
        List<?> points = map.getArcPoints();
        Point2D[] pointArray = new Point2D[points.size()];
        for (int i = 0; i < points.size(); i++) {
            if (points.get(i) instanceof Point2D) {
                pointArray[i] = (Point2D) points.get(i);
            } else
                if (points.get(i) instanceof IntPair) {
                    pointArray[i] = new Point2D.Double(((IntPair) points.get(i)).getX1(), ((IntPair) points.get(i))
                            .getX2());
                }
        }
        AbstractPetriNetElementModel source = editor.getModelProcessor().getElementContainer().getElementById(sourceId);
        source = source != null ? source : tStar;
        AbstractPetriNetElementModel target = editor.getModelProcessor().getElementContainer().getElementById(targetId);
        target = target != null ? target : tStar;
        if (editor.getGraph().isValidConnection(source, target)) {
            if (!editor.getModelProcessor().getElementContainer().hasReference(sourceId, targetId)) {

                String id = map.getArcId();
                // if the id isn't set or the id set already belongs to an
                // existing arc then fetch a new one
                if (id == null | editor.getModelProcessor().getElementContainer().getArcById(id) != null) {
                    id = editor.getModelProcessor().getNexArcId();
                }
                // if aalst source or target -> update Model
                arc = ModelElementFactory.createArcModel(id, (DefaultPort) source.getChildAt(0), (DefaultPort) target
                        .getChildAt(0));
                arc.setPoints(pointArray);
                GraphConstants.setSelectable(arc.getAttributes(), false);
                GraphConstants.setLineColor(arc.getAttributes(), T_STAR_COLOR);

                OperatorTransitionModel operatorModel;
                if (source.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE) {
                    operatorModel = (OperatorTransitionModel) source;
                    operatorModel.addElement(target);
                    operatorModel.registerOutgoingConnection((PetriNetModelProcessor) editor.getModelProcessor(),
                            target);
                } else
                    if (target.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE) {
                        operatorModel = (OperatorTransitionModel) target;
                        operatorModel.addElement(source);
                        operatorModel.registerIncomingConnection((PetriNetModelProcessor) editor.getModelProcessor(),
                                source);

                    }
                editor.getModelProcessor().getElementContainer().addReference(arc);

                editor.getGraph().connect(arc, insertIntoCache);
                for (int i = 0; i < pointArray.length; ++i) {
                    arc.addPoint(pointArray[i]);
                    Map<ArcModel, AttributeMap> arcMap = new HashMap<ArcModel, AttributeMap>();
                    arcMap.put(arc, arc.getAttributes());
                    editor.getGraph().getModel().edit(arcMap, null, null, null);
                }
                arc.setProbability(map.getArcProbability());
                arc.setDisplayOn(map.getDisplayArcProbability());
                if (map.getArcLabelPosition() != null) {
                    arc.setLabelPosition(new Point2D.Double(map.getArcLabelPosition().getX(), map.getArcLabelPosition()
                            .getY()));
                }
            }
        }
        return arc;
View Full Code Here

Examples of org.woped.core.model.ArcModel

    Iterator<String> arcIterator = arcMap.keySet().iterator();

    while (arcIterator.hasNext())
    {
      ArcModel curArc = (ArcModel) arcMap.get(arcIterator.next());

      if (curArc.getSourceId().equals(oldMap.getId()))
        outAcrs.add(curArc.getCreationMap());

      if (curArc.getTargetId().equals(oldMap.getId()))
        incAcrs.add(curArc.getCreationMap());

    }

    // Remove the old transition
    // If we are part of a group (we always should be if we're a transition),
    // we delete the group to make sure we delete name and any other cells
    // that might be grouped along with us
    DefaultGraphCell transitionCell = transition;
    if (transition.getParent() instanceof GroupModel) {
      transitionCell = (DefaultGraphCell) transition.getParent();
    }
    editor.deleteCell(transitionCell, true);
    editor.create(newMap);

    for (int i = 0; i < outAcrs.size(); i++)
    {
      ArcModel am = editor.createArc(outAcrs.get(i),true);
      // Some special behavior: As this method is all about changing
      // the operator type, what could happen to us is that the operator type
      // changed to a non-XOR-split type and previously a probability was
      // displayed for the arc. Catch this and disable the display
      if (!am.isXORsplit(editor.getModelProcessor())) {
        am.setProbability(1);
        am.setDisplayOn(false);
      }
      else {
        if (am.getProbability() != 1)
          am.setDisplayOn(true);
      }
         
    }

    for (int i = 0; i < incAcrs.size(); i++)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.