Merge lp:~tapaal-contributor/tapaal/tikz-export-and-arc-labels-1786458 into lp:tapaal

Proposed by Peter Haahr Taankvist
Status: Merged
Approved by: Jiri Srba
Approved revision: 994
Merged at revision: 1000
Proposed branch: lp:~tapaal-contributor/tapaal/tikz-export-and-arc-labels-1786458
Merge into: lp:tapaal
Diff against target: 89 lines (+29/-25)
1 file modified
src/pipe/gui/TikZExporter.java (+29/-25)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/tikz-export-and-arc-labels-1786458
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Review via email: mp+364647@code.launchpad.net

Commit message

Labels of arcs are placed the same way as they look in tapaal. Sometimes it looks weird due to rounding, as the position of all elements are rounded.

To post a comment you must log in.
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/TikZExporter.java'
2--- src/pipe/gui/TikZExporter.java 2016-05-04 11:54:10 +0000
3+++ src/pipe/gui/TikZExporter.java 2019-03-16 13:06:19 +0000
4@@ -115,46 +115,48 @@
5 out.append(arc.getSource().getId());
6 out.append(") ");
7 out.append(arcPoints);
8- out.append("to[bend right=0] ");
9- out.append(arcLabel);
10- out.append(" (");
11+ out.append("to[bend right=0]");
12+ //out.append(arcLabel);
13+ out.append(" (");
14 out.append(arc.getTarget().getId());
15 out.append(") {};\n");
16+ out.append(arcLabel);
17 }
18 return out;
19 }
20
21 protected String getArcLabels(Arc arc) {
22 String arcLabel = "";
23+ String arcLabelPositionString = "\\draw (" + RoundCoordinate(arc.getNameLabel().getXPosition())+ "," + (RoundCoordinate(arc.getNameLabel().getYPosition())*(-1)) + ") node {";
24+
25 if (arc instanceof TimedInputArcComponent) {
26- if (net.netType().equals(NetType.UNTIMED)) {
27- if (arc.getWeight().value() > 1) {
28- arcLabel += "node[midway,auto] {$" + arc.getWeight().value() + "\\times$}\\ ";
29- }
30- return arcLabel;
31- }
32+ if (net.netType().equals(NetType.UNTIMED)) {
33+ if (arc.getWeight().value() > 1) {
34+ arcLabel += arcLabelPositionString + "$" + arc.getWeight().value() + "\\times$}\\;\n";
35+ }
36+ return arcLabel;
37+ }
38 if (!(arc.getSource() instanceof TimedTransitionComponent)) {
39- arcLabel = "node[midway,auto] {";
40- if (arc.getWeight().value() > 1) {
41- arcLabel += "$" + arc.getWeight().value() + "\\times$\\ ";
42- }
43+ arcLabel = arcLabelPositionString;
44+ if (arc.getWeight().value() > 1) {
45+ arcLabel += "$" + arc.getWeight().value() + "\\times$\\ ";
46+ }
47 arcLabel += "$\\mathrm{" + replaceWithMathLatex(((TimedInputArcComponent) arc).getGuardAsString(false)) + "}$";
48 if (arc instanceof TimedTransportArcComponent)
49 arcLabel += ":" + ((TimedTransportArcComponent) arc).getGroupNr();
50- arcLabel += "}";
51+ arcLabel += "};\n";
52 } else {
53- if (arc instanceof TimedTransportArcComponent)
54- arcLabel = "node[midway,auto] {";
55- if (arc.getWeight().value() > 1) {
56- arcLabel += "$" + arc.getWeight().value() + "\\times$\\ ";
57- }
58- arcLabel += ":" + ((TimedTransportArcComponent) arc).getGroupNr() + "}";
59+ arcLabel = arcLabelPositionString;
60+ if (arc.getWeight().value() > 1) {
61+ arcLabel += "$" + arc.getWeight().value() + "\\times$\\ ";
62+ }
63+ arcLabel += ":" + ((TimedTransportArcComponent) arc).getGroupNr() + "};\n";
64 }
65 } else {
66- if (arc.getWeight().value() > 1) {
67- arcLabel += "node[midway,auto] { $" + arc.getWeight().value() + "\\times$\\ }";
68- }
69- }
70+ if (arc.getWeight().value() > 1) {
71+ arcLabel += arcLabelPositionString + "$" + arc.getWeight().value() + "\\times$\\ };\n";
72+ }
73+ }
74 return arcLabel;
75 }
76
77@@ -277,9 +279,11 @@
78
79 out.append("\\begin{tikzpicture}[font=\\scriptsize, xscale=1, yscale=1]\n");
80 out.append("%% the figure can be scaled by changing xscale and yscale\n");
81- out.append("%% positions of labels that are currently fixed to label=135 degrees\n");
82+ out.append("%% positions of place/transition labels that are currently fixed to label=135 degrees\n");
83 out.append("%% can be adjusted so that they do not cover arcs\n");
84 out.append("%% similarly the curving of arcs can be done by adjusting bend left/right=XX\n");
85+ out.append("%% arc labels may be slightly skewed compared to the tapaal drawing due to rounding.\n");
86+ out.append("%% This can be adjusted by tuning the coordinates of the label of the respective arc\n");
87 out.append("\\tikzstyle{arc}=[->,>=stealth,thick]\n");
88
89 if (!net.netType().equals(NetType.UNTIMED)) out.append("\\tikzstyle{transportArc}=[->,>=diamond,thick]\n");

Subscribers

People subscribed via source and target branches