コード例 #1
0
  /* Changes the position on the Edges From and Two coordinates. */
  private void manipulateEdge(
      GraphicsType graphicsType, EdgeType edge, Map<String, AnnotationData> annotations) {
    AnnotationData annData;

    if (annotations.containsKey(edge.getSourceId())) {
      annData = annotations.get(edge.getSourceId());
      changeLocation(graphicsType, annData);
    }
    if (annotations.containsKey(edge.getTargetId())) {
      annData = annotations.get(edge.getTargetId());
      changeLocation(graphicsType, annData);
    }
  }
コード例 #2
0
ファイル: TranslateEdge.java プロジェクト: woped/ApromoreCode
  public void translateArc(EdgeType edge) {
    // LOGGER.info("Translating edge " + edge.getId());
    org.apromore.pnml.NodeType arcsource = new org.apromore.pnml.NodeType();
    org.apromore.pnml.NodeType arctarget = new org.apromore.pnml.NodeType();

    NodeType source = data.get_nodeRefMap_value(edge.getSourceId());
    NodeType target = data.get_nodeRefMap_value(edge.getTargetId());

    data.put_id_map(edge.getId(), String.valueOf(ids));

    if (data.getStartNodeMap().containsKey(source)) {
      arcsource = data.getEndNodeMap().get(source);
    }

    if (data.getEndNodeMap().containsKey(target)) {
      arctarget = data.getStartNodeMap().get(target);
    }

    if (data.isCpfEdgePnmlPlace()) {
      // Create a PNML Place corresponding to the CPF Edge
      PlaceType place = new PlaceType();
      place.setId(String.valueOf(ids++));
      place.setGraphics(
          TranslateNode.newGraphicsNodeType(
              TranslateNode.dummyPosition(), TranslateNode.placeDefaultDimension()));
      data.getNet().getPlace().add(place);
      // data.put_pnmlRefMap(place.getId(), place);  TranslateNodeAnnotation can't cope with ANF
      // Edges generating PNML Place Graphics

      // Create incoming arc
      ArcType incomingArc = new ArcType();
      incomingArc.setId(String.valueOf(ids++));
      incomingArc.setTarget(place);
      data.getNet().getArc().add(incomingArc);
      data.put_pnmlRefMap(incomingArc.getId(), incomingArc);

      if (!(arcsource instanceof PlaceType)) {
        incomingArc.setSource(arcsource);
      } else { // insert a silent transition before the place
        TransitionType transition = new TransitionType();
        transition.setId(String.valueOf(ids++));
        transition.setGraphics(
            TranslateNode.newGraphicsNodeType(
                TranslateNode.dummyPosition(), TranslateNode.blindTransitionDefaultDimension()));
        data.getNet().getTransition().add(transition);
        data.put_pnmlRefMap(transition.getId(), transition);

        incomingArc.setSource(transition);

        ArcType arc = new ArcType();
        arc.setId(String.valueOf(ids++));
        arc.setSource(arcsource);
        arc.setTarget(transition);
        data.getNet().getArc().add(arc);
        data.put_pnmlRefMap(arc.getId(), arc);
      }

      // Create outgoing arc
      ArcType outgoingArc = new ArcType();
      outgoingArc.setId(String.valueOf(ids++));
      outgoingArc.setSource(place);
      data.getNet().getArc().add(outgoingArc);
      data.put_pnmlRefMap(outgoingArc.getId(), outgoingArc);

      if (!(arctarget instanceof PlaceType)) {
        outgoingArc.setTarget(arctarget);
      } else { // insert a silent transition after the place
        TransitionType transition = new TransitionType();
        transition.setId(String.valueOf(ids++));
        transition.setGraphics(
            TranslateNode.newGraphicsNodeType(
                TranslateNode.dummyPosition(), TranslateNode.blindTransitionDefaultDimension()));
        data.getNet().getTransition().add(transition);
        data.put_pnmlRefMap(transition.getId(), transition);

        outgoingArc.setTarget(transition);

        ArcType arc = new ArcType();
        arc.setId(String.valueOf(ids++));
        arc.setSource(transition);
        arc.setTarget(arctarget);
        data.getNet().getArc().add(arc);
        data.put_pnmlRefMap(arc.getId(), arc);
      }

      data.put_originalid_map(
          BigInteger.valueOf(Long.valueOf(place.getId())), edge.getOriginalID());
    } else { // !data.isCpfEdgePnmlPlace()
      ArcType arc = new ArcType();
      arc.setId(String.valueOf(ids++));

      // Synthesize a place in the case of an edge between two transitions
      if (arcsource instanceof TransitionType && arctarget instanceof TransitionType) {
        // Create the synthetic place
        PlaceType place = new PlaceType();
        place.setId(String.valueOf(ids++));
        place.setGraphics(
            TranslateNode.newGraphicsNodeType(
                TranslateNode.dummyPosition(), TranslateNode.placeDefaultDimension()));
        data.getNet().getPlace().add(place);
        data.getSynthesizedPlaces().add(place);
        data.put_pnmlRefMap(place.getId(), place);

        // Create outgoing arc from the synthetic place to the original arc's target
        ArcType arc2 = new ArcType();
        arc2.setId(String.valueOf(ids++));
        arc2.setSource(place);
        arc2.setTarget(arctarget);
        data.getNet().getArc().add(arc2);
        data.put_pnmlRefMap(arc2.getId(), arc2);

        // Our original arc now targets the synthesized place
        arctarget = place;
      }
      // changed by Marco Hipp
      ArcType removeArc = null;
      // implemented Method to reconnect misbehaving Place to Place Edge
      if (arcsource instanceof PlaceType && arctarget instanceof PlaceType) {
        // iterate through every Arc to get the Arc that has the source Place as Target
        for (ArcType arcList : data.getNet().getArc()) {
          if (arcList.getTarget() instanceof PlaceType) {
            PlaceType aclistTarget = (PlaceType) arcList.getTarget();
            if (aclistTarget.getId().equals(arcsource.getId())) {
              if (arcList.getSource() instanceof PlaceType) {
                PlaceType transitionSourcePlace = (PlaceType) arcList.getSource();
              }
              if (arcList.getSource() instanceof TransitionType) {
                TransitionType transitionSource = (TransitionType) arcList.getSource();
                org.apromore.pnml.NodeType nodeTransitionSource =
                    (org.apromore.pnml.NodeType) transitionSource;
                org.apromore.pnml.NodeType zwischenspeicher = arcsource;
                data.getNet().getPlace().remove((PlaceType) zwischenspeicher);
                arcsource = nodeTransitionSource;
                // data.getEndNodeMap().remove(source);
                data.getRunningPlaceMap().remove(source);
                removeArc = arcList;
                //	            				for (ArcType removeArc : data.getNet().getArc()) {
                //
                //	            				}

                //	            				data.get
              }
            }
          }
          if (arcList.getTarget() instanceof TransitionType) {
            TransitionType aclistTarget = (TransitionType) arcList.getTarget();
            if (aclistTarget.getId().equals(arcsource.getId())) {
              if (arcList.getSource() instanceof PlaceType) {
                PlaceType transitionSourcePlace = (PlaceType) arcList.getSource();
              }
              if (arcList.getSource() instanceof TransitionType) {
                TransitionType transitionSource = (TransitionType) arcList.getSource();
              }
            }
          }
        }
      }
      if (removeArc != null) data.getNet().getArc().remove(removeArc);
      arc.setSource(arcsource);
      arc.setTarget(arctarget);
      ArcNameType inscription = new ArcNameType();
      inscription.setText(1);
      arc.setInscription(inscription);
      data.getNet().getArc().add(arc);
      data.put_pnmlRefMap(arc.getId(), arc);

      data.put_originalid_map(BigInteger.valueOf(Long.valueOf(arc.getId())), edge.getOriginalID());
    }
    // LOGGER.info("Translated edge " + edge.getId() + " as arc " + arc.getId());
  }