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