~tapaal-contributor/tapaal/engine-option-matrix-dev

« back to all changes in this revision

Viewing changes to src/dk/aau/cs/io/TapnXmlLoader.java

  • Committer: ptaankvist at gmail
  • Date: 2020-08-04 08:19:45 UTC
  • mfrom: (1068.1.6 tapaal)
  • Revision ID: ptaankvist@gmail.com-20200804081945-3x1iokg1lnwzbzdg
merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
 
63
63
public class TapnXmlLoader {
64
64
        private static final String PLACENAME_ERROR_MESSAGE = "The keywords \"true\" and \"false\" are reserved and can not be used as place names.\nPlaces with these names will be renamed to \"_true\" and \"_false\" respectively.\n\n Note that any queries using these places may not be parsed correctly.";
65
 
    private HashMap<TimedTransitionComponent, TimedTransportArcComponent> presetArcs = new HashMap<TimedTransitionComponent, TimedTransportArcComponent>();
66
 
        private HashMap<TimedTransitionComponent, TimedTransportArcComponent> postsetArcs = new HashMap<TimedTransitionComponent, TimedTransportArcComponent>();
67
 
        private HashMap<TimedTransportArcComponent, TimeInterval> transportArcsTimeIntervals = new HashMap<TimedTransportArcComponent, TimeInterval>();
68
 
 
69
 
        private NameGenerator nameGenerator = new NameGenerator();
 
65
 
 
66
        private final HashMap<TimedTransitionComponent, TimedTransportArcComponent> presetArcs = new HashMap<TimedTransitionComponent, TimedTransportArcComponent>();
 
67
        private final HashMap<TimedTransitionComponent, TimedTransportArcComponent> postsetArcs = new HashMap<TimedTransitionComponent, TimedTransportArcComponent>();
 
68
        private final HashMap<TimedTransportArcComponent, TimeInterval> transportArcsTimeIntervals = new HashMap<TimedTransportArcComponent, TimeInterval>();
 
69
 
 
70
        private final NameGenerator nameGenerator = new NameGenerator();
70
71
        private boolean firstInhibitorIntervalWarning = true;
71
72
        private boolean firstPlaceRenameWarning = true;
72
 
