Merge lp:~tapaal-contributor/tapaal/tikz-export-label-placement-1820528 into lp:tapaal

Proposed by Peter Haahr Taankvist
Status: Merged
Approved by: Jiri Srba
Approved revision: 1002
Merged at revision: 1004
Proposed branch: lp:~tapaal-contributor/tapaal/tikz-export-label-placement-1820528
Merge into: lp:tapaal
Diff against target: 131 lines (+36/-18)
1 file modified
src/pipe/gui/TikZExporter.java (+36/-18)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/tikz-export-label-placement-1820528
Reviewer Review Type Date Requested Status
Jiri Srba Approve
Review via email: mp+364685@code.launchpad.net

Commit message

Label placement for places and transitions when exporting to tikz now functions the same as for arcs, meaning that there is still a slight rounding issue where the label positions are skewed.

To post a comment you must log in.
Revision history for this message
Jiri Srba (srba) :
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/TikZExporter.java'
2--- src/pipe/gui/TikZExporter.java 2019-03-16 13:01:21 +0000
3+++ src/pipe/gui/TikZExporter.java 2019-03-18 17:00:20 +0000
4@@ -120,6 +120,8 @@
5 out.append(" (");
6 out.append(arc.getTarget().getId());
7 out.append(") {};\n");
8+ if(arcLabel != "")
9+ out.append("%% Label for arc between " + arc.getSource().getName() + " and " + arc.getTarget().getName() + "\n");
10 out.append(arcLabel);
11 }
12 return out;
13@@ -168,11 +170,7 @@
14 angle = ",rotate=" + String.valueOf(trans.getAngle() + 90);
15
16 out.append("\\node[transition");
17- out.append(angle);
18- if (trans.getAttributesVisible()){
19- out.append(",label=135:");
20- out.append(exportMathName(trans.getName()));
21- }
22+ out.append(angle);
23 out.append("] at (");
24 out.append(RoundCoordinate(trans.getPositionX()));
25 out.append(',');
26@@ -189,13 +187,22 @@
27 out.append(".center) { };\n");
28 }
29
30- if(((TimedTransitionComponent)trans).underlyingTransition().isUrgent()){
31+ if(((TimedTransitionComponent)trans).underlyingTransition().isUrgent()){
32 out.append("\\node[urgenttransition");
33 out.append(angle);
34 out.append("] at (");
35 out.append(trans.getId());
36 out.append(".center) { };\n");
37 }
38+ if (trans.getAttributesVisible()){
39+ out.append("%% label for transition " + trans.getName() + "\n");
40+ out.append("\\draw (");
41+ out.append(RoundCoordinate(trans.getNameLabel().getXPosition()) + "," + (RoundCoordinate(trans.getNameLabel().getYPosition()) * -1) + ")");
42+ out.append(" node ");
43+ out.append(" {");
44+ out.append(exportMathName(trans.getName()));
45+ out.append("};\n");
46+ }
47 }
48 return out;
49 }
50@@ -207,12 +214,6 @@
51 String tokensInPlace = getTokenListStringFor(place);
52
53 out.append("\\node[place");
54- if (place.getAttributesVisible()){
55- out.append(",label=135:");
56- out.append(exportMathName(place.getName()));
57- }
58- out.append(',');
59- out.append(invariant);
60 out.append(tokensInPlace);
61 out.append("] at (");
62 out.append(RoundCoordinate(place.getPositionX()));
63@@ -227,6 +228,23 @@
64 out.append(place.getId());
65 out.append(".center) { };\n");
66 }
67+ if (place.getAttributesVisible() || invariant != ""){
68+ out.append("%% label for place " + place.getName() + "\n");
69+ out.append("\\draw (");
70+ out.append(RoundCoordinate(place.getNameLabel().getXPosition()) + "," + (RoundCoordinate(place.getNameLabel().getYPosition()) * -1) + ")");
71+ out.append(" node[align=left] ");
72+ out.append("{");
73+ if(place.getAttributesVisible())
74+ out.append(exportMathName(place.getName()));
75+ if(invariant != "") {
76+ if((place.getAttributesVisible()))
77+ out.append("\\\\");
78+ out.append(invariant);
79+ }else {
80+ out.append("};\n");
81+ }
82+
83+ }
84 }
85
86 return out;
87@@ -239,7 +257,7 @@
88 String tokensInPlace = "";
89 if (tokens.size() > 0) {
90 if (tokens.size() == 1 && !net.netType().equals(NetType.UNTIMED)) {
91- tokensInPlace = "structured tokens={" + tokens.get(0).age().setScale(1) + "},";
92+ tokensInPlace = ", structured tokens={" + tokens.get(0).age().setScale(1) + "},";
93 } else {
94 tokensInPlace = exportMultipleTokens(tokens);
95 }
96@@ -252,14 +270,14 @@
97 String invariant = "";
98
99 if (!((TimedPlaceComponent) place).getInvariantAsString().contains("inf"))
100- invariant = "label=315:inv: $\\mathrm{" + replaceWithMathLatex(((TimedPlaceComponent) place).getInvariantAsString()) + "}$,";
101+ invariant = "$\\mathrm{" + replaceWithMathLatex(((TimedPlaceComponent) place).getInvariantAsString()) + "}$};\n";
102 return invariant;
103 }
104
105 private String exportMultipleTokens(List<TimedToken> tokens) {
106 StringBuffer out = new StringBuffer();
107
108- out.append("structured tokens={\\#");
109+ out.append(", structured tokens={\\#");
110 out.append(String.valueOf(tokens.size()));
111 out.append("},");
112 if (!net.netType().equals(NetType.UNTIMED)) {
113@@ -282,8 +300,8 @@
114 out.append("%% positions of place/transition labels that are currently fixed to label=135 degrees\n");
115 out.append("%% can be adjusted so that they do not cover arcs\n");
116 out.append("%% similarly the curving of arcs can be done by adjusting bend left/right=XX\n");
117- out.append("%% arc labels may be slightly skewed compared to the tapaal drawing due to rounding.\n");
118- out.append("%% This can be adjusted by tuning the coordinates of the label of the respective arc\n");
119+ out.append("%% labels may be slightly skewed compared to the tapaal drawing due to rounding.\n");
120+ out.append("%% This can be adjusted by tuning the coordinates of the label\n");
121 out.append("\\tikzstyle{arc}=[->,>=stealth,thick]\n");
122
123 if (!net.netType().equals(NetType.UNTIMED)) out.append("\\tikzstyle{transportArc}=[->,>=diamond,thick]\n");
124@@ -294,7 +312,7 @@
125 out.append("\\tikzstyle{every token}=[fill=white,text=black]\n");
126 out.append("\\tikzstyle{sharedplace}=[place,minimum size=7.5mm,dashed,thin]\n");
127 out.append("\\tikzstyle{sharedtransition}=[transition, fill opacity=0, minimum width=3.5mm, minimum height=6.5mm,dashed]\n");
128- out.append("\\tikzstyle{urgenttransition}=[place,fill=white,minimum size=2.0mm,thin]");
129+ out.append("\\tikzstyle{urgenttransition}=[place,fill=white,minimum size=2.0mm,thin]");
130 return out;
131 }
132

Subscribers

People subscribed via source and target branches