Merge lp:~yrke/tapaal/placetransitionobjecthandler-refactor-cleanup into lp:tapaal
- placetransitionobjecthandler-refactor-cleanup
- Merge into trunk
Proposed by
Kenneth Yrke Jørgensen
Status: | Merged |
---|---|
Approved by: | Kenneth Yrke Jørgensen |
Approved revision: | 1046 |
Merged at revision: | 986 |
Proposed branch: | lp:~yrke/tapaal/placetransitionobjecthandler-refactor-cleanup |
Merge into: | lp:tapaal |
Prerequisite: | lp:~yrke/tapaal/placetransitionobjecthandler-refactor |
Diff against target: |
1276 lines (+113/-313) 27 files modified
src/dk/aau/cs/gui/TabTransformer.java (+0/-2) src/dk/aau/cs/io/ModelLoader.java (+6/-8) src/dk/aau/cs/io/PNMLoader.java (+2/-12) src/dk/aau/cs/io/TapnLegacyXmlLoader.java (+1/-16) src/dk/aau/cs/io/TapnXmlLoader.java (+1/-16) src/dk/aau/cs/verification/TAPNComposer.java (+6/-14) src/pipe/dataLayer/DataLayer.java (+21/-15) src/pipe/gui/CreateGui.java (+0/-14) src/pipe/gui/DrawingSurfaceImpl.java (+23/-170) src/pipe/gui/ExportBatchDialog.java (+1/-1) src/pipe/gui/GuiFrame.java (+2/-2) src/pipe/gui/graphicElements/Arc.java (+14/-0) src/pipe/gui/graphicElements/ArcPath.java (+1/-1) src/pipe/gui/graphicElements/ArcPathPoint.java (+0/-9) src/pipe/gui/graphicElements/PetriNetObject.java (+1/-1) src/pipe/gui/graphicElements/Place.java (+1/-4) src/pipe/gui/graphicElements/PlaceTransitionObject.java (+0/-3) src/pipe/gui/graphicElements/tapn/TimedInhibitorArcComponent.java (+1/-3) src/pipe/gui/graphicElements/tapn/TimedInputArcComponent.java (+1/-3) src/pipe/gui/graphicElements/tapn/TimedOutputArcComponent.java (+1/-3) src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java (+1/-3) src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java (+1/-3) src/pipe/gui/graphicElements/tapn/TimedTransportArcComponent.java (+2/-3) src/pipe/gui/handler/ArcHandler.java (+6/-0) src/pipe/gui/handler/PetriNetObjectHandler.java (+8/-2) src/pipe/gui/handler/PlaceTransitionObjectHandler.java (+6/-5) src/pipe/gui/handler/TransportArcHandler.java (+6/-0) |
To merge this branch: | bzr merge lp:~yrke/tapaal/placetransitionobjecthandler-refactor-cleanup |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
TAPAAL Reviewers | Pending | ||
Review via email: mp+362283@code.launchpad.net |
Commit message
Merged branch placetransition
Fixes several issues and cleans up code after the placetransition
Description of the change
test drawing of stuff and action handlers
To post a comment you must log in.
Revision history for this message
Kenneth Yrke Jørgensen (yrke) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/dk/aau/cs/gui/TabTransformer.java' |
2 | --- src/dk/aau/cs/gui/TabTransformer.java 2016-11-11 21:51:49 +0000 |
3 | +++ src/dk/aau/cs/gui/TabTransformer.java 2019-01-27 12:55:13 +0000 |
4 | @@ -71,7 +71,6 @@ |
5 | // Set arcPath, guiModel and connectors |
6 | ((TimedInputArcComponent) newArc).setUnderlyingArc(addedArc); |
7 | newArc.setArcPath(newArcPath); |
8 | - newArc.setGuiModel(guiModel); |
9 | newArc.updateArcPosition(); |
10 | guiModel.addPetriNetObject(newArc); |
11 | guiSource.addConnectFrom(newArc); |
12 | @@ -110,7 +109,6 @@ |
13 | // Set arcPath, guiModel and connectors |
14 | ((TimedOutputArcComponent) newArc).setUnderlyingArc(addedArc); |
15 | newArc.setArcPath(newArcPath); |
16 | - newArc.setGuiModel(guiModel); |
17 | newArc.updateArcPosition(); |
18 | guiModel.addPetriNetObject(newArc); |
19 | guiSource.addConnectFrom(newArc); |
20 | |
21 | === modified file 'src/dk/aau/cs/io/ModelLoader.java' |
22 | --- src/dk/aau/cs/io/ModelLoader.java 2014-02-08 16:38:01 +0000 |
23 | +++ src/dk/aau/cs/io/ModelLoader.java 2019-01-27 12:55:13 +0000 |
24 | @@ -7,20 +7,18 @@ |
25 | import pipe.gui.DrawingSurfaceImpl; |
26 | |
27 | public class ModelLoader { |
28 | - private DrawingSurfaceImpl drawingSurface; |
29 | - |
30 | - public ModelLoader(DrawingSurfaceImpl drawingSurface){ |
31 | - this.drawingSurface = drawingSurface; |
32 | + |
33 | + public ModelLoader(){ |
34 | } |
35 | |
36 | public LoadedModel load(File file) throws Exception{ |
37 | - TapnXmlLoader newFormatLoader = new TapnXmlLoader(drawingSurface); |
38 | + TapnXmlLoader newFormatLoader = new TapnXmlLoader(); |
39 | try{ |
40 | LoadedModel loadedModel = newFormatLoader.load(file); |
41 | return loadedModel; |
42 | }catch(Throwable e1){ |
43 | try { |
44 | - TapnLegacyXmlLoader oldFormatLoader = new TapnLegacyXmlLoader(drawingSurface); |
45 | + TapnLegacyXmlLoader oldFormatLoader = new TapnLegacyXmlLoader(); |
46 | LoadedModel loadedModel = oldFormatLoader.load(file); |
47 | return loadedModel; |
48 | } catch(Throwable e2) { |
49 | @@ -31,13 +29,13 @@ |
50 | |
51 | |
52 | public LoadedModel load(InputStream file) throws Exception{ |
53 | - TapnXmlLoader newFormatLoader = new TapnXmlLoader(drawingSurface); |
54 | + TapnXmlLoader newFormatLoader = new TapnXmlLoader(); |
55 | try{ |
56 | LoadedModel loadedModel = newFormatLoader.load(file); |
57 | return loadedModel; |
58 | }catch(Throwable e1){ |
59 | try { |
60 | - TapnLegacyXmlLoader oldFormatLoader = new TapnLegacyXmlLoader(drawingSurface); |
61 | + TapnLegacyXmlLoader oldFormatLoader = new TapnLegacyXmlLoader(); |
62 | LoadedModel loadedModel = oldFormatLoader.load(file); |
63 | return loadedModel; |
64 | } catch(Throwable e2) { |
65 | |
66 | === modified file 'src/dk/aau/cs/io/PNMLoader.java' |
67 | --- src/dk/aau/cs/io/PNMLoader.java 2019-01-27 12:55:12 +0000 |
68 | +++ src/dk/aau/cs/io/PNMLoader.java 2019-01-27 12:55:13 +0000 |
69 | @@ -57,7 +57,6 @@ |
70 | |
71 | enum GraphicsType { Position, Offset } |
72 | |
73 | - private DrawingSurfaceImpl drawingSurface; |
74 | private NameGenerator nameGenerator = new NameGenerator(); |
75 | private IdResolver idResolver = new IdResolver(); |
76 | private HashSet<String> arcs = new HashSet<String>(); |
77 | @@ -68,8 +67,7 @@ |
78 | private int netSize = 0; |
79 | private int maxNetSize = 4000; |
80 | |
81 | - public PNMLoader(DrawingSurfaceImpl drawingSurface) { |
82 | - this.drawingSurface = drawingSurface; |
83 | + public PNMLoader() { |
84 | } |
85 | |
86 | public LoadedModel load(File file) throws FormatException{ |
87 | @@ -203,7 +201,6 @@ |
88 | marking.point.x, marking.point.y); |
89 | placeComponent.setUnderlyingPlace(place); |
90 | template.guiModel().addPetriNetObject(placeComponent); |
91 | - addListeners(placeComponent, template); |
92 | } |
93 | |
94 | idResolver.add(tapn.name(), id, id); |
95 | @@ -249,7 +246,6 @@ |
96 | true, false, 0, 0); |
97 | transitionComponent.setUnderlyingTransition(transition); |
98 | template.guiModel().addPetriNetObject(transitionComponent); |
99 | - addListeners(transitionComponent, template); |
100 | } |
101 | idResolver.add(tapn.name(), id, id); |
102 | } |
103 | @@ -439,7 +435,6 @@ |
104 | arc.setUnderlyingArc(inputArc); |
105 | |
106 | template.guiModel().addPetriNetObject(arc); |
107 | - addListeners(arc, template); |
108 | |
109 | source.addConnectFrom(arc); |
110 | target.addConnectTo(arc); |
111 | @@ -472,7 +467,6 @@ |
112 | arc.setUnderlyingArc(outputArc); |
113 | |
114 | template.guiModel().addPetriNetObject(arc); |
115 | - addListeners(arc, template); |
116 | |
117 | source.addConnectFrom(arc); |
118 | target.addConnectTo(arc); |
119 | @@ -495,7 +489,6 @@ |
120 | |
121 | tempArc.setUnderlyingArc(inhibArc); |
122 | template.guiModel().addPetriNetObject(tempArc); |
123 | - addListeners(tempArc, template); |
124 | template.model().add(inhibArc); |
125 | |
126 | source.addConnectFrom(tempArc); |
127 | @@ -516,8 +509,5 @@ |
128 | } |
129 | return null; |
130 | } |
131 | - |
132 | - private void addListeners(PetriNetObject newObject, Template template) { |
133 | - drawingSurface.addPNListeners(newObject, drawingSurface, template.guiModel()); |
134 | - } |
135 | + |
136 | } |
137 | |
138 | === modified file 'src/dk/aau/cs/io/TapnLegacyXmlLoader.java' |
139 | --- src/dk/aau/cs/io/TapnLegacyXmlLoader.java 2019-01-27 12:55:12 +0000 |
140 | +++ src/dk/aau/cs/io/TapnLegacyXmlLoader.java 2019-01-27 12:55:13 +0000 |
141 | @@ -80,19 +80,17 @@ |
142 | private DataLayer guiModel; |
143 | private ArrayList<TAPNQuery> queries; |
144 | private ConstantStore constants; |
145 | - private DrawingSurfaceImpl drawingSurface; |
146 | private NameGenerator nameGenerator = new NameGenerator(); |
147 | private boolean firstQueryParsingWarning = true; |
148 | private boolean firstInhibitorIntervalWarning = true; |
149 | private boolean firstPlaceRenameWarning = true; |
150 | |
151 | - public TapnLegacyXmlLoader(DrawingSurfaceImpl drawingSurfaceImpl) { |
152 | + public TapnLegacyXmlLoader() { |
153 | presetArcs = new HashMap<TimedTransitionComponent, TimedTransportArcComponent>(); |
154 | postsetArcs = new HashMap<TimedTransitionComponent, TimedTransportArcComponent>(); |
155 | transportArcsTimeIntervals = new HashMap<TimedTransportArcComponent, TimeInterval>(); |
156 | queries = new ArrayList<TAPNQuery>(); |
157 | constants = new ConstantStore(); |
158 | - drawingSurface = drawingSurfaceImpl; |
159 | } |
160 | |
161 | public LoadedModel load(InputStream file) throws FormatException { |
162 | @@ -214,7 +212,6 @@ |
163 | } |
164 | |
165 | guiModel.addPetriNetObject(tempArc); |
166 | - addListeners(tempArc); |
167 | tapn.add(outputArc); |
168 | |
169 | sourceIn.addConnectFrom(tempArc); |
170 | @@ -260,9 +257,7 @@ |
171 | ((TimedTransportArcComponent) tempArc).setUnderlyingArc(transArc); |
172 | postsetTransportArc.setUnderlyingArc(transArc); |
173 | guiModel.addPetriNetObject(tempArc); |
174 | - addListeners(tempArc); |
175 | guiModel.addPetriNetObject(postsetTransportArc); |
176 | - addListeners(postsetTransportArc); |
177 | tapn.add(transArc); |
178 | |
179 | postsetArcs.remove((TimedTransitionComponent) targetIn); |
180 | @@ -288,9 +283,7 @@ |
181 | ((TimedTransportArcComponent) tempArc).setUnderlyingArc(transArc); |
182 | presetTransportArc.setUnderlyingArc(transArc); |
183 | guiModel.addPetriNetObject(presetTransportArc); |
184 | - addListeners(presetTransportArc); |
185 | guiModel.addPetriNetObject(tempArc); |
186 | - addListeners(tempArc); |
187 | tapn.add(transArc); |
188 | |
189 | presetArcs.remove((TimedTransitionComponent) sourceIn); |
190 | @@ -324,7 +317,6 @@ |
191 | } |
192 | |
193 | guiModel.addPetriNetObject(tempArc); |
194 | - addListeners(tempArc); |
195 | tapn.add(inputArc); |
196 | |
197 | sourceIn.addConnectFrom(tempArc); |
198 | @@ -355,7 +347,6 @@ |
199 | |
200 | ((TimedInhibitorArcComponent) tempArc).setUnderlyingArc(inhibArc); |
201 | guiModel.addPetriNetObject(tempArc); |
202 | - addListeners(tempArc); |
203 | tapn.add(inhibArc); |
204 | |
205 | sourceIn.addConnectFrom(tempArc); |
206 | @@ -533,7 +524,6 @@ |
207 | AnnotationNote an = new AnnotationNote(text, positionXInput, |
208 | positionYInput, widthInput, heightInput, borderInput, false); |
209 | guiModel.addPetriNetObject(an); |
210 | - addListeners(an); |
211 | } |
212 | |
213 | private void parseAndAddTransitionAsOldFormat(Element element) throws FormatException { |
214 | @@ -567,7 +557,6 @@ |
215 | infiniteServer, angle, priority); |
216 | transition.setUnderlyingTransition(t); |
217 | guiModel.addPetriNetObject(transition); |
218 | - addListeners(transition); |
219 | tapn.add(t); |
220 | } |
221 | |
222 | @@ -622,7 +611,6 @@ |
223 | |
224 | ((TimedPlaceComponent) place).setUnderlyingPlace(p); |
225 | guiModel.addPetriNetObject(place); |
226 | - addListeners(place); |
227 | |
228 | for (int i = 0; i < initialMarkingInput; i++) { |
229 | marking.add(new TimedToken(p, new BigDecimal(0.0))); |
230 | @@ -881,7 +869,4 @@ |
231 | return 0.0; |
232 | } |
233 | |
234 | - private void addListeners(PetriNetObject newObject) { |
235 | - drawingSurface.addPNListeners(newObject, drawingSurface, guiModel); |
236 | - } |
237 | } |
238 | |
239 | === modified file 'src/dk/aau/cs/io/TapnXmlLoader.java' |
240 | --- src/dk/aau/cs/io/TapnXmlLoader.java 2019-01-27 12:55:12 +0000 |
241 | +++ src/dk/aau/cs/io/TapnXmlLoader.java 2019-01-27 12:55:13 +0000 |
242 | @@ -68,14 +68,12 @@ |
243 | private HashMap<TimedTransitionComponent, TimedTransportArcComponent> postsetArcs = new HashMap<TimedTransitionComponent, TimedTransportArcComponent>(); |
244 | private HashMap<TimedTransportArcComponent, TimeInterval> transportArcsTimeIntervals = new HashMap<TimedTransportArcComponent, TimeInterval>(); |
245 | |
246 | - private DrawingSurfaceImpl drawingSurface; |
247 | private NameGenerator nameGenerator = new NameGenerator(); |
248 | private boolean firstInhibitorIntervalWarning = true; |
249 | private boolean firstPlaceRenameWarning = true; |
250 | private IdResolver idResolver = new IdResolver(); |
251 | |
252 | - public TapnXmlLoader(DrawingSurfaceImpl drawingSurface) { |
253 | - this.drawingSurface = drawingSurface; |
254 | + public TapnXmlLoader() { |
255 | } |
256 | |
257 | public LoadedModel load(InputStream file) throws FormatException { |
258 | @@ -275,15 +273,12 @@ |
259 | if ("labels".equals(element.getNodeName())) { |
260 | AnnotationNote note = parseAnnotation(element); |
261 | template.guiModel().addPetriNetObject(note); |
262 | - addListeners(note, template); |
263 | } else if ("place".equals(element.getNodeName())) { |
264 | TimedPlaceComponent place = parsePlace(element, network, template.model(), constants); |
265 | template.guiModel().addPetriNetObject(place); |
266 | - addListeners(place, template); |
267 | } else if ("transition".equals(element.getNodeName())) { |
268 | TimedTransitionComponent transition = parseTransition(element, network, template.model()); |
269 | template.guiModel().addPetriNetObject(transition); |
270 | - addListeners(transition, template); |
271 | } else if ("arc".equals(element.getNodeName())) { |
272 | parseAndAddArc(element, template, constants); |
273 | } |
274 | @@ -550,7 +545,6 @@ |
275 | } |
276 | |
277 | template.guiModel().addPetriNetObject(tempArc); |
278 | - addListeners(tempArc, template); |
279 | template.model().add(outputArc); |
280 | |
281 | sourceIn.addConnectFrom(tempArc); |
282 | @@ -596,9 +590,7 @@ |
283 | tempArc.setUnderlyingArc(transArc); |
284 | postsetTransportArc.setUnderlyingArc(transArc); |
285 | template.guiModel().addPetriNetObject(tempArc); |
286 | - addListeners(tempArc, template); |
287 | template.guiModel().addPetriNetObject(postsetTransportArc); |
288 | - addListeners(postsetTransportArc, template); |
289 | template.model().add(transArc); |
290 | |
291 | postsetArcs.remove((TimedTransitionComponent) targetIn); |
292 | @@ -623,9 +615,7 @@ |
293 | tempArc.setUnderlyingArc(transArc); |
294 | presetTransportArc.setUnderlyingArc(transArc); |
295 | template.guiModel().addPetriNetObject(presetTransportArc); |
296 | - addListeners(presetTransportArc, template); |
297 | template.guiModel().addPetriNetObject(tempArc); |
298 | - addListeners(tempArc, template); |
299 | template.model().add(transArc); |
300 | |
301 | presetArcs.remove((TimedTransitionComponent) sourceIn); |
302 | @@ -659,7 +649,6 @@ |
303 | } |
304 | |
305 | template.guiModel().addPetriNetObject(tempArc); |
306 | - addListeners(tempArc, template); |
307 | template.model().add(inputArc); |
308 | |
309 | sourceIn.addConnectFrom(tempArc); |
310 | @@ -689,7 +678,6 @@ |
311 | |
312 | tempArc.setUnderlyingArc(inhibArc); |
313 | template.guiModel().addPetriNetObject(tempArc); |
314 | - addListeners(tempArc, template); |
315 | template.model().add(inhibArc); |
316 | |
317 | sourceIn.addConnectFrom(tempArc); |
318 | @@ -731,7 +719,4 @@ |
319 | return new Constant(name, value); |
320 | } |
321 | |
322 | - private void addListeners(PetriNetObject newObject, Template template) { |
323 | - drawingSurface.addPNListeners(newObject, drawingSurface, template.guiModel()); |
324 | - } |
325 | } |
326 | |
327 | === modified file 'src/dk/aau/cs/verification/TAPNComposer.java' |
328 | --- src/dk/aau/cs/verification/TAPNComposer.java 2019-01-27 12:55:12 +0000 |
329 | +++ src/dk/aau/cs/verification/TAPNComposer.java 2019-01-27 12:55:13 +0000 |
330 | @@ -190,10 +190,9 @@ |
331 | oldPlace.getMarkingOffsetXObject().doubleValue(), |
332 | oldPlace.getMarkingOffsetYObject().doubleValue() |
333 | ); |
334 | - newPlace.setGuiModel(guiModel); |
335 | newPlace.setUnderlyingPlace(constructedPlace); |
336 | newPlace.setName(uniquePlaceName); |
337 | - guiModel.addPlace(newPlace); |
338 | + guiModel.addPetriNetObject(newPlace); |
339 | } |
340 | } |
341 | } |
342 | @@ -240,10 +239,9 @@ |
343 | oldPlace.getMarkingOffsetXObject().doubleValue(), |
344 | oldPlace.getMarkingOffsetYObject().doubleValue() |
345 | ); |
346 | - newPlace.setGuiModel(guiModel); |
347 | newPlace.setUnderlyingPlace(place); |
348 | newPlace.setName(uniquePlaceName); |
349 | - guiModel.addPlace(newPlace); |
350 | + guiModel.addPetriNetObject(newPlace); |
351 | } |
352 | } |
353 | } |
354 | @@ -295,10 +293,9 @@ |
355 | false, |
356 | oldTransition.getAngle(), |
357 | 0); |
358 | - newTransition.setGuiModel(guiModel); |
359 | newTransition.setUnderlyingTransition(transition); |
360 | newTransition.setName(uniqueTransitionName); |
361 | - guiModel.addTransition(newTransition); |
362 | + guiModel.addPetriNetObject(newTransition); |
363 | } |
364 | |
365 | if(timedTransition.isShared()){ |
366 | @@ -398,7 +395,6 @@ |
367 | // Set arcPath, guiModel and connectors |
368 | ((TimedInputArcComponent) newArc).setUnderlyingArc(addedArc); |
369 | newArc.setArcPath(newArcPath); |
370 | - newArc.setGuiModel(guiModel); |
371 | newArc.updateArcPosition(); |
372 | guiModel.addPetriNetObject(newArc); |
373 | guiSource.addConnectFrom(newArc); |
374 | @@ -456,9 +452,8 @@ |
375 | // Set arcPath, guiModel and connectors |
376 | newArc.setUnderlyingArc(addedArc); |
377 | newArc.setArcPath(newArcPath); |
378 | - newArc.setGuiModel(guiModel); |
379 | newArc.updateArcPosition(); |
380 | - guiModel.addArc(newArc); |
381 | + guiModel.addPetriNetObject(newArc); |
382 | guiSource.addConnectTo(newArc); |
383 | guiTarget.addConnectFrom(newArc); |
384 | } |
385 | @@ -529,9 +524,8 @@ |
386 | |
387 | newInArc.setUnderlyingArc(addedArc); |
388 | newInArc.setArcPath(newArcPathIn); |
389 | - newInArc.setGuiModel(guiModel); |
390 | newInArc.updateArcPosition(); |
391 | - guiModel.addArc(newInArc); |
392 | + guiModel.addPetriNetObject(newInArc); |
393 | |
394 | guiSourceIn.addConnectTo(newInArc); |
395 | guiTargetIn.addConnectFrom(newInArc); |
396 | @@ -576,9 +570,8 @@ |
397 | |
398 | newOutArc.setUnderlyingArc(addedArc); |
399 | newOutArc.setArcPath(newArcPathOut); |
400 | - newOutArc.setGuiModel(guiModel); |
401 | newOutArc.updateArcPosition(); |
402 | - guiModel.addArc(newOutArc); |
403 | + guiModel.addPetriNetObject(newOutArc); |
404 | |
405 | // Add connection references to the two transport arcs |
406 | newInArc.setConnectedTo(newOutArc); |
407 | @@ -647,7 +640,6 @@ |
408 | |
409 | ((TimedInhibitorArcComponent) newArc).setUnderlyingArc(addedArc); |
410 | newArc.setArcPath(newArcPath); |
411 | - newArc.setGuiModel(guiModel); |
412 | newArc.updateArcPosition(); |
413 | guiModel.addPetriNetObject(newArc); |
414 | guiSource.addConnectTo(newArc); |
415 | |
416 | === modified file 'src/pipe/dataLayer/DataLayer.java' |
417 | --- src/pipe/dataLayer/DataLayer.java 2019-01-27 12:55:12 +0000 |
418 | +++ src/pipe/dataLayer/DataLayer.java 2019-01-27 12:55:13 +0000 |
419 | @@ -83,7 +83,7 @@ |
420 | * @param placeInput |
421 | * Place Object to add |
422 | */ |
423 | - public void addPlace(Place placeInput) { |
424 | + private void addPlace(Place placeInput) { |
425 | Require.that(placeInput != null, "input place was null"); |
426 | |
427 | placesArray.add(placeInput); |
428 | @@ -96,7 +96,7 @@ |
429 | * @param labelInput |
430 | * AnnotationNote Object to add |
431 | */ |
432 | - public void addAnnotation(AnnotationNote labelInput) { |
433 | + private void addAnnotation(AnnotationNote labelInput) { |
434 | labelsArray.add(labelInput); |
435 | } |
436 | |
437 | @@ -107,7 +107,7 @@ |
438 | * @param transitionInput |
439 | * Transition Object to add |
440 | */ |
441 | - public void addTransition(Transition transitionInput) { |
442 | + private void addTransition(Transition transitionInput) { |
443 | Require.that(transitionInput != null, "input transition was null"); |
444 | |
445 | transitionsArray.add(transitionInput); |
446 | @@ -120,7 +120,7 @@ |
447 | * @param arcInput |
448 | * Arc Object to add |
449 | */ |
450 | - public void addArc(TimedOutputArcComponent arcInput) { |
451 | + private void addArc(TimedOutputArcComponent arcInput) { |
452 | boolean unique = true; |
453 | |
454 | // Check if the arcs have a valid source and target |
455 | @@ -224,12 +224,12 @@ |
456 | } |
457 | } |
458 | |
459 | - public void addTransportArc(TimedTransportArcComponent transportArc) { |
460 | + private void addTransportArc(TimedTransportArcComponent transportArc) { |
461 | arcsArray.add(transportArc); |
462 | addArcToArcsMap(transportArc); |
463 | } |
464 | |
465 | - public void addArc(TimedInhibitorArcComponent inhibitorArcInput) { |
466 | + private void addArc(TimedInhibitorArcComponent inhibitorArcInput) { |
467 | boolean unique = true; |
468 | |
469 | if (inhibitorArcInput != null) { |
470 | @@ -351,6 +351,9 @@ |
471 | * The PetriNetObject to be added. |
472 | */ |
473 | public void addPetriNetObject(PetriNetObject pnObject) { |
474 | + |
475 | + pnObject.setGuiModel(this); |
476 | + |
477 | if (setPetriNetObjectArrayList(pnObject)) { |
478 | if (pnObject instanceof TimedInhibitorArcComponent) { |
479 | addArc((TimedInhibitorArcComponent) pnObject); |
480 | @@ -361,8 +364,8 @@ |
481 | } else if (pnObject instanceof Transition) { |
482 | addTransition((Transition) pnObject); |
483 | } else if (pnObject instanceof AnnotationNote) { |
484 | - addAnnotation((AnnotationNote)pnObject); |
485 | - } |
486 | + addAnnotation((AnnotationNote)pnObject); |
487 | + } |
488 | } |
489 | // we reset to null so that the wrong ArrayList can't get added to |
490 | changeArrayList = null; |
491 | @@ -376,6 +379,10 @@ |
492 | * The PetriNetObject to be removed. |
493 | */ |
494 | public void removePetriNetObject(PetriNetObject pnObject) { |
495 | + |
496 | + //XXX: Should remove guiModel for object, but is used for undelete action, KYRKE 2018-10-18 |
497 | + //pnObject.setGuiModel(null); |
498 | + |
499 | boolean didSomething = false; |
500 | ArrayList<?> attachedArcs = null; |
501 | |
502 | @@ -786,7 +793,7 @@ |
503 | |
504 | for(Place p : placesArray) { |
505 | if(p instanceof TimedPlaceComponent) { |
506 | - TimedPlaceComponent place = ((TimedPlaceComponent)p).copy(tapn, guiModel); |
507 | + TimedPlaceComponent place = ((TimedPlaceComponent)p).copy(tapn); |
508 | oldToNewMapping.put(p, place); |
509 | guiModel.addPetriNetObject(place); |
510 | } |
511 | @@ -794,7 +801,7 @@ |
512 | |
513 | for(Transition t : transitionsArray) { |
514 | if(t instanceof TimedTransitionComponent) { |
515 | - TimedTransitionComponent trans = ((TimedTransitionComponent)t).copy(tapn, guiModel); |
516 | + TimedTransitionComponent trans = ((TimedTransitionComponent)t).copy(tapn); |
517 | oldToNewMapping.put(t, trans); |
518 | guiModel.addPetriNetObject(trans); |
519 | } |
520 | @@ -802,19 +809,19 @@ |
521 | |
522 | for(Arc arc : arcsArray) { |
523 | if(arc instanceof TimedTransportArcComponent) { |
524 | - TimedTransportArcComponent transArc = ((TimedTransportArcComponent)arc).copy(tapn, guiModel, oldToNewMapping); |
525 | + Arc transArc = ((TimedTransportArcComponent)arc).copy(tapn, oldToNewMapping); |
526 | guiModel.addPetriNetObject(transArc); |
527 | } |
528 | else if(arc instanceof TimedInhibitorArcComponent) { |
529 | - TimedInhibitorArcComponent inhibArc = ((TimedInhibitorArcComponent)arc).copy(tapn, guiModel, oldToNewMapping); |
530 | + TimedInhibitorArcComponent inhibArc = ((TimedInhibitorArcComponent)arc).copy(tapn, oldToNewMapping); |
531 | guiModel.addPetriNetObject(inhibArc); |
532 | } |
533 | else if(arc instanceof TimedInputArcComponent) { |
534 | - TimedInputArcComponent inputArc = ((TimedInputArcComponent)arc).copy(tapn, guiModel, oldToNewMapping); |
535 | + TimedInputArcComponent inputArc = ((TimedInputArcComponent)arc).copy(tapn, oldToNewMapping); |
536 | guiModel.addPetriNetObject(inputArc); |
537 | } |
538 | else if(arc instanceof TimedOutputArcComponent) { |
539 | - TimedOutputArcComponent outputArc = ((TimedOutputArcComponent)arc).copy(tapn, guiModel, oldToNewMapping); |
540 | + TimedOutputArcComponent outputArc = ((TimedOutputArcComponent)arc).copy(tapn, oldToNewMapping); |
541 | guiModel.addPetriNetObject(outputArc); |
542 | } |
543 | else { |
544 | @@ -824,7 +831,6 @@ |
545 | |
546 | for(AnnotationNote note : labelsArray) { |
547 | AnnotationNote annotation = note.copy(); |
548 | - annotation.setGuiModel(guiModel); |
549 | guiModel.addPetriNetObject(annotation); |
550 | } |
551 | |
552 | |
553 | === modified file 'src/pipe/gui/CreateGui.java' |
554 | --- src/pipe/gui/CreateGui.java 2018-07-30 10:45:32 +0000 |
555 | +++ src/pipe/gui/CreateGui.java 2019-01-27 12:55:13 +0000 |
556 | @@ -56,20 +56,6 @@ |
557 | |
558 | TabContent tab = (tabs.get(index)); |
559 | |
560 | - //XXX: 2018-04-26//kyrke The following code should never be called, a TAB always has a driwingSurface, |
561 | - // if not seems wired to just create it. |
562 | - // Code left in place for history, in case we someday experience problems with this. |
563 | - // If no problems have been observed for some time, please remove the code and comment. |
564 | -// while (tab.drawingSurface() == null) { |
565 | -// |
566 | -// try { |
567 | -// tab.setDrawingSurface(new DrawingSurfaceImpl(tab.getModel(), |
568 | -// tab)); |
569 | -// } catch (Exception e) { |
570 | -// e.printStackTrace(); |
571 | -// } |
572 | -// } |
573 | - |
574 | return tab.drawingSurface(); |
575 | } |
576 | |
577 | |
578 | === modified file 'src/pipe/gui/DrawingSurfaceImpl.java' |
579 | --- src/pipe/gui/DrawingSurfaceImpl.java 2019-01-27 12:55:12 +0000 |
580 | +++ src/pipe/gui/DrawingSurfaceImpl.java 2019-01-27 12:55:13 +0000 |
581 | @@ -2,14 +2,11 @@ |
582 | |
583 | import java.awt.*; |
584 | import java.awt.event.MouseEvent; |
585 | -import java.awt.event.MouseListener; |
586 | import java.awt.event.MouseWheelEvent; |
587 | import java.awt.print.PageFormat; |
588 | import java.awt.print.Printable; |
589 | import java.awt.print.PrinterException; |
590 | import java.util.ArrayList; |
591 | -import java.util.Observable; |
592 | -import java.util.Observer; |
593 | import javax.swing.JLayeredPane; |
594 | import javax.swing.JViewport; |
595 | import javax.swing.SwingUtilities; |
596 | @@ -21,19 +18,14 @@ |
597 | import pipe.gui.Pipe.ElementType; |
598 | import pipe.gui.graphicElements.AnnotationNote; |
599 | import pipe.gui.graphicElements.Arc; |
600 | -import pipe.gui.graphicElements.Note; |
601 | import pipe.gui.graphicElements.PetriNetObject; |
602 | -import pipe.gui.graphicElements.Place; |
603 | import pipe.gui.graphicElements.PlaceTransitionObject; |
604 | -import pipe.gui.graphicElements.Transition; |
605 | import pipe.gui.graphicElements.tapn.*; |
606 | -import pipe.gui.handler.*; |
607 | import pipe.gui.undo.AddPetriNetObjectEdit; |
608 | import pipe.gui.undo.AddTimedPlaceCommand; |
609 | import pipe.gui.undo.AddTimedTransitionCommand; |
610 | import pipe.gui.undo.UndoManager; |
611 | import dk.aau.cs.gui.NameGenerator; |
612 | -import dk.aau.cs.gui.TabContent; |
613 | import dk.aau.cs.model.tapn.TimedArcPetriNet; |
614 | |
615 | /** |
616 | @@ -106,122 +98,43 @@ |
617 | this.guiModel = guiModel; |
618 | this.model = model; |
619 | this.zoomControl = zoomer; |
620 | - CreateGui.getApp().updateZoomCombo(); |
621 | + app.updateZoomCombo(); |
622 | |
623 | if (animationmode) { |
624 | - CreateGui.getAnimator().highlightEnabledTransitions(); |
625 | - CreateGui.getAnimator().unhighlightDisabledTransitions(); |
626 | - CreateGui.getAnimator().reportBlockingPlaces(); |
627 | + app.getAnimator().highlightEnabledTransitions(); |
628 | + app.getAnimator().unhighlightDisabledTransitions(); |
629 | + app.getAnimator().reportBlockingPlaces(); |
630 | } |
631 | |
632 | this.removeAll(); |
633 | setPreferredSize(new Dimension(0,0)); |
634 | for (PetriNetObject pnObject : guiModel.getPetriNetObjects()) { |
635 | pnObject.zoomUpdate(zoomer.getPercent()); |
636 | - add(pnObject); |
637 | + addNewPetriNetObject(pnObject); |
638 | } |
639 | |
640 | - if(CreateGui.getApp().getMode() == ElementType.SELECT) { |
641 | + if(app.getMode() == ElementType.SELECT) { |
642 | this.selection.enableSelection(); |
643 | } |
644 | |
645 | } |
646 | |
647 | - |
648 | - //XXX: KYRKE 2018-09-06: Code moved here, as duplicated several places in net loaders, tmp solution, untill |
649 | - //XXX handlers are handled better. |
650 | - public static void addPNListeners(PetriNetObject newObject, DrawingSurfaceImpl drawingSurface, DataLayer guiModel) { |
651 | - |
652 | - if (newObject != null) { |
653 | - |
654 | - //XXX 2018-09-06 temp solution while we are moving creation of handlers to the objects |
655 | - if(newObject.getMouseHandler() != null) { |
656 | - drawingSurface.add(newObject); |
657 | - }else { |
658 | - throw new RuntimeException("This code should never be called"); |
659 | - |
660 | -// //if (newObject.getMouseListeners().length == 0) { |
661 | -// if (newObject instanceof Place) { |
662 | -// // XXX - kyrke |
663 | -// if (newObject instanceof TimedPlaceComponent) { |
664 | -// |
665 | -// PlaceHandler placeHandler = new PlaceHandler((Place) newObject); |
666 | -// newObject.addMouseListener(placeHandler); |
667 | -// newObject.addMouseWheelListener(placeHandler); |
668 | -// newObject.addMouseMotionListener(placeHandler); |
669 | -// drawingSurface.add(newObject); |
670 | -// |
671 | -// } else { |
672 | -// |
673 | -// PlaceHandler placeHandler = new PlaceHandler((Place) newObject); |
674 | -// newObject.addMouseListener(placeHandler); |
675 | -// newObject.addMouseWheelListener(placeHandler); |
676 | -// newObject.addMouseMotionListener(placeHandler); |
677 | -// drawingSurface.add(newObject); |
678 | -// |
679 | -// } |
680 | -// } else if (newObject instanceof Transition) { |
681 | -// TransitionHandler transitionHandler; |
682 | -// if (newObject instanceof TimedTransitionComponent) { |
683 | -// transitionHandler = new TAPNTransitionHandler((Transition) newObject); |
684 | -// } else { |
685 | -// transitionHandler = new TransitionHandler((Transition) newObject); |
686 | -// } |
687 | -// |
688 | -// newObject.addMouseListener(transitionHandler); |
689 | -// newObject.addMouseMotionListener(transitionHandler); |
690 | -// newObject.addMouseWheelListener(transitionHandler); |
691 | -// |
692 | -// newObject.addMouseListener(new AnimationHandler()); |
693 | -// |
694 | -// drawingSurface.add(newObject); |
695 | -// } else if (newObject instanceof Arc) { |
696 | -// drawingSurface.add(newObject); |
697 | -// |
698 | -// /* CB - Joakim Byg add timed arcs */ |
699 | -// if (newObject instanceof TimedInputArcComponent) { |
700 | -// if (newObject instanceof TimedTransportArcComponent) { |
701 | -// TransportArcHandler transportArcHandler = new TransportArcHandler((Arc) newObject); |
702 | -// newObject.addMouseListener(transportArcHandler); |
703 | -// newObject.addMouseWheelListener(transportArcHandler); |
704 | -// newObject.addMouseMotionListener(transportArcHandler); |
705 | -// } else { |
706 | -// TimedArcHandler timedArcHandler = new TimedArcHandler((Arc) newObject); |
707 | -// newObject.addMouseListener(timedArcHandler); |
708 | -// newObject.addMouseWheelListener(timedArcHandler); |
709 | -// newObject.addMouseMotionListener(timedArcHandler); |
710 | -// } |
711 | -// } else { |
712 | -// /* EOC */ |
713 | -// ArcHandler arcHandler = new ArcHandler((Arc) newObject); |
714 | -// newObject.addMouseListener(arcHandler); |
715 | -// newObject.addMouseWheelListener(arcHandler); |
716 | -// newObject.addMouseMotionListener(arcHandler); |
717 | -// } |
718 | -// } else if (newObject instanceof AnnotationNote) { |
719 | -// drawingSurface.add(newObject); |
720 | -// AnnotationNoteHandler noteHandler = new AnnotationNoteHandler((AnnotationNote) newObject); |
721 | -// newObject.addMouseListener(noteHandler); |
722 | -// newObject.addMouseMotionListener(noteHandler); |
723 | -// ((Note) newObject).getNote().addMouseListener(noteHandler); |
724 | -// ((Note) newObject).getNote().addMouseMotionListener(noteHandler); |
725 | -// } |
726 | -// |
727 | -// newObject.zoomUpdate(drawingSurface.getZoom()); |
728 | - |
729 | - } |
730 | - |
731 | - newObject.setGuiModel(guiModel); |
732 | - //} |
733 | - } |
734 | - |
735 | - |
736 | - } |
737 | - |
738 | public void addNewPetriNetObject(PetriNetObject newObject) { |
739 | - addPNListeners(newObject, this, guiModel); |
740 | - validate(); |
741 | - repaint(); |
742 | + setLayer(newObject, DEFAULT_LAYER + newObject.getLayerOffset()); |
743 | + newObject.zoomUpdate(zoomControl.getPercent()); |
744 | + super.add(newObject); |
745 | + |
746 | + newObject.addedToGui(); |
747 | + petriNetObjects.add(newObject); |
748 | + |
749 | + calculateNewBoundsForScrollPane(newObject.getBounds()); |
750 | + if(newObject.getNameLabel() != null){ |
751 | + calculateNewBoundsForScrollPane(newObject.getNameLabel().getBounds()); |
752 | + } |
753 | + |
754 | + //Does not seem to be needed |
755 | + //validate(); |
756 | + //repaint(); |
757 | } |
758 | |
759 | public int print(Graphics g, PageFormat pageFormat, int pageIndex) |
760 | @@ -320,18 +233,6 @@ |
761 | return zoomControl; |
762 | } |
763 | |
764 | - public void add(PetriNetObject pnObject) { |
765 | - setLayer(pnObject, DEFAULT_LAYER.intValue() + pnObject.getLayerOffset()); |
766 | - super.add(pnObject); |
767 | - pnObject.addedToGui(); |
768 | - petriNetObjects.add(pnObject); |
769 | - |
770 | - calculateNewBoundsForScrollPane(pnObject.getBounds()); |
771 | - if(pnObject.getNameLabel() != null){ |
772 | - calculateNewBoundsForScrollPane(pnObject.getNameLabel().getBounds()); |
773 | - } |
774 | - } |
775 | - |
776 | private void calculateNewBoundsForScrollPane(Rectangle rect) { |
777 | boolean changed = false; |
778 | Dimension current = getPreferredSize(); |
779 | @@ -364,14 +265,6 @@ |
780 | super.removeAll(); |
781 | } |
782 | |
783 | - public Point getPointer() { |
784 | - return getMousePosition(); |
785 | - } |
786 | - |
787 | - /* |
788 | - * Cb Joakim Byg - Animation not needed at the moment public |
789 | - * AnimationHandler getAnimationHandler() { return animationHandler; } EOC |
790 | - */ |
791 | |
792 | public boolean isInAnimationMode() { |
793 | return animationmode; |
794 | @@ -402,9 +295,7 @@ |
795 | @Override |
796 | public void remove(Component comp) { |
797 | petriNetObjects.remove(comp); |
798 | - // if (result) { |
799 | - // System.out.println("DEBUG: remove PNO from view"); |
800 | - // /} |
801 | + |
802 | super.remove(comp); |
803 | } |
804 | |
805 | @@ -530,15 +421,6 @@ |
806 | return p; |
807 | } |
808 | |
809 | -// private PlaceTransitionObject newPlace(Point p) { |
810 | -// p = adjustPoint(p, view.getZoom()); |
811 | -// |
812 | -// pnObject = new Place(Grid.getModifiedX(p.x), Grid.getModifiedY(p.y)); |
813 | -// guiModel.addPetriNetObject(pnObject); |
814 | -// view.addNewPetriNetObject(pnObject); |
815 | -// return (PlaceTransitionObject) pnObject; |
816 | -// } |
817 | - |
818 | private PlaceTransitionObject newTimedPlace(Point p) { |
819 | p = adjustPoint(p, view.getZoom()); |
820 | dk.aau.cs.model.tapn.LocalTimedPlace tp = new dk.aau.cs.model.tapn.LocalTimedPlace(nameGenerator.getNewPlaceName(model)); |
821 | @@ -550,17 +432,6 @@ |
822 | return (PlaceTransitionObject) pnObject; |
823 | } |
824 | |
825 | -/* private PlaceTransitionObject newTransition(Point p, boolean timed) { |
826 | - p = adjustPoint(p, view.getZoom()); |
827 | - |
828 | - pnObject = new Transition(Grid.getModifiedX(p.x), Grid |
829 | - .getModifiedY(p.y)); |
830 | - |
831 | - guiModel.addPetriNetObject(pnObject); |
832 | - view.addNewPetriNetObject(pnObject); |
833 | - return (PlaceTransitionObject) pnObject; |
834 | - }*/ |
835 | - |
836 | private PlaceTransitionObject newTAPNTransition(Point p, boolean timed) { |
837 | p = adjustPoint(p, view.getZoom()); |
838 | dk.aau.cs.model.tapn.TimedTransition transition = new dk.aau.cs.model.tapn.TimedTransition( |
839 | @@ -592,15 +463,6 @@ |
840 | Pipe.ElementType mode = app.getMode(); |
841 | PlaceTransitionObject pto; |
842 | switch (mode) { |
843 | -// case PLACE: |
844 | -// PlaceTransitionObject pto = newPlace(e.getPoint()); |
845 | -// getUndoManager().addNewEdit( |
846 | -// new AddPetriNetObjectEdit(pto, view, guiModel)); |
847 | -// if (e.isControlDown()) { |
848 | -// app.setMode(ElementType.FAST_TRANSITION); |
849 | -// pnObject.dispatchEvent(e); |
850 | -// } |
851 | -// break; |
852 | |
853 | case TAPNPLACE: |
854 | // create place |
855 | @@ -620,16 +482,6 @@ |
856 | } |
857 | break; |
858 | |
859 | -// case IMMTRANS: |
860 | -// case TIMEDTRANS: |
861 | -// boolean timed = (mode == ElementType.TIMEDTRANS); |
862 | -// pto = newTransition(e.getPoint(), timed); |
863 | -// getUndoManager().addNewEdit(new AddPetriNetObjectEdit(pto, view, guiModel)); |
864 | -// if (e.isControlDown()) { |
865 | -// app.setMode(ElementType.FAST_PLACE); |
866 | -// pnObject.dispatchEvent(e); |
867 | -// } |
868 | -// break; |
869 | case TAPNTRANS: |
870 | // create transition |
871 | pto = newTAPNTransition(e.getPoint()); |
872 | @@ -735,6 +587,7 @@ |
873 | private void addPoint(final Arc createArc, final MouseEvent e) { |
874 | int x = Grid.getModifiedX(e.getX()); |
875 | int y = Grid.getModifiedY(e.getY()); |
876 | + |
877 | boolean shiftDown = e.isShiftDown(); |
878 | createArc.setEndPoint(x, y, shiftDown); |
879 | createArc.getArcPath().addPoint(x, y, shiftDown); |
880 | |
881 | === modified file 'src/pipe/gui/ExportBatchDialog.java' |
882 | --- src/pipe/gui/ExportBatchDialog.java 2018-07-13 18:08:43 +0000 |
883 | +++ src/pipe/gui/ExportBatchDialog.java 2019-01-27 12:55:13 +0000 |
884 | @@ -97,7 +97,7 @@ |
885 | static boolean noOrphanTransitions = false; |
886 | |
887 | static ExportBatchDialog exportBatchDialog; |
888 | - ModelLoader loader = new ModelLoader(new DrawingSurfaceImpl(new DataLayer())); |
889 | + ModelLoader loader = new ModelLoader(); |
890 | |
891 | public static boolean isDialogVisible() { |
892 | return exportBatchDialog.isVisible(); |
893 | |
894 | === modified file 'src/pipe/gui/GuiFrame.java' |
895 | --- src/pipe/gui/GuiFrame.java 2018-08-13 09:38:20 +0000 |
896 | +++ src/pipe/gui/GuiFrame.java 2019-01-27 12:55:13 +0000 |
897 | @@ -1717,7 +1717,7 @@ |
898 | |
899 | try { |
900 | |
901 | - ModelLoader loader = new ModelLoader(tab.drawingSurface()); |
902 | + ModelLoader loader = new ModelLoader(); |
903 | LoadedModel loadedModel = loader.load(file); |
904 | |
905 | tab.setNetwork(loadedModel.network(), loadedModel.templates()); |
906 | @@ -1777,7 +1777,7 @@ |
907 | |
908 | LoadedModel loadedModel; |
909 | |
910 | - PNMLoader loader = new PNMLoader(tab.drawingSurface()); |
911 | + PNMLoader loader = new PNMLoader(); |
912 | loadedModel = loader.load(file); |
913 | |
914 | |
915 | |
916 | === modified file 'src/pipe/gui/graphicElements/Arc.java' |
917 | --- src/pipe/gui/graphicElements/Arc.java 2019-01-27 12:55:12 +0000 |
918 | +++ src/pipe/gui/graphicElements/Arc.java 2019-01-27 12:55:13 +0000 |
919 | @@ -33,6 +33,19 @@ |
920 | |
921 | protected ArcPath myPath = new ArcPath(this); |
922 | |
923 | + //Indicated wither the arc is being drawed (true), used to dispatch mouse events to parent |
924 | + //Set to true, when using constructor for creating new arc when drawing |
925 | + protected boolean isPrototype = false; |
926 | + |
927 | + public boolean isPrototype() { |
928 | + return isPrototype; |
929 | + } |
930 | + |
931 | + //Called to indicate arc is no longer a prototype |
932 | + public void sealArc() { |
933 | + isPrototype = false; |
934 | + } |
935 | + |
936 | // Bounds of arc need to be grown in order to avoid clipping problems |
937 | protected int zoomGrow = 10; |
938 | |
939 | @@ -64,6 +77,7 @@ |
940 | * Create Petri-Net Arc object |
941 | */ |
942 | public Arc(PlaceTransitionObject newSource) { |
943 | + isPrototype = true; |
944 | label = new NameLabel(zoom); |
945 | source = newSource; |
946 | myPath.addPoint(); |
947 | |
948 | === modified file 'src/pipe/gui/graphicElements/ArcPath.java' |
949 | --- src/pipe/gui/graphicElements/ArcPath.java 2019-01-27 12:55:12 +0000 |
950 | +++ src/pipe/gui/graphicElements/ArcPath.java 2019-01-27 12:55:13 +0000 |
951 | @@ -615,7 +615,7 @@ |
952 | // we just want to add the new point. |
953 | // Nadeem 21/06/2005 |
954 | if (editWindow.getIndexOf(pathPoint) < 0) { |
955 | - editWindow.add(pathPoint); |
956 | + editWindow.addNewPetriNetObject(pathPoint); |
957 | pathPoint.updatePointLocation(); |
958 | } |
959 | } |
960 | |
961 | === modified file 'src/pipe/gui/graphicElements/ArcPathPoint.java' |
962 | --- src/pipe/gui/graphicElements/ArcPathPoint.java 2019-01-27 12:55:12 +0000 |
963 | +++ src/pipe/gui/graphicElements/ArcPathPoint.java 2019-01-27 12:55:13 +0000 |
964 | @@ -271,15 +271,6 @@ |
965 | super.removeFromContainer(); |
966 | } |
967 | |
968 | - public PetriNetObject paste(double despX, double despY, |
969 | - boolean toAnotherView) { |
970 | - return null; |
971 | - } |
972 | - |
973 | - public PetriNetObject copy() { |
974 | - return null; |
975 | - } |
976 | - |
977 | @Override |
978 | public int getLayerOffset() { |
979 | return Pipe.ARC_POINT_LAYER_OFFSET; |
980 | |
981 | === modified file 'src/pipe/gui/graphicElements/PetriNetObject.java' |
982 | --- src/pipe/gui/graphicElements/PetriNetObject.java 2019-01-27 12:55:12 +0000 |
983 | +++ src/pipe/gui/graphicElements/PetriNetObject.java 2019-01-27 12:55:13 +0000 |
984 | @@ -276,7 +276,7 @@ |
985 | public void undelete(DrawingSurfaceImpl view) { |
986 | guiModel.addPetriNetObject(this); |
987 | if (view.isCurrentGuiModel(guiModel)) { |
988 | - view.add(this); |
989 | + view.addNewPetriNetObject(this); |
990 | } |
991 | } |
992 | |
993 | |
994 | === modified file 'src/pipe/gui/graphicElements/Place.java' |
995 | --- src/pipe/gui/graphicElements/Place.java 2019-01-27 12:55:12 +0000 |
996 | +++ src/pipe/gui/graphicElements/Place.java 2019-01-27 12:55:13 +0000 |
997 | @@ -25,9 +25,6 @@ |
998 | // Initial Marking Y-axis Offset |
999 | protected Double markingOffsetY = 0d; |
1000 | |
1001 | - // Value of the capacity restriction; 0 means no capacity restriction |
1002 | - protected Integer capacity = 0; |
1003 | - |
1004 | protected static final int DIAMETER = Pipe.PLACE_TRANSITION_HEIGHT; |
1005 | |
1006 | // Token Width and Height |
1007 | @@ -187,7 +184,7 @@ |
1008 | @Override |
1009 | public void update(boolean displayConstantNames) { |
1010 | if (attributesVisible) { |
1011 | - pnName.setText("\nk=" + (capacity > 0 ? capacity : "\u221E")); |
1012 | + pnName.setText(""); |
1013 | } else { |
1014 | pnName.setText(""); |
1015 | } |
1016 | |
1017 | === modified file 'src/pipe/gui/graphicElements/PlaceTransitionObject.java' |
1018 | --- src/pipe/gui/graphicElements/PlaceTransitionObject.java 2019-01-27 12:55:12 +0000 |
1019 | +++ src/pipe/gui/graphicElements/PlaceTransitionObject.java 2019-01-27 12:55:13 +0000 |
1020 | @@ -198,9 +198,6 @@ |
1021 | /** |
1022 | * Implemented in subclasses as involves some tailoring according to the |
1023 | * shape |
1024 | - * |
1025 | - * @param e |
1026 | - * Mouse Event |
1027 | */ |
1028 | @Override |
1029 | public void paintComponent(Graphics g) { |
1030 | |
1031 | === modified file 'src/pipe/gui/graphicElements/tapn/TimedInhibitorArcComponent.java' |
1032 | --- src/pipe/gui/graphicElements/tapn/TimedInhibitorArcComponent.java 2019-01-27 12:55:12 +0000 |
1033 | +++ src/pipe/gui/graphicElements/tapn/TimedInhibitorArcComponent.java 2019-01-27 12:55:13 +0000 |
1034 | @@ -168,7 +168,7 @@ |
1035 | g2.setTransform(reset); |
1036 | } |
1037 | |
1038 | - public TimedInhibitorArcComponent copy(TimedArcPetriNet tapn, DataLayer guiModel, Hashtable<PlaceTransitionObject, PlaceTransitionObject> oldToNewMapping) { |
1039 | + public TimedInhibitorArcComponent copy(TimedArcPetriNet tapn, Hashtable<PlaceTransitionObject, PlaceTransitionObject> oldToNewMapping) { |
1040 | TimedInhibitorArcComponent arc = new TimedInhibitorArcComponent(this); |
1041 | arc.setSource(oldToNewMapping.get(this.getSource())); |
1042 | arc.setTarget(oldToNewMapping.get(this.getTarget())); |
1043 | @@ -178,8 +178,6 @@ |
1044 | |
1045 | arc.setUnderlyingArc(tapn.getInhibitorArcFromPlaceAndTransition(tapn.getPlaceByName(inhibitorArc.source().name()), tapn.getTransitionByName(inhibitorArc.destination().name()))); |
1046 | |
1047 | - arc.setGuiModel(guiModel); |
1048 | - |
1049 | return arc; |
1050 | } |
1051 | |
1052 | |
1053 | === modified file 'src/pipe/gui/graphicElements/tapn/TimedInputArcComponent.java' |
1054 | --- src/pipe/gui/graphicElements/tapn/TimedInputArcComponent.java 2019-01-27 12:55:12 +0000 |
1055 | +++ src/pipe/gui/graphicElements/tapn/TimedInputArcComponent.java 2019-01-27 12:55:13 +0000 |
1056 | @@ -182,7 +182,7 @@ |
1057 | updateLabel(true); |
1058 | } |
1059 | |
1060 | - public TimedInputArcComponent copy(TimedArcPetriNet tapn, DataLayer guiModel, Hashtable<PlaceTransitionObject, PlaceTransitionObject> oldToNewMapping) { |
1061 | + public TimedInputArcComponent copy(TimedArcPetriNet tapn, Hashtable<PlaceTransitionObject, PlaceTransitionObject> oldToNewMapping) { |
1062 | TimedInputArcComponent arc = new TimedInputArcComponent(this); |
1063 | |
1064 | arc.setSource(oldToNewMapping.get(this.getSource())); |
1065 | @@ -192,8 +192,6 @@ |
1066 | arc.getSource().addConnectFrom(arc); |
1067 | arc.getTarget().addConnectTo(arc); |
1068 | |
1069 | - arc.setGuiModel(guiModel); |
1070 | - |
1071 | return arc; |
1072 | } |
1073 | |
1074 | |
1075 | === modified file 'src/pipe/gui/graphicElements/tapn/TimedOutputArcComponent.java' |
1076 | --- src/pipe/gui/graphicElements/tapn/TimedOutputArcComponent.java 2019-01-27 12:55:12 +0000 |
1077 | +++ src/pipe/gui/graphicElements/tapn/TimedOutputArcComponent.java 2019-01-27 12:55:13 +0000 |
1078 | @@ -220,7 +220,7 @@ |
1079 | this.outputArc = outputArc; |
1080 | } |
1081 | |
1082 | - public TimedOutputArcComponent copy(TimedArcPetriNet tapn, DataLayer guiModel, Hashtable<PlaceTransitionObject, PlaceTransitionObject> oldToNewMapping) { |
1083 | + public TimedOutputArcComponent copy(TimedArcPetriNet tapn, Hashtable<PlaceTransitionObject, PlaceTransitionObject> oldToNewMapping) { |
1084 | TimedOutputArcComponent newCopyArc = new TimedOutputArcComponent(this); |
1085 | newCopyArc.setSource(oldToNewMapping.get(this.getSource())); |
1086 | newCopyArc.setTarget(oldToNewMapping.get(this.getTarget())); |
1087 | @@ -229,8 +229,6 @@ |
1088 | newCopyArc.getSource().addConnectFrom(newCopyArc); |
1089 | newCopyArc.getTarget().addConnectTo(newCopyArc); |
1090 | |
1091 | - newCopyArc.setGuiModel(guiModel); |
1092 | - |
1093 | return newCopyArc; |
1094 | } |
1095 | |
1096 | |
1097 | === modified file 'src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java' |
1098 | --- src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java 2019-01-27 12:55:12 +0000 |
1099 | +++ src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java 2019-01-27 12:55:13 +0000 |
1100 | @@ -431,12 +431,10 @@ |
1101 | return new Ellipse2D.Double(-Pipe.DASHED_PADDING/2, -Pipe.DASHED_PADDING/2, DIAMETER + Pipe.DASHED_PADDING, DIAMETER + Pipe.DASHED_PADDING); |
1102 | } |
1103 | |
1104 | - public TimedPlaceComponent copy(TimedArcPetriNet tapn, DataLayer guiModel) { |
1105 | + public TimedPlaceComponent copy(TimedArcPetriNet tapn) { |
1106 | TimedPlaceComponent placeComponent = new TimedPlaceComponent(getPositionXObject(), getPositionYObject(), id, nameOffsetX, nameOffsetY, markingOffsetX, markingOffsetY); |
1107 | placeComponent.setUnderlyingPlace(tapn.getPlaceByName(place.name())); |
1108 | |
1109 | - placeComponent.setGuiModel(guiModel); |
1110 | - |
1111 | return placeComponent; |
1112 | } |
1113 | } |
1114 | |
1115 | === modified file 'src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java' |
1116 | --- src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java 2019-01-27 12:55:12 +0000 |
1117 | +++ src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java 2019-01-27 12:55:13 +0000 |
1118 | @@ -225,11 +225,9 @@ |
1119 | return super.rotate(angleInc); |
1120 | } |
1121 | |
1122 | - public TimedTransitionComponent copy(TimedArcPetriNet tapn, DataLayer guiModel) { |
1123 | + public TimedTransitionComponent copy(TimedArcPetriNet tapn) { |
1124 | TimedTransitionComponent transitionComponent = new TimedTransitionComponent(getPositionXObject(), getPositionYObject(), id, nameOffsetX, nameOffsetY, true, false, getAngle(), 0); |
1125 | transitionComponent.setUnderlyingTransition(tapn.getTransitionByName(transition.name())); |
1126 | - |
1127 | - transitionComponent.setGuiModel(guiModel); |
1128 | |
1129 | return transitionComponent; |
1130 | } |
1131 | |
1132 | === modified file 'src/pipe/gui/graphicElements/tapn/TimedTransportArcComponent.java' |
1133 | --- src/pipe/gui/graphicElements/tapn/TimedTransportArcComponent.java 2019-01-27 12:55:12 +0000 |
1134 | +++ src/pipe/gui/graphicElements/tapn/TimedTransportArcComponent.java 2019-01-27 12:55:13 +0000 |
1135 | @@ -34,6 +34,7 @@ |
1136 | setGroup(groupNr); |
1137 | // hack to reprint the label of the arc |
1138 | updateLabel(true); |
1139 | + isPrototype = true; |
1140 | |
1141 | //XXX: se note in funcation |
1142 | addMouseHandler(); |
1143 | @@ -247,7 +248,7 @@ |
1144 | underlyingTransportArc.interval(), oldWeight, weight); |
1145 | } |
1146 | |
1147 | - public TimedTransportArcComponent copy(TimedArcPetriNet tapn, DataLayer guiModel, Hashtable<PlaceTransitionObject, PlaceTransitionObject> oldToNewMapping) { |
1148 | + public TimedTransportArcComponent copy(TimedArcPetriNet tapn, Hashtable<PlaceTransitionObject, PlaceTransitionObject> oldToNewMapping) { |
1149 | TimedTransportArcComponent arc = new TimedTransportArcComponent(this, group, isInPreSet); |
1150 | arc.setSource(oldToNewMapping.get(this.getSource())); |
1151 | arc.setTarget(oldToNewMapping.get(this.getTarget())); |
1152 | @@ -258,8 +259,6 @@ |
1153 | |
1154 | arc.getSource().addConnectFrom(arc); |
1155 | arc.getTarget().addConnectTo(arc); |
1156 | - |
1157 | - arc.setGuiModel(guiModel); |
1158 | |
1159 | return arc; |
1160 | } |
1161 | |
1162 | === modified file 'src/pipe/gui/handler/ArcHandler.java' |
1163 | --- src/pipe/gui/handler/ArcHandler.java 2019-01-27 12:55:12 +0000 |
1164 | +++ src/pipe/gui/handler/ArcHandler.java 2019-01-27 12:55:13 +0000 |
1165 | @@ -54,6 +54,12 @@ |
1166 | } |
1167 | |
1168 | public void mousePressed(MouseEvent e) { |
1169 | + |
1170 | + if (((Arc) myObject).isPrototype()) { |
1171 | + dispatchToParentWithMouseLocationUpdated(e); |
1172 | + return; |
1173 | + } |
1174 | + |
1175 | if (CreateGui.getApp().isEditionAllowed()) { |
1176 | if (e.getClickCount() == 2) { |
1177 | Arc arc = (Arc) myObject; |
1178 | |
1179 | === modified file 'src/pipe/gui/handler/PetriNetObjectHandler.java' |
1180 | --- src/pipe/gui/handler/PetriNetObjectHandler.java 2019-01-27 12:55:12 +0000 |
1181 | +++ src/pipe/gui/handler/PetriNetObjectHandler.java 2019-01-27 12:55:13 +0000 |
1182 | @@ -1,7 +1,6 @@ |
1183 | package pipe.gui.handler; |
1184 | |
1185 | -import java.awt.Container; |
1186 | -import java.awt.Point; |
1187 | +import java.awt.*; |
1188 | import java.awt.event.MouseEvent; |
1189 | import java.awt.event.MouseWheelEvent; |
1190 | |
1191 | @@ -159,4 +158,11 @@ |
1192 | public void mouseWheelMoved(MouseWheelEvent e) { |
1193 | } |
1194 | |
1195 | + //Changes dispatches an event to the parent component, with the mouse location updated to the parent |
1196 | + //MouseLocation is relative to the component |
1197 | + public void dispatchToParentWithMouseLocationUpdated(MouseEvent e) { |
1198 | + e.translatePoint(myObject.getX(), myObject.getY()); |
1199 | + myObject.getParent().dispatchEvent(e); |
1200 | + } |
1201 | + |
1202 | } |
1203 | |
1204 | === modified file 'src/pipe/gui/handler/PlaceTransitionObjectHandler.java' |
1205 | --- src/pipe/gui/handler/PlaceTransitionObjectHandler.java 2019-01-27 12:55:12 +0000 |
1206 | +++ src/pipe/gui/handler/PlaceTransitionObjectHandler.java 2019-01-27 12:55:13 +0000 |
1207 | @@ -66,6 +66,7 @@ |
1208 | |
1209 | // Disable key bindings that are only available when drawing arcs. |
1210 | private void freeArc(Arc newArc){ |
1211 | + newArc.sealArc(); |
1212 | newArc.disableDrawingKeyBindings(); |
1213 | CreateGui.getDrawingSurface().createArc = null; |
1214 | } |
1215 | @@ -175,7 +176,7 @@ |
1216 | //Need to be casted to cointainer, as we only add it to the canvas but not the model |
1217 | ((Container)CreateGui.getDrawingSurface()).remove(createTAPNInhibitorArc); |
1218 | |
1219 | - view.getGuiModel().addArc(createTAPNInhibitorArc); |
1220 | + view.getGuiModel().addPetriNetObject(createTAPNInhibitorArc); |
1221 | |
1222 | view.addNewPetriNetObject(createTAPNInhibitorArc); |
1223 | |
1224 | @@ -251,7 +252,7 @@ |
1225 | //Need to be casted to cointainer, as we only add it to the canvas but not the model |
1226 | ((Container) CreateGui.getDrawingSurface()).remove(transportArcToCreate); |
1227 | |
1228 | - view.getGuiModel().addArc((TimedOutputArcComponent) transportArcToCreate); |
1229 | + view.getGuiModel().addPetriNetObject((TimedOutputArcComponent) transportArcToCreate); |
1230 | view.addNewPetriNetObject(transportArcToCreate); |
1231 | |
1232 | freeArc(transportArcToCreate); |
1233 | @@ -303,7 +304,7 @@ |
1234 | //Need to be casted to cointainer, as we only add it to the canvas but not the model |
1235 | ((Container) CreateGui.getDrawingSurface()).remove(arc2); |
1236 | |
1237 | - view.getGuiModel().addArc(arc2); |
1238 | + view.getGuiModel().addPetriNetObject(arc2); |
1239 | view.addNewPetriNetObject(arc2); |
1240 | |
1241 | currentObject.addConnectTo(arc2); |
1242 | @@ -369,7 +370,7 @@ |
1243 | //Need to be casted to cointainer, as we only add it to the canvas but not the model |
1244 | ((Container)CreateGui.getDrawingSurface()).remove(timedArcToCreate); |
1245 | |
1246 | - view.getGuiModel().addArc((TimedOutputArcComponent) timedArcToCreate); |
1247 | + view.getGuiModel().addPetriNetObject((TimedOutputArcComponent) timedArcToCreate); |
1248 | view.addNewPetriNetObject(timedArcToCreate); |
1249 | |
1250 | undoManager.newEdit(); // new "transaction"" |
1251 | @@ -413,7 +414,7 @@ |
1252 | // Evil hack to prevent the arc being added to GuiView twice |
1253 | //Need to be casted to cointainer, as we only add it to the canvas but not the model |
1254 | ((Container)CreateGui.getDrawingSurface()).remove(timedArcToCreate); |
1255 | - view.getGuiModel().addArc((TimedOutputArcComponent) timedArcToCreate); |
1256 | + view.getGuiModel().addPetriNetObject((TimedOutputArcComponent) timedArcToCreate); |
1257 | view.addNewPetriNetObject(timedArcToCreate); |
1258 | |
1259 | undoManager.newEdit(); // new "transaction"" |
1260 | |
1261 | === modified file 'src/pipe/gui/handler/TransportArcHandler.java' |
1262 | --- src/pipe/gui/handler/TransportArcHandler.java 2019-01-27 12:55:12 +0000 |
1263 | +++ src/pipe/gui/handler/TransportArcHandler.java 2019-01-27 12:55:13 +0000 |
1264 | @@ -54,6 +54,12 @@ |
1265 | } |
1266 | @Override |
1267 | public void mousePressed(MouseEvent e) { |
1268 | + |
1269 | + if (((Arc) myObject).isPrototype()) { |
1270 | + dispatchToParentWithMouseLocationUpdated(e); |
1271 | + return; |
1272 | + } |
1273 | + |
1274 | if (CreateGui.getApp().isEditionAllowed()) { |
1275 | Arc arc = (Arc) myObject; |
1276 | if (e.getClickCount() == 2) { |
This build on changes in placetransition objecthandler- refactor.