        private IdResolver idResolver = new IdResolver();
 
73
        private final IdResolver idResolver = new IdResolver();
 
74
    private final Collection<String> messages = new ArrayList<>(10);
73
75
 
74
76
        private boolean isTimed;
75
77
        private boolean isGame;
76
78
        private boolean hasUncontrollableTransitions = false;
77
79
 
78
80
        public TapnXmlLoader() {
 
81
 
79
82
        }
80
83
 
81
84
        public LoadedModel load(InputStream file) throws FormatException {
132
135
 
133
136
                parseFeature(doc, network);
134
137
 
135
 
                return new LoadedModel(network, templates, queries, isTimed, isGame);
 
138
                return new LoadedModel(network, templates, queries,messages, isTimed, isGame);
 
139
 
136
140
        }
137
141
 
138
142
        private void parseBound(Document doc, TimedArcPetriNetNetwork network){
187
191
                if(name.toLowerCase().equals("true") || name.toLowerCase().equals("false")) {
188
192
                        name = "_" + name;
189
193
                        if(firstPlaceRenameWarning) {
190
 
                                JOptionPane.showMessageDialog(CreateGui.getApp(), PLACENAME_ERROR_MESSAGE, "Invalid Place Name", JOptionPane.INFORMATION_MESSAGE);
 
194
                                messages.add(PLACENAME_ERROR_MESSAGE);
191
195
                                firstPlaceRenameWarning = false;
192
196
                        }
193
197
                }
344
348
                String text = annotation.getTextContent();
345
349
 
346
350
                if (positionXTempStorage.length() > 0) {
347
 
                        positionXInput = Integer.valueOf(positionXTempStorage) + 1;
 
351
                        positionXInput = Integer.parseInt(positionXTempStorage) + 1;
348
352
                }
349
353
 
350
354
                if (positionYTempStorage.length() > 0) {
351
 
                        positionYInput = Integer.valueOf(positionYTempStorage) + 1;
 
355
                        positionYInput = Integer.parseInt(positionYTempStorage) + 1;
352
356
                }
353
357
 
354
358
                if (widthTemp.length() > 0) {
355
 
                        widthInput = Integer.valueOf(widthTemp) + 1;
 
359
                        widthInput = Integer.parseInt(widthTemp) + 1;
356
360
                }
357
361
 
358
362
                if (heightTemp.length() > 0) {
359
 
                        heightInput = Integer.valueOf(heightTemp) + 1;
 
363
                        heightInput = Integer.parseInt(heightTemp) + 1;
360
364
                }
361
365
 
362
366
                if (borderTemp.length() > 0) {
363
 
                        borderInput = Boolean.valueOf(borderTemp);
 
367
                        borderInput = Boolean.parseBoolean(borderTemp);
364
368
                } else {
365
369
                        borderInput = true;
366
370
                }
443
447
                if(nameInput.toLowerCase().equals("true") || nameInput.toLowerCase().equals("false")) {
444
448
                        nameInput = "_" + nameInput;
445
449
                        if(firstPlaceRenameWarning) {
446
 
                                JOptionPane.showMessageDialog(CreateGui.getApp(), PLACENAME_ERROR_MESSAGE, "Invalid Place Name", JOptionPane.INFORMATION_MESSAGE);
 
450
                messages.add(PLACENAME_ERROR_MESSAGE);
447
451
                                firstPlaceRenameWarning = false;
448
452
                        }
449
453
                }
547
551
                                                              PlaceTransitionObject targetIn,
548
552
                                                              int _endx, int _endy, Template template, Weight weight) throws FormatException {
549
553
 
550
 
                TimedOutputArcComponent tempArc = new TimedOutputArcComponent(
551
 
            sourceIn, targetIn, (!inscriptionTempStorage.equals("") ? Integer.valueOf(inscriptionTempStorage) : 1), idInput);
 
554
                TimedOutputArcComponent tempArc = new TimedOutputArcComponent(sourceIn, targetIn,       (!inscriptionTempStorage.equals("") ? Integer.parseInt(inscriptionTempStorage) : 1), idInput);
552
555
 
553
556
                TimedPlace place = template.model().getPlaceByName(targetIn.getName());
554
557
                TimedTransition transition = template.model().getTransitionByName(sourceIn.getName());
675
678
                TimeInterval interval = TimeInterval.parse(inscriptionTempStorage, constants);
676
679
                
677
680
                if(!interval.equals(TimeInterval.ZERO_INF) && firstInhibitorIntervalWarning) {
678
 
                        JOptionPane.showMessageDialog(CreateGui.getApp(), "The chosen model contained inhibitor arcs with unsupported intervals.\n\nTAPAAL only supports inhibitor arcs with intervals [0,inf).\n\nAny other interval on inhibitor arcs will be replaced with [0,inf).", "Unsupported Interval Detected on Inhibitor Arc", JOptionPane.INFORMATION_MESSAGE);
 
681
            messages.add("The chosen model contained inhibitor arcs with unsupported intervals.\n\nTAPAAL only supports inhibitor arcs with intervals [0,inf).\n\nAny other interval on inhibitor arcs will be replaced with [0,inf).");
679
682
                        firstInhibitorIntervalWarning = false;
680
683
                }
681
684
                
703
706
                                                // Wierd naming convention in pipe: this represents if
704
707
                                                // the arc point is a curve point or not
705
708
                                                String arcTempType = element.getAttribute("arcPointType");
706
 
                                                double arcPointX = Double.valueOf(arcTempX);
707
 
                                                double arcPointY = Double.valueOf(arcTempY);
 
709
                                                double arcPointX = Double.parseDouble(arcTempX);
 
710
                                                double arcPointY = Double.parseDouble(arcTempY);
708
711
                                                arcPointX += Pipe.ARC_CONTROL_POINT_CONSTANT + 1;
709
712
                                                arcPointY += Pipe.ARC_CONTROL_POINT_CONSTANT + 1;
710
 
                                                boolean arcPointType = Boolean.valueOf(arcTempType);
 
713
                                                boolean arcPointType = Boolean.parseBoolean(arcTempType);
711
714
                                                tempArc.getArcPath().addPoint(arcPointX, arcPointY,     arcPointType);
712
715
                                        }
713
716
                                }