Merge lp:~yrke/tapaal/positionAsInt into lp:tapaal
- positionAsInt
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Jiri Srba |
Approved revision: | 1383 |
Merged at revision: | 1054 |
Proposed branch: | lp:~yrke/tapaal/positionAsInt |
Merge into: | lp:tapaal |
Diff against target: |
1983 lines (+593/-402) 30 files modified
src/dk/aau/cs/gui/TabContent.java (+2/-2) src/dk/aau/cs/gui/TabTransformer.java (+4/-14) src/dk/aau/cs/gui/smartDraw/SmartDrawWorker.java (+15/-7) src/dk/aau/cs/gui/undo/MovePlaceTransitionObject.java (+6/-7) src/dk/aau/cs/gui/undo/UpdateNameLabelOffsetCommand.java (+2/-2) src/dk/aau/cs/io/PNMLWriter.java (+8/-8) src/dk/aau/cs/io/PNMLoader.java (+15/-17) src/dk/aau/cs/io/TapnLegacyXmlLoader.java (+40/-44) src/dk/aau/cs/io/TapnXmlLoader.java (+37/-42) src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java (+10/-10) src/dk/aau/cs/verification/TAPNComposer.java (+23/-46) src/pipe/gui/CreateGui.java (+1/-0) src/pipe/gui/Zoomer.java (+20/-16) src/pipe/gui/graphicElements/ArcPath.java (+1/-1) src/pipe/gui/graphicElements/ArcPathPoint.java (+21/-30) src/pipe/gui/graphicElements/NameLabel.java (+4/-7) src/pipe/gui/graphicElements/PetriNetObject.java (+8/-29) src/pipe/gui/graphicElements/PetriNetObjectWithLabel.java (+14/-31) src/pipe/gui/graphicElements/Place.java (+0/-11) src/pipe/gui/graphicElements/PlaceTransitionObject.java (+13/-30) src/pipe/gui/graphicElements/Transition.java (+6/-6) src/pipe/gui/graphicElements/tapn/TimedInputArcComponent.java (+1/-7) src/pipe/gui/graphicElements/tapn/TimedOutputArcComponent.java (+4/-13) src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java (+10/-7) src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java (+5/-5) src/pipe/gui/graphicElements/tapn/TimedTransportArcComponent.java (+2/-2) src/pipe/gui/handler/LabelHandler.java (+4/-4) src/pipe/gui/handler/PlaceHandler.java (+2/-2) src/pipe/gui/handler/TransitionHandler.java (+2/-2) tests/dk/aau/cs/io/TapnXmlLoaderTest.kt (+313/-0) |
To merge this branch: | bzr merge lp:~yrke/tapaal/positionAsInt |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jiri Srba | Approve | ||
Peter Haahr Taankvist (community) | Approve | ||
Review via email: mp+383262@code.launchpad.net |
Commit message
Refactored element (places/transition, arcs and arcpath point) to save posisiotn as integers insted of float/doubles. Adds tests for parsing xml.
The internal api always used ints for x,y position. We now mirror this in the which removes a lot of converting from double to int. The change also rounds numbers insted of sealed when dividing.
Test that we are not seing any unexpected drawing of nets.
Description of the change
Jiri Srba (srba) wrote : | # |
Automatic layout is broken.
Open Fischer's protocol, zoom in to 200% and run Automatic Layout, now the anchor points are not removed and it looks weird. The causes the problem in Peter's branch based on this one as well.
- 1383. By Kenneth Yrke Jørgensen
-
Fixed an issue where smartdraw placed arcpathpoint wrongly
Kenneth Yrke Jørgensen (yrke) wrote : | # |
I created a fix for the automatic layout, it was mixing coordinates zoomed and unzoomed. I'm not sure how this was not broken in trunk
Kenneth Yrke Jørgensen (yrke) wrote : | # |
interesting, a bug in how new elements was handles made the code work (the position should not be unzoomed):
- public void setPointLocatio
- double realX = Zoomer.
- double realY = Zoomer.
- getRealPoint(
- point.setLocati
- }
Jiri Srba (srba) : | # |
Preview Diff
1 | === modified file 'src/dk/aau/cs/gui/TabContent.java' |
2 | --- src/dk/aau/cs/gui/TabContent.java 2020-04-30 12:51:14 +0000 |
3 | +++ src/dk/aau/cs/gui/TabContent.java 2020-05-12 11:42:36 +0000 |
4 | @@ -1444,12 +1444,12 @@ |
5 | if(obj instanceof Transition){ |
6 | for(Arc arc : ((PlaceTransitionObject) obj).getPreset()){ |
7 | for(ArcPathPoint point : arc.getArcPath().getArcPathPoints()){ |
8 | - point.setPointLocation(Math.max(point.getPoint().x*factor, point.getWidth()), Math.max(point.getPoint().y*factor, point.getHeight())); |
9 | + point.setPointLocation((int)Math.max(point.getPoint().x*factor, point.getWidth()), (int)Math.max(point.getPoint().y*factor, point.getHeight())); |
10 | } |
11 | } |
12 | for(Arc arc : ((PlaceTransitionObject) obj).getPostset()){ |
13 | for(ArcPathPoint point : arc.getArcPath().getArcPathPoints()){ |
14 | - point.setPointLocation(Math.max(point.getPoint().x*factor, point.getWidth()), Math.max(point.getPoint().y*factor, point.getHeight())); |
15 | + point.setPointLocation((int)Math.max(point.getPoint().x*factor, point.getWidth()), (int)Math.max(point.getPoint().y*factor, point.getHeight())); |
16 | } |
17 | } |
18 | } |
19 | |
20 | === modified file 'src/dk/aau/cs/gui/TabTransformer.java' |
21 | --- src/dk/aau/cs/gui/TabTransformer.java 2020-04-19 13:48:30 +0000 |
22 | +++ src/dk/aau/cs/gui/TabTransformer.java 2020-05-12 11:42:36 +0000 |
23 | @@ -52,15 +52,10 @@ |
24 | Place guiSource = guiModel.getPlaceByName(arc.getSource().getName()); |
25 | Transition guiTarget = guiModel.getTransitionByName(arc.getTarget().getName()); |
26 | Arc newArc = new TimedInputArcComponent(new TimedOutputArcComponent( |
27 | - 0d, |
28 | - 0d, |
29 | - 0d, |
30 | - 0d, |
31 | - guiSource, |
32 | + guiSource, |
33 | guiTarget, |
34 | arc.getWeight().value(), |
35 | - arc.getSource().getName() + "_to_" + arc.getTarget().getName(), |
36 | - false |
37 | + arc.getSource().getName() + "_to_" + arc.getTarget().getName() |
38 | )); |
39 | |
40 | // Build ArcPath |
41 | @@ -110,15 +105,10 @@ |
42 | Place guiTarget = guiModel.getPlaceByName(arc.getTarget().getName()); |
43 | Transition guiSource = guiModel.getTransitionByName(arc.getSource().getName()); |
44 | TimedOutputArcComponent newArc = new TimedOutputArcComponent( |
45 | - 0d, |
46 | - 0d, |
47 | - 0d, |
48 | - 0d, |
49 | - guiSource, |
50 | + guiSource, |
51 | guiTarget, |
52 | arc.getWeight().value(), |
53 | - arc.getSource().getName() + "_to_" + arc.getTarget().getName(), |
54 | - false |
55 | + arc.getSource().getName() + "_to_" + arc.getTarget().getName() |
56 | ); |
57 | |
58 | // Build ArcPath |
59 | |
60 | === modified file 'src/dk/aau/cs/gui/smartDraw/SmartDrawWorker.java' |
61 | --- src/dk/aau/cs/gui/smartDraw/SmartDrawWorker.java 2020-04-18 16:13:35 +0000 |
62 | +++ src/dk/aau/cs/gui/smartDraw/SmartDrawWorker.java 2020-05-12 11:42:36 +0000 |
63 | @@ -13,6 +13,7 @@ |
64 | import dk.aau.cs.gui.undo.MovePlaceTransitionObject; |
65 | import dk.aau.cs.util.Require; |
66 | import pipe.gui.CreateGui; |
67 | +import pipe.gui.Zoomer; |
68 | import pipe.gui.canvas.DrawingSurfaceImpl; |
69 | import pipe.gui.graphicElements.*; |
70 | import pipe.gui.undo.DeleteArcPathPointEdit; |
71 | @@ -426,7 +427,13 @@ |
72 | } |
73 | } |
74 | } |
75 | - |
76 | + |
77 | + |
78 | + //XXX: out bad handeling of zoom bleads over we need to adjust point relative to zoom |
79 | + // midpoint is at current zoom level, but when creaing a new point its coords is at 100% zoom |
80 | + private double unzoom(double pos) { |
81 | + return Zoomer.getUnzoomedValue(pos,(int)CreateGui.getDrawingSurface().getZoom()); |
82 | + } |
83 | /* |
84 | * Add arcPathPoints for arcs where |
85 | * A---> B --> A so they do not overlap |
86 | @@ -435,16 +442,17 @@ |
87 | private void offsetArcPointsFromMiddlepoint(Arc arcOne, Arc arcTwo, Place place, Transition transition) { |
88 | Point.Double pointForArcOne; |
89 | Point.Double pointForArcTwo; |
90 | + |
91 | if(transition.getPositionX() == place.getPositionX()) { |
92 | - pointForArcOne = new Point.Double(arcOne.getArcPath().midPoint.x+30, (arcOne.getArcPath().midPoint.y)); |
93 | - pointForArcTwo = new Point.Double(arcTwo.getArcPath().midPoint.x-30, (arcTwo.getArcPath().midPoint.y)); |
94 | + pointForArcOne = new Point.Double(unzoom(arcOne.getArcPath().midPoint.x+30), unzoom((arcOne.getArcPath().midPoint.y))); |
95 | + pointForArcTwo = new Point.Double(unzoom(arcTwo.getArcPath().midPoint.x-30), unzoom((arcTwo.getArcPath().midPoint.y))); |
96 | } |
97 | else if(transition.getPositionY() == place.getPositionY()) { |
98 | - pointForArcOne = new Point.Double((arcOne.getArcPath().midPoint.x), arcOne.getArcPath().midPoint.y+30); |
99 | - pointForArcTwo = new Point.Double((arcTwo.getArcPath().midPoint.x), arcTwo.getArcPath().midPoint.y-30); |
100 | + pointForArcOne = new Point.Double(unzoom(arcOne.getArcPath().midPoint.x), unzoom(arcOne.getArcPath().midPoint.y+30)); |
101 | + pointForArcTwo = new Point.Double(unzoom(arcTwo.getArcPath().midPoint.x), unzoom(arcTwo.getArcPath().midPoint.y-30)); |
102 | } else { |
103 | - pointForArcOne = new Point.Double((arcOne.getArcPath().midPoint.x+15), arcOne.getArcPath().midPoint.y+15); |
104 | - pointForArcTwo = new Point.Double((arcTwo.getArcPath().midPoint.x-15), arcTwo.getArcPath().midPoint.y-15); |
105 | + pointForArcOne = new Point.Double(unzoom(arcOne.getArcPath().midPoint.x+15), unzoom(arcOne.getArcPath().midPoint.y+15)); |
106 | + pointForArcTwo = new Point.Double(unzoom(arcTwo.getArcPath().midPoint.x-15), unzoom(arcTwo.getArcPath().midPoint.y-15)); |
107 | } |
108 | |
109 | undoManager.addEdit(arcOne.getArcPath().insertPoint(pointForArcOne, false)); |
110 | |
111 | === modified file 'src/dk/aau/cs/gui/undo/MovePlaceTransitionObject.java' |
112 | --- src/dk/aau/cs/gui/undo/MovePlaceTransitionObject.java 2020-03-29 12:40:43 +0000 |
113 | +++ src/dk/aau/cs/gui/undo/MovePlaceTransitionObject.java 2020-05-12 11:42:36 +0000 |
114 | @@ -7,19 +7,18 @@ |
115 | |
116 | public class MovePlaceTransitionObject extends Command { |
117 | |
118 | - private double newY; |
119 | - private double newX; |
120 | + private int newY; |
121 | + private int newX; |
122 | private PlaceTransitionObject objectToBeMoved; |
123 | - private double oldY; |
124 | - private double oldX; |
125 | + private int oldY; |
126 | + private int oldX; |
127 | private boolean doUpdate = false; |
128 | |
129 | |
130 | public MovePlaceTransitionObject(PlaceTransitionObject object, Point point) { |
131 | objectToBeMoved = object; |
132 | - this.newX = point.getX(); |
133 | - this.newY = point.getY(); |
134 | - |
135 | + this.newX = point.x; |
136 | + this.newY = point.y; |
137 | } |
138 | |
139 | @Override |
140 | |
141 | === modified file 'src/dk/aau/cs/gui/undo/UpdateNameLabelOffsetCommand.java' |
142 | --- src/dk/aau/cs/gui/undo/UpdateNameLabelOffsetCommand.java 2020-04-18 13:49:06 +0000 |
143 | +++ src/dk/aau/cs/gui/undo/UpdateNameLabelOffsetCommand.java 2020-05-12 11:42:36 +0000 |
144 | @@ -3,10 +3,10 @@ |
145 | import pipe.gui.graphicElements.PetriNetObjectWithLabel; |
146 | |
147 | public class UpdateNameLabelOffsetCommand extends Command { |
148 | - double newXOffset, newYOffset, oldXOffset, oldYOffset; |
149 | + int newXOffset, newYOffset, oldXOffset, oldYOffset; |
150 | PetriNetObjectWithLabel obj; |
151 | |
152 | - public UpdateNameLabelOffsetCommand(double newXOffset, double newYOffset, double oldXOffset, double oldYOffset, PetriNetObjectWithLabel obj) { |
153 | + public UpdateNameLabelOffsetCommand(int newXOffset, int newYOffset, int oldXOffset, int oldYOffset, PetriNetObjectWithLabel obj) { |
154 | this.obj = obj; |
155 | this.newXOffset = newXOffset; |
156 | this.newYOffset = newYOffset; |
157 | |
158 | === modified file 'src/dk/aau/cs/io/PNMLWriter.java' |
159 | --- src/dk/aau/cs/io/PNMLWriter.java 2019-12-11 15:03:39 +0000 |
160 | +++ src/dk/aau/cs/io/PNMLWriter.java 2020-05-12 11:42:36 +0000 |
161 | @@ -162,8 +162,8 @@ |
162 | name.appendChild(nameGraphics); |
163 | Element nameOffset = document.createElement("offset"); |
164 | nameGraphics.appendChild(nameOffset); |
165 | - nameOffset.setAttribute("x", (inputPlace.getNameOffsetXObject() != null ? String.valueOf(Math.round(inputPlace.getNameOffsetXObject())) : "")); |
166 | - nameOffset.setAttribute("y", (inputPlace.getNameOffsetYObject() != null ? String.valueOf(Math.round(inputPlace.getNameOffsetYObject())) : "")); |
167 | + nameOffset.setAttribute("x", String.valueOf(Math.round(inputPlace.getNameOffsetX()))); |
168 | + nameOffset.setAttribute("y", String.valueOf(Math.round(inputPlace.getNameOffsetY()))); |
169 | Element nameText = document.createElement("text"); |
170 | name.appendChild(nameText); |
171 | nameText.setTextContent(inputPlace.underlyingPlace().name()); |
172 | @@ -172,8 +172,8 @@ |
173 | placeElement.appendChild(graphics); |
174 | Element offset = document.createElement("position"); |
175 | graphics.appendChild(offset); |
176 | - offset.setAttribute("x", (inputPlace.getPositionXObject() != null ? String.valueOf(Math.round(inputPlace.getPositionXObject())) : "")); |
177 | - offset.setAttribute("y", (inputPlace.getPositionYObject() != null ? String.valueOf(Math.round(inputPlace.getPositionYObject())) : "")); |
178 | + offset.setAttribute("x", String.valueOf(Math.round(inputPlace.getPositionX()))); |
179 | + offset.setAttribute("y", String.valueOf(Math.round(inputPlace.getPositionY()))); |
180 | |
181 | Element initialMarking = document.createElement("initialMarking"); //Name |
182 | placeElement.appendChild(name); |
183 | @@ -201,8 +201,8 @@ |
184 | name.appendChild(nameGraphics); |
185 | Element nameOffset = document.createElement("offset"); |
186 | nameGraphics.appendChild(nameOffset); |
187 | - nameOffset.setAttribute("x", (inputTransition.getNameOffsetXObject() != null ? String.valueOf(Math.round(inputTransition.getNameOffsetXObject())) : "")); |
188 | - nameOffset.setAttribute("y", (inputTransition.getNameOffsetYObject() != null ? String.valueOf(Math.round(inputTransition.getNameOffsetYObject())) : "")); |
189 | + nameOffset.setAttribute("x", String.valueOf(Math.round(inputTransition.getNameOffsetX()))); |
190 | + nameOffset.setAttribute("y", String.valueOf(Math.round(inputTransition.getNameOffsetY()))); |
191 | Element nameText = document.createElement("text"); |
192 | name.appendChild(nameText); |
193 | nameText.setTextContent(inputTransition.underlyingTransition().name()); |
194 | @@ -211,8 +211,8 @@ |
195 | transitionElement.appendChild(graphics); |
196 | Element offset = document.createElement("position"); |
197 | graphics.appendChild(offset); |
198 | - offset.setAttribute("x", (inputTransition.getPositionXObject() != null ? String.valueOf(Math.round(inputTransition.getPositionXObject())) : "")); |
199 | - offset.setAttribute("y", (inputTransition.getPositionYObject() != null ? String.valueOf(Math.round(inputTransition.getPositionYObject())) : "")); |
200 | + offset.setAttribute("x", String.valueOf(Math.round(inputTransition.getPositionX()))); |
201 | + offset.setAttribute("y", String.valueOf(Math.round(inputTransition.getPositionY()))); |
202 | |
203 | return transitionElement; |
204 | } |
205 | |
206 | === modified file 'src/dk/aau/cs/io/PNMLoader.java' |
207 | --- src/dk/aau/cs/io/PNMLoader.java 2020-04-18 16:08:44 +0000 |
208 | +++ src/dk/aau/cs/io/PNMLoader.java 2020-05-12 11:42:36 +0000 |
209 | @@ -192,7 +192,7 @@ |
210 | |
211 | if(isNetDrawable()){ |
212 | //We parse the id as both the name and id as in tapaal name = id, and name/id has to be unique |
213 | - TimedPlaceComponent placeComponent = new TimedPlaceComponent(position.getX(), position.getY(), id, name.point.getX(), name.point.getY()); |
214 | + TimedPlaceComponent placeComponent = new TimedPlaceComponent(position.x, position.y, id, name.point.x, name.point.y); |
215 | placeComponent.setUnderlyingPlace(place); |
216 | template.guiModel().addPetriNetObject(placeComponent); |
217 | } |
218 | @@ -236,7 +236,7 @@ |
219 | if(isNetDrawable()){ |
220 | TimedTransitionComponent transitionComponent = |
221 | //We parse the id as both the name and id as in tapaal name = id, and name/id has to be unique |
222 | - new TimedTransitionComponent(position.getX(), position.getY(), id, name.point.getX(), name.point.getY(), |
223 | + new TimedTransitionComponent(position.x, position.y, id, name.point.x, name.point.y, |
224 | true, false, 0, 0); |
225 | transitionComponent.setUnderlyingTransition(transition); |
226 | template.guiModel().addPetriNetObject(transitionComponent); |
227 | @@ -296,11 +296,11 @@ |
228 | Arc tempArc; |
229 | |
230 | if(type != null && type.equals("inhibitor")) { |
231 | - tempArc = parseAndAddTimedInhibitorArc(id, sourcePlace, targetTransition, source, target, weight, _startx, _starty, _endx, _endy, template); |
232 | + tempArc = parseAndAddTimedInhibitorArc(id, sourcePlace, targetTransition, source, target, weight, _endx, _endy, template); |
233 | } else if(sourcePlace != null && targetTransition != null) { |
234 | - tempArc = parseInputArc(id, sourcePlace, targetTransition, source, target, weight, _startx, _starty, _endx, _endy, template); |
235 | + tempArc = parseInputArc(id, sourcePlace, targetTransition, source, target, weight, _endx, _endy, template); |
236 | } else if(sourceTransition != null && targetPlace != null) { |
237 | - tempArc = parseOutputArc(id, sourceTransition, targetPlace, source, target, weight, _startx, _starty, _endx, _endy, template); |
238 | + tempArc = parseOutputArc(id, sourceTransition, targetPlace, source, target, weight, _endx, _endy, template); |
239 | } else { |
240 | throw new FormatException("Arcs must be only between places and transitions"); |
241 | } |
242 | @@ -410,8 +410,8 @@ |
243 | } |
244 | |
245 | private TimedInputArcComponent parseInputArc(String arcId, TimedPlace place, TimedTransition transition, PlaceTransitionObject source, |
246 | - PlaceTransitionObject target, int weight, int _startx, int _starty, int _endx, |
247 | - int _endy, Template template) throws FormatException { |
248 | + PlaceTransitionObject target, int weight, int _endx, |
249 | + int _endy, Template template) throws FormatException { |
250 | |
251 | TimedInputArc inputArc = new TimedInputArc(place, transition, TimeInterval.ZERO_INF, new IntWeight(weight)); |
252 | |
253 | @@ -424,9 +424,7 @@ |
254 | TimedInputArcComponent arc = null; |
255 | |
256 | if(isNetDrawable()){ |
257 | - arc = new TimedInputArcComponent(new TimedOutputArcComponent( |
258 | - _startx, _starty, _endx, _endy, source, target, weight, arcId, |
259 | - false)); |
260 | + arc = new TimedInputArcComponent(new TimedOutputArcComponent(source, target, weight, arcId)); |
261 | arc.setUnderlyingArc(inputArc); |
262 | |
263 | template.guiModel().addPetriNetObject(arc); |
264 | @@ -440,8 +438,8 @@ |
265 | } |
266 | |
267 | private Arc parseOutputArc(String arcId, TimedTransition transition, TimedPlace place, PlaceTransitionObject source, |
268 | - PlaceTransitionObject target, int weight, int _startx, int _starty, int _endx, |
269 | - int _endy, Template template) throws FormatException { |
270 | + PlaceTransitionObject target, int weight, int _endx, |
271 | + int _endy, Template template) throws FormatException { |
272 | |
273 | TimedOutputArc outputArc = new TimedOutputArc(transition, place, new IntWeight(weight)); |
274 | |
275 | @@ -454,8 +452,8 @@ |
276 | TimedOutputArcComponent arc = null; |
277 | |
278 | if(isNetDrawable()){ |
279 | - arc = new TimedOutputArcComponent(_startx, _starty, _endx, _endy, |
280 | - source, target, weight, arcId, false); |
281 | + arc = new TimedOutputArcComponent( |
282 | + source, target, weight, arcId); |
283 | arc.setUnderlyingArc(outputArc); |
284 | |
285 | template.guiModel().addPetriNetObject(arc); |
286 | @@ -467,11 +465,11 @@ |
287 | } |
288 | |
289 | private Arc parseAndAddTimedInhibitorArc(String arcId, TimedPlace place, TimedTransition transition, PlaceTransitionObject source, |
290 | - PlaceTransitionObject target, int weight, int _startx, int _starty, int _endx, |
291 | - int _endy, Template template) { |
292 | + PlaceTransitionObject target, int weight, int _endx, |
293 | + int _endy, Template template) { |
294 | TimedInhibitorArcComponent tempArc = new TimedInhibitorArcComponent( |
295 | new TimedInputArcComponent( |
296 | - new TimedOutputArcComponent(_startx, _starty, _endx, _endy, source, target, weight, arcId, false) |
297 | + new TimedOutputArcComponent(source, target, weight, arcId) |
298 | ), |
299 | ("")); |
300 | |
301 | |
302 | === modified file 'src/dk/aau/cs/io/TapnLegacyXmlLoader.java' |
303 | --- src/dk/aau/cs/io/TapnLegacyXmlLoader.java 2020-04-18 16:13:35 +0000 |
304 | +++ src/dk/aau/cs/io/TapnLegacyXmlLoader.java 2020-05-12 11:42:36 +0000 |
305 | @@ -183,13 +183,13 @@ |
306 | } |
307 | |
308 | private Arc parseAndAddTimedOutputArc(String idInput, boolean taggedArc, |
309 | - String inscriptionTempStorage, PlaceTransitionObject sourceIn, |
310 | - PlaceTransitionObject targetIn, double _startx, double _starty, |
311 | - double _endx, double _endy) throws FormatException { |
312 | + String inscriptionTempStorage, PlaceTransitionObject sourceIn, |
313 | + PlaceTransitionObject targetIn, |
314 | + int _endx, int _endy) throws FormatException { |
315 | |
316 | Arc tempArc; |
317 | - tempArc = new TimedOutputArcComponent(_startx, _starty, _endx, _endy, |
318 | - sourceIn, targetIn, Integer.valueOf(inscriptionTempStorage), idInput, taggedArc); |
319 | + tempArc = new TimedOutputArcComponent( |
320 | + sourceIn, targetIn, Integer.valueOf(inscriptionTempStorage), idInput); |
321 | |
322 | TimedPlace place = tapn.getPlaceByName(targetIn.getName()); |
323 | TimedTransition transition = tapn.getTransitionByName(sourceIn.getName()); |
324 | @@ -208,9 +208,9 @@ |
325 | } |
326 | |
327 | private Arc parseAndAddTransportArc(String idInput, boolean taggedArc, |
328 | - String inscriptionTempStorage, PlaceTransitionObject sourceIn, |
329 | - PlaceTransitionObject targetIn, double _startx, double _starty, |
330 | - double _endx, double _endy) { |
331 | + String inscriptionTempStorage, PlaceTransitionObject sourceIn, |
332 | + PlaceTransitionObject targetIn, |
333 | + int _endx, int _endy) { |
334 | |
335 | Arc tempArc; |
336 | String[] inscriptionSplit = {}; |
337 | @@ -221,9 +221,7 @@ |
338 | if (sourceIn instanceof Place) { |
339 | isInPreSet = true; |
340 | } |
341 | - tempArc = new TimedTransportArcComponent(new TimedInputArcComponent( |
342 | - new TimedOutputArcComponent(_startx, _starty, _endx, _endy, sourceIn, targetIn, 1, idInput, taggedArc), |
343 | - inscriptionSplit[0]), Integer.parseInt(inscriptionSplit[1]), isInPreSet); |
344 | + tempArc = new TimedTransportArcComponent(new TimedInputArcComponent(new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput)), Integer.parseInt(inscriptionSplit[1]), isInPreSet); |
345 | |
346 | |
347 | if (isInPreSet) { |
348 | @@ -282,14 +280,11 @@ |
349 | } |
350 | |
351 | private Arc parseAndAddTimedInputArc(String idInput, boolean taggedArc, |
352 | - String inscriptionTempStorage, PlaceTransitionObject sourceIn, |
353 | - PlaceTransitionObject targetIn, double _startx, double _starty, |
354 | - double _endx, double _endy) throws FormatException { |
355 | + String inscriptionTempStorage, PlaceTransitionObject sourceIn, |
356 | + PlaceTransitionObject targetIn, |
357 | + int _endx, int _endy) throws FormatException { |
358 | Arc tempArc; |
359 | - tempArc = new TimedInputArcComponent(new TimedOutputArcComponent( |
360 | - _startx, _starty, _endx, _endy, sourceIn, targetIn, 1, idInput, |
361 | - taggedArc), |
362 | - (inscriptionTempStorage != null ? inscriptionTempStorage : "")); |
363 | + tempArc = new TimedInputArcComponent(new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput)); |
364 | |
365 | TimedPlace place = tapn.getPlaceByName(sourceIn.getName()); |
366 | TimedTransition transition = tapn.getTransitionByName(targetIn.getName()); |
367 | @@ -309,13 +304,13 @@ |
368 | } |
369 | |
370 | private Arc parseAndAddTimedInhibitorArc(String idInput, boolean taggedArc, |
371 | - String inscriptionTempStorage, PlaceTransitionObject sourceIn, |
372 | - PlaceTransitionObject targetIn, double _startx, double _starty, |
373 | - double _endx, double _endy) { |
374 | + String inscriptionTempStorage, PlaceTransitionObject sourceIn, |
375 | + PlaceTransitionObject targetIn, |
376 | + int _endx, int _endy) { |
377 | Arc tempArc; |
378 | tempArc = new TimedInhibitorArcComponent( |
379 | new TimedInputArcComponent( |
380 | - new TimedOutputArcComponent(_startx, _starty, _endx, _endy, sourceIn, targetIn, 1, idInput, taggedArc) |
381 | + new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput) |
382 | ), |
383 | (inscriptionTempStorage != null ? inscriptionTempStorage : "")); |
384 | TimedPlace place = tapn.getPlaceByName(sourceIn.getName()); |
385 | @@ -508,12 +503,12 @@ |
386 | } |
387 | |
388 | private void parseAndAddTransitionAsOldFormat(Element element) throws FormatException { |
389 | - double positionXInput = getPositionAttribute(element, "x"); |
390 | - double positionYInput = getPositionAttribute(element, "y"); |
391 | + int positionXInput = (int)getPositionAttribute(element, "x"); |
392 | + int positionYInput = (int)getPositionAttribute(element, "y"); |
393 | String idInput = element.getAttribute("id"); |
394 | String nameInput = getChildNodesContentOfValueChildNodeAsString(element, "name"); |
395 | - double nameOffsetXInput = getNameOffsetAttribute(element, "x"); |
396 | - double nameOffsetYInput = getNameOffsetAttribute(element, "y"); |
397 | + int nameOffsetXInput = (int)getNameOffsetAttribute(element, "x"); |
398 | + int nameOffsetYInput = (int)getNameOffsetAttribute(element, "y"); |
399 | boolean timedTransition = getContentOfFirstSpecificChildNodesValueChildNodeAsBoolean(element, "timed"); |
400 | boolean infiniteServer = getContentOfFirstSpecificChildNodesValueChildNodeAsBoolean(element, "infiniteServer"); |
401 | int angle = getContentOfFirstSpecificChildNodesValueChildNodeAsInt(element,"orientation"); |
402 | @@ -541,12 +536,12 @@ |
403 | } |
404 | |
405 | private void parseAndAddPlaceAsOldFormat(Element element, TimedMarking marking) throws FormatException { |
406 | - double positionXInput = getPositionAttribute(element, "x"); |
407 | - double positionYInput = getPositionAttribute(element, "y"); |
408 | + int positionXInput = (int)getPositionAttribute(element, "x"); |
409 | + int positionYInput = (int)getPositionAttribute(element, "y"); |
410 | String idInput = element.getAttribute("id"); |
411 | String nameInput = getChildNodesContentOfValueChildNodeAsString(element, "name"); |
412 | - double nameOffsetXInput = getNameOffsetAttribute(element, "x"); |
413 | - double nameOffsetYInput = getNameOffsetAttribute(element, "y"); |
414 | + int nameOffsetXInput = (int)getNameOffsetAttribute(element, "x"); |
415 | + int nameOffsetYInput = (int)getNameOffsetAttribute(element, "y"); |
416 | int initialMarkingInput = getContentOfFirstSpecificChildNodesValueChildNodeAsInt(element, "initialMarking"); |
417 | String invariant = getChildNodesContentOfValueChildNodeAsString(element, "invariant"); |
418 | |
419 | @@ -576,8 +571,7 @@ |
420 | // markingOffsetYInput, capacityInput); |
421 | // |
422 | // } else { |
423 | - place = new TimedPlaceComponent(positionXInput, positionYInput, |
424 | - idInput, nameOffsetXInput, nameOffsetYInput); |
425 | + place = new TimedPlaceComponent(positionXInput, positionYInput, idInput, nameOffsetXInput, nameOffsetYInput); |
426 | |
427 | LocalTimedPlace p = new LocalTimedPlace(nameInput, TimeInvariant.parse(invariant, constants)); |
428 | tapn.add(p); |
429 | @@ -597,13 +591,15 @@ |
430 | String targetInput = inputArcElement.getAttribute("target"); |
431 | boolean taggedArc = getContentOfFirstSpecificChildNodesValueChildNodeAsBoolean(inputArcElement, "tagged"); |
432 | String inscriptionTempStorage = getChildNodesContentOfValueChildNodeAsString(inputArcElement, "inscription"); |
433 | - double nameOffsetXInput; |
434 | - double nameOffsetYInput; |
435 | + int nameOffsetXInput; |
436 | + int nameOffsetYInput; |
437 | |
438 | //This check is done, as arcs in nets saved before this change do not have a nameOffset |
439 | + |
440 | if(!inputArcElement.getAttribute("nameOffsetX").equals("") && !inputArcElement.getAttribute("nameOffsetY").equals("")) { |
441 | - nameOffsetXInput = Double.parseDouble(inputArcElement.getAttribute("nameOffsetX")); |
442 | - nameOffsetYInput = Double.parseDouble(inputArcElement.getAttribute("nameOffsetY")); |
443 | + nameOffsetXInput = (int) Double.parseDouble(inputArcElement.getAttribute("nameOffsetX")); |
444 | + nameOffsetYInput = (int) Double.parseDouble(inputArcElement.getAttribute("nameOffsetY")); |
445 | + |
446 | } else { |
447 | nameOffsetXInput = 0; |
448 | nameOffsetYInput = 0; |
449 | @@ -630,24 +626,24 @@ |
450 | if (type.equals("tapnInhibitor")) { |
451 | |
452 | tempArc = parseAndAddTimedInhibitorArc(idInput, taggedArc, |
453 | - inscriptionTempStorage, sourceIn, targetIn, aStartx, |
454 | - aStarty, aEndx, aEndy); |
455 | + inscriptionTempStorage, sourceIn, targetIn, |
456 | + aEndx, aEndy); |
457 | |
458 | } else { |
459 | if (type.equals("timed")) { |
460 | tempArc = parseAndAddTimedInputArc(idInput, taggedArc, |
461 | - inscriptionTempStorage, sourceIn, targetIn, aStartx, |
462 | - aStarty, aEndx, aEndy); |
463 | + inscriptionTempStorage, sourceIn, targetIn, |
464 | + aEndx, aEndy); |
465 | |
466 | } else if (type.equals("transport")) { |
467 | tempArc = parseAndAddTransportArc(idInput, taggedArc, |
468 | - inscriptionTempStorage, sourceIn, targetIn, aStartx, |
469 | - aStarty, aEndx, aEndy); |
470 | + inscriptionTempStorage, sourceIn, targetIn, |
471 | + aEndx, aEndy); |
472 | |
473 | } else { |
474 | tempArc = parseAndAddTimedOutputArc(idInput, taggedArc, |
475 | - inscriptionTempStorage, sourceIn, targetIn, aStartx, |
476 | - aStarty, aEndx, aEndy); |
477 | + inscriptionTempStorage, sourceIn, targetIn, |
478 | + aEndx, aEndy); |
479 | } |
480 | |
481 | } |
482 | |
483 | === modified file 'src/dk/aau/cs/io/TapnXmlLoader.java' |
484 | --- src/dk/aau/cs/io/TapnXmlLoader.java 2020-04-18 16:13:35 +0000 |
485 | +++ src/dk/aau/cs/io/TapnXmlLoader.java 2020-05-12 11:42:36 +0000 |
486 | @@ -338,16 +338,16 @@ |
487 | } |
488 | |
489 | private TimedTransitionComponent parseTransition(Element transition, TimedArcPetriNetNetwork network, TimedArcPetriNet tapn) { |
490 | - double positionXInput = Double.parseDouble(transition.getAttribute("positionX")); |
491 | - double positionYInput = Double.parseDouble(transition.getAttribute("positionY")); |
492 | + int positionXInput = (int)Double.parseDouble(transition.getAttribute("positionX")); |
493 | + int positionYInput = (int)Double.parseDouble(transition.getAttribute("positionY")); |
494 | String idInput = transition.getAttribute("id"); |
495 | String nameInput = transition.getAttribute("name"); |
496 | boolean isUrgent = Boolean.parseBoolean(transition.getAttribute("urgent")); |
497 | |
498 | idResolver.add(tapn.name(), idInput, nameInput); |
499 | |
500 | - double nameOffsetXInput = Double.parseDouble(transition.getAttribute("nameOffsetX")); |
501 | - double nameOffsetYInput = Double.parseDouble(transition.getAttribute("nameOffsetY")); |
502 | + int nameOffsetXInput = (int)Double.parseDouble(transition.getAttribute("nameOffsetX")); |
503 | + int nameOffsetYInput = (int)Double.parseDouble(transition.getAttribute("nameOffsetY")); |
504 | boolean infiniteServer = transition.getAttribute("infiniteServer").equals("true"); |
505 | int angle = Integer.parseInt(transition.getAttribute("angle")); |
506 | int priority = Integer.parseInt(transition.getAttribute("priority")); |
507 | @@ -386,12 +386,12 @@ |
508 | } |
509 | |
510 | private TimedPlaceComponent parsePlace(Element place, TimedArcPetriNetNetwork network, TimedArcPetriNet tapn, ConstantStore constants) { |
511 | - double positionXInput = Double.parseDouble(place.getAttribute("positionX")); |
512 | - double positionYInput = Double.parseDouble(place.getAttribute("positionY")); |
513 | + int positionXInput = (int)Double.parseDouble(place.getAttribute("positionX")); |
514 | + int positionYInput = (int)Double.parseDouble(place.getAttribute("positionY")); |
515 | String idInput = place.getAttribute("id"); |
516 | String nameInput = place.getAttribute("name"); |
517 | - double nameOffsetXInput = Double.parseDouble(place.getAttribute("nameOffsetX")); |
518 | - double nameOffsetYInput = Double.parseDouble(place.getAttribute("nameOffsetY")); |
519 | + int nameOffsetXInput = (int)Double.parseDouble(place.getAttribute("nameOffsetX")); |
520 | + int nameOffsetYInput = (int)Double.parseDouble(place.getAttribute("nameOffsetY")); |
521 | int initialMarkingInput = Integer.parseInt(place.getAttribute("initialMarking")); |
522 | String invariant = place.getAttribute("invariant"); |
523 | boolean displayName = place.getAttribute("displayName").equals("false") ? false : true; |
524 | @@ -444,13 +444,13 @@ |
525 | boolean taggedArc = arc.getAttribute("tagged").equals("true") ? true : false; |
526 | String inscriptionTempStorage = arc.getAttribute("inscription"); |
527 | String type = arc.getAttribute("type"); |
528 | - double nameOffsetXInput; |
529 | - double nameOffsetYInput; |
530 | + int nameOffsetXInput; |
531 | + int nameOffsetYInput; |
532 | |
533 | //This check is done, as arcs in nets saved before this change do not have a nameOffset |
534 | if(!arc.getAttribute("nameOffsetX").equals("") && !arc.getAttribute("nameOffsetY").equals("")) { |
535 | - nameOffsetXInput = Double.parseDouble(arc.getAttribute("nameOffsetX")); |
536 | - nameOffsetYInput = Double.parseDouble(arc.getAttribute("nameOffsetY")); |
537 | + nameOffsetXInput = (int) Double.parseDouble(arc.getAttribute("nameOffsetX")); |
538 | + nameOffsetYInput = (int) Double.parseDouble(arc.getAttribute("nameOffsetY")); |
539 | } else { |
540 | nameOffsetXInput = 0; |
541 | nameOffsetYInput = 0; |
542 | @@ -480,24 +480,24 @@ |
543 | if (type.equals("tapnInhibitor")) { |
544 | |
545 | tempArc = parseAndAddTimedInhibitorArc(idInput, taggedArc, |
546 | - inscriptionTempStorage, sourceIn, targetIn, _startx, |
547 | - _starty, _endx, _endy,template, constants, weight); |
548 | + inscriptionTempStorage, sourceIn, targetIn, |
549 | + _endx, _endy,template, constants, weight); |
550 | |
551 | } else { |
552 | if (type.equals("timed")) { |
553 | tempArc = parseAndAddTimedInputArc(idInput, taggedArc, |
554 | - inscriptionTempStorage, sourceIn, targetIn, _startx, |
555 | - _starty, _endx, _endy, template, constants, weight); |
556 | + inscriptionTempStorage, sourceIn, targetIn, |
557 | + _endx, _endy, template, constants, weight); |
558 | |
559 | } else if (type.equals("transport")) { |
560 | tempArc = parseAndAddTransportArc(idInput, taggedArc, |
561 | - inscriptionTempStorage, sourceIn, targetIn, _startx, |
562 | - _starty, _endx, _endy, template, constants, weight); |
563 | + inscriptionTempStorage, sourceIn, targetIn, |
564 | + _endx, _endy, template, constants, weight); |
565 | |
566 | } else { |
567 | tempArc = parseAndAddTimedOutputArc(idInput, taggedArc, |
568 | - inscriptionTempStorage, sourceIn, targetIn, _startx, |
569 | - _starty, _endx, _endy, template, weight); |
570 | + inscriptionTempStorage, sourceIn, targetIn, |
571 | + _endx, _endy, template, weight); |
572 | } |
573 | |
574 | } |
575 | @@ -508,12 +508,12 @@ |
576 | } |
577 | |
578 | private TimedOutputArcComponent parseAndAddTimedOutputArc(String idInput, boolean taggedArc, |
579 | - String inscriptionTempStorage, PlaceTransitionObject sourceIn, |
580 | - PlaceTransitionObject targetIn, double _startx, double _starty, |
581 | - double _endx, double _endy, Template template, Weight weight) throws FormatException { |
582 | + String inscriptionTempStorage, PlaceTransitionObject sourceIn, |
583 | + PlaceTransitionObject targetIn, |
584 | + int _endx, int _endy, Template template, Weight weight) throws FormatException { |
585 | |
586 | - TimedOutputArcComponent tempArc = new TimedOutputArcComponent(_startx, _starty, _endx, _endy, |
587 | - sourceIn, targetIn, (!inscriptionTempStorage.equals("") ? Integer.valueOf(inscriptionTempStorage) : 1), idInput, taggedArc); |
588 | + TimedOutputArcComponent tempArc = new TimedOutputArcComponent( |
589 | + sourceIn, targetIn, (!inscriptionTempStorage.equals("") ? Integer.valueOf(inscriptionTempStorage) : 1), idInput); |
590 | |
591 | TimedPlace place = template.model().getPlaceByName(targetIn.getName()); |
592 | TimedTransition transition = template.model().getTransitionByName(sourceIn.getName()); |
593 | @@ -532,9 +532,9 @@ |
594 | } |
595 | |
596 | private TimedTransportArcComponent parseAndAddTransportArc(String idInput, boolean taggedArc, |
597 | - String inscriptionTempStorage, PlaceTransitionObject sourceIn, |
598 | - PlaceTransitionObject targetIn, double _startx, double _starty, |
599 | - double _endx, double _endy, Template template, ConstantStore constants, Weight weight) { |
600 | + String inscriptionTempStorage, PlaceTransitionObject sourceIn, |
601 | + PlaceTransitionObject targetIn, |
602 | + int _endx, int _endy, Template template, ConstantStore constants, Weight weight) { |
603 | |
604 | |
605 | String[] inscriptionSplit = {}; |
606 | @@ -545,9 +545,7 @@ |
607 | if (sourceIn instanceof Place) { |
608 | isInPreSet = true; |
609 | } |
610 | - TimedTransportArcComponent tempArc = new TimedTransportArcComponent(new TimedInputArcComponent( |
611 | - new TimedOutputArcComponent(_startx, _starty, _endx, _endy, sourceIn, targetIn, 1, idInput, taggedArc), |
612 | - inscriptionSplit[0]), Integer.parseInt(inscriptionSplit[1]), isInPreSet); |
613 | + TimedTransportArcComponent tempArc = new TimedTransportArcComponent(new TimedInputArcComponent(new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput)), Integer.parseInt(inscriptionSplit[1]), isInPreSet); |
614 | |
615 | |
616 | if (isInPreSet) { |
617 | @@ -605,14 +603,11 @@ |
618 | } |
619 | |
620 | private Arc parseAndAddTimedInputArc(String idInput, boolean taggedArc, |
621 | - String inscriptionTempStorage, PlaceTransitionObject sourceIn, |
622 | - PlaceTransitionObject targetIn, double _startx, double _starty, |
623 | - double _endx, double _endy, Template template, ConstantStore constants, Weight weight) throws FormatException { |
624 | + String inscriptionTempStorage, PlaceTransitionObject sourceIn, |
625 | + PlaceTransitionObject targetIn, |
626 | + int _endx, int _endy, Template template, ConstantStore constants, Weight weight) throws FormatException { |
627 | Arc tempArc; |
628 | - tempArc = new TimedInputArcComponent(new TimedOutputArcComponent( |
629 | - _startx, _starty, _endx, _endy, sourceIn, targetIn, 1, idInput, |
630 | - taggedArc), |
631 | - (inscriptionTempStorage != null ? inscriptionTempStorage : "")); |
632 | + tempArc = new TimedInputArcComponent(new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput)); |
633 | |
634 | TimedPlace place = template.model().getPlaceByName(sourceIn.getName()); |
635 | TimedTransition transition = template.model().getTransitionByName(targetIn.getName()); |
636 | @@ -632,12 +627,12 @@ |
637 | } |
638 | |
639 | private Arc parseAndAddTimedInhibitorArc(String idInput, boolean taggedArc, |
640 | - String inscriptionTempStorage, PlaceTransitionObject sourceIn, |
641 | - PlaceTransitionObject targetIn, double _startx, double _starty, |
642 | - double _endx, double _endy, Template template, ConstantStore constants, Weight weight) { |
643 | + String inscriptionTempStorage, PlaceTransitionObject sourceIn, |
644 | + PlaceTransitionObject targetIn, |
645 | + int _endx, int _endy, Template template, ConstantStore constants, Weight weight) { |
646 | TimedInhibitorArcComponent tempArc = new TimedInhibitorArcComponent( |
647 | new TimedInputArcComponent( |
648 | - new TimedOutputArcComponent(_startx, _starty, _endx, _endy, sourceIn, targetIn, 1, idInput, taggedArc) |
649 | + new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput) |
650 | ), |
651 | (inscriptionTempStorage != null ? inscriptionTempStorage : "")); |
652 | TimedPlace place = template.model().getPlaceByName(sourceIn.getName()); |
653 | |
654 | === modified file 'src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java' |
655 | --- src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java 2020-04-18 15:50:17 +0000 |
656 | +++ src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java 2020-05-12 11:42:36 +0000 |
657 | @@ -368,13 +368,13 @@ |
658 | |
659 | Element placeElement = document.createElement("place"); |
660 | |
661 | - placeElement.setAttribute("positionX", (inputPlace.getPositionXObject() != null ? String.valueOf(inputPlace.getPositionXObject()) : "")); |
662 | - placeElement.setAttribute("positionY", (inputPlace.getPositionYObject() != null ? String.valueOf(inputPlace.getPositionYObject()) : "")); |
663 | + placeElement.setAttribute("positionX", String.valueOf(inputPlace.getPositionX())); |
664 | + placeElement.setAttribute("positionY", String.valueOf(inputPlace.getPositionY())); |
665 | placeElement.setAttribute("name", inputPlace.underlyingPlace().name()); |
666 | placeElement.setAttribute("displayName", (inputPlace.getAttributesVisible() ? "true" : "false")); |
667 | placeElement.setAttribute("id", (inputPlace.getId() != null ? inputPlace.getId() : "error")); |
668 | - placeElement.setAttribute("nameOffsetX", (inputPlace.getNameOffsetXObject() != null ? String.valueOf(inputPlace.getNameOffsetXObject()) : "")); |
669 | - placeElement.setAttribute("nameOffsetY", (inputPlace.getNameOffsetYObject() != null ? String.valueOf(inputPlace.getNameOffsetYObject()) : "")); |
670 | + placeElement.setAttribute("nameOffsetX", String.valueOf(inputPlace.getNameOffsetX())); |
671 | + placeElement.setAttribute("nameOffsetY", String.valueOf(inputPlace.getNameOffsetY())); |
672 | placeElement.setAttribute("initialMarking", ((Integer) inputPlace.getNumberOfTokens() != null ? String.valueOf((Integer) inputPlace.getNumberOfTokens()) : "0")); |
673 | placeElement.setAttribute("invariant", inputPlace.underlyingPlace().invariant().toString()); |
674 | |
675 | @@ -406,10 +406,10 @@ |
676 | |
677 | Element transitionElement = document.createElement("transition"); |
678 | |
679 | - transitionElement.setAttribute("positionX", (inputTransition.getPositionXObject() != null ? String.valueOf(inputTransition.getPositionXObject()) : "")); |
680 | - transitionElement.setAttribute("positionY", (inputTransition.getPositionYObject() != null ? String.valueOf(inputTransition.getPositionYObject()) : "")); |
681 | - transitionElement.setAttribute("nameOffsetX", (inputTransition.getNameOffsetXObject() != null ? String.valueOf(inputTransition.getNameOffsetXObject()) : "")); |
682 | - transitionElement.setAttribute("nameOffsetY", (inputTransition.getNameOffsetYObject() != null ? String.valueOf(inputTransition.getNameOffsetYObject()) : "")); |
683 | + transitionElement.setAttribute("positionX", String.valueOf(inputTransition.getPositionX())); |
684 | + transitionElement.setAttribute("positionY", String.valueOf(inputTransition.getPositionY())); |
685 | + transitionElement.setAttribute("nameOffsetX", String.valueOf(inputTransition.getNameOffsetX())); |
686 | + transitionElement.setAttribute("nameOffsetY", String.valueOf(inputTransition.getNameOffsetY())); |
687 | transitionElement.setAttribute("name", inputTransition.underlyingTransition().name()); |
688 | transitionElement.setAttribute("displayName", (inputTransition.getAttributesVisible() ? "true" : "false")); |
689 | transitionElement.setAttribute("id", (inputTransition.getId() != null ? inputTransition.getId() : "error")); |
690 | @@ -431,8 +431,8 @@ |
691 | arcElement.setAttribute("id", (inputArc.getId() != null ? inputArc.getId() : "error")); |
692 | arcElement.setAttribute("source", (inputArc.getSource().getId() != null ? inputArc.getSource().getId() : "")); |
693 | arcElement.setAttribute("target", (inputArc.getTarget().getId() != null ? inputArc.getTarget().getId() : "")); |
694 | - arcElement.setAttribute("nameOffsetX", (inputArc.getNameOffsetXObject() != null ? String.valueOf(inputArc.getNameOffsetXObject()) : "")); |
695 | - arcElement.setAttribute("nameOffsetY", (inputArc.getNameOffsetYObject() != null ? String.valueOf(inputArc.getNameOffsetYObject()) : "")); |
696 | + arcElement.setAttribute("nameOffsetX", String.valueOf(inputArc.getNameOffsetX())); |
697 | + arcElement.setAttribute("nameOffsetY", String.valueOf(inputArc.getNameOffsetY())); |
698 | |
699 | if (inputArc instanceof TimedOutputArcComponent) { |
700 | if (inputArc instanceof TimedInputArcComponent) { |
701 | |
702 | === modified file 'src/dk/aau/cs/verification/TAPNComposer.java' |
703 | --- src/dk/aau/cs/verification/TAPNComposer.java 2020-04-18 15:50:17 +0000 |
704 | +++ src/dk/aau/cs/verification/TAPNComposer.java 2020-05-12 11:42:36 +0000 |
705 | @@ -70,7 +70,7 @@ |
706 | hasShownMessage = false; |
707 | |
708 | |
709 | - double greatestWidth = 0, |
710 | + int greatestWidth = 0, |
711 | greatestHeight = 0; |
712 | if (this.guiModels != null) { |
713 | for (TimedArcPetriNet tapn1 : model.activeTemplates()) { |
714 | @@ -195,7 +195,7 @@ |
715 | } |
716 | } |
717 | |
718 | - private void createPlaces(TimedArcPetriNetNetwork model, TimedArcPetriNet constructedModel, NameMapping mapping, DataLayer guiModel, double greatestWidth, double greatestHeight) { |
719 | + private void createPlaces(TimedArcPetriNetNetwork model, TimedArcPetriNet constructedModel, NameMapping mapping, DataLayer guiModel, int greatestWidth, int greatestHeight) { |
720 | int i = 0; |
721 | for (TimedArcPetriNet tapn : model.activeTemplates()) { |
722 | DataLayer currentGuiModel = null; |
723 | @@ -246,7 +246,7 @@ |
724 | } |
725 | } |
726 | |
727 | - private void createTransitions(TimedArcPetriNetNetwork model, TimedArcPetriNet constructedModel, NameMapping mapping, DataLayer guiModel, double greatestWidth, double greatestHeight) { |
728 | + private void createTransitions(TimedArcPetriNetNetwork model, TimedArcPetriNet constructedModel, NameMapping mapping, DataLayer guiModel, int greatestWidth, int greatestHeight) { |
729 | int i = 0; |
730 | for (TimedArcPetriNet tapn : model.activeTemplates()) { |
731 | |
732 | @@ -318,7 +318,7 @@ |
733 | } |
734 | } |
735 | |
736 | - private ArcPath createArcPath(DataLayer currentGuiModel, PlaceTransitionObject source, PlaceTransitionObject target, Arc arc, double offsetX, double offsetY) { |
737 | + private ArcPath createArcPath(DataLayer currentGuiModel, PlaceTransitionObject source, PlaceTransitionObject target, Arc arc, int offsetX, int offsetY) { |
738 | Arc guiArc = currentGuiModel.getArcByEndpoints(source, target); |
739 | ArcPath arcPath = guiArc.getArcPath(); |
740 | int arcPathPointsNum = arcPath.getNumPoints(); |
741 | @@ -338,7 +338,7 @@ |
742 | return newArcPath; |
743 | } |
744 | |
745 | - private void createInputArcs(TimedArcPetriNetNetwork model, TimedArcPetriNet constructedModel, NameMapping mapping, DataLayer guiModel, double greatestWidth, double greatestHeight) { |
746 | + private void createInputArcs(TimedArcPetriNetNetwork model, TimedArcPetriNet constructedModel, NameMapping mapping, DataLayer guiModel, int greatestWidth, int greatestHeight) { |
747 | int i = 0; |
748 | for (TimedArcPetriNet tapn : model.activeTemplates()) { |
749 | |
750 | @@ -375,15 +375,11 @@ |
751 | Transition guiTarget = guiModel.getTransitionByName(mapping.map(targetTemplate, arc.destination().name())); |
752 | |
753 | Arc newArc = new TimedInputArcComponent(new TimedOutputArcComponent( |
754 | - 0d, |
755 | - 0d, |
756 | - 0d, |
757 | - 0d, |
758 | - guiSource, |
759 | + guiSource, |
760 | guiTarget, |
761 | arc.getWeight().value(), |
762 | - mapping.map(sourceTemplate, arc.source().name()) + "_to_" + mapping.map(targetTemplate, arc.destination().name()), |
763 | - false) |
764 | + mapping.map(sourceTemplate, arc.source().name()) + "_to_" + mapping.map(targetTemplate, arc.destination().name()) |
765 | + ) |
766 | ); |
767 | |
768 | // Build ArcPath |
769 | @@ -402,7 +398,7 @@ |
770 | } |
771 | } |
772 | |
773 | - private void createOutputArcs(TimedArcPetriNetNetwork model, TimedArcPetriNet constructedModel, NameMapping mapping, DataLayer guiModel, double greatestWidth, double greatestHeight) { |
774 | + private void createOutputArcs(TimedArcPetriNetNetwork model, TimedArcPetriNet constructedModel, NameMapping mapping, DataLayer guiModel, int greatestWidth, int greatestHeight) { |
775 | int i = 0; |
776 | for (TimedArcPetriNet tapn : model.activeTemplates()) { |
777 | DataLayer currentGuiModel = null; |
778 | @@ -430,16 +426,11 @@ |
779 | Place guiTarget = guiModel.getPlaceByName(mapping.map(destinationTemplate, arc.destination().name())); |
780 | |
781 | TimedOutputArcComponent newArc = new TimedOutputArcComponent( |
782 | - 0d, |
783 | - 0d, |
784 | - 0d, |
785 | - 0d, |
786 | - guiModel.getTransitionByName(mapping.map(sourceTemplate, arc.source().name())), |
787 | + guiModel.getTransitionByName(mapping.map(sourceTemplate, arc.source().name())), |
788 | guiModel.getPlaceByName(mapping.map(destinationTemplate, arc.destination().name())), |
789 | arc.getWeight().value(), |
790 | - mapping.map(sourceTemplate, arc.source().name()) + "_to_" + mapping.map(destinationTemplate, arc.destination().name()), |
791 | - false |
792 | - ); |
793 | + mapping.map(sourceTemplate, arc.source().name()) + "_to_" + mapping.map(destinationTemplate, arc.destination().name()) |
794 | + ); |
795 | |
796 | // Build ArcPath |
797 | Transition oldGuiSource = currentGuiModel.getTransitionByName(arc.source().name()); |
798 | @@ -457,7 +448,7 @@ |
799 | } |
800 | } |
801 | |
802 | - private void createTransportArcs(TimedArcPetriNetNetwork model, TimedArcPetriNet constructedModel, NameMapping mapping, DataLayer guiModel, double greatestWidth, double greatestHeight) { |
803 | + private void createTransportArcs(TimedArcPetriNetNetwork model, TimedArcPetriNet constructedModel, NameMapping mapping, DataLayer guiModel, int greatestWidth, int greatestHeight) { |
804 | int i = 0; |
805 | int nextGroupNr = 0; |
806 | for (TimedArcPetriNet tapn : model.activeTemplates()) { |
807 | @@ -498,16 +489,11 @@ |
808 | |
809 | TimedTransportArcComponent newInArc = new TimedTransportArcComponent( |
810 | new TimedInputArcComponent(new TimedOutputArcComponent( |
811 | - 0d, |
812 | - 0d, |
813 | - 0d, |
814 | - 0d, |
815 | - guiSourceIn, |
816 | + guiSourceIn, |
817 | guiTargetIn, |
818 | arc.getWeight().value(), |
819 | - mapping.map(sourceTemplate, arc.source().name()) + "_to_" + mapping.map(transitionTemplate, arc.transition().name()), |
820 | - false |
821 | - ) |
822 | + mapping.map(sourceTemplate, arc.source().name()) + "_to_" + mapping.map(transitionTemplate, arc.transition().name()) |
823 | + ) |
824 | ), |
825 | nextGroupNr, |
826 | true |
827 | @@ -542,15 +528,11 @@ |
828 | |
829 | TimedTransportArcComponent newOutArc = new TimedTransportArcComponent( |
830 | new TimedInputArcComponent(new TimedOutputArcComponent( |
831 | - 0d, |
832 | - 0d, |
833 | - 0d, |
834 | - 0d, |
835 | - guiSourceOut, |
836 | + guiSourceOut, |
837 | guiTargetOut, |
838 | 1, |
839 | - mapping.map(transitionTemplate, arc.transition().name()) + "_to_" + mapping.map(destinationTemplate, arc.destination().name()), |
840 | - false) |
841 | + mapping.map(transitionTemplate, arc.transition().name()) + "_to_" + mapping.map(destinationTemplate, arc.destination().name()) |
842 | + ) |
843 | ), |
844 | nextGroupNr + 1, |
845 | false |
846 | @@ -574,7 +556,7 @@ |
847 | |
848 | |
849 | |
850 | - private void createInhibitorArcs(TimedArcPetriNetNetwork model, TimedArcPetriNet constructedModel, NameMapping mapping, DataLayer guiModel, double greatestWidth, double greatestHeight) { |
851 | + private void createInhibitorArcs(TimedArcPetriNetNetwork model, TimedArcPetriNet constructedModel, NameMapping mapping, DataLayer guiModel, int greatestWidth, int greatestHeight) { |
852 | int i = 0; |
853 | for (TimedArcPetriNet tapn : model.activeTemplates()) { |
854 | |
855 | @@ -609,16 +591,11 @@ |
856 | Place guiSource = guiModel.getPlaceByName(mapping.map(sourceTemplate, arc.source().name())); |
857 | Transition guiTarget = guiModel.getTransitionByName(mapping.map(destinationTemplate, arc.destination().name())); |
858 | Arc newArc = new TimedInhibitorArcComponent(new TimedOutputArcComponent( |
859 | - 0d, |
860 | - 0d, |
861 | - 0d, |
862 | - 0d, |
863 | - guiSource, |
864 | + guiSource, |
865 | guiTarget, |
866 | arc.getWeight().value(), |
867 | - mapping.map(sourceTemplate, arc.source().name()) + "_to_" + mapping.map(destinationTemplate, arc.destination().name()), |
868 | - false |
869 | - ), ""); |
870 | + mapping.map(sourceTemplate, arc.source().name()) + "_to_" + mapping.map(destinationTemplate, arc.destination().name()) |
871 | + ), ""); |
872 | |
873 | // Build ArcPath |
874 | Place oldGuiSource = currentGuiModel.getPlaceByName(arc.source().name()); |
875 | |
876 | === modified file 'src/pipe/gui/CreateGui.java' |
877 | --- src/pipe/gui/CreateGui.java 2020-04-18 13:49:06 +0000 |
878 | +++ src/pipe/gui/CreateGui.java 2020-05-12 11:42:36 +0000 |
879 | @@ -39,6 +39,7 @@ |
880 | |
881 | @Deprecated |
882 | public static DataLayer getModel() { |
883 | + if (appGui==null) return null; |
884 | return getModel(appGui.getSelectedTabIndex()); |
885 | } |
886 | |
887 | |
888 | === modified file 'src/pipe/gui/Zoomer.java' |
889 | --- src/pipe/gui/Zoomer.java 2020-04-18 13:28:36 +0000 |
890 | +++ src/pipe/gui/Zoomer.java 2020-05-12 11:42:36 +0000 |
891 | @@ -46,32 +46,36 @@ |
892 | return setPercent(newPercent); |
893 | } |
894 | |
895 | + public static AffineTransform getTransform(int zoom) { |
896 | + return AffineTransform.getScaleInstance(zoom * 0.01, zoom * 0.01); |
897 | + } |
898 | + |
899 | + public static double getScaleFactor(int zoom) { |
900 | + return zoom * 0.01; |
901 | + } |
902 | + |
903 | public static int getZoomedValue(int x, int zoom) { |
904 | - return (int) (x * zoom * 0.01); |
905 | - } |
906 | - |
907 | - public static double getZoomedValue(double x, int zoom) { |
908 | - return x * zoom * 0.01; |
909 | - } |
910 | - |
911 | - public static AffineTransform getTransform(int zoom) { |
912 | - return AffineTransform.getScaleInstance(zoom * 0.01, zoom * 0.01); |
913 | - } |
914 | - |
915 | - public static double getScaleFactor(int zoom) { |
916 | - return zoom * 0.01; |
917 | + return (int) Math.round((x * zoom * 0.01)); |
918 | + } |
919 | + |
920 | + /** |
921 | + * @deprecated use int getUnzoomedValue(int x, int zoom) |
922 | + */ |
923 | + @Deprecated |
924 | + public static int getZoomedValue(double x, int zoom) { |
925 | + return (int) Math.round((x * zoom * 0.01)); |
926 | } |
927 | |
928 | public static int getUnzoomedValue(int x, int zoom) { |
929 | - return (int) (x / (zoom * 0.01)); |
930 | + return (int) Math.round((x / (zoom * 0.01))); |
931 | } |
932 | |
933 | /** |
934 | * @deprecated use int getUnzoomedValue(int x, int zoom) |
935 | */ |
936 | @Deprecated |
937 | - public static double getUnzoomedValue(double x, int zoom) { |
938 | - return x / (zoom * 0.01); |
939 | + public static int getUnzoomedValue(double x, int zoom) { |
940 | + return (int) Math.round(x / (zoom * 0.01)); |
941 | } |
942 | |
943 | } |
944 | |
945 | === modified file 'src/pipe/gui/graphicElements/ArcPath.java' |
946 | --- src/pipe/gui/graphicElements/ArcPath.java 2020-04-18 15:59:30 +0000 |
947 | +++ src/pipe/gui/graphicElements/ArcPath.java 2020-05-12 11:42:36 +0000 |
948 | @@ -367,7 +367,7 @@ |
949 | |
950 | public void setPointLocation(int index, double x, double y) { |
951 | if (index < pathPoints.size() && index >= 0) { |
952 | - (pathPoints.get(index)).setPointLocation(x, y); |
953 | + (pathPoints.get(index)).setPointLocation((int)x,(int) y); |
954 | } |
955 | } |
956 | |
957 | |
958 | === modified file 'src/pipe/gui/graphicElements/ArcPathPoint.java' |
959 | --- src/pipe/gui/graphicElements/ArcPathPoint.java 2020-04-18 13:28:36 +0000 |
960 | +++ src/pipe/gui/graphicElements/ArcPathPoint.java 2020-05-12 11:42:36 +0000 |
961 | @@ -32,8 +32,6 @@ |
962 | private final int DELTA = 10; |
963 | |
964 | private ArcPath myArcPath; |
965 | - private Point2D.Double point = new Point2D.Double(); |
966 | - private Point2D.Double realPoint = new Point2D.Double(); |
967 | |
968 | private Point2D.Double control1 = new Point2D.Double(); |
969 | private Point2D.Double control2 = new Point2D.Double(); |
970 | @@ -53,7 +51,8 @@ |
971 | public ArcPathPoint(double x, double y, boolean _pointType, ArcPath a) { |
972 | this(); |
973 | myArcPath = a; |
974 | - setPointLocation(x, y); |
975 | + setPositionX((int)x); |
976 | + setPositionY((int)y); |
977 | pointType = _pointType; |
978 | } |
979 | |
980 | @@ -72,14 +71,12 @@ |
981 | } |
982 | |
983 | public Point2D.Double getPoint() { |
984 | - return point; |
985 | + return new Point2D.Double(getPositionX(), getPositionY()); |
986 | } |
987 | |
988 | - public void setPointLocation(double x, double y) { |
989 | - double realX = Zoomer.getUnzoomedValue(x, myArcPath.getArc().getZoom()); |
990 | - double realY = Zoomer.getUnzoomedValue(y, myArcPath.getArc().getZoom()); |
991 | - getRealPoint().setLocation(realX, realY); |
992 | - point.setLocation(x, y); |
993 | + public void setPointLocation(int x, int y) { |
994 | + setPositionX(x); |
995 | + setPositionY(y); |
996 | setBounds((int) x - SIZE, (int) y - SIZE, 2 * SIZE + SIZE_OFFSET, 2 |
997 | * SIZE + SIZE_OFFSET); |
998 | } |
999 | @@ -89,7 +86,8 @@ |
1000 | } |
1001 | |
1002 | public void updatePointLocation() { |
1003 | - setPointLocation(point.x, point.y); |
1004 | + //XXX |
1005 | + //setPointLocation(point.x, point.y); |
1006 | } |
1007 | |
1008 | public void setPointType(boolean type) { |
1009 | @@ -114,16 +112,12 @@ |
1010 | public double getAngle(Point2D.Double p2) { |
1011 | double angle; |
1012 | |
1013 | - if (point.y <= p2.y) { |
1014 | - angle = Math.atan((point.x - p2.x) / (p2.y - point.y)); |
1015 | + if (getPositionY() <= p2.y) { |
1016 | + angle = Math.atan((getPositionX() - p2.x) / (p2.y - getPositionY())); |
1017 | } else { |
1018 | - angle = Math.atan((point.x - p2.x) / (p2.y - point.y)) + Math.PI; |
1019 | + angle = Math.atan((getPositionX() - p2.x) / (p2.y - getPositionY())) + Math.PI; |
1020 | } |
1021 | |
1022 | - // Needed to eliminate an exception on Windows |
1023 | - if (point.equals(p2)) { |
1024 | - angle = 0; |
1025 | - } |
1026 | return angle; |
1027 | } |
1028 | |
1029 | @@ -178,8 +172,7 @@ |
1030 | public Command splitPoint() { |
1031 | int i = getIndex(); // Get the index of this point |
1032 | |
1033 | - ArcPathPoint newPoint = new ArcPathPoint(point.x + DELTA, point.y, |
1034 | - pointType, myArcPath); |
1035 | + ArcPathPoint newPoint = new ArcPathPoint(getPositionX() + DELTA, getPositionY(), pointType, myArcPath); |
1036 | myArcPath.insertPoint(i + 1, newPoint); |
1037 | myArcPath.getArc().updateArcPosition(); |
1038 | return new AddArcPathPointEdit(myArcPath.getArc(), newPoint, myArcPath.getArc().getGuiModel()); |
1039 | @@ -187,8 +180,8 @@ |
1040 | |
1041 | public Point2D.Double getMidPoint(ArcPathPoint target) { |
1042 | return new Point2D.Double( |
1043 | - (target.point.x + point.x) / 2, |
1044 | - (target.point.y + point.y) / 2 |
1045 | + (target.getPositionX() + getPositionX()) / 2, |
1046 | + (target.getPositionY() + getPositionY()) / 2 |
1047 | ); |
1048 | } |
1049 | |
1050 | @@ -240,7 +233,7 @@ |
1051 | } |
1052 | |
1053 | public void translate(int x, int y) { |
1054 | - this.setPointLocation(point.x + x, point.y + y); |
1055 | + this.setPointLocation(getPositionX() + x, getPositionY() + y); |
1056 | myArcPath.updateArc(); |
1057 | } |
1058 | |
1059 | @@ -260,23 +253,21 @@ |
1060 | } else { |
1061 | SIZE = 3; |
1062 | } |
1063 | - double x = Zoomer.getZoomedValue(getRealPoint().x, zoom); |
1064 | - double y = Zoomer.getZoomedValue(getRealPoint().y, zoom); |
1065 | - point.setLocation(x, y); |
1066 | + int x = (int)Zoomer.getZoomedValue(getRealPoint().x, zoom); |
1067 | + int y = (int)Zoomer.getZoomedValue(getRealPoint().y, zoom); |
1068 | + setPositionX(x); |
1069 | + setPositionY(y); |
1070 | setBounds((int) x - SIZE, (int) y - SIZE, 2 * SIZE + SIZE_OFFSET, 2 |
1071 | * SIZE + SIZE_OFFSET); |
1072 | } |
1073 | |
1074 | public Point2D.Double getRealPoint() { |
1075 | - return realPoint; |
1076 | + return new Point2D.Double(getOriginalX(), getOriginalY()); |
1077 | } |
1078 | |
1079 | - public void setRealPoint(Point2D.Double realPoint) { |
1080 | - this.realPoint = realPoint; |
1081 | - } |
1082 | - |
1083 | public boolean isEndPoint() { |
1084 | return this.getIndex() == 0 || this.getIndex() == myArcPath.getEndIndex(); |
1085 | } |
1086 | |
1087 | + |
1088 | } |
1089 | |
1090 | === modified file 'src/pipe/gui/graphicElements/NameLabel.java' |
1091 | --- src/pipe/gui/graphicElements/NameLabel.java 2020-04-18 13:49:06 +0000 |
1092 | +++ src/pipe/gui/graphicElements/NameLabel.java 2020-05-12 11:42:36 +0000 |
1093 | @@ -24,19 +24,15 @@ |
1094 | |
1095 | private Font font = new Font(Pipe.LABEL_FONT, Font.BOLD, Pipe.LABEL_DEFAULT_FONT_SIZE); |
1096 | |
1097 | - public NameLabel(int zoom) { |
1098 | + public NameLabel() { |
1099 | this(""); |
1100 | - |
1101 | - //Kind of important to know about deriveFont: --kyrke 2020-04-02 |
1102 | - // deriveFont(int) - sets text style |
1103 | - // deriveFont(float) - sets text size |
1104 | - setFont(getFont().deriveFont((float)Zoomer.getZoomedValue(Pipe.LABEL_DEFAULT_FONT_SIZE, zoom))); |
1105 | } |
1106 | |
1107 | public NameLabel(String nameInput) { |
1108 | super(nameInput); |
1109 | name = nameInput; |
1110 | setFont(font); |
1111 | + |
1112 | setCursor(new java.awt.Cursor(java.awt.Cursor.CROSSHAIR_CURSOR)); |
1113 | setEditable(false); |
1114 | setFocusable(false); |
1115 | @@ -109,10 +105,11 @@ |
1116 | } |
1117 | |
1118 | public void zoomUpdate(int value) { |
1119 | + |
1120 | //Kind of important to know about deriveFont: --kyrke 2020-04-02 |
1121 | // deriveFont(int) - sets text style |
1122 | // deriveFont(float) - sets text size |
1123 | - setFont(getFont().deriveFont((float)Zoomer.getZoomedValue(Pipe.LABEL_DEFAULT_FONT_SIZE, value))); |
1124 | + setFont(getFont().deriveFont((float)Zoomer.getZoomedValue(Pipe.LABEL_DEFAULT_FONT_SIZE, value))); |
1125 | |
1126 | updateSize(); |
1127 | } |
1128 | |
1129 | === modified file 'src/pipe/gui/graphicElements/PetriNetObject.java' |
1130 | --- src/pipe/gui/graphicElements/PetriNetObject.java 2020-04-18 12:27:02 +0000 |
1131 | +++ src/pipe/gui/graphicElements/PetriNetObject.java 2020-05-12 11:42:36 +0000 |
1132 | @@ -22,8 +22,8 @@ |
1133 | |
1134 | protected static final int COMPONENT_DRAW_OFFSET= 5; |
1135 | /** x/y position position on screen (zoomed) */ |
1136 | - protected double positionX; |
1137 | - protected double positionY; |
1138 | + protected int positionX; |
1139 | + protected int positionY; |
1140 | |
1141 | // The x/y coordinate of object at 100% zoom. |
1142 | //XXX: pushed down from PlaceTransitionObject and consolidated from note, need further refactoring and rename, //kyrke 2019-08-23 |
1143 | @@ -274,27 +274,6 @@ |
1144 | public int getOriginalY() { |
1145 | return originalY; |
1146 | } |
1147 | - /** |
1148 | - * Get X-axis position, returns null if value not yet entered |
1149 | - * |
1150 | - * @return Double value for X-axis position |
1151 | - * @deprecated use getOriginalX |
1152 | - */ |
1153 | - @Deprecated |
1154 | - public Double getPositionXObject() { |
1155 | - return (double) originalX; |
1156 | - } |
1157 | - |
1158 | - /** |
1159 | - * Get Y-axis position, returns null if value not yet entered |
1160 | - * |
1161 | - * @return Double value for Y-axis position |
1162 | - * @deprecated use getOriginalY |
1163 | - */ |
1164 | - @Deprecated |
1165 | - public Double getPositionYObject() { |
1166 | - return (double) originalY; |
1167 | - } |
1168 | |
1169 | @Override |
1170 | public void zoomUpdate(int zoom) { |
1171 | @@ -314,9 +293,9 @@ |
1172 | * @param positionXInput |
1173 | * Double value for X-axis position |
1174 | */ |
1175 | - public void setPositionX(double positionXInput) { |
1176 | + public void setPositionX(int positionXInput) { |
1177 | positionX = positionXInput; |
1178 | - originalX = (int)Zoomer.getUnzoomedValue(positionX, getZoom()); |
1179 | + originalX = Zoomer.getUnzoomedValue(positionX, getZoom()); |
1180 | } |
1181 | |
1182 | //XXX: pushed down from Placetransition object, might be dublicated //kyrke 2019-09-20 |
1183 | @@ -326,9 +305,9 @@ |
1184 | * @param positionYInput |
1185 | * Double value for Y-axis position |
1186 | */ |
1187 | - public void setPositionY(double positionYInput) { |
1188 | + public void setPositionY(int positionYInput) { |
1189 | positionY = positionYInput; |
1190 | - originalY = (int)Zoomer.getUnzoomedValue(positionY, getZoom()); |
1191 | + originalY = Zoomer.getUnzoomedValue(positionY, getZoom()); |
1192 | } |
1193 | |
1194 | //XXX: pushed down from Placetransition object, might be dublicated //kyrke 2019-09-20 |
1195 | @@ -337,7 +316,7 @@ |
1196 | * |
1197 | * @return Double value for X-axis position |
1198 | */ |
1199 | - public double getPositionX() { |
1200 | + public int getPositionX() { |
1201 | return positionX; |
1202 | } |
1203 | |
1204 | @@ -347,7 +326,7 @@ |
1205 | * |
1206 | * @return Double value for Y-axis position |
1207 | */ |
1208 | - public double getPositionY() { |
1209 | + public int getPositionY() { |
1210 | return positionY; |
1211 | } |
1212 | } |
1213 | |
1214 | === modified file 'src/pipe/gui/graphicElements/PetriNetObjectWithLabel.java' |
1215 | --- src/pipe/gui/graphicElements/PetriNetObjectWithLabel.java 2020-04-06 07:46:34 +0000 |
1216 | +++ src/pipe/gui/graphicElements/PetriNetObjectWithLabel.java 2020-05-12 11:42:36 +0000 |
1217 | @@ -10,10 +10,10 @@ |
1218 | |
1219 | |
1220 | /* Name Label for displaying name */ |
1221 | - protected NameLabel pnName = new NameLabel(Pipe.ZOOM_DEFAULT); |
1222 | + protected NameLabel pnName = new NameLabel(); |
1223 | /** X/Y-axis Position on screen */ |
1224 | - private double nameOffsetX; |
1225 | - private double nameOffsetY; |
1226 | + private int nameOffsetX; |
1227 | + private int nameOffsetY; |
1228 | |
1229 | PetriNetObjectWithLabel(int nameOffsetX, int nameOffsetY) { |
1230 | super(); |
1231 | @@ -42,13 +42,14 @@ |
1232 | protected void updateLabelLocation(boolean alignToGrid) { |
1233 | if(alignToGrid) { |
1234 | this.getNameLabel().setPosition( |
1235 | - Grid.getModifiedX((int) (positionX + Zoomer.getZoomedValue(nameOffsetX, getZoom()))), |
1236 | - Grid.getModifiedY((int) (positionY + Zoomer.getZoomedValue(nameOffsetY, getZoom()))) |
1237 | + Grid.getModifiedX(positionX + Zoomer.getZoomedValue(nameOffsetX, getZoom())), |
1238 | + Grid.getModifiedY(positionY + Zoomer.getZoomedValue(nameOffsetY, getZoom())) |
1239 | ); |
1240 | } else { |
1241 | this.getNameLabel().setPosition( |
1242 | - ((int)(positionX + Zoomer.getZoomedValue(nameOffsetX, getZoom()))), |
1243 | - ((int)(positionY + Zoomer.getZoomedValue(nameOffsetY, getZoom())))); |
1244 | + positionX + Zoomer.getZoomedValue(nameOffsetX, getZoom()), |
1245 | + positionY + Zoomer.getZoomedValue(nameOffsetY, getZoom()) |
1246 | + ); |
1247 | } |
1248 | } |
1249 | |
1250 | @@ -72,7 +73,7 @@ |
1251 | * @param nameOffsetXInput |
1252 | * Double value for name X-axis offset |
1253 | */ |
1254 | - public void setNameOffsetX(double nameOffsetXInput) { |
1255 | + public void setNameOffsetX(int nameOffsetXInput) { |
1256 | nameOffsetX = Zoomer.getUnzoomedValue(nameOffsetXInput, getZoom()); |
1257 | } |
1258 | |
1259 | @@ -82,42 +83,24 @@ |
1260 | * @param nameOffsetYInput |
1261 | * Double value for name Y-axis offset |
1262 | */ |
1263 | - public void setNameOffsetY(double nameOffsetYInput) { |
1264 | + public void setNameOffsetY(int nameOffsetYInput) { |
1265 | nameOffsetY = Zoomer.getUnzoomedValue(nameOffsetYInput, getZoom()); |
1266 | } |
1267 | |
1268 | - public void updateNameOffsetX(double nameOffsetXInput) { |
1269 | + public void updateNameOffsetX(int nameOffsetXInput) { |
1270 | nameOffsetX += Zoomer.getUnzoomedValue(nameOffsetXInput, getZoom()); |
1271 | |
1272 | } |
1273 | |
1274 | - public void updateNameOffsetY(double nameOffsetYInput) { |
1275 | + public void updateNameOffsetY(int nameOffsetYInput) { |
1276 | nameOffsetY += Zoomer.getUnzoomedValue(nameOffsetYInput, getZoom()); |
1277 | } |
1278 | |
1279 | - /** |
1280 | - * Get X-axis offset for ... |
1281 | - * |
1282 | - * @return Double value for X-axis offset of ... |
1283 | - */ |
1284 | - public Double getNameOffsetXObject() { |
1285 | - return nameOffsetX; |
1286 | - } |
1287 | - |
1288 | - /** |
1289 | - * Moved to PetriNetObject Get Y-axis offset for ... |
1290 | - * |
1291 | - * @return Double value for Y-axis offset of ... |
1292 | - */ |
1293 | - public Double getNameOffsetYObject() { |
1294 | - return nameOffsetY; |
1295 | - } |
1296 | - |
1297 | //XXX pushed up from PlaceTransitionObject while refactorings, dublicates getNameOffsetXObject? //kyrke 2019-09-17 |
1298 | - public double getNameOffsetX() { |
1299 | + public int getNameOffsetX() { |
1300 | return nameOffsetX; |
1301 | } |
1302 | - public double getNameOffsetY() { |
1303 | + public int getNameOffsetY() { |
1304 | return nameOffsetY; |
1305 | } |
1306 | |
1307 | |
1308 | === modified file 'src/pipe/gui/graphicElements/Place.java' |
1309 | --- src/pipe/gui/graphicElements/Place.java 2020-04-18 12:27:02 +0000 |
1310 | +++ src/pipe/gui/graphicElements/Place.java 2020-05-12 11:42:36 +0000 |
1311 | @@ -47,17 +47,6 @@ |
1312 | componentHeight = DIAMETER; |
1313 | } |
1314 | |
1315 | - @Deprecated |
1316 | - public Place(double positionXInput, double positionYInput, String idInput, |
1317 | - double nameOffsetXInput, double nameOffsetYInput) { |
1318 | - this((int)positionXInput, (int)positionYInput, idInput, (int)nameOffsetXInput, (int)nameOffsetYInput); |
1319 | - } |
1320 | - |
1321 | - @Deprecated |
1322 | - public Place(double positionXInput, double positionYInput) { |
1323 | - this((int)positionXInput, (int)positionYInput, null, 0,0); |
1324 | - } |
1325 | - |
1326 | public Place(int positionXInput, int positionYInput) { |
1327 | this(positionXInput, positionYInput, null, 0,0); |
1328 | } |
1329 | |
1330 | === modified file 'src/pipe/gui/graphicElements/PlaceTransitionObject.java' |
1331 | --- src/pipe/gui/graphicElements/PlaceTransitionObject.java 2020-04-18 13:49:06 +0000 |
1332 | +++ src/pipe/gui/graphicElements/PlaceTransitionObject.java 2020-05-12 11:42:36 +0000 |
1333 | @@ -1,13 +1,13 @@ |
1334 | package pipe.gui.graphicElements; |
1335 | |
1336 | +import pipe.gui.Pipe; |
1337 | +import pipe.gui.Zoomer; |
1338 | + |
1339 | import java.awt.*; |
1340 | import java.awt.geom.Point2D; |
1341 | import java.util.Iterator; |
1342 | import java.util.LinkedList; |
1343 | |
1344 | -import pipe.gui.Pipe; |
1345 | -import pipe.gui.Zoomer; |
1346 | - |
1347 | /** |
1348 | * Petri-Net Place or Transition SuperClass |
1349 | * |
1350 | @@ -42,24 +42,6 @@ |
1351 | this(positionXInput, positionYInput, null, Pipe.DEFAULT_OFFSET_X, Pipe.DEFAULT_OFFSET_Y); |
1352 | } |
1353 | |
1354 | - @Deprecated |
1355 | - public PlaceTransitionObject( |
1356 | - double positionXInput, |
1357 | - double positionYInput, |
1358 | - String idInput, |
1359 | - double nameOffsetXInput, |
1360 | - double nameOffsetYInput |
1361 | - ) { |
1362 | - this((int)positionXInput, (int) positionYInput, idInput, (int)nameOffsetXInput, (int)nameOffsetYInput); |
1363 | - } |
1364 | - |
1365 | - @Deprecated |
1366 | - public PlaceTransitionObject(double positionXInput, double positionYInput) { |
1367 | - this(positionXInput, positionYInput, null, Pipe.DEFAULT_OFFSET_X, Pipe.DEFAULT_OFFSET_Y); |
1368 | - } |
1369 | - |
1370 | - |
1371 | - |
1372 | /** |
1373 | * Set name |
1374 | * |
1375 | @@ -147,12 +129,13 @@ |
1376 | /** Calculates the BoundsOffsets used for setBounds() method */ |
1377 | public void updateBounds() { |
1378 | double scaleFactor = Zoomer.getScaleFactor(getZoom()); |
1379 | - positionX = originalX * scaleFactor; |
1380 | - positionY = originalY * scaleFactor; |
1381 | - Rectangle bounds = new Rectangle(); |
1382 | - bounds.setBounds((int) positionX, (int) positionY, |
1383 | - (int) (componentWidth * scaleFactor), |
1384 | - (int) (componentHeight * scaleFactor)); |
1385 | + positionX = (int)Math.round(originalX * scaleFactor); |
1386 | + positionY = (int)Math.round(originalY * scaleFactor); |
1387 | + |
1388 | + int width = (int) Math.round(componentWidth * scaleFactor); |
1389 | + int height = (int) Math.round(componentHeight * scaleFactor); |
1390 | + |
1391 | + Rectangle bounds = new Rectangle(positionX, positionY, width, height); |
1392 | bounds.grow(COMPONENT_DRAW_OFFSET, COMPONENT_DRAW_OFFSET); |
1393 | setBounds(bounds); |
1394 | } |
1395 | @@ -196,9 +179,9 @@ |
1396 | } |
1397 | |
1398 | /** Sets the center of the component to position x, y */ |
1399 | - public void setCentre(double x, double y) { |
1400 | - setPositionX(x - (getWidth() / 2.0)); |
1401 | - setPositionY(y - (getHeight() / 2.0)); |
1402 | + public void setCentre(int x, int y) { |
1403 | + setPositionX((int) Math.round(x - (getWidth() / 2.0))); |
1404 | + setPositionY((int) Math.round(y - (getHeight() / 2.0))); |
1405 | update(true); |
1406 | } |
1407 | |
1408 | |
1409 | === modified file 'src/pipe/gui/graphicElements/Transition.java' |
1410 | --- src/pipe/gui/graphicElements/Transition.java 2020-04-18 12:27:02 +0000 |
1411 | +++ src/pipe/gui/graphicElements/Transition.java 2020-05-12 11:42:36 +0000 |
1412 | @@ -51,11 +51,11 @@ |
1413 | /** |
1414 | * Create Petri-Net Transition object |
1415 | */ |
1416 | - public Transition(double positionXInput, double positionYInput, |
1417 | - String idInput, double nameOffsetXInput, |
1418 | - double nameOffsetYInput, |
1419 | + public Transition(int positionXInput, int positionYInput, |
1420 | + String idInput, int nameOffsetXInput, |
1421 | + int nameOffsetYInput, |
1422 | boolean infServer, int angleInput, int priority) { |
1423 | - this((int)positionXInput, (int)positionYInput, idInput, (int)nameOffsetXInput, (int)nameOffsetYInput, angleInput); |
1424 | + this(positionXInput, positionYInput, idInput, nameOffsetXInput, nameOffsetYInput, angleInput); |
1425 | } |
1426 | |
1427 | /** |
1428 | @@ -86,8 +86,8 @@ |
1429 | * @param positionYInput |
1430 | * Y-axis Position |
1431 | */ |
1432 | - public Transition(double positionXInput, double positionYInput) { |
1433 | - this((int)positionXInput, (int)positionYInput,null, 0,0, 0); |
1434 | + public Transition(int positionXInput, int positionYInput) { |
1435 | + this(positionXInput, positionYInput,null, 0,0, 0); |
1436 | } |
1437 | |
1438 | @Override |
1439 | |
1440 | === modified file 'src/pipe/gui/graphicElements/tapn/TimedInputArcComponent.java' |
1441 | --- src/pipe/gui/graphicElements/tapn/TimedInputArcComponent.java 2020-04-18 12:27:02 +0000 |
1442 | +++ src/pipe/gui/graphicElements/tapn/TimedInputArcComponent.java 2020-05-12 11:42:36 +0000 |
1443 | @@ -30,13 +30,7 @@ |
1444 | updateLabel(true); |
1445 | } |
1446 | |
1447 | - /** @deprecated */ |
1448 | - @Deprecated |
1449 | - public TimedInputArcComponent(TimedOutputArcComponent arc, String guard) { |
1450 | - this(arc); |
1451 | - } |
1452 | - |
1453 | - @Override |
1454 | + @Override |
1455 | protected void addMouseHandler() { |
1456 | //XXX: kyrke 2018-09-06, this is bad as we leak "this", think its ok for now, as it alwas constructed when |
1457 | //XXX: handler is called. Make static constructor and add handler from there, to make it safe. |
1458 | |
1459 | === modified file 'src/pipe/gui/graphicElements/tapn/TimedOutputArcComponent.java' |
1460 | --- src/pipe/gui/graphicElements/tapn/TimedOutputArcComponent.java 2020-04-18 12:27:02 +0000 |
1461 | +++ src/pipe/gui/graphicElements/tapn/TimedOutputArcComponent.java 2020-05-12 11:42:36 +0000 |
1462 | @@ -29,16 +29,6 @@ |
1463 | super(sourceInput, targetInput, weightInput, idInput); |
1464 | } |
1465 | |
1466 | - /** @deprecated */ |
1467 | - @Deprecated |
1468 | - public TimedOutputArcComponent(double startPositionXInput, |
1469 | - double startPositionYInput, double endPositionXInput, |
1470 | - double endPositionYInput, PlaceTransitionObject sourceInput, |
1471 | - PlaceTransitionObject targetInput, int weightInput, String idInput, |
1472 | - boolean taggedInput) { |
1473 | - this(sourceInput, targetInput, weightInput, idInput); |
1474 | - } |
1475 | - |
1476 | /** |
1477 | * Create Petri-Net Arc object |
1478 | */ |
1479 | @@ -56,11 +46,12 @@ |
1480 | id = arc.id; |
1481 | this.setSource(arc.getSource()); |
1482 | this.setTarget(arc.getTarget()); |
1483 | - this.setNameOffsetX(arc.getNameOffsetXObject()); |
1484 | - this.setNameOffsetY(arc.getNameOffsetYObject()); |
1485 | + this.setNameOffsetX(arc.getNameOffsetX()); |
1486 | + this.setNameOffsetY(arc.getNameOffsetY()); |
1487 | this.getNameLabel().setPosition( |
1488 | Grid.getModifiedX((int) (arc.getNameLabel().getXPosition() + Zoomer.getZoomedValue(getNameOffsetX(), getZoom()))), |
1489 | - Grid.getModifiedY((int) (arc.getNameLabel().getYPosition() + Zoomer.getZoomedValue(getNameOffsetY(), getZoom())))); |
1490 | + Grid.getModifiedY((int) (arc.getNameLabel().getYPosition() + Zoomer.getZoomedValue(getNameOffsetY(), getZoom()))) |
1491 | + ); |
1492 | |
1493 | } |
1494 | |
1495 | |
1496 | === modified file 'src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java' |
1497 | --- src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java 2020-04-18 12:27:02 +0000 |
1498 | +++ src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java 2020-05-12 11:42:36 +0000 |
1499 | @@ -51,7 +51,7 @@ |
1500 | private Window ageOfTokensWindow; |
1501 | private Shape dashedOutline = createDashedOutline(); |
1502 | |
1503 | - public TimedPlaceComponent(double positionXInput, double positionYInput, dk.aau.cs.model.tapn.TimedPlace place) { |
1504 | + public TimedPlaceComponent(int positionXInput, int positionYInput, dk.aau.cs.model.tapn.TimedPlace place) { |
1505 | super(positionXInput, positionYInput); |
1506 | this.place = place; |
1507 | listener = timedPlaceListener(); |
1508 | @@ -62,12 +62,15 @@ |
1509 | |
1510 | } |
1511 | |
1512 | - public TimedPlaceComponent(double positionXInput, double positionYInput, |
1513 | - String idInput, double nameOffsetXInput, |
1514 | - double nameOffsetYInput) { |
1515 | + public TimedPlaceComponent( |
1516 | + int positionXInput, |
1517 | + int positionYInput, |
1518 | + String idInput, |
1519 | + int nameOffsetXInput, |
1520 | + int nameOffsetYInput |
1521 | + ) { |
1522 | |
1523 | - super(positionXInput, positionYInput, idInput, |
1524 | - nameOffsetXInput, nameOffsetYInput); |
1525 | + super(positionXInput, positionYInput, idInput, nameOffsetXInput, nameOffsetYInput); |
1526 | listener = timedPlaceListener(); |
1527 | attributesVisible = true; |
1528 | ageOfTokensWindow = new Window(new Frame()); |
1529 | @@ -427,7 +430,7 @@ |
1530 | } |
1531 | |
1532 | public TimedPlaceComponent copy(TimedArcPetriNet tapn) { |
1533 | - TimedPlaceComponent placeComponent = new TimedPlaceComponent(getPositionXObject(), getPositionYObject(), id, getNameOffsetX(), getNameOffsetY()); |
1534 | + TimedPlaceComponent placeComponent = new TimedPlaceComponent(getOriginalX(), getOriginalY(), id, getNameOffsetX(), getNameOffsetY()); |
1535 | placeComponent.setUnderlyingPlace(tapn.getPlaceByName(place.name())); |
1536 | |
1537 | return placeComponent; |
1538 | |
1539 | === modified file 'src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java' |
1540 | --- src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java 2020-05-06 14:58:56 +0000 |
1541 | +++ src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java 2020-05-12 11:42:36 +0000 |
1542 | @@ -36,7 +36,7 @@ |
1543 | private dk.aau.cs.model.tapn.event.TimedTransitionListener listener; |
1544 | private GeneralPath dashedOutline; |
1545 | |
1546 | - public TimedTransitionComponent(double positionXInput, double positionYInput, |
1547 | + public TimedTransitionComponent(int positionXInput, int positionYInput, |
1548 | dk.aau.cs.model.tapn.TimedTransition transition) { |
1549 | super(positionXInput, positionYInput); |
1550 | this.transition = transition; |
1551 | @@ -46,9 +46,9 @@ |
1552 | |
1553 | } |
1554 | |
1555 | - public TimedTransitionComponent(double positionXInput, |
1556 | - double positionYInput, String idInput, |
1557 | - double nameOffsetXInput, double nameOffsetYInput, |
1558 | + public TimedTransitionComponent(int positionXInput, |
1559 | + int positionYInput, String idInput, |
1560 | + int nameOffsetXInput, int nameOffsetYInput, |
1561 | boolean timedTransition, boolean infServer, int angleInput, |
1562 | int priority) { |
1563 | super(positionXInput, positionYInput, idInput, |
1564 | @@ -202,7 +202,7 @@ |
1565 | } |
1566 | |
1567 | public TimedTransitionComponent copy(TimedArcPetriNet tapn) { |
1568 | - TimedTransitionComponent transitionComponent = new TimedTransitionComponent(getPositionXObject(), getPositionYObject(), id, getNameOffsetX(), getNameOffsetY(), true, false, getAngle(), 0); |
1569 | + TimedTransitionComponent transitionComponent = new TimedTransitionComponent(getOriginalX(), getOriginalY(), id, getNameOffsetX(), getNameOffsetY(), true, false, getAngle(), 0); |
1570 | transitionComponent.setUnderlyingTransition(tapn.getTransitionByName(transition.name())); |
1571 | |
1572 | return transitionComponent; |
1573 | |
1574 | === modified file 'src/pipe/gui/graphicElements/tapn/TimedTransportArcComponent.java' |
1575 | --- src/pipe/gui/graphicElements/tapn/TimedTransportArcComponent.java 2020-04-18 13:18:51 +0000 |
1576 | +++ src/pipe/gui/graphicElements/tapn/TimedTransportArcComponent.java 2020-05-12 11:42:36 +0000 |
1577 | @@ -34,7 +34,7 @@ |
1578 | } |
1579 | |
1580 | public TimedTransportArcComponent(TimedInputArcComponent timedArc, int group, boolean isInPreSet) { |
1581 | - super(timedArc, ""); |
1582 | + super(timedArc); |
1583 | this.isInPreSet = isInPreSet; |
1584 | |
1585 | this.setGroup(group); |
1586 | @@ -80,7 +80,7 @@ |
1587 | @Override |
1588 | public void updateLabel(boolean displayConstantNames) { |
1589 | if (isInPreSet && underlyingTransportArc != null) { |
1590 | - if (CreateGui.getApp().showZeroToInfinityIntervals()){ |
1591 | + if (CreateGui.getApp() != null && CreateGui.getApp().showZeroToInfinityIntervals()){ |
1592 | getNameLabel().setText(underlyingTransportArc.interval().toString( |
1593 | displayConstantNames) |
1594 | + " : " + getGroup()); |
1595 | |
1596 | === modified file 'src/pipe/gui/handler/LabelHandler.java' |
1597 | --- src/pipe/gui/handler/LabelHandler.java 2020-04-02 09:44:05 +0000 |
1598 | +++ src/pipe/gui/handler/LabelHandler.java 2020-05-12 11:42:36 +0000 |
1599 | @@ -21,7 +21,7 @@ |
1600 | private NameLabel nl; |
1601 | |
1602 | protected Point dragInit = new Point(); |
1603 | - private double originalOffsetX, originalOffsetY; |
1604 | + private int originalOffsetX, originalOffsetY; |
1605 | |
1606 | public LabelHandler(NameLabel _nl, PetriNetObjectWithLabel _obj) { |
1607 | obj = _obj; |
1608 | @@ -53,8 +53,8 @@ |
1609 | dragInit = e.getPoint(); // |
1610 | |
1611 | dragInit = javax.swing.SwingUtilities.convertPoint(nl, dragInit, obj); |
1612 | - originalOffsetX = obj.getNameOffsetXObject(); |
1613 | - originalOffsetY = obj.getNameOffsetYObject(); |
1614 | + originalOffsetX = obj.getNameOffsetX(); |
1615 | + originalOffsetY = obj.getNameOffsetY(); |
1616 | } |
1617 | |
1618 | @Override |
1619 | @@ -77,7 +77,7 @@ |
1620 | Point p = javax.swing.SwingUtilities.convertPoint(nl, e.getPoint(), obj); |
1621 | |
1622 | CreateGui.getCurrentTab().getUndoManager().addNewEdit( |
1623 | - new UpdateNameLabelOffsetCommand(obj.getNameOffsetXObject(), obj.getNameOffsetYObject(), originalOffsetX, originalOffsetY, obj) |
1624 | + new UpdateNameLabelOffsetCommand(obj.getNameOffsetX(), obj.getNameOffsetY(), originalOffsetX, originalOffsetY, obj) |
1625 | ); |
1626 | |
1627 | } |
1628 | |
1629 | === modified file 'src/pipe/gui/handler/PlaceHandler.java' |
1630 | --- src/pipe/gui/handler/PlaceHandler.java 2020-04-02 09:44:05 +0000 |
1631 | +++ src/pipe/gui/handler/PlaceHandler.java 2020-05-12 11:42:36 +0000 |
1632 | @@ -90,8 +90,8 @@ |
1633 | if (m != null) { |
1634 | |
1635 | if (myObject instanceof PetriNetObjectWithLabel) { |
1636 | - int x = Zoomer.getZoomedValue(((PetriNetObjectWithLabel)myObject).getNameOffsetXObject().intValue(), myObject.getZoom()); |
1637 | - int y = Zoomer.getZoomedValue(((PetriNetObjectWithLabel)myObject).getNameOffsetYObject().intValue(), myObject.getZoom()); |
1638 | + int x = Zoomer.getZoomedValue(((PetriNetObjectWithLabel)myObject).getNameOffsetX(), myObject.getZoom()); |
1639 | + int y = Zoomer.getZoomedValue(((PetriNetObjectWithLabel)myObject).getNameOffsetY(), myObject.getZoom()); |
1640 | m.show(myObject, x, y); |
1641 | } |
1642 | } |
1643 | |
1644 | === modified file 'src/pipe/gui/handler/TransitionHandler.java' |
1645 | --- src/pipe/gui/handler/TransitionHandler.java 2020-04-18 13:49:06 +0000 |
1646 | +++ src/pipe/gui/handler/TransitionHandler.java 2020-05-12 11:42:36 +0000 |
1647 | @@ -82,11 +82,11 @@ |
1648 | JPopupMenu m = getPopup(e); |
1649 | if (m != null) { |
1650 | int x = Zoomer.getZoomedValue( |
1651 | - ((Transition) myObject).getNameOffsetXObject().intValue(), |
1652 | + ((Transition) myObject).getNameOffsetX(), |
1653 | myObject.getZoom() |
1654 | ); |
1655 | int y = Zoomer.getZoomedValue( |
1656 | - ((Transition) myObject).getNameOffsetYObject().intValue(), |
1657 | + ((Transition) myObject).getNameOffsetY(), |
1658 | myObject.getZoom() |
1659 | ); |
1660 | m.show(myObject, x, y); |
1661 | |
1662 | === added directory 'tests/dk' |
1663 | === added directory 'tests/dk/aau' |
1664 | === added directory 'tests/dk/aau/cs' |
1665 | === added directory 'tests/dk/aau/cs/io' |
1666 | === added file 'tests/dk/aau/cs/io/TapnXmlLoaderTest.kt' |
1667 | --- tests/dk/aau/cs/io/TapnXmlLoaderTest.kt 1970-01-01 00:00:00 +0000 |
1668 | +++ tests/dk/aau/cs/io/TapnXmlLoaderTest.kt 2020-05-12 11:42:36 +0000 |
1669 | @@ -0,0 +1,313 @@ |
1670 | +package dk.aau.cs.io |
1671 | + |
1672 | +import org.junit.jupiter.api.Assertions |
1673 | +import org.junit.jupiter.api.Disabled |
1674 | +import org.junit.jupiter.api.Test |
1675 | +import org.junit.jupiter.api.function.ThrowingSupplier |
1676 | + |
1677 | + |
1678 | + |
1679 | +internal class TapnXmlLoaderTest { |
1680 | + |
1681 | + internal class MalformedXML { |
1682 | + @Test @Disabled |
1683 | + fun `Malformed XML should throw an exception`() { |
1684 | + val tapnXmlLoader = TapnXmlLoader(); |
1685 | + Assertions.assertThrows(Exception::class.java) { |
1686 | + tapnXmlLoader.load("hello".asInpurtStream()) |
1687 | + } |
1688 | + } |
1689 | + } |
1690 | + |
1691 | + class Place { |
1692 | + |
1693 | + @Test |
1694 | + fun `Parse place`() { |
1695 | + val net = xmlNet( |
1696 | + """ |
1697 | + <place displayName="true" id="Start" initialMarking="1" invariant="< inf" name="Start" nameOffsetX="-5" nameOffsetY="35" positionX="135" positionY="30"/> |
1698 | + """ |
1699 | + ).asInpurtStream() |
1700 | + val tapnXmlLoader = TapnXmlLoader(); |
1701 | + |
1702 | + val r = Assertions.assertDoesNotThrow(ThrowingSupplier { |
1703 | + tapnXmlLoader.load(net) |
1704 | + }) |
1705 | + |
1706 | + Assertions.assertEquals(1, r.templates().first().guiModel().places.size) |
1707 | + |
1708 | + val place = r.templates().first().guiModel().places[0] |
1709 | + Assertions.assertEquals("Start", place.name) |
1710 | + Assertions.assertEquals(135, place.positionX) |
1711 | + Assertions.assertEquals(30, place.positionY) |
1712 | + |
1713 | + Assertions.assertEquals(-5, place.nameOffsetX) |
1714 | + Assertions.assertEquals(35, place.nameOffsetY) |
1715 | + |
1716 | + } |
1717 | + |
1718 | + @Test |
1719 | + //Older version of TAPAAL saved the positionX/Y and nameOffsetX/Y in double format eg. 35.0 |
1720 | + fun `Place positions can be double formatted`(){ |
1721 | + |
1722 | + val net = xmlNet( |
1723 | + """ |
1724 | + <place displayName="true" id="Start" initialMarking="1" invariant="< inf" name="Start" nameOffsetX="-5.0" nameOffsetY="35.0" positionX="135.0" positionY="30.0"/> |
1725 | + """ |
1726 | + ).asInpurtStream() |
1727 | + val tapnXmlLoader = TapnXmlLoader(); |
1728 | + |
1729 | + val r = Assertions.assertDoesNotThrow(ThrowingSupplier { |
1730 | + tapnXmlLoader.load(net) |
1731 | + }) |
1732 | + |
1733 | + val place = r.templates().first().guiModel().places[0] |
1734 | + |
1735 | + Assertions.assertEquals(135, place.positionX) |
1736 | + Assertions.assertEquals(30, place.positionY) |
1737 | + |
1738 | + Assertions.assertEquals(-5, place.nameOffsetX) |
1739 | + Assertions.assertEquals(35, place.nameOffsetY) |
1740 | + |
1741 | + } |
1742 | + |
1743 | + @Test |
1744 | + fun `Empty place`() { |
1745 | + val net = xmlNet("<place></place>").asInpurtStream() |
1746 | + val tapnXmlLoader = TapnXmlLoader() |
1747 | + |
1748 | + Assertions.assertThrows(Exception::class.java){ |
1749 | + tapnXmlLoader.load(net) |
1750 | + } |
1751 | + } |
1752 | + |
1753 | + |
1754 | + } |
1755 | + |
1756 | + class Transition { |
1757 | + @Test |
1758 | + fun `Parse Transition`() { |
1759 | + val net = xmlNet( |
1760 | + """ |
1761 | + <transition angle="90" displayName="true" id="T1" infiniteServer="false" name="T1" nameOffsetX="-5" nameOffsetY="35" positionX="360" positionY="300" priority="0" urgent="false"/> |
1762 | + """ |
1763 | + ).asInpurtStream() |
1764 | + val tapnXmlLoader = TapnXmlLoader(); |
1765 | + |
1766 | + val r = Assertions.assertDoesNotThrow(ThrowingSupplier { |
1767 | + tapnXmlLoader.load(net) |
1768 | + }) |
1769 | + |
1770 | + Assertions.assertEquals(1, r.templates().first().guiModel().transitions.size) |
1771 | + |
1772 | + val transition = r.templates().first().guiModel().transitions[0] |
1773 | + Assertions.assertEquals("T1", transition.name) |
1774 | + Assertions.assertEquals(360, transition.positionX) |
1775 | + Assertions.assertEquals(300, transition.positionY) |
1776 | + |
1777 | + Assertions.assertEquals(-5, transition.nameOffsetX) |
1778 | + Assertions.assertEquals(35, transition.nameOffsetY) |
1779 | + |
1780 | + } |
1781 | + |
1782 | + @Test |
1783 | + //Older version of TAPAAL saved the positionX/Y and nameOffsetX/Y in double format eg. 35.0 |
1784 | + fun `Transiton positions can be double formatted`(){ |
1785 | + val net = xmlNet( |
1786 | + """ |
1787 | + <transition angle="90" displayName="true" id="T1" infiniteServer="false" name="T1" nameOffsetX="-5" nameOffsetY="35" positionX="360" positionY="300" priority="0" urgent="false"/> |
1788 | + """ |
1789 | + ).asInpurtStream() |
1790 | + val tapnXmlLoader = TapnXmlLoader(); |
1791 | + |
1792 | + val r = Assertions.assertDoesNotThrow(ThrowingSupplier { |
1793 | + tapnXmlLoader.load(net) |
1794 | + }) |
1795 | + |
1796 | + val transition = r.templates().first().guiModel().transitions[0] |
1797 | + Assertions.assertEquals(360, transition.positionX) |
1798 | + Assertions.assertEquals(300, transition.positionY) |
1799 | + |
1800 | + Assertions.assertEquals(-5, transition.nameOffsetX) |
1801 | + Assertions.assertEquals(35, transition.nameOffsetY) |
1802 | + |
1803 | + } |
1804 | + |
1805 | + @Test |
1806 | + fun `Empty Transition`() { |
1807 | + val net = xmlNet("<transition></transition>").asInpurtStream() |
1808 | + val tapnXmlLoader = TapnXmlLoader() |
1809 | + |
1810 | + Assertions.assertThrows(Exception::class.java){ |
1811 | + tapnXmlLoader.load(net) |
1812 | + } |
1813 | + } |
1814 | + |
1815 | + @Test |
1816 | + fun `if urgent not defined, default value is false`() { |
1817 | + val net = xmlNet(""" |
1818 | + <transition angle="0" displayName="true" id="T1" infiniteServer="false" name="T1" nameOffsetX="-5" nameOffsetY="35" positionX="360" positionY="300" priority="0"/> |
1819 | + """).asInpurtStream() |
1820 | + val tapnXmlLoader = TapnXmlLoader() |
1821 | + |
1822 | + val r = Assertions.assertDoesNotThrow(ThrowingSupplier { |
1823 | + tapnXmlLoader.load(net) |
1824 | + }) |
1825 | + |
1826 | + Assertions.assertFalse( r.network().allTemplates().first().getTransitionByName("T1").isUrgent ) |
1827 | + |
1828 | + |
1829 | + } |
1830 | + } |
1831 | + |
1832 | + class InputArc { |
1833 | + @Test |
1834 | + fun `Parse Input Arc`() { |
1835 | + val net = xmlNet( |
1836 | + """ |
1837 | + <place displayName="true" id="P0" initialMarking="0" invariant="< inf" name="P0" nameOffsetX="0" nameOffsetY="0" positionX="60" positionY="60"/> |
1838 | + <transition angle="0" displayName="true" id="T0" infiniteServer="false" name="T0" nameOffsetX="0" nameOffsetY="0" positionX="240" positionY="60" priority="0" urgent="false"/> |
1839 | + <arc id="P0 to T0" inscription="[0,inf)" nameOffsetX="0" nameOffsetY="0" source="P0" target="T0" type="timed" weight="1"></arc> |
1840 | + """ |
1841 | + ).asInpurtStream() |
1842 | + |
1843 | + val tapnXmlLoader = TapnXmlLoader() |
1844 | + |
1845 | + val r = Assertions.assertDoesNotThrow(ThrowingSupplier { |
1846 | + tapnXmlLoader.load(net) |
1847 | + }) |
1848 | + } |
1849 | + } |
1850 | + |
1851 | + class OutputArc { |
1852 | + @Test |
1853 | + fun `Parse Output Arc`() { |
1854 | + val net = xmlNet( |
1855 | + """ |
1856 | + <place displayName="true" id="P0" initialMarking="0" invariant="< inf" name="P0" nameOffsetX="0" nameOffsetY="0" positionX="60" positionY="60"/> |
1857 | + <transition angle="0" displayName="true" id="T0" infiniteServer="false" name="T0" nameOffsetX="0" nameOffsetY="0" positionX="240" positionY="60" priority="0" urgent="false"/> |
1858 | + <arc id="T0 to P0" inscription="1" nameOffsetX="0" nameOffsetY="0" source="T0" target="P0" type="normal" weight="1"></arc> |
1859 | + """ |
1860 | + ).asInpurtStream() |
1861 | + |
1862 | + val tapnXmlLoader = TapnXmlLoader() |
1863 | + |
1864 | + val r = Assertions.assertDoesNotThrow(ThrowingSupplier { |
1865 | + tapnXmlLoader.load(net) |
1866 | + }) |
1867 | + } |
1868 | + } |
1869 | + |
1870 | + class InhibitorArc { |
1871 | + @Test |
1872 | + fun `Inhibitor Arc`() { |
1873 | + val net = xmlNet( |
1874 | + """ |
1875 | + <place displayName="true" id="P0" initialMarking="0" invariant="< inf" name="P0" nameOffsetX="0" nameOffsetY="0" positionX="60" positionY="60"/> |
1876 | + <transition angle="0" displayName="true" id="T0" infiniteServer="false" name="T0" nameOffsetX="0" nameOffsetY="0" positionX="240" positionY="60" priority="0" urgent="false"/> |
1877 | + <arc id="P0 to T0" inscription="[0,inf)" nameOffsetX="0" nameOffsetY="0" source="P0" target="T0" type="tapnInhibitor" weight="1"></arc> |
1878 | + """ |
1879 | + ).asInpurtStream() |
1880 | + |
1881 | + val tapnXmlLoader = TapnXmlLoader() |
1882 | + |
1883 | + val r = Assertions.assertDoesNotThrow(ThrowingSupplier { |
1884 | + tapnXmlLoader.load(net) |
1885 | + }) |
1886 | + } |
1887 | + } |
1888 | + |
1889 | + class TransportArc { |
1890 | + @Test |
1891 | + fun `Transport Arc`() { |
1892 | + val net = xmlNet( |
1893 | + """ |
1894 | + <place displayName="true" id="P0" initialMarking="0" invariant="< inf" name="P0" nameOffsetX="0" nameOffsetY="0" positionX="60" positionY="60"/> |
1895 | + <place displayName="true" id="P1" initialMarking="0" invariant="< inf" name="P1" nameOffsetX="0" nameOffsetY="0" positionX="60" positionY="60"/> |
1896 | + <transition angle="0" displayName="true" id="T0" infiniteServer="false" name="T0" nameOffsetX="0" nameOffsetY="0" positionX="240" positionY="60" priority="0" urgent="false"/> |
1897 | + <arc id="T0 to P1" inscription="[0,inf):1" nameOffsetX="0" nameOffsetY="0" source="T0" target="P1" type="transport" weight="1"></arc> |
1898 | + <arc id="P0 to T0" inscription="[0,inf):1" nameOffsetX="0" nameOffsetY="0" source="P0" target="T0" type="transport" weight="1"></arc> |
1899 | + """ |
1900 | + ).asInpurtStream() |
1901 | + |
1902 | + val tapnXmlLoader = TapnXmlLoader() |
1903 | + |
1904 | + val r = Assertions.assertDoesNotThrow(ThrowingSupplier { |
1905 | + tapnXmlLoader.load(net) |
1906 | + }) |
1907 | + } |
1908 | + |
1909 | + @Test @Disabled |
1910 | + fun `Transport missing parter, gives error`() { |
1911 | + val net = xmlNet( |
1912 | + """ |
1913 | + <place displayName="true" id="P0" initialMarking="0" invariant="< inf" name="P0" nameOffsetX="0" nameOffsetY="0" positionX="60" positionY="60"/> |
1914 | + <place displayName="true" id="P1" initialMarking="0" invariant="< inf" name="P1" nameOffsetX="0" nameOffsetY="0" positionX="60" positionY="60"/> |
1915 | + <transition angle="0" displayName="true" id="T0" infiniteServer="false" name="T0" nameOffsetX="0" nameOffsetY="0" positionX="240" positionY="60" priority="0" urgent="false"/> |
1916 | + <arc id="P0 to T0" inscription="[0,inf):1" nameOffsetX="0" nameOffsetY="0" source="P0" target="T0" type="transport" weight="1"></arc> |
1917 | + """ |
1918 | + ).asInpurtStream() |
1919 | + |
1920 | + val tapnXmlLoader = TapnXmlLoader() |
1921 | + |
1922 | + Assertions.assertThrows(java.lang.Exception::class.java) { |
1923 | + tapnXmlLoader.load(net) |
1924 | + } |
1925 | + } |
1926 | + } |
1927 | + |
1928 | + class ArcPathPoints { |
1929 | + @Test |
1930 | + fun `Parse Arc without arcpathpoints`() { |
1931 | + val net = xmlNet( |
1932 | + """ |
1933 | + <place displayName="true" id="P0" initialMarking="0" invariant="< inf" name="P0" nameOffsetX="0" nameOffsetY="0" positionX="60" positionY="60"/> |
1934 | + <transition angle="0" displayName="true" id="T0" infiniteServer="false" name="T0" nameOffsetX="0" nameOffsetY="0" positionX="240" positionY="60" priority="0" urgent="false"/> |
1935 | + <arc id="P0 to T0" inscription="[0,inf)" nameOffsetX="0" nameOffsetY="0" source="P0" target="T0" type="timed" weight="1"> |
1936 | + </arc> |
1937 | + """ |
1938 | + ).asInpurtStream() |
1939 | + |
1940 | + val tapnXmlLoader = TapnXmlLoader() |
1941 | + |
1942 | + val r = Assertions.assertDoesNotThrow(ThrowingSupplier { |
1943 | + tapnXmlLoader.load(net) |
1944 | + }) |
1945 | + } |
1946 | + |
1947 | + @Test @Disabled |
1948 | + fun `Parse Arc with only one arcpathpoint should fail`() { |
1949 | + val net = xmlNet( |
1950 | + """ |
1951 | + <place displayName="true" id="P0" initialMarking="0" invariant="< inf" name="P0" nameOffsetX="0" nameOffsetY="0" positionX="60" positionY="60"/> |
1952 | + <transition angle="0" displayName="true" id="T0" infiniteServer="false" name="T0" nameOffsetX="0" nameOffsetY="0" positionX="240" positionY="60" priority="0" urgent="false"/> |
1953 | + <arc id="P0 to T0" inscription="[0,inf)" nameOffsetX="0" nameOffsetY="0" source="P0" target="T0" type="timed" weight="1"> |
1954 | + <arcpath arcPointType="false" id="0" xCoord="87" yCoord="72"/> |
1955 | + </arc> |
1956 | + """ |
1957 | + ).asInpurtStream() |
1958 | + |
1959 | + val tapnXmlLoader = TapnXmlLoader() |
1960 | + |
1961 | + Assertions.assertThrows(java.lang.Exception::class.java) { |
1962 | + tapnXmlLoader.load(net) |
1963 | + } |
1964 | + } |
1965 | + } |
1966 | +} |
1967 | + |
1968 | + |
1969 | +fun String.asInpurtStream() : java.io.InputStream { |
1970 | + return java.io.StringBufferInputStream(this) |
1971 | +} |
1972 | + |
1973 | +fun xmlNet(s:String) : String { |
1974 | + return """ |
1975 | + <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
1976 | + <pnml xmlns="http://www.informatik.hu-berlin.de/top/pnml/ptNetb"> |
1977 | + <net active="true" id="IntroExample" type="P/T net"> |
1978 | + $s |
1979 | + </net> |
1980 | + </pnml> |
1981 | + """.trimIndent() |
1982 | +} |
1983 | \ No newline at end of file |
Seems to work as intended.
Tested open/save, import/export pnml and drawing of all things.