// <label1>&<label2>&...  => p(label1),p(label2),...
 private ArrayList<Predicate> getPredicateListFromArc(String placeName, Arc arc)
     throws ParseException {
   if (!MIDParser.isIdentifier(placeName))
     throw new ParseException(
         placeName + " " + LocaleBundle.bundleString("should start with a letter"));
   String activeTokenClassID = CreateGui.getModel().getActiveTokenClassID();
   int pos = CreateGui.getModel().getPosInList(activeTokenClassID, arc.getWeight());
   if (pos >= 0) {
     String arcLabel = arc.getWeight().get(pos).getCurrentMarking().trim();
     ArrayList<Predicate> predicates = new ArrayList<Predicate>();
     try {
       ArrayList<ArrayList<String>> arcLabelList = MIDParser.parseArcLabelString(arcLabel);
       for (ArrayList<String> labelArguments : arcLabelList)
         predicates.add(new Predicate(placeName, labelArguments, arc instanceof InhibitorArc));
       return predicates;
     } catch (ParseException e) {
       throw new ParseException(
           LocaleBundle.bundleString("Arc label")
               + " "
               + arcLabel
               + " ("
               + arc.getSource().getName()
               + " , "
               + arc.getTarget().getName()
               + "). "
               + e.toString());
     }
   }
   return new ArrayList<Predicate>();
 }
 private ArrayList<String> getBiArcPlaces(PipeTransition pipeTransition) {
   ArrayList<String> placeNames = new ArrayList<String>();
   // bidirectional arcs
   @SuppressWarnings("rawtypes")
   Iterator inputArcIterator = pipeTransition.getConnectToIterator();
   while (inputArcIterator.hasNext()) {
     Arc inputArc = (Arc) (inputArcIterator.next());
     if (inputArc instanceof BidirectionalArc) {
       placeNames.add(inputArc.getSource().getName());
     }
   }
   @SuppressWarnings("rawtypes")
   Iterator outputArcIterator = pipeTransition.getConnectFromIterator();
   while (outputArcIterator.hasNext()) {
     Arc outputArc = (Arc) (outputArcIterator.next());
     if (outputArc instanceof BidirectionalArc) {
       placeNames.add(outputArc.getTarget().getName());
     }
   }
   /*System.out.println(pipeTransition.getName()+" biarc places: ");
   for (String place: placeNames)
   	System.out.print(place+" ");
   */
   return placeNames;
 }
 private ArrayList<Predicate> getPostcondition(PipeTransition pipeTransition)
     throws ParseException {
   ArrayList<Predicate> postcondition = new ArrayList<Predicate>();
   // bidirectional arcs
   @SuppressWarnings("rawtypes")
   Iterator inputArcIterator = pipeTransition.getConnectToIterator();
   while (inputArcIterator.hasNext()) {
     Arc inputArc = (Arc) (inputArcIterator.next());
     if (inputArc instanceof BidirectionalArc) {
       String placeName = inputArc.getSource().getName();
       for (Predicate predicate : getPredicateListFromArc(placeName, inputArc))
         postcondition.add(predicate);
     }
   }
   // directed arcs
   @SuppressWarnings("rawtypes")
   Iterator outputArcIterator = pipeTransition.getConnectFromIterator();
   while (outputArcIterator.hasNext()) {
     Arc outputArc = (Arc) (outputArcIterator.next());
     String placeName = outputArc.getTarget().getName();
     if (isRESETArcLabel(outputArc)) {
       ArrayList<String> arguments = new ArrayList<String>();
       arguments.add(placeName);
       postcondition.add(new Predicate(MID.RESET, arguments));
     } else {
       for (Predicate predicate : getPredicateListFromArc(placeName, outputArc))
         postcondition.add(predicate);
     }
   }
   return postcondition;
 }
  public InsertPointAction(Arc arc, Point mousepos) {
    selected = arc;

    // Mousepos is relative to selected component i.e. the arc
    // Need to convert this into actual coordinates
    Point2D.Float offset = new Point2D.Float(selected.getX(), selected.getY());
    mouseposition = new Point2D.Float(mousepos.x + offset.x, mousepos.y + offset.y);
  }
 private ArrayList<String> getInhibitorPlaces(PipeTransition pipeTransition) {
   ArrayList<String> placeNames = new ArrayList<String>();
   // inhibitor arcs
   @SuppressWarnings("rawtypes")
   Iterator inhibitorArcIterator = pipeTransition.getConnectToIterator();
   while (inhibitorArcIterator.hasNext()) {
     Arc inhibitorArc = (Arc) (inhibitorArcIterator.next());
     if (inhibitorArc instanceof InhibitorArc) {
       placeNames.add(inhibitorArc.getSource().getName());
     }
   }
   /*System.out.println("\n"+pipeTransition.getName()+" inhibitor places: ");
   for (String place: placeNames)
   	System.out.print(place+" ");
   */ return placeNames;
 }
 private boolean isRESETArcLabel(Arc outputArc) {
   String activeTokenClassID = CreateGui.getModel().getActiveTokenClassID();
   int pos = CreateGui.getModel().getPosInList(activeTokenClassID, outputArc.getWeight());
   if (pos >= 0) {
     String arcLabel = outputArc.getWeight().get(pos).getCurrentMarking().trim();
     try {
       ArrayList<ArrayList<String>> arcLabelList = MIDParser.parseArcLabelString(arcLabel);
       if (arcLabelList.size() > 1) return false;
       ArrayList<String> labelArguments = arcLabelList.get(0);
       return labelArguments.size() == 1 && labelArguments.get(0).equalsIgnoreCase(MID.RESET);
     } catch (ParseException e) {
       return false;
     }
   }
   return false;
 }
 private ArrayList<String> getOutputPlaces(PipeTransition pipeTransition) {
   ArrayList<String> placeNames = getBiArcPlaces(pipeTransition);
   // directed arcs
   @SuppressWarnings("rawtypes")
   Iterator outputArcIterator = pipeTransition.getConnectFromIterator();
   while (outputArcIterator.hasNext()) {
     Arc outputArc = (Arc) (outputArcIterator.next());
     if (outputArc instanceof NormalArc) {
       placeNames.add(outputArc.getTarget().getName());
     }
   }
   /*System.out.println("\n"+pipeTransition.getName()+" output places: ");
   	for (String place: placeNames)
   		System.out.print(place+" ");
   */
   return placeNames;
 }
 private ArrayList<Predicate> getPrecondition(PipeTransition pipeTransition)
     throws ParseException {
   ArrayList<Predicate> precondition = new ArrayList<Predicate>();
   // bidirectional arcs
   @SuppressWarnings("rawtypes")
   Iterator outputArcIterator = pipeTransition.getConnectFromIterator();
   while (outputArcIterator.hasNext()) {
     Arc outputArc = (Arc) (outputArcIterator.next());
     if (outputArc instanceof BidirectionalArc) {
       String placeName = outputArc.getTarget().getName();
       for (Predicate predicate : getPredicateListFromArc(placeName, outputArc))
         precondition.add(predicate);
     }
   }
   // directed arcs
   @SuppressWarnings("rawtypes")
   Iterator inputArcIterator = pipeTransition.getConnectToIterator();
   while (inputArcIterator.hasNext()) {
     Arc inputArc = (Arc) (inputArcIterator.next());
     if (!(inputArc instanceof InhibitorArc)) {
       String placeName = inputArc.getSource().getName();
       for (Predicate predicate : getPredicateListFromArc(placeName, inputArc))
         precondition.add(predicate);
     }
   }
   // inhibitor arcs
   @SuppressWarnings("rawtypes")
   Iterator inhibitorArcIterator = pipeTransition.getConnectToIterator();
   while (inhibitorArcIterator.hasNext()) {
     Arc inhibitorArc = (Arc) (inhibitorArcIterator.next());
     if (inhibitorArc instanceof InhibitorArc) {
       String placeName = inhibitorArc.getSource().getName();
       for (Predicate predicate : getPredicateListFromArc(placeName, inhibitorArc))
         precondition.add(predicate);
     }
   }
   return precondition;
 }
 public void actionPerformed(ActionEvent arg0) {
   CreateGui.getView()
       .getUndoManager()
       .addNewEdit(selected.getArcPath().insertPointAt(mouseposition, ArcPathPoint.CURVED));
 }