Merge lp:~yrke/tapaal/tapaal-DatalayerClenup into lp:tapaal

Proposed by Kenneth Yrke Jørgensen
Status: Merged
Approved by: Jiri Srba
Approved revision: 976
Merged at revision: 977
Proposed branch: lp:~yrke/tapaal/tapaal-DatalayerClenup
Merge into: lp:tapaal
Diff against target: 353 lines (+10/-136)
3 files modified
src/dk/aau/cs/io/PNMLoader.java (+0/-2)
src/pipe/dataLayer/DataLayer.java (+10/-131)
src/pipe/gui/Animator.java (+0/-3)
To merge this branch: bzr merge lp:~yrke/tapaal/tapaal-DatalayerClenup
Reviewer Review Type Date Requested Status
Jiri Srba Pending
TAPAAL Reviewers Pending
Review via email: mp+352343@code.launchpad.net

Commit message

Cleanup in the Datalayer code

To post a comment you must log in.
Revision history for this message
Jiri Srba (srba) wrote :

Why is this on hold?

Revision history for this message
Kenneth Yrke Jørgensen (yrke) wrote :

Hi, I changed the status to need review, I forget to set the correct status.

Revision history for this message
Jiri Srba (srba) wrote :

Is there something to be tested in particular or is it just deadcode removeal?

Revision history for this message
Kenneth Yrke Jørgensen (yrke) wrote :

