Merge lp:~mhm/tapaal/tapaal-fix-873427 into lp:tapaal

Proposed by mhm
Status: Merged
Approved by: Kenneth Yrke Jørgensen
Approved revision: 641
Merged at revision: 641
Proposed branch: lp:~mhm/tapaal/tapaal-fix-873427
Merge into: lp:tapaal
Diff against target: 199 lines (+46/-25)
8 files modified
src/pipe/gui/DrawingSurfaceImpl.java (+1/-0)
src/pipe/gui/graphicElements/AnnotationNote.java (+1/-1)
src/pipe/gui/graphicElements/ArcPath.java (+6/-0)
src/pipe/gui/graphicElements/ArcPathPoint.java (+17/-4)
src/pipe/gui/graphicElements/PetriNetObject.java (+1/-1)
src/pipe/gui/graphicElements/tapn/TimedOutputArcComponent.java (+18/-17)
src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java (+1/-1)
src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java (+1/-1)
To merge this branch: bzr merge lp:~mhm/tapaal/tapaal-fix-873427
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Kenneth Yrke Jørgensen Approve
mhm (community) Approve
Review via email: mp+84592@code.launchpad.net

This proposal supersedes a proposal from 2011-12-06.

Commit message

Added, zoom "loading/update" functionality when setting the model of the DrawinSurface(DS), fixes bug 873427.

    When selecting a PN-component, the corresponding net is set as the model for the DS. But setting the model for the DS, did not update the zoom.

    This problem was introduced when adding the functionallity to copy components. Before models where only loaded from file, or as a new component, both always with zoom level 100%.

    But when copying a loaded component, it might not be at zoom level 100%, the new compenent had the right zoom level, but it was not loaded correctly.

    The graphical element where copied with a zoomed position, this did not work, as the graphical size of the elements where not "zoomed", and the position did not correspond to the zoom level.

    Now the graphical elements places, transitions and notes are copied with the original position, i.e. at zoom level 100%, and then they are updated when drawn on the DS.

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

Seems to work fine in most cases now, except for the situation when you have some control points
on arcs for making them curved. To see the problem, open e.g. the ABP in the examples, zoom to
50% and make a component copy. Then go to the copy and zoom back to 100%. All works as it should
except for the control points on arcs that stay as they were in the 50% zoom.

review: Needs Fixing
Revision history for this message
mhm (mhm) wrote : Posted in a previous version of this proposal

I have now fixed the problem Jiri mentioned.

Ready for a new review.

review: Needs Resubmitting
Revision history for this message
mhm (mhm) :
review: Approve
Revision history for this message
Jiri Srba (srba) wrote :

Works fine now.

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

Seens to work great

