Merge lp:~tapaal-contributor/tapaal/fix-tikz-export-1945642 into lp:tapaal
- fix-tikz-export-1945642
- Merge into trunk
Status: | Superseded | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~tapaal-contributor/tapaal/fix-tikz-export-1945642 | ||||
Merge into: | lp:tapaal | ||||
Diff against target: |
403 lines (+224/-47) 1 file modified
src/pipe/gui/TikZExporter.java (+224/-47) |
||||
To merge this branch: | bzr merge lp:~tapaal-contributor/tapaal/fix-tikz-export-1945642 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jiri Srba | Pending | ||
Review via email:
|
This proposal supersedes a proposal from 2021-10-10.
This proposal has been superseded by a proposal from 2021-10-14.
Commit message
Improved quality of Tikz export and various fixes
Description of the change
1. Fixed transition rotation
2. Added support for dots (replaces marking #1-5 with dots, like in the GUI)
3. Now correctly shows a place's marking (#1-2) like in the GUI
4. Improved location of place labels
5. Improved location of transition labels
6. Improved location of arc labels
7. Improved scaling so that some nets are no longer 'squished' together
8. Now currecly exports curved arcs
Other comments:
In some nets, labels for places, transitions and arcs are not positioned optimally like in the GUI. It has been difficult to find a solution to this, as some ways works for some of the nets while making other nets looks significantly worse. I'm not sure why this is. I have a suspicion it is due to the X- and Y coordinates of the labels somehow not being correct, or due to some other unintentional sideeffects. I have tried a lot of different ways to place these labels as close as possible, and have settled on the current result.
Unmerged revisions
Preview Diff
1 | === modified file 'src/pipe/gui/TikZExporter.java' | |||
2 | --- src/pipe/gui/TikZExporter.java 2020-08-04 08:19:44 +0000 | |||
3 | +++ src/pipe/gui/TikZExporter.java 2021-10-14 20:24:42 +0000 | |||
4 | @@ -27,11 +27,6 @@ | |||
5 | 27 | private final DataLayer net; | 27 | private final DataLayer net; |
6 | 28 | private final String fullpath; | 28 | private final String fullpath; |
7 | 29 | private final TikZOutputOption option; | 29 | private final TikZOutputOption option; |
8 | 30 | private final double scale = 1.0 / 55.0; | ||
9 | 31 | |||
10 | 32 | private double RoundCoordinate(double position) { | ||
11 | 33 | return Math.round(position * scale * 10)/10.0d; | ||
12 | 34 | } | ||
13 | 35 | 30 | ||
14 | 36 | public TikZExporter(DataLayer net, String fullpath, TikZOutputOption option) { | 31 | public TikZExporter(DataLayer net, String fullpath, TikZOutputOption option) { |
15 | 37 | this.net = net; | 32 | this.net = net; |
16 | @@ -75,37 +70,44 @@ | |||
17 | 75 | } catch (IOException e) { | 70 | } catch (IOException e) { |
18 | 76 | 71 | ||
19 | 77 | } finally { | 72 | } finally { |
26 | 78 | if (out != null) | 73 | if (out != null) { |
27 | 79 | out.close(); | 74 | out.close(); |
28 | 80 | if (outFile != null) | 75 | } |
29 | 81 | try { | 76 | if (outFile != null) { |
30 | 82 | outFile.close(); | 77 | try { |
31 | 83 | } catch (IOException e2) { | 78 | outFile.close(); |
32 | 79 | } catch (IOException e2) { | ||
33 | 84 | 80 | ||
35 | 85 | } | 81 | } |
36 | 82 | } | ||
37 | 86 | } | 83 | } |
38 | 87 | } | 84 | } |
39 | 88 | 85 | ||
40 | 89 | private StringBuffer exportArcs(Arc[] arcs) { | 86 | private StringBuffer exportArcs(Arc[] arcs) { |
41 | 90 | StringBuffer out = new StringBuffer(); | 87 | StringBuffer out = new StringBuffer(); |
42 | 88 | |||
43 | 91 | for (Arc arc : arcs) { | 89 | for (Arc arc : arcs) { |
44 | 92 | String arcPoints = ""; | 90 | String arcPoints = ""; |
45 | 91 | |||
46 | 93 | for (int i = 1; i < arc.getArcPath().getEndIndex(); i++) { | 92 | for (int i = 1; i < arc.getArcPath().getEndIndex(); i++) { |
62 | 94 | ArcPathPoint point = arc.getArcPath().getArcPathPoint(i); | 93 | ArcPathPoint currentPoint = arc.getArcPath().getArcPathPoint(i); |
63 | 95 | arcPoints += "to[bend right=0] (" + RoundCoordinate(point.getX()) + "," + RoundCoordinate(point.getY() * (-1)) + ") "; | 94 | |
64 | 96 | } | 95 | if(currentPoint.getPointType() == ArcPathPoint.STRAIGHT) { |
65 | 97 | 96 | arcPoints += "to[bend right=0] (" + (currentPoint.getX()) + "," + (currentPoint.getY() * (-1)) + ") "; | |
66 | 98 | String arrowType = ""; | 97 | } else if (currentPoint.getPointType() == ArcPathPoint.CURVED) { |
67 | 99 | if (arc instanceof TimedInhibitorArcComponent) { | 98 | double xCtrl1 = Math.round(currentPoint.getControl1().getX()); |
68 | 100 | arrowType = "inhibArc"; | 99 | double yCtrl1 = Math.round(currentPoint.getControl1().getY() * (-1)); |
69 | 101 | } else if (arc instanceof TimedTransportArcComponent) { | 100 | double xCtrl2 = Math.round(currentPoint.getControl2().getX()); |
70 | 102 | arrowType = "transportArc"; | 101 | double yCtrl2 = Math.round(currentPoint.getControl2().getY() * (-1)); |
71 | 103 | } else if (arc instanceof TimedInputArcComponent) { | 102 | |
72 | 104 | arrowType = "arc"; | 103 | arcPoints += " .. controls(" + xCtrl1 + "," + yCtrl1 + ")"; |
73 | 105 | } else { | 104 | arcPoints += " and "; |
74 | 106 | arrowType = "arc"; | 105 | arcPoints += "(" + xCtrl2 + "," + yCtrl2 + ") .. "; |
75 | 107 | } | 106 | arcPoints += "(" + currentPoint.getX() + "," + currentPoint.getY() * (-1) + ") "; |
76 | 108 | 107 | } | |
77 | 108 | } | ||
78 | 109 | |||
79 | 110 | String arrowType = getArcArrowType(arc); | ||
80 | 109 | String arcLabel = getArcLabels(arc); | 111 | String arcLabel = getArcLabels(arc); |
81 | 110 | 112 | ||
82 | 111 | out.append("\\draw["); | 113 | out.append("\\draw["); |
83 | @@ -115,7 +117,6 @@ | |||
84 | 115 | out.append(") "); | 117 | out.append(") "); |
85 | 116 | out.append(arcPoints); | 118 | out.append(arcPoints); |
86 | 117 | out.append("to[bend right=0]"); | 119 | out.append("to[bend right=0]"); |
87 | 118 | //out.append(arcLabel); | ||
88 | 119 | out.append(" ("); | 120 | out.append(" ("); |
89 | 120 | out.append(arc.getTarget().getId()); | 121 | out.append(arc.getTarget().getId()); |
90 | 121 | out.append(") {};\n"); | 122 | out.append(") {};\n"); |
91 | @@ -126,9 +127,23 @@ | |||
92 | 126 | return out; | 127 | return out; |
93 | 127 | } | 128 | } |
94 | 128 | 129 | ||
95 | 130 | private String getArcArrowType(Arc arc) { | ||
96 | 131 | String arrowType = ""; | ||
97 | 132 | if (arc instanceof TimedInhibitorArcComponent) { | ||
98 | 133 | arrowType = "inhibArc"; | ||
99 | 134 | } else if (arc instanceof TimedTransportArcComponent) { | ||
100 | 135 | arrowType = "transportArc"; | ||
101 | 136 | } else if (arc instanceof TimedInputArcComponent) { | ||
102 | 137 | arrowType = "arc"; | ||
103 | 138 | } else { | ||
104 | 139 | arrowType = "arc"; | ||
105 | 140 | } | ||
106 | 141 | return arrowType; | ||
107 | 142 | } | ||
108 | 143 | |||
109 | 129 | protected String getArcLabels(Arc arc) { | 144 | protected String getArcLabels(Arc arc) { |
110 | 130 | String arcLabel = ""; | 145 | String arcLabel = ""; |
112 | 131 | String arcLabelPositionString = "\\draw (" + RoundCoordinate(arc.getNameLabel().getXPosition())+ "," + (RoundCoordinate(arc.getNameLabel().getYPosition())*(-1)) + ") node {"; | 146 | String arcLabelPositionString = "\\draw (" + (arc.getNameLabel().getX()) + "," + (arc.getNameLabel().getY())*(-1) + ") node {"; |
113 | 132 | 147 | ||
114 | 133 | if (arc instanceof TimedInputArcComponent) { | 148 | if (arc instanceof TimedInputArcComponent) { |
115 | 134 | if (!(arc.getSource() instanceof TimedTransitionComponent)) { | 149 | if (!(arc.getSource() instanceof TimedTransitionComponent)) { |
116 | @@ -136,10 +151,16 @@ | |||
117 | 136 | if (arc.getWeight().value() > 1) { | 151 | if (arc.getWeight().value() > 1) { |
118 | 137 | arcLabel += "$" + arc.getWeight().value() + "\\times$\\ "; | 152 | arcLabel += "$" + arc.getWeight().value() + "\\times$\\ "; |
119 | 138 | } | 153 | } |
124 | 139 | arcLabel += "$\\mathrm{" + replaceWithMathLatex(getGuardAsStringIfNotHidden((TimedInputArcComponent) arc)) + "}$"; | 154 | |
125 | 140 | if (arc instanceof TimedTransportArcComponent) | 155 | if(CreateGui.getApp().getCurrentTab().getLens().isTimed()) { |
126 | 141 | arcLabel += ":" + ((TimedTransportArcComponent) arc).getGroupNr(); | 156 | arcLabel += "$\\mathrm{" + replaceWithMathLatex(getGuardAsStringIfNotHidden((TimedInputArcComponent) arc)) + "}$"; |
127 | 142 | arcLabel += "};\n"; | 157 | if (arc instanceof TimedTransportArcComponent) |
128 | 158 | arcLabel += ":" + ((TimedTransportArcComponent) arc).getGroupNr(); | ||
129 | 159 | arcLabel += "};\n"; | ||
130 | 160 | } else { | ||
131 | 161 | arcLabel += "};\n"; | ||
132 | 162 | } | ||
133 | 163 | |||
134 | 143 | } else { | 164 | } else { |
135 | 144 | arcLabel = arcLabelPositionString; | 165 | arcLabel = arcLabelPositionString; |
136 | 145 | if (arc.getWeight().value() > 1) { | 166 | if (arc.getWeight().value() > 1) { |
137 | @@ -147,16 +168,17 @@ | |||
138 | 147 | } | 168 | } |
139 | 148 | arcLabel += ":" + ((TimedTransportArcComponent) arc).getGroupNr() + "};\n"; | 169 | arcLabel += ":" + ((TimedTransportArcComponent) arc).getGroupNr() + "};\n"; |
140 | 149 | } | 170 | } |
141 | 171 | |||
142 | 150 | } else { | 172 | } else { |
143 | 151 | if (arc.getWeight().value() > 1) { | 173 | if (arc.getWeight().value() > 1) { |
145 | 152 | arcLabel += arcLabelPositionString + "$" + arc.getWeight().value() + "\\times$\\ };\n"; | 174 | arcLabel += arcLabelPositionString + "$" + arc.getWeight().value() + "\\times$\\ };\n"; |
146 | 153 | } | 175 | } |
147 | 154 | } | 176 | } |
148 | 155 | return arcLabel; | 177 | return arcLabel; |
149 | 156 | } | 178 | } |
150 | 157 | 179 | ||
151 | 158 | private String getGuardAsStringIfNotHidden(TimedInputArcComponent arc) { | 180 | private String getGuardAsStringIfNotHidden(TimedInputArcComponent arc) { |
153 | 159 | if (!CreateGui.getApp().showZeroToInfinityIntervals() && arc.getGuardAsString().equals("[0,inf)")){ | 181 | if (!CreateGui.getApp().showZeroToInfinityIntervals() && arc.getGuardAsString().equals("[0,inf)")){ |
154 | 160 | return ""; | 182 | return ""; |
155 | 161 | } else { | 183 | } else { |
156 | 162 | return arc.getGuardAsString(); | 184 | return arc.getGuardAsString(); |
157 | @@ -168,14 +190,15 @@ | |||
158 | 168 | for (Transition trans : transitions) { | 190 | for (Transition trans : transitions) { |
159 | 169 | String angle = ""; | 191 | String angle = ""; |
160 | 170 | if (trans.getAngle() != 0) | 192 | if (trans.getAngle() != 0) |
162 | 171 | angle = ",rotate=" + (trans.getAngle() + 90); | 193 | angle = ",rotate=-" + (trans.getAngle()); |
163 | 194 | |||
164 | 172 | 195 | ||
165 | 173 | out.append("\\node[transition"); | 196 | out.append("\\node[transition"); |
166 | 174 | out.append(angle); | 197 | out.append(angle); |
167 | 175 | out.append("] at ("); | 198 | out.append("] at ("); |
169 | 176 | out.append(RoundCoordinate(trans.getPositionX())); | 199 | out.append((trans.getPositionX())); |
170 | 177 | out.append(','); | 200 | out.append(','); |
172 | 178 | out.append(RoundCoordinate(trans.getPositionY() * (-1))); | 201 | out.append((trans.getPositionY() * (-1))); |
173 | 179 | out.append(") ("); | 202 | out.append(") ("); |
174 | 180 | out.append(trans.getId()); | 203 | out.append(trans.getId()); |
175 | 181 | out.append(") {};\n"); | 204 | out.append(") {};\n"); |
176 | @@ -203,9 +226,13 @@ | |||
177 | 203 | out.append(".center) { };\n"); | 226 | out.append(".center) { };\n"); |
178 | 204 | } | 227 | } |
179 | 205 | if (trans.getAttributesVisible()){ | 228 | if (trans.getAttributesVisible()){ |
180 | 229 | boolean isLabelAboveTransition = trans.getY() > trans.getNameLabel().getY(); | ||
181 | 230 | boolean isLabelBehindTrans = trans.getX() < trans.getNameLabel().getX(); | ||
182 | 231 | double xOffset = trans.getName().length() > 5 && !isLabelAboveTransition && !isLabelBehindTrans ? trans.getLayerOffset() : 0; | ||
183 | 232 | |||
184 | 206 | out.append("%% label for transition " + trans.getName() + "\n"); | 233 | out.append("%% label for transition " + trans.getName() + "\n"); |
185 | 207 | out.append("\\draw ("); | 234 | out.append("\\draw ("); |
187 | 208 | out.append(RoundCoordinate(trans.getNameLabel().getXPosition()) + "," + (RoundCoordinate(trans.getNameLabel().getYPosition()) * -1) + ")"); | 235 | out.append(trans.getNameLabel().getX() + xOffset + "," + (trans.getNameLabel().getY() * -1) + ")"); |
188 | 209 | out.append(" node "); | 236 | out.append(" node "); |
189 | 210 | out.append(" {"); | 237 | out.append(" {"); |
190 | 211 | out.append(exportMathName(trans.getName())); | 238 | out.append(exportMathName(trans.getName())); |
191 | @@ -217,19 +244,21 @@ | |||
192 | 217 | 244 | ||
193 | 218 | private StringBuffer exportPlacesWithTokens(Place[] places) { | 245 | private StringBuffer exportPlacesWithTokens(Place[] places) { |
194 | 219 | StringBuffer out = new StringBuffer(); | 246 | StringBuffer out = new StringBuffer(); |
195 | 247 | |||
196 | 220 | for (Place place : places) { | 248 | for (Place place : places) { |
197 | 221 | String invariant = getPlaceInvariantString(place); | 249 | String invariant = getPlaceInvariantString(place); |
198 | 222 | String tokensInPlace = getTokenListStringFor(place); | 250 | String tokensInPlace = getTokenListStringFor(place); |
199 | 223 | 251 | ||
200 | 224 | out.append("\\node[place"); | 252 | out.append("\\node[place"); |
201 | 225 | out.append(tokensInPlace); | ||
202 | 226 | out.append("] at ("); | 253 | out.append("] at ("); |
204 | 227 | out.append(RoundCoordinate(place.getPositionX())); | 254 | out.append(place.getPositionX()); |
205 | 228 | out.append(','); | 255 | out.append(','); |
207 | 229 | out.append(RoundCoordinate(place.getPositionY() * (-1))); | 256 | out.append(place.getPositionY() * (-1)); |
208 | 230 | out.append(") ("); | 257 | out.append(") ("); |
209 | 231 | out.append(place.getId()); | 258 | out.append(place.getId()); |
210 | 232 | out.append(") {};\n"); | 259 | out.append(") {};\n"); |
211 | 260 | |||
212 | 261 | exportPlaceTokens(place, out, ((TimedPlaceComponent) place).underlyingPlace().tokens().size()); | ||
213 | 233 | 262 | ||
214 | 234 | if(((TimedPlaceComponent)place).underlyingPlace().isShared()){ | 263 | if(((TimedPlaceComponent)place).underlyingPlace().isShared()){ |
215 | 235 | out.append("\\node[sharedplace] at ("); | 264 | out.append("\\node[sharedplace] at ("); |
216 | @@ -237,9 +266,14 @@ | |||
217 | 237 | out.append(".center) { };\n"); | 266 | out.append(".center) { };\n"); |
218 | 238 | } | 267 | } |
219 | 239 | if (place.getAttributesVisible() || !invariant.equals("")){ | 268 | if (place.getAttributesVisible() || !invariant.equals("")){ |
220 | 269 | boolean isLabelAbovePlace = place.getY() > place.getNameLabel().getY(); | ||
221 | 270 | boolean isLabelBehindPlace = place.getX() < place.getNameLabel().getX(); | ||
222 | 271 | double xOffset = place.getName().length() > 6 && !isLabelAbovePlace && !isLabelBehindPlace ? place.getLayerOffset() : 0; | ||
223 | 272 | double yOffset = isLabelAbovePlace ? (place.getNameLabel().getHeight() / 2) : 0; | ||
224 | 273 | |||
225 | 240 | out.append("%% label for place " + place.getName() + "\n"); | 274 | out.append("%% label for place " + place.getName() + "\n"); |
226 | 241 | out.append("\\draw ("); | 275 | out.append("\\draw ("); |
228 | 242 | out.append(RoundCoordinate(place.getNameLabel().getXPosition()) + "," + (RoundCoordinate(place.getNameLabel().getYPosition()) * -1) + ")"); | 276 | out.append((place.getNameLabel().getX() + xOffset) + "," + ((place.getNameLabel().getY() * -1) + yOffset) +")"); |
229 | 243 | out.append(" node[align=left] "); | 277 | out.append(" node[align=left] "); |
230 | 244 | out.append("{"); | 278 | out.append("{"); |
231 | 245 | if(place.getAttributesVisible()) | 279 | if(place.getAttributesVisible()) |
232 | @@ -252,16 +286,159 @@ | |||
233 | 252 | out.append("};\n"); | 286 | out.append("};\n"); |
234 | 253 | } | 287 | } |
235 | 254 | 288 | ||
237 | 255 | } | 289 | } |
238 | 256 | } | 290 | } |
239 | 257 | 291 | ||
240 | 258 | return out; | 292 | return out; |
241 | 259 | } | 293 | } |
242 | 260 | 294 | ||
243 | 295 | private void exportPlaceTokens(Place place, StringBuffer out, int numOfTokens) { | ||
244 | 296 | // Dot radius | ||
245 | 297 | final double tRadius = 1; | ||
246 | 298 | |||
247 | 299 | // Token dot position offsets | ||
248 | 300 | final double tLeftX = 7; | ||
249 | 301 | final double tRightX = 7; | ||
250 | 302 | final double tTopY = 7; | ||
251 | 303 | final double tBotY = 7; | ||
252 | 304 | |||
253 | 305 | boolean isTimed = CreateGui.getApp().getCurrentTab().getLens().isTimed(); | ||
254 | 306 | |||
255 | 307 | double placeXpos = (place.getPositionX()); | ||
256 | 308 | double placeYpos = (place.getPositionY() * (-1)); | ||
257 | 309 | double xPos, yPos; | ||
258 | 310 | |||
259 | 311 | if(isTimed && numOfTokens > 0) { | ||
260 | 312 | switch (numOfTokens) { | ||
261 | 313 | case 2: | ||
262 | 314 | out.append("\\node at ("); // Top | ||
263 | 315 | out.append(placeXpos); | ||
264 | 316 | out.append(","); | ||
265 | 317 | out.append(placeYpos + 4); | ||
266 | 318 | out.append(")"); | ||
267 | 319 | out.append("{0,0};\n"); | ||
268 | 320 | |||
269 | 321 | out.append("\\node at ("); // Bottom | ||
270 | 322 | out.append(placeXpos); | ||
271 | 323 | out.append(","); | ||
272 | 324 | out.append(placeYpos - 5); | ||
273 | 325 | out.append(")"); | ||
274 | 326 | out.append("{0,0};\n"); | ||
275 | 327 | return; | ||
276 | 328 | case 1: | ||
277 | 329 | out.append("\\node at ("); // Top | ||
278 | 330 | out.append(placeXpos); | ||
279 | 331 | out.append(","); | ||
280 | 332 | out.append(placeYpos); | ||
281 | 333 | out.append(")"); | ||
282 | 334 | out.append("{0,0};\n"); | ||
283 | 335 | return; | ||
284 | 336 | default: | ||
285 | 337 | out.append("\\node at ("); | ||
286 | 338 | out.append(placeXpos); | ||
287 | 339 | out.append(","); | ||
288 | 340 | out.append(placeYpos); | ||
289 | 341 | out.append(")"); | ||
290 | 342 | out.append("{$\\mathrm{"); | ||
291 | 343 | out.append("\\#" + numOfTokens + "}$};\n"); | ||
292 | 344 | return; | ||
293 | 345 | } | ||
294 | 346 | } else if(numOfTokens > 5 && !isTimed ) { | ||
295 | 347 | out.append("\\node at ("); | ||
296 | 348 | out.append(placeXpos); | ||
297 | 349 | out.append(","); | ||
298 | 350 | out.append(placeYpos); | ||
299 | 351 | out.append(")"); | ||
300 | 352 | out.append("{$\\mathrm{"); | ||
301 | 353 | out.append("\\#" + numOfTokens + "}$};\n"); | ||
302 | 354 | return; | ||
303 | 355 | } | ||
304 | 356 | |||
305 | 357 | switch (numOfTokens) { | ||
306 | 358 | case 5: // middle | ||
307 | 359 | out.append("\\node at ("); | ||
308 | 360 | out.append(placeXpos); | ||
309 | 361 | out.append(","); | ||
310 | 362 | out.append(placeYpos); | ||
311 | 363 | out.append(")"); | ||
312 | 364 | out.append("[circle,fill,inner sep="); | ||
313 | 365 | out.append(tRadius); | ||
314 | 366 | out.append("pt]{};\n"); | ||
315 | 367 | /* falls through */ | ||
316 | 368 | case 4: // top left | ||
317 | 369 | out.append("\\node at ("); | ||
318 | 370 | out.append(placeXpos - tLeftX); | ||
319 | 371 | out.append(","); | ||
320 | 372 | out.append(placeYpos + tTopY); | ||
321 | 373 | out.append(")"); | ||
322 | 374 | out.append("[circle,fill,inner sep="); | ||
323 | 375 | out.append(tRadius); | ||
324 | 376 | out.append("pt]{};\n"); | ||
325 | 377 | /* falls through */ | ||
326 | 378 | case 3: | ||
327 | 379 | if(numOfTokens == 5 || numOfTokens == 4) { // top right | ||
328 | 380 | xPos = placeXpos + tRightX; | ||
329 | 381 | yPos = placeYpos + tTopY; | ||
330 | 382 | } else { // top left | ||
331 | 383 | xPos = placeXpos - tLeftX; | ||
332 | 384 | yPos = placeYpos + tTopY; | ||
333 | 385 | } | ||
334 | 386 | out.append("\\node at ("); | ||
335 | 387 | out.append(xPos); | ||
336 | 388 | out.append(","); | ||
337 | 389 | out.append(yPos); | ||
338 | 390 | out.append(")"); | ||
339 | 391 | out.append("[circle,fill,inner sep="); | ||
340 | 392 | out.append(tRadius); | ||
341 | 393 | out.append("pt]{};\n"); | ||
342 | 394 | /* falls through */ | ||
343 | 395 | case 2: | ||
344 | 396 | if(numOfTokens == 5 || numOfTokens == 4) { // bottom left | ||
345 | 397 | xPos = placeXpos - tLeftX; | ||
346 | 398 | yPos = placeYpos - tBotY; | ||
347 | 399 | } else if (numOfTokens == 3){ // middle | ||
348 | 400 | xPos = placeXpos; | ||
349 | 401 | yPos = placeYpos; | ||
350 | 402 | } else { // left middle | ||
351 | 403 | xPos = placeXpos - tLeftX; | ||
352 | 404 | yPos = placeYpos; | ||
353 | 405 | } | ||
354 | 406 | out.append("\\node at ("); | ||
355 | 407 | out.append(xPos); | ||
356 | 408 | out.append(","); | ||
357 | 409 | out.append(yPos); | ||
358 | 410 | out.append(")"); | ||
359 | 411 | out.append("[circle,fill,inner sep="); | ||
360 | 412 | out.append(tRadius); | ||
361 | 413 | out.append("pt]{};\n"); | ||
362 | 414 | /* falls through */ | ||
363 | 415 | case 1: | ||
364 | 416 | if(numOfTokens == 5 || numOfTokens == 4 || numOfTokens == 3) { // bottom right | ||
365 | 417 | xPos = placeXpos + tRightX; | ||
366 | 418 | yPos = placeYpos - tBotY; | ||
367 | 419 | } else if (numOfTokens == 2){ // right middle | ||
368 | 420 | xPos = placeXpos + tRightX; | ||
369 | 421 | yPos = placeYpos; | ||
370 | 422 | } else { // middle | ||
371 | 423 | xPos = placeXpos; | ||
372 | 424 | yPos = placeYpos; | ||
373 | 425 | } | ||
374 | 426 | out.append("\\node at ("); | ||
375 | 427 | out.append(xPos); | ||
376 | 428 | out.append(","); | ||
377 | 429 | out.append(yPos); | ||
378 | 430 | out.append(")"); | ||
379 | 431 | out.append("[circle,fill,inner sep="); | ||
380 | 432 | out.append(tRadius); | ||
381 | 433 | out.append("pt]{};\n"); | ||
382 | 434 | default: | ||
383 | 435 | break; | ||
384 | 436 | } | ||
385 | 437 | } | ||
386 | 438 | |||
387 | 261 | protected String getTokenListStringFor(Place place) { | 439 | protected String getTokenListStringFor(Place place) { |
388 | 262 | |||
389 | 263 | List<TimedToken> tokens = ((TimedPlaceComponent) place).underlyingPlace().tokens(); | 440 | List<TimedToken> tokens = ((TimedPlaceComponent) place).underlyingPlace().tokens(); |
391 | 264 | 441 | ||
392 | 265 | String tokensInPlace = ""; | 442 | String tokensInPlace = ""; |
393 | 266 | if (tokens.size() > 0) { | 443 | if (tokens.size() > 0) { |
394 | 267 | if (tokens.size() == 1) { | 444 | if (tokens.size() == 1) { |
395 | @@ -301,7 +478,7 @@ | |||
396 | 301 | private StringBuffer exportTikZstyle() { | 478 | private StringBuffer exportTikZstyle() { |
397 | 302 | StringBuffer out = new StringBuffer(); | 479 | StringBuffer out = new StringBuffer(); |
398 | 303 | 480 | ||
400 | 304 | out.append("\\begin{tikzpicture}[font=\\scriptsize, xscale=1, yscale=1]\n"); | 481 | out.append("\\begin{tikzpicture}[font=\\scriptsize, xscale=0.45, yscale=0.45, x=1.33px, y=1.33px]\n"); |
401 | 305 | out.append("%% the figure can be scaled by changing xscale and yscale\n"); | 482 | out.append("%% the figure can be scaled by changing xscale and yscale\n"); |
402 | 306 | out.append("%% positions of place/transition labels that are currently fixed to label=135 degrees\n"); | 483 | out.append("%% positions of place/transition labels that are currently fixed to label=135 degrees\n"); |
403 | 307 | out.append("%% can be adjusted so that they do not cover arcs\n"); | 484 | out.append("%% can be adjusted so that they do not cover arcs\n"); |