this just removes unused code,

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/dk/aau/cs/io/PNMLoader.java'
2--- src/dk/aau/cs/io/PNMLoader.java 2015-11-24 07:26:42 +0000
3+++ src/dk/aau/cs/io/PNMLoader.java 2018-08-05 16:27:59 +0000
4@@ -171,8 +171,6 @@
5 node = node.getNextSibling();
6 }
7
8- template.guiModel().setDrawable(isNetDrawable());
9-
10 node = first;
11 //We parse the places and transitions first
12 while(node != null){
13
14=== modified file 'src/pipe/dataLayer/DataLayer.java'
15--- src/pipe/dataLayer/DataLayer.java 2018-05-04 08:01:39 +0000
16+++ src/pipe/dataLayer/DataLayer.java 2018-08-05 16:27:59 +0000
17@@ -23,7 +23,7 @@
18 import dk.aau.cs.util.Require;
19
20
21-public class DataLayer extends Observable implements Cloneable {
22+public class DataLayer implements Cloneable {
23
24 /** PNML File Name */
25 public String pnmlName = null;
26@@ -46,11 +46,6 @@
27 */
28 private ArrayList<? extends PetriNetObject> changeArrayList = null;
29
30- /** Used to determine whether the matrixes have been modified */
31- static boolean initialMarkingVectorChanged = true;
32-
33- static boolean currentMarkingVectorChanged = true;
34-
35 /**
36 * Hashtable which maps PlaceTransitionObjects to their list of connected
37 * arcs
38@@ -65,9 +60,6 @@
39
40 private NetType type = NetType.TAPN;
41
42- //Is the net too big to be drawn
43- private boolean isDrawable= true;
44-
45 /**
46 * Create empty Petri-Net object
47 */
48@@ -76,7 +68,6 @@
49 transitionsArray = new ArrayList<Transition>();
50 arcsArray = new ArrayList<Arc>();
51
52- // tapnInhibitorsArray = new ArrayList();
53 labelsArray = new ArrayList<AnnotationNote>();
54
55 // may as well do the hashtable here as well
56@@ -96,8 +87,6 @@
57 Require.that(placeInput != null, "input place was null");
58
59 placesArray.add(placeInput);
60- setChanged();
61- notifyObservers(placeInput);
62 }
63
64 /**
65@@ -109,8 +98,6 @@
66 */
67 public void addAnnotation(AnnotationNote labelInput) {
68 labelsArray.add(labelInput);
69- setChanged();
70- notifyObservers(labelInput);
71 }
72
73 /**
74@@ -124,8 +111,6 @@
75 Require.that(transitionInput != null, "input transition was null");
76
77 transitionsArray.add(transitionInput);
78- setChanged();
79- notifyObservers(transitionInput);
80 }
81
82 /**
83@@ -236,18 +221,12 @@
84 arcsArray.add(arcInput);
85 addArcToArcsMap(arcInput);
86
87- setChanged();
88-
89- // notifyObservers(arcInput.getBounds());
90- notifyObservers(arcInput);
91 }
92 }
93
94 public void addTransportArc(TimedTransportArcComponent transportArc) {
95 arcsArray.add(transportArc);
96 addArcToArcsMap(transportArc);
97- setChanged();
98- notifyObservers();
99 }
100
101 public void addArc(TimedInhibitorArcComponent inhibitorArcInput) {
102@@ -292,10 +271,6 @@
103 arcsArray.add(inhibitorArcInput);
104 addInhibitorArcToInhibitorsMap(inhibitorArcInput);
105
106- setChanged();
107-
108- // notifyObservers(arcInput.getBounds());
109- notifyObservers(inhibitorArcInput);
110 }
111 }
112
113@@ -307,20 +282,15 @@
114 * New Arc
115 * */
116 private void addArcToArcsMap(TimedOutputArcComponent arcInput) {
117- // now we want to add the arc to the list of arcs for it's source and
118- // target
119+ // now we want to add the arc to the list of arcs for it's source and target
120 PlaceTransitionObject source = arcInput.getSource();
121 PlaceTransitionObject target = arcInput.getTarget();
122 ArrayList<TimedOutputArcComponent> newList = null;
123
124 if (source != null) {
125- // Pete: Place/Transitions now always moveable
126- // source.setMovable(false);
127 if (arcsMap.get(source) != null) {
128- // System.out.println("adding arc to existing list");
129 arcsMap.get(source).add(arcInput);
130 } else {
131- // System.out.println("creating new arc list");
132 newList = new ArrayList<TimedOutputArcComponent>();
133 newList.add(arcInput);
134 arcsMap.put(source, newList);
135@@ -328,31 +298,24 @@
136 }
137
138 if (target != null) {
139- // Pete: Place/Transitions now always moveable
140- // target.setMovable(false);
141 if (arcsMap.get(target) != null) {
142- // System.out.println("adding arc to existing list2");
143 arcsMap.get(target).add(arcInput);
144 } else {
145- // System.out.println("creating new arc list2");
146 newList = new ArrayList<TimedOutputArcComponent>();
147 newList.add(arcInput);
148 arcsMap.put(target, newList);
149 }
150 }
151- // System.out.println("arcsMap size: " + arcsMap.size());
152 }
153
154 /**
155 * Update the inhibitorsMap hashtable to reflect the new inhibitor arc
156 *
157- * @param arcInput
158+ * @param inhibitorArcInput
159 * New Arc
160 */
161 private void addInhibitorArcToInhibitorsMap(TimedInhibitorArcComponent inhibitorArcInput) {
162- // now we want to add the inhibitor arc to the list of inhibitor arcs
163- // for
164- // it's source and target
165+ // now we want to add the inhibitor arc to the list of inhibitor arcs for it's source and target
166 PlaceTransitionObject source = inhibitorArcInput.getSource();
167 PlaceTransitionObject target = inhibitorArcInput.getTarget();
168 ArrayList<TimedInhibitorArcComponent> newList = null;
169@@ -376,7 +339,6 @@
170 tapnInhibitorsMap.put(target, newList);
171 }
172 }
173- // System.out.println("inhibitorsMap size: " + inhibitorsMap.size());
174 }
175
176
177@@ -424,13 +386,10 @@
178 if (pnObject instanceof PlaceTransitionObject) {
179 if (arcsMap.get(pnObject) != null) {
180
181- // get the list of attached arcs for the object we are
182- // removing
183+ // get the list of attached arcs for the object we are removing
184 attachedArcs = arcsMap.get(pnObject);
185
186- // iterate over all the attached arcs, removing them all
187- // Pere: in inverse order!
188- // for (int i=0; i < attachedArcs.size(); i++){
189+ // iterate over all the attached arcs, removing them all in inverse order!
190 for (int i = attachedArcs.size() - 1; i >= 0; i--) {
191 try {
192 ((Arc) attachedArcs.get(i)).delete();
193@@ -446,13 +405,10 @@
194
195 if (tapnInhibitorsMap.get(pnObject) != null) {
196
197- // get the list of attached arcs for the object we are
198- // removing
199+ // get the list of attached arcs for the object we are removing
200 attachedArcs = tapnInhibitorsMap.get(pnObject);
201
202- // iterate over all the attached arcs, removing them all
203- // Pere: in inverse order!
204- // for (int i=0; i < attachedArcs.size(); i++){
205+ // iterate over all the attached arcs, removing them all in inverse order!
206 for (int i = attachedArcs.size() - 1; i >= 0; i--) {
207 ((Arc) attachedArcs.get(i)).delete();
208 }
209@@ -535,12 +491,6 @@
210 }
211 }
212
213- if (didSomething) {
214- setChanged();
215-
216- // notifyObservers(pnObject.getBounds());
217- notifyObservers(pnObject);
218- }
219 }
220 } catch (NullPointerException npe) {
221 System.out.println("NullPointerException [debug]\n"
222@@ -719,29 +669,10 @@
223 return returnTransition;
224 }
225
226- public Transition getTransitionByNameIgnoreGiven(Transition ignore,
227- String transitionName) {
228- Transition returnTransition = null;
229-
230- if (transitionsArray != null) {
231- if (transitionName != null) {
232- for (int i = 0; i < transitionsArray.size(); i++) {
233- if (!transitionsArray.get(i).equals(ignore)) {
234- if (transitionName.equalsIgnoreCase((transitionsArray
235- .get(i)).getName())) {
236- returnTransition = transitionsArray.get(i);
237- }
238- }
239- }
240- }
241- }
242- return returnTransition;
243- }
244-
245 /**
246 * Return the Place called placeName from the Petri-Net
247- *
248- * @param placeId
249+ *
250+ * @param placeID
251 * ID of Place object to return
252 * @return The first Place object found with id equal to placeId
253 */
254@@ -783,24 +714,6 @@
255 return returnPlace;
256 }
257
258- public Place getPlaceByNameIgnoreGiven(Place ignore, String placeName) {
259- Place returnPlace = null;
260-
261- if (placesArray != null) {
262- if (placeName != null) {
263- for (int i = 0; i < placesArray.size(); i++) {
264- if (!placesArray.get(i).equals(ignore)) {
265- if (placeName.equalsIgnoreCase((placesArray.get(i))
266- .getName())) {
267- returnPlace = placesArray.get(i);
268- }
269- }
270- }
271- }
272- }
273- return returnPlace;
274- }
275-
276 /**
277 * Return the PlaceTransitionObject called ptoName from the Petri-Net
278 *
279@@ -821,32 +734,6 @@
280 return null;
281 }
282
283- public boolean hasTAPNInhibitorArcs() { // TODO: Fix this to make it faster
284- for (Arc arc : arcsArray) {
285- if (arc instanceof TimedInhibitorArcComponent) {
286- return true;
287- }
288- }
289- return false;
290- }
291-
292- public boolean hasTransportArcs() {
293- for(Arc arc : arcsArray) {
294- if(arc instanceof TimedTransportArcComponent) {
295- return true;
296- }
297- }
298- return false;
299- }
300-
301- public boolean hasInvariants() {
302- for(Place p : placesArray) {
303- if(!((TimedPlaceComponent)p).underlyingPlace().invariant().equals(TimeInvariant.LESS_THAN_INFINITY))
304- return true;
305- }
306- return false;
307- }
308-
309 public NetType netType() {
310 return type;
311 }
312@@ -944,13 +831,5 @@
313
314 return guiModel;
315 }
316-
317- public void setDrawable(boolean isDrawable) {
318- this.isDrawable = isDrawable;
319- }
320-
321- public boolean getDrawable(){
322- return isDrawable;
323- }
324
325 }
326
327=== modified file 'src/pipe/gui/Animator.java'
328--- src/pipe/gui/Animator.java 2018-04-29 08:38:52 +0000
329+++ src/pipe/gui/Animator.java 2018-08-05 16:27:59 +0000
330@@ -146,7 +146,6 @@
331 while (transitionIterator.hasNext()) {
332 Transition tempTransition = transitionIterator.next();
333 if (tempTransition.isEnabled(true) || (tempTransition.isDelayEnabledTransition(true) && !isUrgentTransitionEnabled)) {
334- current.notifyObservers();
335 tempTransition.repaint();
336 }
337 }
338@@ -162,7 +161,6 @@
339 while (transitionIterator.hasNext()) {
340 Transition tempTransition = transitionIterator.next();
341 if (!(tempTransition.isEnabled(true)) || !tempTransition.isDelayEnabledTransition(true) || (tempTransition.isDelayEnabledTransition(true) && isUrgentTransitionEnabled)) {
342- current.notifyObservers();
343 tempTransition.repaint();
344 }
345 }
346@@ -209,7 +207,6 @@
347 Transition tempTransition = transitionIterator.next();
348 tempTransition.setEnabledFalse();
349 tempTransition.setDelayEnabledTransitionFalse();
350- activeGuiModel().notifyObservers();
351 tempTransition.repaint();
352 }
353 }

Subscribers

People subscribed via source and target branches