review: Approve
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
1=== modified file 'src/pipe/gui/DrawingSurfaceImpl.java'
2--- src/pipe/gui/DrawingSurfaceImpl.java 2011-11-27 10:15:02 +0000
3+++ src/pipe/gui/DrawingSurfaceImpl.java 2011-12-06 10:17:23 +0000
4@@ -153,6 +153,7 @@
5 this.removeAll();
6 setPreferredSize(new Dimension(0,0));
7 for (PetriNetObject pnObject : guiModel.getPetriNetObjects()) {
8+ pnObject.zoomUpdate(zoomer.getPercent());
9 add(pnObject);
10 }
11
12
13=== modified file 'src/pipe/gui/graphicElements/AnnotationNote.java'
14--- src/pipe/gui/graphicElements/AnnotationNote.java 2011-12-01 18:14:49 +0000
15+++ src/pipe/gui/graphicElements/AnnotationNote.java 2011-12-06 10:17:23 +0000
16@@ -326,7 +326,7 @@
17 }
18
19 public AnnotationNote copy() {
20- AnnotationNote annotation = new AnnotationNote(note.getText(), Zoomer.getUnzoomedValue(this.getX(), zoom), Zoomer.getUnzoomedValue(this.getY(), zoom), note.getWidth(), note.getHeight(), this.isShowingBorder());
21+ AnnotationNote annotation = new AnnotationNote(note.getText(), getOriginalX(), getOriginalY(), note.getWidth(), note.getHeight(), this.isShowingBorder());
22 AnnotationNoteHandler noteHandler = new AnnotationNoteHandler((DrawingSurfaceImpl)getParent(), annotation);
23 annotation.addMouseListener(noteHandler);
24 annotation.addMouseMotionListener(noteHandler);
25
26=== modified file 'src/pipe/gui/graphicElements/ArcPath.java'
27--- src/pipe/gui/graphicElements/ArcPath.java 2011-09-25 09:35:57 +0000
28+++ src/pipe/gui/graphicElements/ArcPath.java 2011-12-06 10:17:23 +0000
29@@ -312,6 +312,12 @@
30 public void addPoint(double x, double y, boolean type) {
31 pathPoints.add(new ArcPathPoint((float) x, (float) y, type, this));
32 }
33+
34+ public void addPoint(double x, double y, boolean type,int zoom) {
35+ pathPoints.add(new ArcPathPoint((float) x, (float) y, type, this,zoom));
36+ }
37+
38+
39
40 public void addPoint() {
41 pathPoints.add(new ArcPathPoint(this));
42
43=== modified file 'src/pipe/gui/graphicElements/ArcPathPoint.java'
44--- src/pipe/gui/graphicElements/ArcPathPoint.java 2011-09-23 20:48:39 +0000
45+++ src/pipe/gui/graphicElements/ArcPathPoint.java 2011-12-06 10:17:23 +0000
46@@ -44,7 +44,7 @@
47
48 private ArcPathPoint() {
49 copyPasteable = false; // we can't copy & paste indivial arc points!
50- zoom = 100;
51+ zoom = Pipe.ZOOM_DEFAULT;
52 }
53
54 public ArcPathPoint(ArcPath a) {
55@@ -59,6 +59,11 @@
56 setPointLocation(x, y);
57 pointType = _pointType;
58 }
59+
60+ public ArcPathPoint(float x, float y, boolean _pointType, ArcPath a, int zoomLevel) {
61+ this(x,y,_pointType,a);
62+ zoom = zoomLevel;
63+ }
64
65 /**
66 * @author Nadeem
67@@ -74,7 +79,7 @@
68 public void setPointLocation(float x, float y) {
69 double realX = Zoomer.getUnzoomedValue(x, zoom);
70 double realY = Zoomer.getUnzoomedValue(y, zoom);
71- realPoint.setLocation(realX, realY);
72+ getRealPoint().setLocation(realX, realY);
73 point.setLocation(x, y);
74 setBounds((int) x - SIZE, (int) y - SIZE, 2 * SIZE + SIZE_OFFSET, 2
75 * SIZE + SIZE_OFFSET);
76@@ -286,11 +291,19 @@
77 } else {
78 SIZE = 3;
79 }
80- float x = Zoomer.getZoomedValue(realPoint.x, zoom);
81- float y = Zoomer.getZoomedValue(realPoint.y, zoom);
82+ float x = Zoomer.getZoomedValue(getRealPoint().x, zoom);
83+ float y = Zoomer.getZoomedValue(getRealPoint().y, zoom);
84 point.setLocation(x, y);
85 setBounds((int) x - SIZE, (int) y - SIZE, 2 * SIZE + SIZE_OFFSET, 2
86 * SIZE + SIZE_OFFSET);
87 }
88
89+ public Point2D.Float getRealPoint() {
90+ return realPoint;
91+ }
92+
93+ public void setRealPoint(Point2D.Float realPoint) {
94+ this.realPoint = realPoint;
95+ }
96+
97 }
98
99=== modified file 'src/pipe/gui/graphicElements/PetriNetObject.java'
100--- src/pipe/gui/graphicElements/PetriNetObject.java 2011-10-14 12:03:06 +0000
101+++ src/pipe/gui/graphicElements/PetriNetObject.java 2011-12-06 10:17:23 +0000
102@@ -44,7 +44,7 @@
103 protected boolean markedAsDeleted = false;
104
105 // Integer value which represents a zoom percentage
106- protected int zoom = 100;
107+ protected int zoom = Pipe.ZOOM_DEFAULT;
108 private DataLayer guiModel;
109
110 public PetriNetObject() {
111
112=== modified file 'src/pipe/gui/graphicElements/tapn/TimedOutputArcComponent.java'
113--- src/pipe/gui/graphicElements/tapn/TimedOutputArcComponent.java 2011-09-23 21:23:31 +0000
114+++ src/pipe/gui/graphicElements/tapn/TimedOutputArcComponent.java 2011-12-06 10:17:23 +0000
115@@ -78,17 +78,18 @@
116 }
117
118 public TimedOutputArcComponent(TimedOutputArcComponent arc) {
119+ zoom = arc.zoom;
120 label = new NameLabel(zoom);
121-
122 myPath = new ArcPath(this);
123 for (int i = 0; i <= arc.myPath.getEndIndex(); i++) {
124- myPath.addPoint(arc.myPath.getPoint(i).getX(), arc.myPath.getPoint(i).getY(), arc.myPath.getPointType(i));
125+ myPath.addPoint(arc.myPath.getPoint(i).getX(), arc.myPath.getPoint(i).getY(), arc.myPath.getPointType(i),zoom);
126 }
127 myPath.createPath();
128 this.updateBounds();
129 id = arc.id;
130 this.setSource(arc.getSource());
131 this.setTarget(arc.getTarget());
132+
133 }
134
135 public TimedOutputArcComponent paste(double despX, double despY,
136@@ -209,22 +210,22 @@
137 }
138
139 public TimedOutputArcComponent copy(TimedArcPetriNet tapn, DataLayer guiModel, Hashtable<PlaceTransitionObject, PlaceTransitionObject> oldToNewMapping) {
140- TimedOutputArcComponent arc = new TimedOutputArcComponent(this);
141- arc.setSource(oldToNewMapping.get(this.getSource()));
142- arc.setTarget(oldToNewMapping.get(this.getTarget()));
143- arc.setUnderlyingArc(tapn.getOutputArcFromTransitionAndPlace(tapn.getTransitionByName(outputArc.source().name()), tapn.getPlaceByName(outputArc.destination().name())));
144-
145- arc.getSource().addConnectFrom(arc);
146- arc.getTarget().addConnectTo(arc);
147-
148- ArcHandler arcHandler = new ArcHandler((DrawingSurfaceImpl)getParent(), arc);
149- arc.addMouseListener(arcHandler);
150+ TimedOutputArcComponent newCopyArc = new TimedOutputArcComponent(this);
151+ newCopyArc.setSource(oldToNewMapping.get(this.getSource()));
152+ newCopyArc.setTarget(oldToNewMapping.get(this.getTarget()));
153+ newCopyArc.setUnderlyingArc(tapn.getOutputArcFromTransitionAndPlace(tapn.getTransitionByName(outputArc.source().name()), tapn.getPlaceByName(outputArc.destination().name())));
154+
155+ newCopyArc.getSource().addConnectFrom(newCopyArc);
156+ newCopyArc.getTarget().addConnectTo(newCopyArc);
157+
158+ ArcHandler arcHandler = new ArcHandler((DrawingSurfaceImpl)getParent(), newCopyArc);
159+ newCopyArc.addMouseListener(arcHandler);
160 //arc.addMouseWheelListener(arcHandler);
161- arc.addMouseMotionListener(arcHandler);
162-
163- arc.setGuiModel(guiModel);
164-
165- return arc;
166+ newCopyArc.addMouseMotionListener(arcHandler);
167+
168+ newCopyArc.setGuiModel(guiModel);
169+
170+ return newCopyArc;
171 }
172
173 }
174
175=== modified file 'src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java'
176--- src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java 2011-09-23 21:23:31 +0000
177+++ src/pipe/gui/graphicElements/tapn/TimedPlaceComponent.java 2011-12-06 10:17:23 +0000
178@@ -368,7 +368,7 @@
179 }
180
181 public TimedPlaceComponent copy(TimedArcPetriNet tapn, DataLayer guiModel) {
182- TimedPlaceComponent placeComponent = new TimedPlaceComponent(positionX, positionY, id, place.name(), nameOffsetX, nameOffsetY, 0, markingOffsetX, markingOffsetY, capacity);
183+ TimedPlaceComponent placeComponent = new TimedPlaceComponent(getPositionXObject(), getPositionYObject(), id, place.name(), nameOffsetX, nameOffsetY, 0, markingOffsetX, markingOffsetY, capacity);
184 placeComponent.setUnderlyingPlace(tapn.getPlaceByName(place.name()));
185
186 LabelHandler labelHandler = new LabelHandler(placeComponent.getNameLabel(), placeComponent);
187
188=== modified file 'src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java'
189--- src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java 2011-09-25 10:07:00 +0000
190+++ src/pipe/gui/graphicElements/tapn/TimedTransitionComponent.java 2011-12-06 10:17:23 +0000
191@@ -173,7 +173,7 @@
192 }
193
194 public TimedTransitionComponent copy(TimedArcPetriNet tapn, DataLayer guiModel) {
195- TimedTransitionComponent transitionComponent = new TimedTransitionComponent(positionX, positionY, id, transition.name(), nameOffsetX, nameOffsetY, true, false, getAngle(), 0);
196+ TimedTransitionComponent transitionComponent = new TimedTransitionComponent(getPositionXObject(), getPositionYObject(), id, transition.name(), nameOffsetX, nameOffsetY, true, false, getAngle(), 0);
197 transitionComponent.setUnderlyingTransition(tapn.getTransitionByName(transition.name()));
198
199 LabelHandler labelHandler = new LabelHandler(transitionComponent.getNameLabel(), transitionComponent);

Subscribers

People subscribed via source and target branches