Merge lp:~yrke/tapaal/positionAsInt into lp:tapaal

Proposed by Kenneth Yrke Jørgensen
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
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.

To post a comment you must log in.
Revision history for this message
Peter Haahr Taankvist (ptaank) wrote :

Seems to work as intended.

Tested open/save, import/export pnml and drawing of all things.

review: Approve
Revision history for this message
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.

review: Needs Fixing
lp:~yrke/tapaal/positionAsInt updated
1383. By Kenneth Yrke Jørgensen

Fixed an issue where smartdraw placed arcpathpoint wrongly

Revision history for this message
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

Revision history for this message
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 setPointLocation(double x, double y) {
- double realX = Zoomer.getUnzoomedValue(x, myArcPath.getArc().getZoom());
- double realY = Zoomer.getUnzoomedValue(y, myArcPath.getArc().getZoom());
- getRealPoint().setLocation(realX, realY);
- point.setLocation(x, y);
- }

Revision history for this message
Jiri Srba (srba) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/dk/aau/cs/gui/TabContent.java'
--- src/dk/aau/cs/gui/TabContent.java 2020-04-30 12:51:14 +0000
+++ src/dk/aau/cs/gui/TabContent.java 2020-05-12 11:42:36 +0000
@@ -1444,12 +1444,12 @@
1444 if(obj instanceof Transition){1444 if(obj instanceof Transition){
1445 for(Arc arc : ((PlaceTransitionObject) obj).getPreset()){1445 for(Arc arc : ((PlaceTransitionObject) obj).getPreset()){
1446 for(ArcPathPoint point : arc.getArcPath().getArcPathPoints()){1446 for(ArcPathPoint point : arc.getArcPath().getArcPathPoints()){
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()));
1448 }1448 }
1449 }1449 }
1450 for(Arc arc : ((PlaceTransitionObject) obj).getPostset()){1450 for(Arc arc : ((PlaceTransitionObject) obj).getPostset()){
1451 for(ArcPathPoint point : arc.getArcPath().getArcPathPoints()){1451 for(ArcPathPoint point : arc.getArcPath().getArcPathPoints()){
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()));
1453 }1453 }
1454 }1454 }
1455 }1455 }
14561456
=== modified file 'src/dk/aau/cs/gui/TabTransformer.java'
--- src/dk/aau/cs/gui/TabTransformer.java 2020-04-19 13:48:30 +0000
+++ src/dk/aau/cs/gui/TabTransformer.java 2020-05-12 11:42:36 +0000
@@ -52,15 +52,10 @@
52 Place guiSource = guiModel.getPlaceByName(arc.getSource().getName());52 Place guiSource = guiModel.getPlaceByName(arc.getSource().getName());
53 Transition guiTarget = guiModel.getTransitionByName(arc.getTarget().getName());53 Transition guiTarget = guiModel.getTransitionByName(arc.getTarget().getName());
54 Arc newArc = new TimedInputArcComponent(new TimedOutputArcComponent(54 Arc newArc = new TimedInputArcComponent(new TimedOutputArcComponent(
55 0d,55 guiSource,
56 0d,
57 0d,
58 0d,
59 guiSource,
60 guiTarget,56 guiTarget,
61 arc.getWeight().value(),57 arc.getWeight().value(),
62 arc.getSource().getName() + "_to_" + arc.getTarget().getName(),58 arc.getSource().getName() + "_to_" + arc.getTarget().getName()
63 false
64 ));59 ));
6560
66 // Build ArcPath61 // Build ArcPath
@@ -110,15 +105,10 @@
110 Place guiTarget = guiModel.getPlaceByName(arc.getTarget().getName());105 Place guiTarget = guiModel.getPlaceByName(arc.getTarget().getName());
111 Transition guiSource = guiModel.getTransitionByName(arc.getSource().getName());106 Transition guiSource = guiModel.getTransitionByName(arc.getSource().getName());
112 TimedOutputArcComponent newArc = new TimedOutputArcComponent(107 TimedOutputArcComponent newArc = new TimedOutputArcComponent(
113 0d,108 guiSource,
114 0d,
115 0d,
116 0d,
117 guiSource,
118 guiTarget,109 guiTarget,
119 arc.getWeight().value(),110 arc.getWeight().value(),
120 arc.getSource().getName() + "_to_" + arc.getTarget().getName(),111 arc.getSource().getName() + "_to_" + arc.getTarget().getName()
121 false
122 );112 );
123113
124 // Build ArcPath114 // Build ArcPath
125115
=== modified file 'src/dk/aau/cs/gui/smartDraw/SmartDrawWorker.java'
--- src/dk/aau/cs/gui/smartDraw/SmartDrawWorker.java 2020-04-18 16:13:35 +0000
+++ src/dk/aau/cs/gui/smartDraw/SmartDrawWorker.java 2020-05-12 11:42:36 +0000
@@ -13,6 +13,7 @@
13import dk.aau.cs.gui.undo.MovePlaceTransitionObject;13import dk.aau.cs.gui.undo.MovePlaceTransitionObject;
14import dk.aau.cs.util.Require;14import dk.aau.cs.util.Require;
15import pipe.gui.CreateGui;15import pipe.gui.CreateGui;
16import pipe.gui.Zoomer;
16import pipe.gui.canvas.DrawingSurfaceImpl;17import pipe.gui.canvas.DrawingSurfaceImpl;
17import pipe.gui.graphicElements.*;18import pipe.gui.graphicElements.*;
18import pipe.gui.undo.DeleteArcPathPointEdit;19import pipe.gui.undo.DeleteArcPathPointEdit;
@@ -426,7 +427,13 @@
426 }427 }
427 }428 }
428 }429 }
429 430
431
432 //XXX: out bad handeling of zoom bleads over we need to adjust point relative to zoom
433 // midpoint is at current zoom level, but when creaing a new point its coords is at 100% zoom
434 private double unzoom(double pos) {
435 return Zoomer.getUnzoomedValue(pos,(int)CreateGui.getDrawingSurface().getZoom());
436 }
430 /*437 /*
431 * Add arcPathPoints for arcs where438 * Add arcPathPoints for arcs where
432 * A---> B --> A so they do not overlap439 * A---> B --> A so they do not overlap
@@ -435,16 +442,17 @@
435 private void offsetArcPointsFromMiddlepoint(Arc arcOne, Arc arcTwo, Place place, Transition transition) {442 private void offsetArcPointsFromMiddlepoint(Arc arcOne, Arc arcTwo, Place place, Transition transition) {
436 Point.Double pointForArcOne;443 Point.Double pointForArcOne;
437 Point.Double pointForArcTwo;444 Point.Double pointForArcTwo;
445
438 if(transition.getPositionX() == place.getPositionX()) {446 if(transition.getPositionX() == place.getPositionX()) {
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)));
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)));
441 } 449 }
442 else if(transition.getPositionY() == place.getPositionY()) {450 else if(transition.getPositionY() == place.getPositionY()) {
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));
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));
445 } else {453 } else {
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));
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));
448 }456 }
449 457
450 undoManager.addEdit(arcOne.getArcPath().insertPoint(pointForArcOne, false));458 undoManager.addEdit(arcOne.getArcPath().insertPoint(pointForArcOne, false));
451459
=== modified file 'src/dk/aau/cs/gui/undo/MovePlaceTransitionObject.java'
--- src/dk/aau/cs/gui/undo/MovePlaceTransitionObject.java 2020-03-29 12:40:43 +0000
+++ src/dk/aau/cs/gui/undo/MovePlaceTransitionObject.java 2020-05-12 11:42:36 +0000
@@ -7,19 +7,18 @@
77
8public class MovePlaceTransitionObject extends Command {8public class MovePlaceTransitionObject extends Command {
9 9
10 private double newY;10 private int newY;
11 private double newX;11 private int newX;
12 private PlaceTransitionObject objectToBeMoved;12 private PlaceTransitionObject objectToBeMoved;
13 private double oldY;13 private int oldY;
14 private double oldX;14 private int oldX;
15 private boolean doUpdate = false;15 private boolean doUpdate = false;
16 16
17 17
18 public MovePlaceTransitionObject(PlaceTransitionObject object, Point point) {18 public MovePlaceTransitionObject(PlaceTransitionObject object, Point point) {
19 objectToBeMoved = object;19 objectToBeMoved = object;
20 this.newX = point.getX();20 this.newX = point.x;
21 this.newY = point.getY();21 this.newY = point.y;
22
23 }22 }
2423
25 @Override24 @Override
2625
=== modified file 'src/dk/aau/cs/gui/undo/UpdateNameLabelOffsetCommand.java'
--- src/dk/aau/cs/gui/undo/UpdateNameLabelOffsetCommand.java 2020-04-18 13:49:06 +0000
+++ src/dk/aau/cs/gui/undo/UpdateNameLabelOffsetCommand.java 2020-05-12 11:42:36 +0000
@@ -3,10 +3,10 @@
3import pipe.gui.graphicElements.PetriNetObjectWithLabel;3import pipe.gui.graphicElements.PetriNetObjectWithLabel;
44
5public class UpdateNameLabelOffsetCommand extends Command {5public class UpdateNameLabelOffsetCommand extends Command {
6 double newXOffset, newYOffset, oldXOffset, oldYOffset;6 int newXOffset, newYOffset, oldXOffset, oldYOffset;
7 PetriNetObjectWithLabel obj;7 PetriNetObjectWithLabel obj;
8 8
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) {
10 this.obj = obj;10 this.obj = obj;
11 this.newXOffset = newXOffset;11 this.newXOffset = newXOffset;
12 this.newYOffset = newYOffset;12 this.newYOffset = newYOffset;
1313
=== modified file 'src/dk/aau/cs/io/PNMLWriter.java'
--- src/dk/aau/cs/io/PNMLWriter.java 2019-12-11 15:03:39 +0000
+++ src/dk/aau/cs/io/PNMLWriter.java 2020-05-12 11:42:36 +0000
@@ -162,8 +162,8 @@
162 name.appendChild(nameGraphics);162 name.appendChild(nameGraphics);
163 Element nameOffset = document.createElement("offset");163 Element nameOffset = document.createElement("offset");
164 nameGraphics.appendChild(nameOffset);164 nameGraphics.appendChild(nameOffset);
165 nameOffset.setAttribute("x", (inputPlace.getNameOffsetXObject() != null ? String.valueOf(Math.round(inputPlace.getNameOffsetXObject())) : ""));165 nameOffset.setAttribute("x", String.valueOf(Math.round(inputPlace.getNameOffsetX())));
166 nameOffset.setAttribute("y", (inputPlace.getNameOffsetYObject() != null ? String.valueOf(Math.round(inputPlace.getNameOffsetYObject())) : ""));166 nameOffset.setAttribute("y", String.valueOf(Math.round(inputPlace.getNameOffsetY())));
167 Element nameText = document.createElement("text");167 Element nameText = document.createElement("text");
168 name.appendChild(nameText);168 name.appendChild(nameText);
169 nameText.setTextContent(inputPlace.underlyingPlace().name());169 nameText.setTextContent(inputPlace.underlyingPlace().name());
@@ -172,8 +172,8 @@
172 placeElement.appendChild(graphics);172 placeElement.appendChild(graphics);
173 Element offset = document.createElement("position");173 Element offset = document.createElement("position");
174 graphics.appendChild(offset);174 graphics.appendChild(offset);
175 offset.setAttribute("x", (inputPlace.getPositionXObject() != null ? String.valueOf(Math.round(inputPlace.getPositionXObject())) : ""));175 offset.setAttribute("x", String.valueOf(Math.round(inputPlace.getPositionX())));
176 offset.setAttribute("y", (inputPlace.getPositionYObject() != null ? String.valueOf(Math.round(inputPlace.getPositionYObject())) : ""));176 offset.setAttribute("y", String.valueOf(Math.round(inputPlace.getPositionY())));
177 177
178 Element initialMarking = document.createElement("initialMarking"); //Name178 Element initialMarking = document.createElement("initialMarking"); //Name
179 placeElement.appendChild(name);179 placeElement.appendChild(name);
@@ -201,8 +201,8 @@
201 name.appendChild(nameGraphics);201 name.appendChild(nameGraphics);
202 Element nameOffset = document.createElement("offset");202 Element nameOffset = document.createElement("offset");
203 nameGraphics.appendChild(nameOffset);203 nameGraphics.appendChild(nameOffset);
204 nameOffset.setAttribute("x", (inputTransition.getNameOffsetXObject() != null ? String.valueOf(Math.round(inputTransition.getNameOffsetXObject())) : ""));204 nameOffset.setAttribute("x", String.valueOf(Math.round(inputTransition.getNameOffsetX())));
205 nameOffset.setAttribute("y", (inputTransition.getNameOffsetYObject() != null ? String.valueOf(Math.round(inputTransition.getNameOffsetYObject())) : ""));205 nameOffset.setAttribute("y", String.valueOf(Math.round(inputTransition.getNameOffsetY())));
206 Element nameText = document.createElement("text");206 Element nameText = document.createElement("text");
207 name.appendChild(nameText);207 name.appendChild(nameText);
208 nameText.setTextContent(inputTransition.underlyingTransition().name());208 nameText.setTextContent(inputTransition.underlyingTransition().name());
@@ -211,8 +211,8 @@
211 transitionElement.appendChild(graphics);211 transitionElement.appendChild(graphics);
212 Element offset = document.createElement("position");212 Element offset = document.createElement("position");
213 graphics.appendChild(offset);213 graphics.appendChild(offset);
214 offset.setAttribute("x", (inputTransition.getPositionXObject() != null ? String.valueOf(Math.round(inputTransition.getPositionXObject())) : ""));214 offset.setAttribute("x", String.valueOf(Math.round(inputTransition.getPositionX())));
215 offset.setAttribute("y", (inputTransition.getPositionYObject() != null ? String.valueOf(Math.round(inputTransition.getPositionYObject())) : ""));215 offset.setAttribute("y", String.valueOf(Math.round(inputTransition.getPositionY())));
216216
217 return transitionElement;217 return transitionElement;
218 }218 }
219219
=== modified file 'src/dk/aau/cs/io/PNMLoader.java'
--- src/dk/aau/cs/io/PNMLoader.java 2020-04-18 16:08:44 +0000
+++ src/dk/aau/cs/io/PNMLoader.java 2020-05-12 11:42:36 +0000
@@ -192,7 +192,7 @@
192 192
193 if(isNetDrawable()){193 if(isNetDrawable()){
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
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);
196 placeComponent.setUnderlyingPlace(place);196 placeComponent.setUnderlyingPlace(place);
197 template.guiModel().addPetriNetObject(placeComponent);197 template.guiModel().addPetriNetObject(placeComponent);
198 }198 }
@@ -236,7 +236,7 @@
236 if(isNetDrawable()){236 if(isNetDrawable()){
237 TimedTransitionComponent transitionComponent = 237 TimedTransitionComponent transitionComponent =
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
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,
240 true, false, 0, 0);240 true, false, 0, 0);
241 transitionComponent.setUnderlyingTransition(transition);241 transitionComponent.setUnderlyingTransition(transition);
242 template.guiModel().addPetriNetObject(transitionComponent);242 template.guiModel().addPetriNetObject(transitionComponent);
@@ -296,11 +296,11 @@
296 Arc tempArc;296 Arc tempArc;
297 297
298 if(type != null && type.equals("inhibitor")) {298 if(type != null && type.equals("inhibitor")) {
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);
300 } else if(sourcePlace != null && targetTransition != null) {300 } else if(sourcePlace != null && targetTransition != null) {
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);
302 } else if(sourceTransition != null && targetPlace != null) {302 } else if(sourceTransition != null && targetPlace != null) {
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);
304 } else {304 } else {
305 throw new FormatException("Arcs must be only between places and transitions");305 throw new FormatException("Arcs must be only between places and transitions");
306 }306 }
@@ -410,8 +410,8 @@
410 }410 }
411 411
412 private TimedInputArcComponent parseInputArc(String arcId, TimedPlace place, TimedTransition transition, PlaceTransitionObject source,412 private TimedInputArcComponent parseInputArc(String arcId, TimedPlace place, TimedTransition transition, PlaceTransitionObject source,
413 PlaceTransitionObject target, int weight, int _startx, int _starty, int _endx,413 PlaceTransitionObject target, int weight, int _endx,
414 int _endy, Template template) throws FormatException {414 int _endy, Template template) throws FormatException {
415415
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));
417 417
@@ -424,9 +424,7 @@
424 TimedInputArcComponent arc = null;424 TimedInputArcComponent arc = null;
425 425
426 if(isNetDrawable()){426 if(isNetDrawable()){
427 arc = new TimedInputArcComponent(new TimedOutputArcComponent(427 arc = new TimedInputArcComponent(new TimedOutputArcComponent(source, target, weight, arcId));
428 _startx, _starty, _endx, _endy, source, target, weight, arcId,
429 false));
430 arc.setUnderlyingArc(inputArc);428 arc.setUnderlyingArc(inputArc);
431429
432 template.guiModel().addPetriNetObject(arc);430 template.guiModel().addPetriNetObject(arc);
@@ -440,8 +438,8 @@
440 }438 }
441 439
442 private Arc parseOutputArc(String arcId, TimedTransition transition, TimedPlace place, PlaceTransitionObject source,440 private Arc parseOutputArc(String arcId, TimedTransition transition, TimedPlace place, PlaceTransitionObject source,
443 PlaceTransitionObject target, int weight, int _startx, int _starty, int _endx,441 PlaceTransitionObject target, int weight, int _endx,
444 int _endy, Template template) throws FormatException {442 int _endy, Template template) throws FormatException {
445 443
446 TimedOutputArc outputArc = new TimedOutputArc(transition, place, new IntWeight(weight));444 TimedOutputArc outputArc = new TimedOutputArc(transition, place, new IntWeight(weight));
447 445
@@ -454,8 +452,8 @@
454 TimedOutputArcComponent arc = null;452 TimedOutputArcComponent arc = null;
455 453
456 if(isNetDrawable()){454 if(isNetDrawable()){
457 arc = new TimedOutputArcComponent(_startx, _starty, _endx, _endy, 455 arc = new TimedOutputArcComponent(
458 source, target, weight, arcId, false);456 source, target, weight, arcId);
459 arc.setUnderlyingArc(outputArc);457 arc.setUnderlyingArc(outputArc);
460458
461 template.guiModel().addPetriNetObject(arc);459 template.guiModel().addPetriNetObject(arc);
@@ -467,11 +465,11 @@
467 }465 }
468 466
469 private Arc parseAndAddTimedInhibitorArc(String arcId, TimedPlace place, TimedTransition transition, PlaceTransitionObject source,467 private Arc parseAndAddTimedInhibitorArc(String arcId, TimedPlace place, TimedTransition transition, PlaceTransitionObject source,
470 PlaceTransitionObject target, int weight, int _startx, int _starty, int _endx,468 PlaceTransitionObject target, int weight, int _endx,
471 int _endy, Template template) {469 int _endy, Template template) {
472 TimedInhibitorArcComponent tempArc = new TimedInhibitorArcComponent(470 TimedInhibitorArcComponent tempArc = new TimedInhibitorArcComponent(
473 new TimedInputArcComponent(471 new TimedInputArcComponent(
474 new TimedOutputArcComponent(_startx, _starty, _endx, _endy, source, target, weight, arcId, false)472 new TimedOutputArcComponent(source, target, weight, arcId)
475 ),473 ),
476 (""));474 (""));
477 475
478476
=== modified file 'src/dk/aau/cs/io/TapnLegacyXmlLoader.java'
--- src/dk/aau/cs/io/TapnLegacyXmlLoader.java 2020-04-18 16:13:35 +0000
+++ src/dk/aau/cs/io/TapnLegacyXmlLoader.java 2020-05-12 11:42:36 +0000
@@ -183,13 +183,13 @@
183 }183 }
184184
185 private Arc parseAndAddTimedOutputArc(String idInput, boolean taggedArc,185 private Arc parseAndAddTimedOutputArc(String idInput, boolean taggedArc,
186 String inscriptionTempStorage, PlaceTransitionObject sourceIn,186 String inscriptionTempStorage, PlaceTransitionObject sourceIn,
187 PlaceTransitionObject targetIn, double _startx, double _starty,187 PlaceTransitionObject targetIn,
188 double _endx, double _endy) throws FormatException {188 int _endx, int _endy) throws FormatException {
189 189
190 Arc tempArc;190 Arc tempArc;
191 tempArc = new TimedOutputArcComponent(_startx, _starty, _endx, _endy, 191 tempArc = new TimedOutputArcComponent(
192 sourceIn, targetIn, Integer.valueOf(inscriptionTempStorage), idInput, taggedArc);192 sourceIn, targetIn, Integer.valueOf(inscriptionTempStorage), idInput);
193193
194 TimedPlace place = tapn.getPlaceByName(targetIn.getName());194 TimedPlace place = tapn.getPlaceByName(targetIn.getName());
195 TimedTransition transition = tapn.getTransitionByName(sourceIn.getName());195 TimedTransition transition = tapn.getTransitionByName(sourceIn.getName());
@@ -208,9 +208,9 @@
208 }208 }
209209
210 private Arc parseAndAddTransportArc(String idInput, boolean taggedArc,210 private Arc parseAndAddTransportArc(String idInput, boolean taggedArc,
211 String inscriptionTempStorage, PlaceTransitionObject sourceIn,211 String inscriptionTempStorage, PlaceTransitionObject sourceIn,
212 PlaceTransitionObject targetIn, double _startx, double _starty,212 PlaceTransitionObject targetIn,
213 double _endx, double _endy) {213 int _endx, int _endy) {
214 214
215 Arc tempArc;215 Arc tempArc;
216 String[] inscriptionSplit = {};216 String[] inscriptionSplit = {};
@@ -221,9 +221,7 @@
221 if (sourceIn instanceof Place) {221 if (sourceIn instanceof Place) {
222 isInPreSet = true;222 isInPreSet = true;
223 }223 }
224 tempArc = new TimedTransportArcComponent(new TimedInputArcComponent(224 tempArc = new TimedTransportArcComponent(new TimedInputArcComponent(new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput)), Integer.parseInt(inscriptionSplit[1]), isInPreSet);
225 new TimedOutputArcComponent(_startx, _starty, _endx, _endy, sourceIn, targetIn, 1, idInput, taggedArc),
226 inscriptionSplit[0]), Integer.parseInt(inscriptionSplit[1]), isInPreSet);
227225
228226
229 if (isInPreSet) {227 if (isInPreSet) {
@@ -282,14 +280,11 @@
282 }280 }
283281
284 private Arc parseAndAddTimedInputArc(String idInput, boolean taggedArc,282 private Arc parseAndAddTimedInputArc(String idInput, boolean taggedArc,
285 String inscriptionTempStorage, PlaceTransitionObject sourceIn,283 String inscriptionTempStorage, PlaceTransitionObject sourceIn,
286 PlaceTransitionObject targetIn, double _startx, double _starty,284 PlaceTransitionObject targetIn,
287 double _endx, double _endy) throws FormatException {285 int _endx, int _endy) throws FormatException {
288 Arc tempArc;286 Arc tempArc;
289 tempArc = new TimedInputArcComponent(new TimedOutputArcComponent(287 tempArc = new TimedInputArcComponent(new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput));
290 _startx, _starty, _endx, _endy, sourceIn, targetIn, 1, idInput,
291 taggedArc),
292 (inscriptionTempStorage != null ? inscriptionTempStorage : ""));
293288
294 TimedPlace place = tapn.getPlaceByName(sourceIn.getName());289 TimedPlace place = tapn.getPlaceByName(sourceIn.getName());
295 TimedTransition transition = tapn.getTransitionByName(targetIn.getName());290 TimedTransition transition = tapn.getTransitionByName(targetIn.getName());
@@ -309,13 +304,13 @@
309 }304 }
310305
311 private Arc parseAndAddTimedInhibitorArc(String idInput, boolean taggedArc,306 private Arc parseAndAddTimedInhibitorArc(String idInput, boolean taggedArc,
312 String inscriptionTempStorage, PlaceTransitionObject sourceIn,307 String inscriptionTempStorage, PlaceTransitionObject sourceIn,
313 PlaceTransitionObject targetIn, double _startx, double _starty,308 PlaceTransitionObject targetIn,
314 double _endx, double _endy) {309 int _endx, int _endy) {
315 Arc tempArc;310 Arc tempArc;
316 tempArc = new TimedInhibitorArcComponent(311 tempArc = new TimedInhibitorArcComponent(
317 new TimedInputArcComponent(312 new TimedInputArcComponent(
318 new TimedOutputArcComponent(_startx, _starty, _endx, _endy, sourceIn, targetIn, 1, idInput, taggedArc)313 new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput)
319 ),314 ),
320 (inscriptionTempStorage != null ? inscriptionTempStorage : ""));315 (inscriptionTempStorage != null ? inscriptionTempStorage : ""));
321 TimedPlace place = tapn.getPlaceByName(sourceIn.getName());316 TimedPlace place = tapn.getPlaceByName(sourceIn.getName());
@@ -508,12 +503,12 @@
508 }503 }
509504
510 private void parseAndAddTransitionAsOldFormat(Element element) throws FormatException {505 private void parseAndAddTransitionAsOldFormat(Element element) throws FormatException {
511 double positionXInput = getPositionAttribute(element, "x");506 int positionXInput = (int)getPositionAttribute(element, "x");
512 double positionYInput = getPositionAttribute(element, "y");507 int positionYInput = (int)getPositionAttribute(element, "y");
513 String idInput = element.getAttribute("id");508 String idInput = element.getAttribute("id");
514 String nameInput = getChildNodesContentOfValueChildNodeAsString(element, "name");509 String nameInput = getChildNodesContentOfValueChildNodeAsString(element, "name");
515 double nameOffsetXInput = getNameOffsetAttribute(element, "x");510 int nameOffsetXInput = (int)getNameOffsetAttribute(element, "x");
516 double nameOffsetYInput = getNameOffsetAttribute(element, "y");511 int nameOffsetYInput = (int)getNameOffsetAttribute(element, "y");
517 boolean timedTransition = getContentOfFirstSpecificChildNodesValueChildNodeAsBoolean(element, "timed");512 boolean timedTransition = getContentOfFirstSpecificChildNodesValueChildNodeAsBoolean(element, "timed");
518 boolean infiniteServer = getContentOfFirstSpecificChildNodesValueChildNodeAsBoolean(element, "infiniteServer");513 boolean infiniteServer = getContentOfFirstSpecificChildNodesValueChildNodeAsBoolean(element, "infiniteServer");
519 int angle = getContentOfFirstSpecificChildNodesValueChildNodeAsInt(element,"orientation");514 int angle = getContentOfFirstSpecificChildNodesValueChildNodeAsInt(element,"orientation");
@@ -541,12 +536,12 @@
541 }536 }
542537
543 private void parseAndAddPlaceAsOldFormat(Element element, TimedMarking marking) throws FormatException {538 private void parseAndAddPlaceAsOldFormat(Element element, TimedMarking marking) throws FormatException {
544 double positionXInput = getPositionAttribute(element, "x");539 int positionXInput = (int)getPositionAttribute(element, "x");
545 double positionYInput = getPositionAttribute(element, "y");540 int positionYInput = (int)getPositionAttribute(element, "y");
546 String idInput = element.getAttribute("id");541 String idInput = element.getAttribute("id");
547 String nameInput = getChildNodesContentOfValueChildNodeAsString(element, "name");542 String nameInput = getChildNodesContentOfValueChildNodeAsString(element, "name");
548 double nameOffsetXInput = getNameOffsetAttribute(element, "x");543 int nameOffsetXInput = (int)getNameOffsetAttribute(element, "x");
549 double nameOffsetYInput = getNameOffsetAttribute(element, "y");544 int nameOffsetYInput = (int)getNameOffsetAttribute(element, "y");
550 int initialMarkingInput = getContentOfFirstSpecificChildNodesValueChildNodeAsInt(element, "initialMarking");545 int initialMarkingInput = getContentOfFirstSpecificChildNodesValueChildNodeAsInt(element, "initialMarking");
551 String invariant = getChildNodesContentOfValueChildNodeAsString(element, "invariant");546 String invariant = getChildNodesContentOfValueChildNodeAsString(element, "invariant");
552 547
@@ -576,8 +571,7 @@
576// markingOffsetYInput, capacityInput);571// markingOffsetYInput, capacityInput);
577//572//
578// } else {573// } else {
579 place = new TimedPlaceComponent(positionXInput, positionYInput,574 place = new TimedPlaceComponent(positionXInput, positionYInput, idInput, nameOffsetXInput, nameOffsetYInput);
580 idInput, nameOffsetXInput, nameOffsetYInput);
581 575
582 LocalTimedPlace p = new LocalTimedPlace(nameInput, TimeInvariant.parse(invariant, constants));576 LocalTimedPlace p = new LocalTimedPlace(nameInput, TimeInvariant.parse(invariant, constants));
583 tapn.add(p);577 tapn.add(p);
@@ -597,13 +591,15 @@
597 String targetInput = inputArcElement.getAttribute("target");591 String targetInput = inputArcElement.getAttribute("target");
598 boolean taggedArc = getContentOfFirstSpecificChildNodesValueChildNodeAsBoolean(inputArcElement, "tagged");592 boolean taggedArc = getContentOfFirstSpecificChildNodesValueChildNodeAsBoolean(inputArcElement, "tagged");
599 String inscriptionTempStorage = getChildNodesContentOfValueChildNodeAsString(inputArcElement, "inscription");593 String inscriptionTempStorage = getChildNodesContentOfValueChildNodeAsString(inputArcElement, "inscription");
600 double nameOffsetXInput;594 int nameOffsetXInput;
601 double nameOffsetYInput;595 int nameOffsetYInput;
602 596
603 //This check is done, as arcs in nets saved before this change do not have a nameOffset597 //This check is done, as arcs in nets saved before this change do not have a nameOffset
598
604 if(!inputArcElement.getAttribute("nameOffsetX").equals("") && !inputArcElement.getAttribute("nameOffsetY").equals("")) {599 if(!inputArcElement.getAttribute("nameOffsetX").equals("") && !inputArcElement.getAttribute("nameOffsetY").equals("")) {
605 nameOffsetXInput = Double.parseDouble(inputArcElement.getAttribute("nameOffsetX"));600 nameOffsetXInput = (int) Double.parseDouble(inputArcElement.getAttribute("nameOffsetX"));
606 nameOffsetYInput = Double.parseDouble(inputArcElement.getAttribute("nameOffsetY"));601 nameOffsetYInput = (int) Double.parseDouble(inputArcElement.getAttribute("nameOffsetY"));
602
607 } else {603 } else {
608 nameOffsetXInput = 0;604 nameOffsetXInput = 0;
609 nameOffsetYInput = 0;605 nameOffsetYInput = 0;
@@ -630,24 +626,24 @@
630 if (type.equals("tapnInhibitor")) {626 if (type.equals("tapnInhibitor")) {
631627
632 tempArc = parseAndAddTimedInhibitorArc(idInput, taggedArc,628 tempArc = parseAndAddTimedInhibitorArc(idInput, taggedArc,
633 inscriptionTempStorage, sourceIn, targetIn, aStartx,629 inscriptionTempStorage, sourceIn, targetIn,
634 aStarty, aEndx, aEndy);630 aEndx, aEndy);
635631
636 } else {632 } else {
637 if (type.equals("timed")) {633 if (type.equals("timed")) {
638 tempArc = parseAndAddTimedInputArc(idInput, taggedArc,634 tempArc = parseAndAddTimedInputArc(idInput, taggedArc,
639 inscriptionTempStorage, sourceIn, targetIn, aStartx,635 inscriptionTempStorage, sourceIn, targetIn,
640 aStarty, aEndx, aEndy);636 aEndx, aEndy);
641637
642 } else if (type.equals("transport")) {638 } else if (type.equals("transport")) {
643 tempArc = parseAndAddTransportArc(idInput, taggedArc,639 tempArc = parseAndAddTransportArc(idInput, taggedArc,
644 inscriptionTempStorage, sourceIn, targetIn, aStartx,640 inscriptionTempStorage, sourceIn, targetIn,
645 aStarty, aEndx, aEndy);641 aEndx, aEndy);
646642
647 } else {643 } else {
648 tempArc = parseAndAddTimedOutputArc(idInput, taggedArc,644 tempArc = parseAndAddTimedOutputArc(idInput, taggedArc,
649 inscriptionTempStorage, sourceIn, targetIn, aStartx,645 inscriptionTempStorage, sourceIn, targetIn,
650 aStarty, aEndx, aEndy);646 aEndx, aEndy);
651 }647 }
652648
653 }649 }
654650
=== modified file 'src/dk/aau/cs/io/TapnXmlLoader.java'
--- src/dk/aau/cs/io/TapnXmlLoader.java 2020-04-18 16:13:35 +0000
+++ src/dk/aau/cs/io/TapnXmlLoader.java 2020-05-12 11:42:36 +0000
@@ -338,16 +338,16 @@
338 }338 }
339339
340 private TimedTransitionComponent parseTransition(Element transition, TimedArcPetriNetNetwork network, TimedArcPetriNet tapn) {340 private TimedTransitionComponent parseTransition(Element transition, TimedArcPetriNetNetwork network, TimedArcPetriNet tapn) {
341 double positionXInput = Double.parseDouble(transition.getAttribute("positionX"));341 int positionXInput = (int)Double.parseDouble(transition.getAttribute("positionX"));
342 double positionYInput = Double.parseDouble(transition.getAttribute("positionY"));342 int positionYInput = (int)Double.parseDouble(transition.getAttribute("positionY"));
343 String idInput = transition.getAttribute("id");343 String idInput = transition.getAttribute("id");
344 String nameInput = transition.getAttribute("name");344 String nameInput = transition.getAttribute("name");
345 boolean isUrgent = Boolean.parseBoolean(transition.getAttribute("urgent"));345 boolean isUrgent = Boolean.parseBoolean(transition.getAttribute("urgent"));
346 346
347 idResolver.add(tapn.name(), idInput, nameInput);347 idResolver.add(tapn.name(), idInput, nameInput);
348 348
349 double nameOffsetXInput = Double.parseDouble(transition.getAttribute("nameOffsetX"));349 int nameOffsetXInput = (int)Double.parseDouble(transition.getAttribute("nameOffsetX"));
350 double nameOffsetYInput = Double.parseDouble(transition.getAttribute("nameOffsetY"));350 int nameOffsetYInput = (int)Double.parseDouble(transition.getAttribute("nameOffsetY"));
351 boolean infiniteServer = transition.getAttribute("infiniteServer").equals("true");351 boolean infiniteServer = transition.getAttribute("infiniteServer").equals("true");
352 int angle = Integer.parseInt(transition.getAttribute("angle"));352 int angle = Integer.parseInt(transition.getAttribute("angle"));
353 int priority = Integer.parseInt(transition.getAttribute("priority"));353 int priority = Integer.parseInt(transition.getAttribute("priority"));
@@ -386,12 +386,12 @@
386 }386 }
387387
388 private TimedPlaceComponent parsePlace(Element place, TimedArcPetriNetNetwork network, TimedArcPetriNet tapn, ConstantStore constants) {388 private TimedPlaceComponent parsePlace(Element place, TimedArcPetriNetNetwork network, TimedArcPetriNet tapn, ConstantStore constants) {
389 double positionXInput = Double.parseDouble(place.getAttribute("positionX"));389 int positionXInput = (int)Double.parseDouble(place.getAttribute("positionX"));
390 double positionYInput = Double.parseDouble(place.getAttribute("positionY"));390 int positionYInput = (int)Double.parseDouble(place.getAttribute("positionY"));
391 String idInput = place.getAttribute("id");391 String idInput = place.getAttribute("id");
392 String nameInput = place.getAttribute("name");392 String nameInput = place.getAttribute("name");
393 double nameOffsetXInput = Double.parseDouble(place.getAttribute("nameOffsetX"));393 int nameOffsetXInput = (int)Double.parseDouble(place.getAttribute("nameOffsetX"));
394 double nameOffsetYInput = Double.parseDouble(place.getAttribute("nameOffsetY"));394 int nameOffsetYInput = (int)Double.parseDouble(place.getAttribute("nameOffsetY"));
395 int initialMarkingInput = Integer.parseInt(place.getAttribute("initialMarking"));395 int initialMarkingInput = Integer.parseInt(place.getAttribute("initialMarking"));
396 String invariant = place.getAttribute("invariant");396 String invariant = place.getAttribute("invariant");
397 boolean displayName = place.getAttribute("displayName").equals("false") ? false : true;397 boolean displayName = place.getAttribute("displayName").equals("false") ? false : true;
@@ -444,13 +444,13 @@
444 boolean taggedArc = arc.getAttribute("tagged").equals("true") ? true : false;444 boolean taggedArc = arc.getAttribute("tagged").equals("true") ? true : false;
445 String inscriptionTempStorage = arc.getAttribute("inscription");445 String inscriptionTempStorage = arc.getAttribute("inscription");
446 String type = arc.getAttribute("type");446 String type = arc.getAttribute("type");
447 double nameOffsetXInput;447 int nameOffsetXInput;
448 double nameOffsetYInput;448 int nameOffsetYInput;
449 449
450 //This check is done, as arcs in nets saved before this change do not have a nameOffset450 //This check is done, as arcs in nets saved before this change do not have a nameOffset
451 if(!arc.getAttribute("nameOffsetX").equals("") && !arc.getAttribute("nameOffsetY").equals("")) {451 if(!arc.getAttribute("nameOffsetX").equals("") && !arc.getAttribute("nameOffsetY").equals("")) {
452 nameOffsetXInput = Double.parseDouble(arc.getAttribute("nameOffsetX"));452 nameOffsetXInput = (int) Double.parseDouble(arc.getAttribute("nameOffsetX"));
453 nameOffsetYInput = Double.parseDouble(arc.getAttribute("nameOffsetY"));453 nameOffsetYInput = (int) Double.parseDouble(arc.getAttribute("nameOffsetY"));
454 } else {454 } else {
455 nameOffsetXInput = 0;455 nameOffsetXInput = 0;
456 nameOffsetYInput = 0;456 nameOffsetYInput = 0;
@@ -480,24 +480,24 @@
480 if (type.equals("tapnInhibitor")) {480 if (type.equals("tapnInhibitor")) {
481481
482 tempArc = parseAndAddTimedInhibitorArc(idInput, taggedArc,482 tempArc = parseAndAddTimedInhibitorArc(idInput, taggedArc,
483 inscriptionTempStorage, sourceIn, targetIn, _startx,483 inscriptionTempStorage, sourceIn, targetIn,
484 _starty, _endx, _endy,template, constants, weight);484 _endx, _endy,template, constants, weight);
485485
486 } else {486 } else {
487 if (type.equals("timed")) {487 if (type.equals("timed")) {
488 tempArc = parseAndAddTimedInputArc(idInput, taggedArc,488 tempArc = parseAndAddTimedInputArc(idInput, taggedArc,
489 inscriptionTempStorage, sourceIn, targetIn, _startx,489 inscriptionTempStorage, sourceIn, targetIn,
490 _starty, _endx, _endy, template, constants, weight);490 _endx, _endy, template, constants, weight);
491491
492 } else if (type.equals("transport")) {492 } else if (type.equals("transport")) {
493 tempArc = parseAndAddTransportArc(idInput, taggedArc,493 tempArc = parseAndAddTransportArc(idInput, taggedArc,
494 inscriptionTempStorage, sourceIn, targetIn, _startx,494 inscriptionTempStorage, sourceIn, targetIn,
495 _starty, _endx, _endy, template, constants, weight);495 _endx, _endy, template, constants, weight);
496496
497 } else {497 } else {
498 tempArc = parseAndAddTimedOutputArc(idInput, taggedArc,498 tempArc = parseAndAddTimedOutputArc(idInput, taggedArc,
499 inscriptionTempStorage, sourceIn, targetIn, _startx,499 inscriptionTempStorage, sourceIn, targetIn,
500 _starty, _endx, _endy, template, weight);500 _endx, _endy, template, weight);
501 }501 }
502502
503 }503 }
@@ -508,12 +508,12 @@
508 }508 }
509509
510 private TimedOutputArcComponent parseAndAddTimedOutputArc(String idInput, boolean taggedArc,510 private TimedOutputArcComponent parseAndAddTimedOutputArc(String idInput, boolean taggedArc,
511 String inscriptionTempStorage, PlaceTransitionObject sourceIn,511 String inscriptionTempStorage, PlaceTransitionObject sourceIn,
512 PlaceTransitionObject targetIn, double _startx, double _starty,512 PlaceTransitionObject targetIn,
513 double _endx, double _endy, Template template, Weight weight) throws FormatException {513 int _endx, int _endy, Template template, Weight weight) throws FormatException {
514514
515 TimedOutputArcComponent tempArc = new TimedOutputArcComponent(_startx, _starty, _endx, _endy, 515 TimedOutputArcComponent tempArc = new TimedOutputArcComponent(
516 sourceIn, targetIn, (!inscriptionTempStorage.equals("") ? Integer.valueOf(inscriptionTempStorage) : 1), idInput, taggedArc);516 sourceIn, targetIn, (!inscriptionTempStorage.equals("") ? Integer.valueOf(inscriptionTempStorage) : 1), idInput);
517517
518 TimedPlace place = template.model().getPlaceByName(targetIn.getName());518 TimedPlace place = template.model().getPlaceByName(targetIn.getName());
519 TimedTransition transition = template.model().getTransitionByName(sourceIn.getName());519 TimedTransition transition = template.model().getTransitionByName(sourceIn.getName());
@@ -532,9 +532,9 @@
532 }532 }
533533
534 private TimedTransportArcComponent parseAndAddTransportArc(String idInput, boolean taggedArc,534 private TimedTransportArcComponent parseAndAddTransportArc(String idInput, boolean taggedArc,
535 String inscriptionTempStorage, PlaceTransitionObject sourceIn,535 String inscriptionTempStorage, PlaceTransitionObject sourceIn,
536 PlaceTransitionObject targetIn, double _startx, double _starty,536 PlaceTransitionObject targetIn,
537 double _endx, double _endy, Template template, ConstantStore constants, Weight weight) {537 int _endx, int _endy, Template template, ConstantStore constants, Weight weight) {
538538
539 539
540 String[] inscriptionSplit = {};540 String[] inscriptionSplit = {};
@@ -545,9 +545,7 @@
545 if (sourceIn instanceof Place) {545 if (sourceIn instanceof Place) {
546 isInPreSet = true;546 isInPreSet = true;
547 }547 }
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);
549 new TimedOutputArcComponent(_startx, _starty, _endx, _endy, sourceIn, targetIn, 1, idInput, taggedArc),
550 inscriptionSplit[0]), Integer.parseInt(inscriptionSplit[1]), isInPreSet);
551549
552550
553 if (isInPreSet) {551 if (isInPreSet) {
@@ -605,14 +603,11 @@
605 }603 }
606604
607 private Arc parseAndAddTimedInputArc(String idInput, boolean taggedArc,605 private Arc parseAndAddTimedInputArc(String idInput, boolean taggedArc,
608 String inscriptionTempStorage, PlaceTransitionObject sourceIn,606 String inscriptionTempStorage, PlaceTransitionObject sourceIn,
609 PlaceTransitionObject targetIn, double _startx, double _starty,607 PlaceTransitionObject targetIn,
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 {
611 Arc tempArc;609 Arc tempArc;
612 tempArc = new TimedInputArcComponent(new TimedOutputArcComponent(610 tempArc = new TimedInputArcComponent(new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput));
613 _startx, _starty, _endx, _endy, sourceIn, targetIn, 1, idInput,
614 taggedArc),
615 (inscriptionTempStorage != null ? inscriptionTempStorage : ""));
616611
617 TimedPlace place = template.model().getPlaceByName(sourceIn.getName());612 TimedPlace place = template.model().getPlaceByName(sourceIn.getName());
618 TimedTransition transition = template.model().getTransitionByName(targetIn.getName());613 TimedTransition transition = template.model().getTransitionByName(targetIn.getName());
@@ -632,12 +627,12 @@
632 }627 }
633628
634 private Arc parseAndAddTimedInhibitorArc(String idInput, boolean taggedArc,629 private Arc parseAndAddTimedInhibitorArc(String idInput, boolean taggedArc,
635 String inscriptionTempStorage, PlaceTransitionObject sourceIn,630 String inscriptionTempStorage, PlaceTransitionObject sourceIn,
636 PlaceTransitionObject targetIn, double _startx, double _starty,631 PlaceTransitionObject targetIn,
637 double _endx, double _endy, Template template, ConstantStore constants, Weight weight) {632 int _endx, int _endy, Template template, ConstantStore constants, Weight weight) {
638 TimedInhibitorArcComponent tempArc = new TimedInhibitorArcComponent(633 TimedInhibitorArcComponent tempArc = new TimedInhibitorArcComponent(
639 new TimedInputArcComponent(634 new TimedInputArcComponent(
640 new TimedOutputArcComponent(_startx, _starty, _endx, _endy, sourceIn, targetIn, 1, idInput, taggedArc)635 new TimedOutputArcComponent(sourceIn, targetIn, 1, idInput)
641 ),636 ),
642 (inscriptionTempStorage != null ? inscriptionTempStorage : ""));637 (inscriptionTempStorage != null ? inscriptionTempStorage : ""));
643 TimedPlace place = template.model().getPlaceByName(sourceIn.getName());638 TimedPlace place = template.model().getPlaceByName(sourceIn.getName());
644639
=== modified file 'src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java'
--- src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java 2020-04-18 15:50:17 +0000
+++ src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java 2020-05-12 11:42:36 +0000
@@ -368,13 +368,13 @@
368 368
369 Element placeElement = document.createElement("place");369 Element placeElement = document.createElement("place");
370370
371 placeElement.setAttribute("positionX", (inputPlace.getPositionXObject() != null ? String.valueOf(inputPlace.getPositionXObject()) : ""));371 placeElement.setAttribute("positionX", String.valueOf(inputPlace.getPositionX()));
372 placeElement.setAttribute("positionY", (inputPlace.getPositionYObject() != null ? String.valueOf(inputPlace.getPositionYObject()) : ""));372 placeElement.setAttribute("positionY", String.valueOf(inputPlace.getPositionY()));
373 placeElement.setAttribute("name", inputPlace.underlyingPlace().name());373 placeElement.setAttribute("name", inputPlace.underlyingPlace().name());
374 placeElement.setAttribute("displayName", (inputPlace.getAttributesVisible() ? "true" : "false"));374 placeElement.setAttribute("displayName", (inputPlace.getAttributesVisible() ? "true" : "false"));
375 placeElement.setAttribute("id", (inputPlace.getId() != null ? inputPlace.getId() : "error"));375 placeElement.setAttribute("id", (inputPlace.getId() != null ? inputPlace.getId() : "error"));
376 placeElement.setAttribute("nameOffsetX", (inputPlace.getNameOffsetXObject() != null ? String.valueOf(inputPlace.getNameOffsetXObject()) : ""));376 placeElement.setAttribute("nameOffsetX", String.valueOf(inputPlace.getNameOffsetX()));
377 placeElement.setAttribute("nameOffsetY", (inputPlace.getNameOffsetYObject() != null ? String.valueOf(inputPlace.getNameOffsetYObject()) : ""));377 placeElement.setAttribute("nameOffsetY", String.valueOf(inputPlace.getNameOffsetY()));
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"));
379 placeElement.setAttribute("invariant", inputPlace.underlyingPlace().invariant().toString());379 placeElement.setAttribute("invariant", inputPlace.underlyingPlace().invariant().toString());
380380
@@ -406,10 +406,10 @@
406 406
407 Element transitionElement = document.createElement("transition");407 Element transitionElement = document.createElement("transition");
408408
409 transitionElement.setAttribute("positionX", (inputTransition.getPositionXObject() != null ? String.valueOf(inputTransition.getPositionXObject()) : ""));409 transitionElement.setAttribute("positionX", String.valueOf(inputTransition.getPositionX()));
410 transitionElement.setAttribute("positionY", (inputTransition.getPositionYObject() != null ? String.valueOf(inputTransition.getPositionYObject()) : ""));410 transitionElement.setAttribute("positionY", String.valueOf(inputTransition.getPositionY()));
411 transitionElement.setAttribute("nameOffsetX", (inputTransition.getNameOffsetXObject() != null ? String.valueOf(inputTransition.getNameOffsetXObject()) : ""));411 transitionElement.setAttribute("nameOffsetX", String.valueOf(inputTransition.getNameOffsetX()));
412 transitionElement.setAttribute("nameOffsetY", (inputTransition.getNameOffsetYObject() != null ? String.valueOf(inputTransition.getNameOffsetYObject()) : ""));412 transitionElement.setAttribute("nameOffsetY", String.valueOf(inputTransition.getNameOffsetY()));
413 transitionElement.setAttribute("name", inputTransition.underlyingTransition().name());413 transitionElement.setAttribute("name", inputTransition.underlyingTransition().name());
414 transitionElement.setAttribute("displayName", (inputTransition.getAttributesVisible() ? "true" : "false"));414 transitionElement.setAttribute("displayName", (inputTransition.getAttributesVisible() ? "true" : "false"));
415 transitionElement.setAttribute("id", (inputTransition.getId() != null ? inputTransition.getId() : "error"));415 transitionElement.setAttribute("id", (inputTransition.getId() != null ? inputTransition.getId() : "error"));
@@ -431,8 +431,8 @@
431 arcElement.setAttribute("id", (inputArc.getId() != null ? inputArc.getId() : "error"));431 arcElement.setAttribute("id", (inputArc.getId() != null ? inputArc.getId() : "error"));
432 arcElement.setAttribute("source", (inputArc.getSource().getId() != null ? inputArc.getSource().getId() : ""));432 arcElement.setAttribute("source", (inputArc.getSource().getId() != null ? inputArc.getSource().getId() : ""));
433 arcElement.setAttribute("target", (inputArc.getTarget().getId() != null ? inputArc.getTarget().getId() : ""));433 arcElement.setAttribute("target", (inputArc.getTarget().getId() != null ? inputArc.getTarget().getId() : ""));
434 arcElement.setAttribute("nameOffsetX", (inputArc.getNameOffsetXObject() != null ? String.valueOf(inputArc.getNameOffsetXObject()) : ""));434 arcElement.setAttribute("nameOffsetX", String.valueOf(inputArc.getNameOffsetX()));
435 arcElement.setAttribute("nameOffsetY", (inputArc.getNameOffsetYObject() != null ? String.valueOf(inputArc.getNameOffsetYObject()) : ""));435 arcElement.setAttribute("nameOffsetY", String.valueOf(inputArc.getNameOffsetY()));
436 436
437 if (inputArc instanceof TimedOutputArcComponent) {437 if (inputArc instanceof TimedOutputArcComponent) {
438 if (inputArc instanceof TimedInputArcComponent) {438 if (inputArc instanceof TimedInputArcComponent) {
439439
=== modified file 'src/dk/aau/cs/verification/TAPNComposer.java'
--- src/dk/aau/cs/verification/TAPNComposer.java 2020-04-18 15:50:17 +0000
+++ src/dk/aau/cs/verification/TAPNComposer.java 2020-05-12 11:42:36 +0000
@@ -70,7 +70,7 @@
70 hasShownMessage = false;70 hasShownMessage = false;
7171
72 72
73 double greatestWidth = 0,73 int greatestWidth = 0,
74 greatestHeight = 0;74 greatestHeight = 0;
75 if (this.guiModels != null) {75 if (this.guiModels != null) {
76 for (TimedArcPetriNet tapn1 : model.activeTemplates()) {76 for (TimedArcPetriNet tapn1 : model.activeTemplates()) {
@@ -195,7 +195,7 @@
195 }195 }
196 }196 }
197197
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) {
199 int i = 0;199 int i = 0;
200 for (TimedArcPetriNet tapn : model.activeTemplates()) {200 for (TimedArcPetriNet tapn : model.activeTemplates()) {
201 DataLayer currentGuiModel = null;201 DataLayer currentGuiModel = null;
@@ -246,7 +246,7 @@
246 }246 }
247 }247 }
248248
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) {
250 int i = 0;250 int i = 0;
251 for (TimedArcPetriNet tapn : model.activeTemplates()) {251 for (TimedArcPetriNet tapn : model.activeTemplates()) {
252 252
@@ -318,7 +318,7 @@
318 }318 }
319 }319 }
320 320
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) {
322 Arc guiArc = currentGuiModel.getArcByEndpoints(source, target);322 Arc guiArc = currentGuiModel.getArcByEndpoints(source, target);
323 ArcPath arcPath = guiArc.getArcPath();323 ArcPath arcPath = guiArc.getArcPath();
324 int arcPathPointsNum = arcPath.getNumPoints();324 int arcPathPointsNum = arcPath.getNumPoints();
@@ -338,7 +338,7 @@
338 return newArcPath;338 return newArcPath;
339 }339 }
340340
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) {
342 int i = 0;342 int i = 0;
343 for (TimedArcPetriNet tapn : model.activeTemplates()) {343 for (TimedArcPetriNet tapn : model.activeTemplates()) {
344 344
@@ -375,15 +375,11 @@
375 Transition guiTarget = guiModel.getTransitionByName(mapping.map(targetTemplate, arc.destination().name()));375 Transition guiTarget = guiModel.getTransitionByName(mapping.map(targetTemplate, arc.destination().name()));
376 376
377 Arc newArc = new TimedInputArcComponent(new TimedOutputArcComponent(377 Arc newArc = new TimedInputArcComponent(new TimedOutputArcComponent(
378 0d,378 guiSource,
379 0d,
380 0d,
381 0d,
382 guiSource,
383 guiTarget,379 guiTarget,
384 arc.getWeight().value(),380 arc.getWeight().value(),
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())
386 false)382 )
387 );383 );
388 384
389 // Build ArcPath385 // Build ArcPath
@@ -402,7 +398,7 @@
402 }398 }
403 }399 }
404400
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) {
406 int i = 0;402 int i = 0;
407 for (TimedArcPetriNet tapn : model.activeTemplates()) {403 for (TimedArcPetriNet tapn : model.activeTemplates()) {
408 DataLayer currentGuiModel = null;404 DataLayer currentGuiModel = null;
@@ -430,16 +426,11 @@
430 Place guiTarget = guiModel.getPlaceByName(mapping.map(destinationTemplate, arc.destination().name()));426 Place guiTarget = guiModel.getPlaceByName(mapping.map(destinationTemplate, arc.destination().name()));
431 427
432 TimedOutputArcComponent newArc = new TimedOutputArcComponent(428 TimedOutputArcComponent newArc = new TimedOutputArcComponent(
433 0d,429 guiModel.getTransitionByName(mapping.map(sourceTemplate, arc.source().name())),
434 0d,
435 0d,
436 0d,
437 guiModel.getTransitionByName(mapping.map(sourceTemplate, arc.source().name())),
438 guiModel.getPlaceByName(mapping.map(destinationTemplate, arc.destination().name())),430 guiModel.getPlaceByName(mapping.map(destinationTemplate, arc.destination().name())),
439 arc.getWeight().value(),431 arc.getWeight().value(),
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())
441 false433 );
442 );
443 434
444 // Build ArcPath435 // Build ArcPath
445 Transition oldGuiSource = currentGuiModel.getTransitionByName(arc.source().name());436 Transition oldGuiSource = currentGuiModel.getTransitionByName(arc.source().name());
@@ -457,7 +448,7 @@
457 }448 }
458 }449 }
459450
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) {
461 int i = 0;452 int i = 0;
462 int nextGroupNr = 0;453 int nextGroupNr = 0;
463 for (TimedArcPetriNet tapn : model.activeTemplates()) {454 for (TimedArcPetriNet tapn : model.activeTemplates()) {
@@ -498,16 +489,11 @@
498 489
499 TimedTransportArcComponent newInArc = new TimedTransportArcComponent(490 TimedTransportArcComponent newInArc = new TimedTransportArcComponent(
500 new TimedInputArcComponent(new TimedOutputArcComponent(491 new TimedInputArcComponent(new TimedOutputArcComponent(
501 0d,492 guiSourceIn,
502 0d,
503 0d,
504 0d,
505 guiSourceIn,
506 guiTargetIn,493 guiTargetIn,
507 arc.getWeight().value(),494 arc.getWeight().value(),
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())
509 false496 )
510 )
511 ),497 ),
512 nextGroupNr, 498 nextGroupNr,
513 true499 true
@@ -542,15 +528,11 @@
542 528
543 TimedTransportArcComponent newOutArc = new TimedTransportArcComponent(529 TimedTransportArcComponent newOutArc = new TimedTransportArcComponent(
544 new TimedInputArcComponent(new TimedOutputArcComponent(530 new TimedInputArcComponent(new TimedOutputArcComponent(
545 0d,531 guiSourceOut,
546 0d,
547 0d,
548 0d,
549 guiSourceOut,
550 guiTargetOut,532 guiTargetOut,
551 1,533 1,
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())
553 false)535 )
554 ),536 ),
555 nextGroupNr + 1, 537 nextGroupNr + 1,
556 false538 false
@@ -574,7 +556,7 @@
574556
575 557
576 558
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) {
578 int i = 0;560 int i = 0;
579 for (TimedArcPetriNet tapn : model.activeTemplates()) {561 for (TimedArcPetriNet tapn : model.activeTemplates()) {
580 562
@@ -609,16 +591,11 @@
609 Place guiSource = guiModel.getPlaceByName(mapping.map(sourceTemplate, arc.source().name()));591 Place guiSource = guiModel.getPlaceByName(mapping.map(sourceTemplate, arc.source().name()));
610 Transition guiTarget = guiModel.getTransitionByName(mapping.map(destinationTemplate, arc.destination().name()));592 Transition guiTarget = guiModel.getTransitionByName(mapping.map(destinationTemplate, arc.destination().name()));
611 Arc newArc = new TimedInhibitorArcComponent(new TimedOutputArcComponent(593 Arc newArc = new TimedInhibitorArcComponent(new TimedOutputArcComponent(
612 0d,594 guiSource,
613 0d,
614 0d,
615 0d,
616 guiSource,
617 guiTarget,595 guiTarget,
618 arc.getWeight().value(),596 arc.getWeight().value(),
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())
620 false598 ), "");
621 ), "");
622 599
623 // Build ArcPath600 // Build ArcPath
624 Place oldGuiSource = currentGuiModel.getPlaceByName(arc.source().name());601 Place oldGuiSource = currentGuiModel.getPlaceByName(arc.source().name());
625602
=== modified file 'src/pipe/gui/CreateGui.java'
--- src/pipe/gui/CreateGui.java 2020-04-18 13:49:06 +0000
+++ src/pipe/gui/CreateGui.java 2020-05-12 11:42:36 +0000
@@ -39,6 +39,7 @@
3939
40 @Deprecated40 @Deprecated
41 public static DataLayer getModel() {41 public static DataLayer getModel() {
42 if (appGui==null) return null;
42 return getModel(appGui.getSelectedTabIndex());43 return getModel(appGui.getSelectedTabIndex());
43 }44 }
4445
4546
=== modified file 'src/pipe/gui/Zoomer.java'
--- src/pipe/gui/Zoomer.java 2020-04-18 13:28:36 +0000
+++ src/pipe/gui/Zoomer.java 2020-05-12 11:42:36 +0000
@@ -46,32 +46,36 @@
46 return setPercent(newPercent);46 return setPercent(newPercent);
47 }47 }
4848
49 public static AffineTransform getTransform(int zoom) {
50 return AffineTransform.getScaleInstance(zoom * 0.01, zoom * 0.01);
51 }
52
53 public static double getScaleFactor(int zoom) {
54 return zoom * 0.01;
55 }
56
49 public static int getZoomedValue(int x, int zoom) {57 public static int getZoomedValue(int x, int zoom) {
50 return (int) (x * zoom * 0.01);58 return (int) Math.round((x * zoom * 0.01));
51 }59 }
5260
53 public static double getZoomedValue(double x, int zoom) {61 /**
54 return x * zoom * 0.01;62 * @deprecated use int getUnzoomedValue(int x, int zoom)
55 }63 */
5664 @Deprecated
57 public static AffineTransform getTransform(int zoom) {65 public static int getZoomedValue(double x, int zoom) {
58 return AffineTransform.getScaleInstance(zoom * 0.01, zoom * 0.01);66 return (int) Math.round((x * zoom * 0.01));
59 }
60
61 public static double getScaleFactor(int zoom) {
62 return zoom * 0.01;
63 }67 }
6468
65 public static int getUnzoomedValue(int x, int zoom) {69 public static int getUnzoomedValue(int x, int zoom) {
66 return (int) (x / (zoom * 0.01));70 return (int) Math.round((x / (zoom * 0.01)));
67 }71 }
6872
69 /**73 /**
70 * @deprecated use int getUnzoomedValue(int x, int zoom)74 * @deprecated use int getUnzoomedValue(int x, int zoom)
71 */75 */
72 @Deprecated76 @Deprecated
73 public static double getUnzoomedValue(double x, int zoom) {77 public static int getUnzoomedValue(double x, int zoom) {
74 return x / (zoom * 0.01);78 return (int) Math.round(x / (zoom * 0.01));
75 }79 }
7680
77}81}
7882
=== modified file 'src/pipe/gui/graphicElements/ArcPath.java'
--- src/pipe/gui/graphicElements/ArcPath.java 2020-04-18 15:59:30 +0000
+++ src/pipe/gui/graphicElements/ArcPath.java 2020-05-12 11:42:36 +0000
@@ -367,7 +367,7 @@
367367
368 public void setPointLocation(int index, double x, double y) {368 public void setPointLocation(int index, double x, double y) {
369 if (index < pathPoints.size() && index >= 0) {369 if (index < pathPoints.size() && index >= 0) {
370 (pathPoints.get(index)).setPointLocation(x, y);370 (pathPoints.get(index)).setPointLocation((int)x,(int) y);
371 }371 }
372 }372 }
373373
374374
=== modified file 'src/pipe/gui/graphicElements/ArcPathPoint.java'
--- src/pipe/gui/graphicElements/ArcPathPoint.java 2020-04-18 13:28:36 +0000
+++ src/pipe/gui/graphicElements/ArcPathPoint.java 2020-05-12 11:42:36 +0000
@@ -32,8 +32,6 @@
32 private final int DELTA = 10;32 private final int DELTA = 10;
3333
34 private ArcPath myArcPath;34 private ArcPath myArcPath;
35 private Point2D.Double point = new Point2D.Double();
36 private Point2D.Double realPoint = new Point2D.Double();
3735
38 private Point2D.Double control1 = new Point2D.Double();36 private Point2D.Double control1 = new Point2D.Double();
39 private Point2D.Double control2 = new Point2D.Double();37 private Point2D.Double control2 = new Point2D.Double();
@@ -53,7 +51,8 @@
53 public ArcPathPoint(double x, double y, boolean _pointType, ArcPath a) {51 public ArcPathPoint(double x, double y, boolean _pointType, ArcPath a) {
54 this();52 this();
55 myArcPath = a;53 myArcPath = a;
56 setPointLocation(x, y);54 setPositionX((int)x);
55 setPositionY((int)y);
57 pointType = _pointType;56 pointType = _pointType;
58 }57 }
5958
@@ -72,14 +71,12 @@
72 }71 }
7372
74 public Point2D.Double getPoint() {73 public Point2D.Double getPoint() {
75 return point;74 return new Point2D.Double(getPositionX(), getPositionY());
76 }75 }
7776
78 public void setPointLocation(double x, double y) {77 public void setPointLocation(int x, int y) {
79 double realX = Zoomer.getUnzoomedValue(x, myArcPath.getArc().getZoom());78 setPositionX(x);
80 double realY = Zoomer.getUnzoomedValue(y, myArcPath.getArc().getZoom());79 setPositionY(y);
81 getRealPoint().setLocation(realX, realY);
82 point.setLocation(x, y);
83 setBounds((int) x - SIZE, (int) y - SIZE, 2 * SIZE + SIZE_OFFSET, 280 setBounds((int) x - SIZE, (int) y - SIZE, 2 * SIZE + SIZE_OFFSET, 2
84 * SIZE + SIZE_OFFSET);81 * SIZE + SIZE_OFFSET);
85 }82 }
@@ -89,7 +86,8 @@
89 }86 }
9087
91 public void updatePointLocation() {88 public void updatePointLocation() {
92 setPointLocation(point.x, point.y);89 //XXX
90 //setPointLocation(point.x, point.y);
93 }91 }
9492
95 public void setPointType(boolean type) {93 public void setPointType(boolean type) {
@@ -114,16 +112,12 @@
114 public double getAngle(Point2D.Double p2) {112 public double getAngle(Point2D.Double p2) {
115 double angle;113 double angle;
116114
117 if (point.y <= p2.y) {115 if (getPositionY() <= p2.y) {
118 angle = Math.atan((point.x - p2.x) / (p2.y - point.y));116 angle = Math.atan((getPositionX() - p2.x) / (p2.y - getPositionY()));
119 } else {117 } else {
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;
121 }119 }
122120
123 // Needed to eliminate an exception on Windows
124 if (point.equals(p2)) {
125 angle = 0;
126 }
127 return angle;121 return angle;
128 }122 }
129123
@@ -178,8 +172,7 @@
178 public Command splitPoint() {172 public Command splitPoint() {
179 int i = getIndex(); // Get the index of this point173 int i = getIndex(); // Get the index of this point
180174
181 ArcPathPoint newPoint = new ArcPathPoint(point.x + DELTA, point.y,175 ArcPathPoint newPoint = new ArcPathPoint(getPositionX() + DELTA, getPositionY(), pointType, myArcPath);
182 pointType, myArcPath);
183 myArcPath.insertPoint(i + 1, newPoint);176 myArcPath.insertPoint(i + 1, newPoint);
184 myArcPath.getArc().updateArcPosition();177 myArcPath.getArc().updateArcPosition();
185 return new AddArcPathPointEdit(myArcPath.getArc(), newPoint, myArcPath.getArc().getGuiModel());178 return new AddArcPathPointEdit(myArcPath.getArc(), newPoint, myArcPath.getArc().getGuiModel());
@@ -187,8 +180,8 @@
187180
188 public Point2D.Double getMidPoint(ArcPathPoint target) {181 public Point2D.Double getMidPoint(ArcPathPoint target) {
189 return new Point2D.Double(182 return new Point2D.Double(
190 (target.point.x + point.x) / 2,183 (target.getPositionX() + getPositionX()) / 2,
191 (target.point.y + point.y) / 2184 (target.getPositionY() + getPositionY()) / 2
192 );185 );
193 }186 }
194187
@@ -240,7 +233,7 @@
240 }233 }
241234
242 public void translate(int x, int y) {235 public void translate(int x, int y) {
243 this.setPointLocation(point.x + x, point.y + y);236 this.setPointLocation(getPositionX() + x, getPositionY() + y);
244 myArcPath.updateArc();237 myArcPath.updateArc();
245 }238 }
246239
@@ -260,23 +253,21 @@
260 } else {253 } else {
261 SIZE = 3;254 SIZE = 3;
262 }255 }
263 double x = Zoomer.getZoomedValue(getRealPoint().x, zoom);256 int x = (int)Zoomer.getZoomedValue(getRealPoint().x, zoom);
264 double y = Zoomer.getZoomedValue(getRealPoint().y, zoom);257 int y = (int)Zoomer.getZoomedValue(getRealPoint().y, zoom);
265 point.setLocation(x, y);258 setPositionX(x);
259 setPositionY(y);
266 setBounds((int) x - SIZE, (int) y - SIZE, 2 * SIZE + SIZE_OFFSET, 2260 setBounds((int) x - SIZE, (int) y - SIZE, 2 * SIZE + SIZE_OFFSET, 2
267 * SIZE + SIZE_OFFSET);261 * SIZE + SIZE_OFFSET);
268 }262 }
269263
270 public Point2D.Double getRealPoint() {264 public Point2D.Double getRealPoint() {
271 return realPoint;265 return new Point2D.Double(getOriginalX(), getOriginalY());
272 }266 }
273267
274 public void setRealPoint(Point2D.Double realPoint) {
275 this.realPoint = realPoint;
276 }
277
278 public boolean isEndPoint() {268 public boolean isEndPoint() {
279 return this.getIndex() == 0 || this.getIndex() == myArcPath.getEndIndex();269 return this.getIndex() == 0 || this.getIndex() == myArcPath.getEndIndex();
280 }270 }
281271
272
282}273}
283274
=== modified file 'src/pipe/gui/graphicElements/NameLabel.java'
--- src/pipe/gui/graphicElements/NameLabel.java 2020-04-18 13:49:06 +0000
+++ src/pipe/gui/graphicElements/NameLabel.java 2020-05-12 11:42:36 +0000
@@ -24,19 +24,15 @@
2424
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);
2626
27 public NameLabel(int zoom) {27 public NameLabel() {
28 this("");28 this("");
29
30 //Kind of important to know about deriveFont: --kyrke 2020-04-02
31 // deriveFont(int) - sets text style
32 // deriveFont(float) - sets text size
33 setFont(getFont().deriveFont((float)Zoomer.getZoomedValue(Pipe.LABEL_DEFAULT_FONT_SIZE, zoom)));
34 }29 }
3530
36 public NameLabel(String nameInput) {31 public NameLabel(String nameInput) {
37 super(nameInput);32 super(nameInput);
38 name = nameInput;33 name = nameInput;
39 setFont(font);34 setFont(font);
35
40 setCursor(new java.awt.Cursor(java.awt.Cursor.CROSSHAIR_CURSOR));36 setCursor(new java.awt.Cursor(java.awt.Cursor.CROSSHAIR_CURSOR));
41 setEditable(false);37 setEditable(false);
42 setFocusable(false);38 setFocusable(false);
@@ -109,10 +105,11 @@
109 }105 }
110106
111 public void zoomUpdate(int value) {107 public void zoomUpdate(int value) {
108
112 //Kind of important to know about deriveFont: --kyrke 2020-04-02109 //Kind of important to know about deriveFont: --kyrke 2020-04-02
113 // deriveFont(int) - sets text style110 // deriveFont(int) - sets text style
114 // deriveFont(float) - sets text size111 // deriveFont(float) - sets text size
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)));
116113
117 updateSize();114 updateSize();
118 }115 }
119116
=== modified file 'src/pipe/gui/graphicElements/PetriNetObject.java'
--- src/pipe/gui/graphicElements/PetriNetObject.java 2020-04-18 12:27:02 +0000
+++ src/pipe/gui/graphicElements/PetriNetObject.java 2020-05-12 11:42:36 +0000
@@ -22,8 +22,8 @@
2222
23 protected static final int COMPONENT_DRAW_OFFSET= 5;23 protected static final int COMPONENT_DRAW_OFFSET= 5;
24 /** x/y position position on screen (zoomed) */24 /** x/y position position on screen (zoomed) */
25 protected double positionX;25 protected int positionX;
26 protected double positionY;26 protected int positionY;
2727
28 // The x/y coordinate of object at 100% zoom.28 // The x/y coordinate of object at 100% zoom.
29 //XXX: pushed down from PlaceTransitionObject and consolidated from note, need further refactoring and rename, //kyrke 2019-08-2329 //XXX: pushed down from PlaceTransitionObject and consolidated from note, need further refactoring and rename, //kyrke 2019-08-23
@@ -274,27 +274,6 @@
274 public int getOriginalY() {274 public int getOriginalY() {
275 return originalY;275 return originalY;
276 }276 }
277 /**
278 * Get X-axis position, returns null if value not yet entered
279 *
280 * @return Double value for X-axis position
281 * @deprecated use getOriginalX
282 */
283 @Deprecated
284 public Double getPositionXObject() {
285 return (double) originalX;
286 }
287
288 /**
289 * Get Y-axis position, returns null if value not yet entered
290 *
291 * @return Double value for Y-axis position
292 * @deprecated use getOriginalY
293 */
294 @Deprecated
295 public Double getPositionYObject() {
296 return (double) originalY;
297 }
298277
299 @Override278 @Override
300 public void zoomUpdate(int zoom) {279 public void zoomUpdate(int zoom) {
@@ -314,9 +293,9 @@
314 * @param positionXInput293 * @param positionXInput
315 * Double value for X-axis position294 * Double value for X-axis position
316 */295 */
317 public void setPositionX(double positionXInput) {296 public void setPositionX(int positionXInput) {
318 positionX = positionXInput;297 positionX = positionXInput;
319 originalX = (int)Zoomer.getUnzoomedValue(positionX, getZoom());298 originalX = Zoomer.getUnzoomedValue(positionX, getZoom());
320 }299 }
321300
322 //XXX: pushed down from Placetransition object, might be dublicated //kyrke 2019-09-20301 //XXX: pushed down from Placetransition object, might be dublicated //kyrke 2019-09-20
@@ -326,9 +305,9 @@
326 * @param positionYInput305 * @param positionYInput
327 * Double value for Y-axis position306 * Double value for Y-axis position
328 */307 */
329 public void setPositionY(double positionYInput) {308 public void setPositionY(int positionYInput) {
330 positionY = positionYInput;309 positionY = positionYInput;
331 originalY = (int)Zoomer.getUnzoomedValue(positionY, getZoom());310 originalY = Zoomer.getUnzoomedValue(positionY, getZoom());
332 }311 }
333312
334 //XXX: pushed down from Placetransition object, might be dublicated //kyrke 2019-09-20313 //XXX: pushed down from Placetransition object, might be dublicated //kyrke 2019-09-20
@@ -337,7 +316,7 @@
337 *316 *
338 * @return Double value for X-axis position317 * @return Double value for X-axis position
339 */318 */
340 public double getPositionX() {319 public int getPositionX() {
341 return positionX;320 return positionX;
342 }321 }
343322
@@ -347,7 +326,7 @@
347 *326 *
348 * @return Double value for Y-axis position327 * @return Double value for Y-axis position
349 */328 */
350 public double getPositionY() {329 public int getPositionY() {
351 return positionY;330 return positionY;
352 }331 }
353}332}
354333
=== modified file 'src/pipe/gui/graphicElements/PetriNetObjectWithLabel.java'
--- src/pipe/gui/graphicElements/PetriNetObjectWithLabel.java 2020-04-06 07:46:34 +0000
+++ src/pipe/gui/graphicElements/PetriNetObjectWithLabel.java 2020-05-12 11:42:36 +0000
@@ -10,10 +10,10 @@
1010
1111
12 /* Name Label for displaying name */12 /* Name Label for displaying name */
13 protected NameLabel pnName = new NameLabel(Pipe.ZOOM_DEFAULT);13 protected NameLabel pnName = new NameLabel();
14 /** X/Y-axis Position on screen */14 /** X/Y-axis Position on screen */
15 private double nameOffsetX;15 private int nameOffsetX;
16 private double nameOffsetY;16 private int nameOffsetY;
1717
18 PetriNetObjectWithLabel(int nameOffsetX, int nameOffsetY) {18 PetriNetObjectWithLabel(int nameOffsetX, int nameOffsetY) {
19 super();19 super();
@@ -42,13 +42,14 @@
42 protected void updateLabelLocation(boolean alignToGrid) {42 protected void updateLabelLocation(boolean alignToGrid) {
43 if(alignToGrid) {43 if(alignToGrid) {
44 this.getNameLabel().setPosition(44 this.getNameLabel().setPosition(
45 Grid.getModifiedX((int) (positionX + Zoomer.getZoomedValue(nameOffsetX, getZoom()))),45 Grid.getModifiedX(positionX + Zoomer.getZoomedValue(nameOffsetX, getZoom())),
46 Grid.getModifiedY((int) (positionY + Zoomer.getZoomedValue(nameOffsetY, getZoom())))46 Grid.getModifiedY(positionY + Zoomer.getZoomedValue(nameOffsetY, getZoom()))
47 );47 );
48 } else {48 } else {
49 this.getNameLabel().setPosition(49 this.getNameLabel().setPosition(
50 ((int)(positionX + Zoomer.getZoomedValue(nameOffsetX, getZoom()))),50 positionX + Zoomer.getZoomedValue(nameOffsetX, getZoom()),
51 ((int)(positionY + Zoomer.getZoomedValue(nameOffsetY, getZoom()))));51 positionY + Zoomer.getZoomedValue(nameOffsetY, getZoom())
52 );
52 }53 }
53 }54 }
5455
@@ -72,7 +73,7 @@
72 * @param nameOffsetXInput73 * @param nameOffsetXInput
73 * Double value for name X-axis offset74 * Double value for name X-axis offset
74 */75 */
75 public void setNameOffsetX(double nameOffsetXInput) {76 public void setNameOffsetX(int nameOffsetXInput) {
76 nameOffsetX = Zoomer.getUnzoomedValue(nameOffsetXInput, getZoom());77 nameOffsetX = Zoomer.getUnzoomedValue(nameOffsetXInput, getZoom());
77 }78 }
7879
@@ -82,42 +83,24 @@
82 * @param nameOffsetYInput83 * @param nameOffsetYInput
83 * Double value for name Y-axis offset84 * Double value for name Y-axis offset
84 */85 */
85 public void setNameOffsetY(double nameOffsetYInput) {86 public void setNameOffsetY(int nameOffsetYInput) {
86 nameOffsetY = Zoomer.getUnzoomedValue(nameOffsetYInput, getZoom());87 nameOffsetY = Zoomer.getUnzoomedValue(nameOffsetYInput, getZoom());
87 }88 }
8889
89 public void updateNameOffsetX(double nameOffsetXInput) {90 public void updateNameOffsetX(int nameOffsetXInput) {
90 nameOffsetX += Zoomer.getUnzoomedValue(nameOffsetXInput, getZoom());91 nameOffsetX += Zoomer.getUnzoomedValue(nameOffsetXInput, getZoom());
9192
92 }93 }
9394
94 public void updateNameOffsetY(double nameOffsetYInput) {95 public void updateNameOffsetY(int nameOffsetYInput) {
95 nameOffsetY += Zoomer.getUnzoomedValue(nameOffsetYInput, getZoom());96 nameOffsetY += Zoomer.getUnzoomedValue(nameOffsetYInput, getZoom());
96 }97 }
9798
98 /**
99 * Get X-axis offset for ...
100 *
101 * @return Double value for X-axis offset of ...
102 */
103 public Double getNameOffsetXObject() {
104 return nameOffsetX;
105 }
106
107 /**
108 * Moved to PetriNetObject Get Y-axis offset for ...
109 *
110 * @return Double value for Y-axis offset of ...
111 */
112 public Double getNameOffsetYObject() {
113 return nameOffsetY;
114 }
115
116 //XXX pushed up from PlaceTransitionObject while refactorings, dublicates getNameOffsetXObject? //kyrke 2019-09-1799 //XXX pushed up from PlaceTransitionObject while refactorings, dublicates getNameOffsetXObject? //kyrke 2019-09-17
117 public double getNameOffsetX() {100 public int getNameOffsetX() {
118 return nameOffsetX;101 return nameOffsetX;
119 }102 }
120 public double getNameOffsetY() {103 public int getNameOffsetY() {
121 return nameOffsetY;104 return nameOffsetY;
122 }105 }
123106
124107
=== modified file 'src/pipe/gui/graphicElements/Place.java'
--- src/pipe/gui/graphicElements/Place.java 2020-04-18 12:27:02 +0000
+++ src/pipe/gui/graphicElements/Place.java 2020-05-12 11:42:36 +0000
@@ -47,17 +47,6 @@
47 componentHeight = DIAMETER;47 componentHeight = DIAMETER;
48 }48 }
4949
50 @Deprecated
51 public Place(double positionXInput, double positionYInput, String idInput,
52 double nameOffsetXInput, double nameOffsetYInput) {
53 this((int)positionXInput, (int)positionYInput, idInput, (int)nameOffsetXInput, (int)nameOffsetYInput);
54 }
55
56 @Deprecated
57 public Place(double positionXInput, double positionYInput) {
58 this((int)positionXInput, (int)positionYInput, null, 0,0);
59 }
60
61 public Place(int positionXInput, int positionYInput) {50 public Place(int positionXInput, int positionYInput) {
62 this(positionXInput, positionYInput, null, 0,0);51 this(positionXInput, positionYInput, null, 0,0);
63 }52 }
6453
=== modified file 'src/pipe/gui/graphicElements/PlaceTransitionObject.java'
--- src/pipe/gui/graphicElements/PlaceTransitionObject.java 2020-04-18 13:49:06 +0000
+++ src/pipe/gui/graphicElements/PlaceTransitionObject.java 2020-05-12 11:42:36 +0000
@@ -1,13 +1,13 @@
1package pipe.gui.graphicElements;1package pipe.gui.graphicElements;
22
3import pipe.gui.Pipe;
4import pipe.gui.Zoomer;
5
3import java.awt.*;6import java.awt.*;
4import java.awt.geom.Point2D;7import java.awt.geom.Point2D;
5import java.util.Iterator;8import java.util.Iterator;
6import java.util.LinkedList;9import java.util.LinkedList;
710
8import pipe.gui.Pipe;
9import pipe.gui.Zoomer;
10
11/**11/**
12 * Petri-Net Place or Transition SuperClass12 * Petri-Net Place or Transition SuperClass
13 * 13 *
@@ -42,24 +42,6 @@
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);
43 }43 }
4444
45 @Deprecated
46 public PlaceTransitionObject(
47 double positionXInput,
48 double positionYInput,
49 String idInput,
50 double nameOffsetXInput,
51 double nameOffsetYInput
52 ) {
53 this((int)positionXInput, (int) positionYInput, idInput, (int)nameOffsetXInput, (int)nameOffsetYInput);
54 }
55
56 @Deprecated
57 public PlaceTransitionObject(double positionXInput, double positionYInput) {
58 this(positionXInput, positionYInput, null, Pipe.DEFAULT_OFFSET_X, Pipe.DEFAULT_OFFSET_Y);
59 }
60
61
62
63 /**45 /**
64 * Set name46 * Set name
65 * 47 *
@@ -147,12 +129,13 @@
147 /** Calculates the BoundsOffsets used for setBounds() method */129 /** Calculates the BoundsOffsets used for setBounds() method */
148 public void updateBounds() {130 public void updateBounds() {
149 double scaleFactor = Zoomer.getScaleFactor(getZoom());131 double scaleFactor = Zoomer.getScaleFactor(getZoom());
150 positionX = originalX * scaleFactor;132 positionX = (int)Math.round(originalX * scaleFactor);
151 positionY = originalY * scaleFactor;133 positionY = (int)Math.round(originalY * scaleFactor);
152 Rectangle bounds = new Rectangle();134
153 bounds.setBounds((int) positionX, (int) positionY,135 int width = (int) Math.round(componentWidth * scaleFactor);
154 (int) (componentWidth * scaleFactor),136 int height = (int) Math.round(componentHeight * scaleFactor);
155 (int) (componentHeight * scaleFactor));137
138 Rectangle bounds = new Rectangle(positionX, positionY, width, height);
156 bounds.grow(COMPONENT_DRAW_OFFSET, COMPONENT_DRAW_OFFSET);139 bounds.grow(COMPONENT_DRAW_OFFSET, COMPONENT_DRAW_OFFSET);
157 setBounds(bounds);140 setBounds(bounds);
158 }141 }
@@ -196,9 +179,9 @@
196 }179 }
197180
198 /** Sets the center of the component to position x, y */181 /** Sets the center of the component to position x, y */
199 public void setCentre(double x, double y) {182 public void setCentre(int x, int y) {
200 setPositionX(x - (getWidth() / 2.0));183 setPositionX((int) Math.round(x - (getWidth() / 2.0)));
201 setPositionY(y - (getHeight() / 2.0));184 setPositionY((int) Math.round(y - (getHeight() / 2.0)));
202 update(true);185 update(true);
203 }186 }
204187
205188
=== modified file 'src/pipe/gui/graphicElements/Transition.java'
--- src/pipe/gui/graphicElements/Transition.java 2020-04-18 12:27:02 +0000
+++ src/pipe/gui/graphicElements/Transition.java 2020-05-12 11:42:36 +0000
@@ -51,11 +51,11 @@
51 /**51 /**
52 * Create Petri-Net Transition object52 * Create Petri-Net Transition object
53 */53 */
54 public Transition(double positionXInput, double positionYInput,54 public Transition(int positionXInput, int positionYInput,
55 String idInput, double nameOffsetXInput,55 String idInput, int nameOffsetXInput,
56 double nameOffsetYInput,56 int nameOffsetYInput,
57 boolean infServer, int angleInput, int priority) {57 boolean infServer, int angleInput, int priority) {
58 this((int)positionXInput, (int)positionYInput, idInput, (int)nameOffsetXInput, (int)nameOffsetYInput, angleInput);58 this(positionXInput, positionYInput, idInput, nameOffsetXInput, nameOffsetYInput, angleInput);
59 }59 }
6060
61 /**61 /**
@@ -86,8 +86,8 @@
86 * @param positionYInput86 * @param positionYInput
87 * Y-axis Position87 * Y-axis Position
88 */88 */
89 public Transition(double positionXInput, double positionYInput) {89 public Transition(int positionXInput, int positionYInput) {
90 this((int)positionXInput, (int)positionYInput,null, 0,0, 0);90 this(positionXInput, positionYInput,null, 0,0, 0);
91 }91 }
9292
93 @Override93 @Override
9494
=== modified file 'src/pipe/gui/graphicElements/tapn/TimedInputArcComponent.java'
--- src/pipe/gui/graphicElements/tapn/TimedInputArcComponent.java 2020-04-18 12:27:02 +0000
+++ src/pipe/gui/graphicElements/tapn/TimedInputArcComponent.java 2020-05-12 11:42:36 +0000
@@ -30,13 +30,7 @@
30 updateLabel(true);30 updateLabel(true);
31 }31 }
3232
33 /** @deprecated */33 @Override
34 @Deprecated
35 public TimedInputArcComponent(TimedOutputArcComponent arc, String guard) {
36 this(arc);
37 }
38
39 @Override
40 protected void addMouseHandler() {34 protected void addMouseHandler() {
41 //XXX: kyrke 2018-09-06, this is bad as we leak "this", think its ok for now, as it alwas constructed when35 //XXX: kyrke 2018-09-06, this is bad as we leak "this", think its ok for now, as it alwas constructed when
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.
4337
=== modified file 'src/pipe/gui/graphicElements/tapn/TimedOutputArcComponent.java'
--- src/pipe/gui/graphicElements/tapn/TimedOutputArcComponent.java 2020-04-18 12:27:02 +0000
+++ src/pipe/gui/graphicElements/tapn/TimedOutputArcComponent.java 2020-05-12 11:42:36 +0000
@@ -29,16 +29,6 @@
29 super(sourceInput, targetInput, weightInput, idInput);29 super(sourceInput, targetInput, weightInput, idInput);
30 }30 }
3131
32 /** @deprecated */
33 @Deprecated
34 public TimedOutputArcComponent(double startPositionXInput,
35 double startPositionYInput, double endPositionXInput,
36 double endPositionYInput, PlaceTransitionObject sourceInput,
37 PlaceTransitionObject targetInput, int weightInput, String idInput,
38 boolean taggedInput) {
39 this(sourceInput, targetInput, weightInput, idInput);
40 }
41
42 /**32 /**
43 * Create Petri-Net Arc object33 * Create Petri-Net Arc object
44 */34 */
@@ -56,11 +46,12 @@
56 id = arc.id;46 id = arc.id;
57 this.setSource(arc.getSource());47 this.setSource(arc.getSource());
58 this.setTarget(arc.getTarget());48 this.setTarget(arc.getTarget());
59 this.setNameOffsetX(arc.getNameOffsetXObject());49 this.setNameOffsetX(arc.getNameOffsetX());
60 this.setNameOffsetY(arc.getNameOffsetYObject());50 this.setNameOffsetY(arc.getNameOffsetY());
61 this.getNameLabel().setPosition(51 this.getNameLabel().setPosition(
62 Grid.getModifiedX((int) (arc.getNameLabel().getXPosition() + Zoomer.getZoomedValue(getNameOffsetX(), getZoom()))),52 Grid.getModifiedX((int) (arc.getNameLabel().getXPosition() + Zoomer.getZoomedValue(getNameOffsetX(), getZoom()))),
63 Grid.getModifiedY((int) (arc.getNameLabel().getYPosition() + Zoomer.getZoomedValue(getNameOffsetY(), getZoom()))));53 Grid.getModifiedY((int) (arc.getNameLabel().getYPosition() + Zoomer.getZoomedValue(getNameOffsetY(), getZoom())))
54 );
6455
65 }56 }
6657
6758
=== modified file 'src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java'
--- src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java 2020-04-18 12:27:02 +0000
+++ src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java 2020-05-12 11:42:36 +0000
@@ -51,7 +51,7 @@
51 private Window ageOfTokensWindow;51 private Window ageOfTokensWindow;
52 private Shape dashedOutline = createDashedOutline();52 private Shape dashedOutline = createDashedOutline();
5353
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) {
55 super(positionXInput, positionYInput);55 super(positionXInput, positionYInput);
56 this.place = place;56 this.place = place;
57 listener = timedPlaceListener(); 57 listener = timedPlaceListener();
@@ -62,12 +62,15 @@
6262
63 }63 }
6464
65 public TimedPlaceComponent(double positionXInput, double positionYInput,65 public TimedPlaceComponent(
66 String idInput, double nameOffsetXInput,66 int positionXInput,
67 double nameOffsetYInput) {67 int positionYInput,
68 String idInput,
69 int nameOffsetXInput,
70 int nameOffsetYInput
71 ) {
6872
69 super(positionXInput, positionYInput, idInput,73 super(positionXInput, positionYInput, idInput, nameOffsetXInput, nameOffsetYInput);
70 nameOffsetXInput, nameOffsetYInput);
71 listener = timedPlaceListener();74 listener = timedPlaceListener();
72 attributesVisible = true;75 attributesVisible = true;
73 ageOfTokensWindow = new Window(new Frame());76 ageOfTokensWindow = new Window(new Frame());
@@ -427,7 +430,7 @@
427 }430 }
428431
429 public TimedPlaceComponent copy(TimedArcPetriNet tapn) {432 public TimedPlaceComponent copy(TimedArcPetriNet tapn) {
430 TimedPlaceComponent placeComponent = new TimedPlaceComponent(getPositionXObject(), getPositionYObject(), id, getNameOffsetX(), getNameOffsetY());433 TimedPlaceComponent placeComponent = new TimedPlaceComponent(getOriginalX(), getOriginalY(), id, getNameOffsetX(), getNameOffsetY());
431 placeComponent.setUnderlyingPlace(tapn.getPlaceByName(place.name()));434 placeComponent.setUnderlyingPlace(tapn.getPlaceByName(place.name()));
432435
433 return placeComponent;436 return placeComponent;
434437
=== modified file 'src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java'
--- src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java 2020-05-06 14:58:56 +0000
+++ src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java 2020-05-12 11:42:36 +0000
@@ -36,7 +36,7 @@
36 private dk.aau.cs.model.tapn.event.TimedTransitionListener listener;36 private dk.aau.cs.model.tapn.event.TimedTransitionListener listener;
37 private GeneralPath dashedOutline;37 private GeneralPath dashedOutline;
3838
39 public TimedTransitionComponent(double positionXInput, double positionYInput,39 public TimedTransitionComponent(int positionXInput, int positionYInput,
40 dk.aau.cs.model.tapn.TimedTransition transition) {40 dk.aau.cs.model.tapn.TimedTransition transition) {
41 super(positionXInput, positionYInput);41 super(positionXInput, positionYInput);
42 this.transition = transition;42 this.transition = transition;
@@ -46,9 +46,9 @@
4646
47 }47 }
4848
49 public TimedTransitionComponent(double positionXInput,49 public TimedTransitionComponent(int positionXInput,
50 double positionYInput, String idInput,50 int positionYInput, String idInput,
51 double nameOffsetXInput, double nameOffsetYInput,51 int nameOffsetXInput, int nameOffsetYInput,
52 boolean timedTransition, boolean infServer, int angleInput,52 boolean timedTransition, boolean infServer, int angleInput,
53 int priority) {53 int priority) {
54 super(positionXInput, positionYInput, idInput,54 super(positionXInput, positionYInput, idInput,
@@ -202,7 +202,7 @@
202 }202 }
203203
204 public TimedTransitionComponent copy(TimedArcPetriNet tapn) {204 public TimedTransitionComponent copy(TimedArcPetriNet tapn) {
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);
206 transitionComponent.setUnderlyingTransition(tapn.getTransitionByName(transition.name()));206 transitionComponent.setUnderlyingTransition(tapn.getTransitionByName(transition.name()));
207207
208 return transitionComponent;208 return transitionComponent;
209209
=== modified file 'src/pipe/gui/graphicElements/tapn/TimedTransportArcComponent.java'
--- src/pipe/gui/graphicElements/tapn/TimedTransportArcComponent.java 2020-04-18 13:18:51 +0000
+++ src/pipe/gui/graphicElements/tapn/TimedTransportArcComponent.java 2020-05-12 11:42:36 +0000
@@ -34,7 +34,7 @@
34 }34 }
3535
36 public TimedTransportArcComponent(TimedInputArcComponent timedArc, int group, boolean isInPreSet) {36 public TimedTransportArcComponent(TimedInputArcComponent timedArc, int group, boolean isInPreSet) {
37 super(timedArc, "");37 super(timedArc);
38 this.isInPreSet = isInPreSet;38 this.isInPreSet = isInPreSet;
3939
40 this.setGroup(group);40 this.setGroup(group);
@@ -80,7 +80,7 @@
80 @Override80 @Override
81 public void updateLabel(boolean displayConstantNames) {81 public void updateLabel(boolean displayConstantNames) {
82 if (isInPreSet && underlyingTransportArc != null) {82 if (isInPreSet && underlyingTransportArc != null) {
83 if (CreateGui.getApp().showZeroToInfinityIntervals()){83 if (CreateGui.getApp() != null && CreateGui.getApp().showZeroToInfinityIntervals()){
84 getNameLabel().setText(underlyingTransportArc.interval().toString(84 getNameLabel().setText(underlyingTransportArc.interval().toString(
85 displayConstantNames)85 displayConstantNames)
86 + " : " + getGroup());86 + " : " + getGroup());
8787
=== modified file 'src/pipe/gui/handler/LabelHandler.java'
--- src/pipe/gui/handler/LabelHandler.java 2020-04-02 09:44:05 +0000
+++ src/pipe/gui/handler/LabelHandler.java 2020-05-12 11:42:36 +0000
@@ -21,7 +21,7 @@
21 private NameLabel nl;21 private NameLabel nl;
2222
23 protected Point dragInit = new Point();23 protected Point dragInit = new Point();
24 private double originalOffsetX, originalOffsetY;24 private int originalOffsetX, originalOffsetY;
2525
26 public LabelHandler(NameLabel _nl, PetriNetObjectWithLabel _obj) {26 public LabelHandler(NameLabel _nl, PetriNetObjectWithLabel _obj) {
27 obj = _obj;27 obj = _obj;
@@ -53,8 +53,8 @@
53 dragInit = e.getPoint(); //53 dragInit = e.getPoint(); //
5454
55 dragInit = javax.swing.SwingUtilities.convertPoint(nl, dragInit, obj);55 dragInit = javax.swing.SwingUtilities.convertPoint(nl, dragInit, obj);
56 originalOffsetX = obj.getNameOffsetXObject();56 originalOffsetX = obj.getNameOffsetX();
57 originalOffsetY = obj.getNameOffsetYObject();57 originalOffsetY = obj.getNameOffsetY();
58 }58 }
5959
60 @Override60 @Override
@@ -77,7 +77,7 @@
77 Point p = javax.swing.SwingUtilities.convertPoint(nl, e.getPoint(), obj);77 Point p = javax.swing.SwingUtilities.convertPoint(nl, e.getPoint(), obj);
78 78
79 CreateGui.getCurrentTab().getUndoManager().addNewEdit(79 CreateGui.getCurrentTab().getUndoManager().addNewEdit(
80 new UpdateNameLabelOffsetCommand(obj.getNameOffsetXObject(), obj.getNameOffsetYObject(), originalOffsetX, originalOffsetY, obj)80 new UpdateNameLabelOffsetCommand(obj.getNameOffsetX(), obj.getNameOffsetY(), originalOffsetX, originalOffsetY, obj)
81 );81 );
82 82
83 }83 }
8484
=== modified file 'src/pipe/gui/handler/PlaceHandler.java'
--- src/pipe/gui/handler/PlaceHandler.java 2020-04-02 09:44:05 +0000
+++ src/pipe/gui/handler/PlaceHandler.java 2020-05-12 11:42:36 +0000
@@ -90,8 +90,8 @@
90 if (m != null) {90 if (m != null) {
9191
92 if (myObject instanceof PetriNetObjectWithLabel) {92 if (myObject instanceof PetriNetObjectWithLabel) {
93 int x = Zoomer.getZoomedValue(((PetriNetObjectWithLabel)myObject).getNameOffsetXObject().intValue(), myObject.getZoom());93 int x = Zoomer.getZoomedValue(((PetriNetObjectWithLabel)myObject).getNameOffsetX(), myObject.getZoom());
94 int y = Zoomer.getZoomedValue(((PetriNetObjectWithLabel)myObject).getNameOffsetYObject().intValue(), myObject.getZoom());94 int y = Zoomer.getZoomedValue(((PetriNetObjectWithLabel)myObject).getNameOffsetY(), myObject.getZoom());
95 m.show(myObject, x, y);95 m.show(myObject, x, y);
96 }96 }
97 }97 }
9898
=== modified file 'src/pipe/gui/handler/TransitionHandler.java'
--- src/pipe/gui/handler/TransitionHandler.java 2020-04-18 13:49:06 +0000
+++ src/pipe/gui/handler/TransitionHandler.java 2020-05-12 11:42:36 +0000
@@ -82,11 +82,11 @@
82 JPopupMenu m = getPopup(e);82 JPopupMenu m = getPopup(e);
83 if (m != null) {83 if (m != null) {
84 int x = Zoomer.getZoomedValue(84 int x = Zoomer.getZoomedValue(
85 ((Transition) myObject).getNameOffsetXObject().intValue(),85 ((Transition) myObject).getNameOffsetX(),
86 myObject.getZoom()86 myObject.getZoom()
87 );87 );
88 int y = Zoomer.getZoomedValue(88 int y = Zoomer.getZoomedValue(
89 ((Transition) myObject).getNameOffsetYObject().intValue(),89 ((Transition) myObject).getNameOffsetY(),
90 myObject.getZoom()90 myObject.getZoom()
91 );91 );
92 m.show(myObject, x, y);92 m.show(myObject, x, y);
9393
=== added directory 'tests/dk'
=== added directory 'tests/dk/aau'
=== added directory 'tests/dk/aau/cs'
=== added directory 'tests/dk/aau/cs/io'
=== added file 'tests/dk/aau/cs/io/TapnXmlLoaderTest.kt'
--- tests/dk/aau/cs/io/TapnXmlLoaderTest.kt 1970-01-01 00:00:00 +0000
+++ tests/dk/aau/cs/io/TapnXmlLoaderTest.kt 2020-05-12 11:42:36 +0000
@@ -0,0 +1,313 @@
1package dk.aau.cs.io
2
3import org.junit.jupiter.api.Assertions
4import org.junit.jupiter.api.Disabled
5import org.junit.jupiter.api.Test
6import org.junit.jupiter.api.function.ThrowingSupplier
7
8
9
10internal class TapnXmlLoaderTest {
11
12 internal class MalformedXML {
13 @Test @Disabled
14 fun `Malformed XML should throw an exception`() {
15 val tapnXmlLoader = TapnXmlLoader();
16 Assertions.assertThrows(Exception::class.java) {
17 tapnXmlLoader.load("hello".asInpurtStream())
18 }
19 }
20 }
21
22 class Place {
23
24 @Test
25 fun `Parse place`() {
26 val net = xmlNet(
27 """
28 <place displayName="true" id="Start" initialMarking="1" invariant="&lt; inf" name="Start" nameOffsetX="-5" nameOffsetY="35" positionX="135" positionY="30"/>
29 """
30 ).asInpurtStream()
31 val tapnXmlLoader = TapnXmlLoader();
32
33 val r = Assertions.assertDoesNotThrow(ThrowingSupplier {
34 tapnXmlLoader.load(net)
35 })
36
37 Assertions.assertEquals(1, r.templates().first().guiModel().places.size)
38
39 val place = r.templates().first().guiModel().places[0]
40 Assertions.assertEquals("Start", place.name)
41 Assertions.assertEquals(135, place.positionX)
42 Assertions.assertEquals(30, place.positionY)
43
44 Assertions.assertEquals(-5, place.nameOffsetX)
45 Assertions.assertEquals(35, place.nameOffsetY)
46
47 }
48
49 @Test
50 //Older version of TAPAAL saved the positionX/Y and nameOffsetX/Y in double format eg. 35.0
51 fun `Place positions can be double formatted`(){
52
53 val net = xmlNet(
54 """
55 <place displayName="true" id="Start" initialMarking="1" invariant="&lt; inf" name="Start" nameOffsetX="-5.0" nameOffsetY="35.0" positionX="135.0" positionY="30.0"/>
56 """
57 ).asInpurtStream()
58 val tapnXmlLoader = TapnXmlLoader();
59
60 val r = Assertions.assertDoesNotThrow(ThrowingSupplier {
61 tapnXmlLoader.load(net)
62 })
63
64 val place = r.templates().first().guiModel().places[0]
65
66 Assertions.assertEquals(135, place.positionX)
67 Assertions.assertEquals(30, place.positionY)
68
69 Assertions.assertEquals(-5, place.nameOffsetX)
70 Assertions.assertEquals(35, place.nameOffsetY)
71
72 }
73
74 @Test
75 fun `Empty place`() {
76 val net = xmlNet("<place></place>").asInpurtStream()
77 val tapnXmlLoader = TapnXmlLoader()
78
79 Assertions.assertThrows(Exception::class.java){
80 tapnXmlLoader.load(net)
81 }
82 }
83
84
85 }
86
87 class Transition {
88 @Test
89 fun `Parse Transition`() {
90 val net = xmlNet(
91 """
92 <transition angle="90" displayName="true" id="T1" infiniteServer="false" name="T1" nameOffsetX="-5" nameOffsetY="35" positionX="360" positionY="300" priority="0" urgent="false"/>
93 """
94 ).asInpurtStream()
95 val tapnXmlLoader = TapnXmlLoader();
96
97 val r = Assertions.assertDoesNotThrow(ThrowingSupplier {
98 tapnXmlLoader.load(net)
99 })
100
101 Assertions.assertEquals(1, r.templates().first().guiModel().transitions.size)
102
103 val transition = r.templates().first().guiModel().transitions[0]
104 Assertions.assertEquals("T1", transition.name)
105 Assertions.assertEquals(360, transition.positionX)
106 Assertions.assertEquals(300, transition.positionY)
107
108 Assertions.assertEquals(-5, transition.nameOffsetX)
109 Assertions.assertEquals(35, transition.nameOffsetY)
110
111 }
112
113 @Test
114 //Older version of TAPAAL saved the positionX/Y and nameOffsetX/Y in double format eg. 35.0
115 fun `Transiton positions can be double formatted`(){
116 val net = xmlNet(
117 """
118 <transition angle="90" displayName="true" id="T1" infiniteServer="false" name="T1" nameOffsetX="-5" nameOffsetY="35" positionX="360" positionY="300" priority="0" urgent="false"/>
119 """
120 ).asInpurtStream()
121 val tapnXmlLoader = TapnXmlLoader();
122
123 val r = Assertions.assertDoesNotThrow(ThrowingSupplier {
124 tapnXmlLoader.load(net)
125 })
126
127 val transition = r.templates().first().guiModel().transitions[0]
128 Assertions.assertEquals(360, transition.positionX)
129 Assertions.assertEquals(300, transition.positionY)
130
131 Assertions.assertEquals(-5, transition.nameOffsetX)
132 Assertions.assertEquals(35, transition.nameOffsetY)
133
134 }
135
136 @Test
137 fun `Empty Transition`() {
138 val net = xmlNet("<transition></transition>").asInpurtStream()
139 val tapnXmlLoader = TapnXmlLoader()
140
141 Assertions.assertThrows(Exception::class.java){
142 tapnXmlLoader.load(net)
143 }
144 }
145
146 @Test
147 fun `if urgent not defined, default value is false`() {
148 val net = xmlNet("""
149 <transition angle="0" displayName="true" id="T1" infiniteServer="false" name="T1" nameOffsetX="-5" nameOffsetY="35" positionX="360" positionY="300" priority="0"/>
150 """).asInpurtStream()
151 val tapnXmlLoader = TapnXmlLoader()
152
153 val r = Assertions.assertDoesNotThrow(ThrowingSupplier {
154 tapnXmlLoader.load(net)
155 })
156
157 Assertions.assertFalse( r.network().allTemplates().first().getTransitionByName("T1").isUrgent )
158
159
160 }
161 }
162
163 class InputArc {
164 @Test
165 fun `Parse Input Arc`() {
166 val net = xmlNet(
167 """
168 <place displayName="true" id="P0" initialMarking="0" invariant="&lt; inf" name="P0" nameOffsetX="0" nameOffsetY="0" positionX="60" positionY="60"/>
169 <transition angle="0" displayName="true" id="T0" infiniteServer="false" name="T0" nameOffsetX="0" nameOffsetY="0" positionX="240" positionY="60" priority="0" urgent="false"/>
170 <arc id="P0 to T0" inscription="[0,inf)" nameOffsetX="0" nameOffsetY="0" source="P0" target="T0" type="timed" weight="1"></arc>
171 """
172 ).asInpurtStream()
173
174 val tapnXmlLoader = TapnXmlLoader()
175
176 val r = Assertions.assertDoesNotThrow(ThrowingSupplier {
177 tapnXmlLoader.load(net)
178 })
179 }
180 }
181
182 class OutputArc {
183 @Test
184 fun `Parse Output Arc`() {
185 val net = xmlNet(
186 """
187 <place displayName="true" id="P0" initialMarking="0" invariant="&lt; inf" name="P0" nameOffsetX="0" nameOffsetY="0" positionX="60" positionY="60"/>
188 <transition angle="0" displayName="true" id="T0" infiniteServer="false" name="T0" nameOffsetX="0" nameOffsetY="0" positionX="240" positionY="60" priority="0" urgent="false"/>
189 <arc id="T0 to P0" inscription="1" nameOffsetX="0" nameOffsetY="0" source="T0" target="P0" type="normal" weight="1"></arc>
190 """
191 ).asInpurtStream()
192
193 val tapnXmlLoader = TapnXmlLoader()
194
195 val r = Assertions.assertDoesNotThrow(ThrowingSupplier {
196 tapnXmlLoader.load(net)
197 })
198 }
199 }
200
201 class InhibitorArc {
202 @Test
203 fun `Inhibitor Arc`() {
204 val net = xmlNet(
205 """
206 <place displayName="true" id="P0" initialMarking="0" invariant="&lt; inf" name="P0" nameOffsetX="0" nameOffsetY="0" positionX="60" positionY="60"/>
207 <transition angle="0" displayName="true" id="T0" infiniteServer="false" name="T0" nameOffsetX="0" nameOffsetY="0" positionX="240" positionY="60" priority="0" urgent="false"/>
208 <arc id="P0 to T0" inscription="[0,inf)" nameOffsetX="0" nameOffsetY="0" source="P0" target="T0" type="tapnInhibitor" weight="1"></arc>
209 """
210 ).asInpurtStream()
211
212 val tapnXmlLoader = TapnXmlLoader()
213
214 val r = Assertions.assertDoesNotThrow(ThrowingSupplier {
215 tapnXmlLoader.load(net)
216 })
217 }
218 }
219
220 class TransportArc {
221 @Test
222 fun `Transport Arc`() {
223 val net = xmlNet(
224 """
225 <place displayName="true" id="P0" initialMarking="0" invariant="&lt; inf" name="P0" nameOffsetX="0" nameOffsetY="0" positionX="60" positionY="60"/>
226 <place displayName="true" id="P1" initialMarking="0" invariant="&lt; inf" name="P1" nameOffsetX="0" nameOffsetY="0" positionX="60" positionY="60"/>
227 <transition angle="0" displayName="true" id="T0" infiniteServer="false" name="T0" nameOffsetX="0" nameOffsetY="0" positionX="240" positionY="60" priority="0" urgent="false"/>
228 <arc id="T0 to P1" inscription="[0,inf):1" nameOffsetX="0" nameOffsetY="0" source="T0" target="P1" type="transport" weight="1"></arc>
229 <arc id="P0 to T0" inscription="[0,inf):1" nameOffsetX="0" nameOffsetY="0" source="P0" target="T0" type="transport" weight="1"></arc>
230 """
231 ).asInpurtStream()
232
233 val tapnXmlLoader = TapnXmlLoader()
234
235 val r = Assertions.assertDoesNotThrow(ThrowingSupplier {
236 tapnXmlLoader.load(net)
237 })
238 }
239
240 @Test @Disabled
241 fun `Transport missing parter, gives error`() {
242 val net = xmlNet(
243 """
244 <place displayName="true" id="P0" initialMarking="0" invariant="&lt; inf" name="P0" nameOffsetX="0" nameOffsetY="0" positionX="60" positionY="60"/>
245 <place displayName="true" id="P1" initialMarking="0" invariant="&lt; inf" name="P1" nameOffsetX="0" nameOffsetY="0" positionX="60" positionY="60"/>
246 <transition angle="0" displayName="true" id="T0" infiniteServer="false" name="T0" nameOffsetX="0" nameOffsetY="0" positionX="240" positionY="60" priority="0" urgent="false"/>
247 <arc id="P0 to T0" inscription="[0,inf):1" nameOffsetX="0" nameOffsetY="0" source="P0" target="T0" type="transport" weight="1"></arc>
248 """
249 ).asInpurtStream()
250
251 val tapnXmlLoader = TapnXmlLoader()
252
253 Assertions.assertThrows(java.lang.Exception::class.java) {
254 tapnXmlLoader.load(net)
255 }
256 }
257 }
258
259 class ArcPathPoints {
260 @Test
261 fun `Parse Arc without arcpathpoints`() {
262 val net = xmlNet(
263 """
264 <place displayName="true" id="P0" initialMarking="0" invariant="&lt; inf" name="P0" nameOffsetX="0" nameOffsetY="0" positionX="60" positionY="60"/>
265 <transition angle="0" displayName="true" id="T0" infiniteServer="false" name="T0" nameOffsetX="0" nameOffsetY="0" positionX="240" positionY="60" priority="0" urgent="false"/>
266 <arc id="P0 to T0" inscription="[0,inf)" nameOffsetX="0" nameOffsetY="0" source="P0" target="T0" type="timed" weight="1">
267 </arc>
268 """
269 ).asInpurtStream()
270
271 val tapnXmlLoader = TapnXmlLoader()
272
273 val r = Assertions.assertDoesNotThrow(ThrowingSupplier {
274 tapnXmlLoader.load(net)
275 })
276 }
277
278 @Test @Disabled
279 fun `Parse Arc with only one arcpathpoint should fail`() {
280 val net = xmlNet(
281 """
282 <place displayName="true" id="P0" initialMarking="0" invariant="&lt; inf" name="P0" nameOffsetX="0" nameOffsetY="0" positionX="60" positionY="60"/>
283 <transition angle="0" displayName="true" id="T0" infiniteServer="false" name="T0" nameOffsetX="0" nameOffsetY="0" positionX="240" positionY="60" priority="0" urgent="false"/>
284 <arc id="P0 to T0" inscription="[0,inf)" nameOffsetX="0" nameOffsetY="0" source="P0" target="T0" type="timed" weight="1">
285 <arcpath arcPointType="false" id="0" xCoord="87" yCoord="72"/>
286 </arc>
287 """
288 ).asInpurtStream()
289
290 val tapnXmlLoader = TapnXmlLoader()
291
292 Assertions.assertThrows(java.lang.Exception::class.java) {
293 tapnXmlLoader.load(net)
294 }
295 }
296 }
297}
298
299
300fun String.asInpurtStream() : java.io.InputStream {
301 return java.io.StringBufferInputStream(this)
302}
303
304fun xmlNet(s:String) : String {
305 return """
306 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
307 <pnml xmlns="http://www.informatik.hu-berlin.de/top/pnml/ptNetb">
308 <net active="true" id="IntroExample" type="P/T net">
309 $s
310 </net>
311 </pnml>
312 """.trimIndent()
313}
0\ No newline at end of file314\ No newline at end of file

Subscribers

People subscribed via source and target branches