~tapaal-contributor/tapaal/disappearing-tokens-1940098

« back to all changes in this revision

Viewing changes to src/dk/aau/cs/model/tapn/TimedArcPetriNet.java

- Did some refactorings in the model.
- Added double click shortcut to shared places/transitions list.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
        private String name;
10
10
        private TimedArcPetriNetNetwork parentNetwork;
11
11
 
12
 
        private List<TimedPlace> places;
13
 
        private List<TimedTransition> transitions;
14
 
        private List<TimedInputArc> inputArcs;
15
 
        private List<TimedOutputArc> outputArcs;
16
 
        private List<TimedInhibitorArc> inhibitorArcs;
17
 
        private List<TransportArc> transportArcs;
 
12
        private List<TimedPlace> places = new ArrayList<TimedPlace>();
 
13
        private List<TimedTransition> transitions = new ArrayList<TimedTransition>();
 
14
        private List<TimedInputArc> inputArcs = new ArrayList<TimedInputArc>();
 
15
        private List<TimedOutputArc> outputArcs = new ArrayList<TimedOutputArc>();
 
16
        private List<TimedInhibitorArc> inhibitorArcs = new ArrayList<TimedInhibitorArc>();
 
17
        private List<TransportArc> transportArcs = new ArrayList<TransportArc>();
18
18
 
19
19
        private TimedMarking currentMarking;
20
20
 
21
21
        public TimedArcPetriNet(String name) {
22
 
                Require.that(name != null && !name.isEmpty(), "Error: name cannot be empty or null");
23
 
                
24
 
                this.name = name;
25
 
                places = new ArrayList<TimedPlace>();
26
 
                transitions = new ArrayList<TimedTransition>();
27
 
                inputArcs = new ArrayList<TimedInputArc>();
28
 
                outputArcs = new ArrayList<TimedOutputArc>();
29
 
                inhibitorArcs = new ArrayList<TimedInhibitorArc>();
30
 
                transportArcs = new ArrayList<TransportArc>();
31
 
 
 
22
                setName(name);
32
23
                setMarking(new TimedMarking());
33
24
        }
34
25
        
92
83
 
93
84
                arc.setModel(this);
94
85
                inhibitorArcs.add(arc);
 
86
                arc.source().addInhibitorArc(arc);
95
87
                arc.destination().addInhibitorArc(arc);
96
88
        }
97
89
 
163
155
                boolean removed = inhibitorArcs.remove(arc);
164
156
                if (removed) {
165
157
                        arc.setModel(null);
 
158
                        arc.source().removeInhibitorArc(arc);
166
159
                        arc.destination().removeInhibitorArc(arc);
167
160
                }
168
161
        }
225
218
        }
226
219
 
227
220
        public void setName(String newName) {
228
 
                if (name != null && name != "")
229
 
                        name = newName;
 
221
                Require.that(newName != null && !newName.isEmpty(), "name cannot be null or empty");
 
222
                name = newName;
230
223
        }
231
224
 
232
225
        public TimedPlace getPlaceByName(String placeName) {