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
=== modified file 'src/pipe/gui/TikZExporter.java'
--- src/pipe/gui/TikZExporter.java 2019-03-16 13:01:21 +0000
+++ src/pipe/gui/TikZExporter.java 2019-03-18 17:00:20 +0000
@@ -120,6 +120,8 @@
120 out.append(" (");120 out.append(" (");
121 out.append(arc.getTarget().getId());121 out.append(arc.getTarget().getId());
122 out.append(") {};\n");122 out.append(") {};\n");
123 if(arcLabel != "")
124 out.append("%% Label for arc between " + arc.getSource().getName() + " and " + arc.getTarget().getName() + "\n");
123 out.append(arcLabel);125 out.append(arcLabel);
124 }126 }
125 return out;127 return out;
@@ -168,11 +170,7 @@
168 angle = ",rotate=" + String.valueOf(trans.getAngle() + 90);170 angle = ",rotate=" + String.valueOf(trans.getAngle() + 90);
169171
170 out.append("\\node[transition");172 out.append("\\node[transition");
171 out.append(angle);173 out.append(angle);
172 if (trans.getAttributesVisible()){
173 out.append(",label=135:");
174 out.append(exportMathName(trans.getName()));
175 }
176 out.append("] at (");174 out.append("] at (");
177 out.append(RoundCoordinate(trans.getPositionX()));175 out.append(RoundCoordinate(trans.getPositionX()));
178 out.append(',');176 out.append(',');
@@ -189,13 +187,22 @@
189 out.append(".center) { };\n");187 out.append(".center) { };\n");
190 }188 }
191 189
192 if(((TimedTransitionComponent)trans).underlyingTransition().isUrgent()){190 if(((TimedTransitionComponent)trans).underlyingTransition().isUrgent()){
193 out.append("\\node[urgenttransition");191 out.append("\\node[urgenttransition");
194 out.append(angle);192 out.append(angle);
195 out.append("] at (");193 out.append("] at (");
196 out.append(trans.getId());194 out.append(trans.getId());
197 out.append(".center) { };\n");195 out.append(".center) { };\n");
198 }196 }
197 if (trans.getAttributesVisible()){
198 out.append("%% label for transition " + trans.getName() + "\n");
199 out.append("\\draw (");
200 out.append(RoundCoordinate(trans.getNameLabel().getXPosition()) + "," + (RoundCoordinate(trans.getNameLabel().getYPosition()) * -1) + ")");
201 out.append(" node ");
202 out.append(" {");
203 out.append(exportMathName(trans.getName()));
204 out.append("};\n");
205 }
199 }206 }
200 return out;207 return out;
201 }208 }
@@ -207,12 +214,6 @@
207 String tokensInPlace = getTokenListStringFor(place);214 String tokensInPlace = getTokenListStringFor(place);
208215
209 out.append("\\node[place");216 out.append("\\node[place");
210 if (place.getAttributesVisible()){
211 out.append(",label=135:");
212 out.append(exportMathName(place.getName()));
213 }
214 out.append(',');
215 out.append(invariant);
216 out.append(tokensInPlace);217 out.append(tokensInPlace);
217 out.append("] at (");218 out.append("] at (");
218 out.append(RoundCoordinate(place.getPositionX()));219 out.append(RoundCoordinate(place.getPositionX()));
@@ -227,6 +228,23 @@
227 out.append(place.getId());228 out.append(place.getId());
228 out.append(".center) { };\n");229 out.append(".center) { };\n");
229 }230 }
231 if (place.getAttributesVisible() || invariant != ""){
232 out.append("%% label for place " + place.getName() + "\n");
233 out.append("\\draw (");
234 out.append(RoundCoordinate(place.getNameLabel().getXPosition()) + "," + (RoundCoordinate(place.getNameLabel().getYPosition()) * -1) + ")");
235 out.append(" node[align=left] ");
236 out.append("{");
237 if(place.getAttributesVisible())
238 out.append(exportMathName(place.getName()));
239 if(invariant != "") {
240 if((place.getAttributesVisible()))
241 out.append("\\\\");
242 out.append(invariant);
243 }else {
244 out.append("};\n");
245 }
246
247 }
230 }248 }
231249
232 return out;250 return out;
@@ -239,7 +257,7 @@
239 String tokensInPlace = "";257 String tokensInPlace = "";
240 if (tokens.size() > 0) {258 if (tokens.size() > 0) {
241 if (tokens.size() == 1 && !net.netType().equals(NetType.UNTIMED)) {259 if (tokens.size() == 1 && !net.netType().equals(NetType.UNTIMED)) {
242 tokensInPlace = "structured tokens={" + tokens.get(0).age().setScale(1) + "},";260 tokensInPlace = ", structured tokens={" + tokens.get(0).age().setScale(1) + "},";
243 } else {261 } else {
244 tokensInPlace = exportMultipleTokens(tokens);262 tokensInPlace = exportMultipleTokens(tokens);
245 }263 }
@@ -252,14 +270,14 @@
252 String invariant = "";270 String invariant = "";
253271
254 if (!((TimedPlaceComponent) place).getInvariantAsString().contains("inf"))272 if (!((TimedPlaceComponent) place).getInvariantAsString().contains("inf"))
255 invariant = "label=315:inv: $\\mathrm{" + replaceWithMathLatex(((TimedPlaceComponent) place).getInvariantAsString()) + "}$,";273 invariant = "$\\mathrm{" + replaceWithMathLatex(((TimedPlaceComponent) place).getInvariantAsString()) + "}$};\n";
256 return invariant;274 return invariant;
257 }275 }
258276
259 private String exportMultipleTokens(List<TimedToken> tokens) {277 private String exportMultipleTokens(List<TimedToken> tokens) {
260 StringBuffer out = new StringBuffer();278 StringBuffer out = new StringBuffer();
261279
262 out.append("structured tokens={\\#");280 out.append(", structured tokens={\\#");
263 out.append(String.valueOf(tokens.size()));281 out.append(String.valueOf(tokens.size()));
264 out.append("},");282 out.append("},");
265 if (!net.netType().equals(NetType.UNTIMED)) {283 if (!net.netType().equals(NetType.UNTIMED)) {
@@ -282,8 +300,8 @@
282 out.append("%% positions of place/transition labels that are currently fixed to label=135 degrees\n");300 out.append("%% positions of place/transition labels that are currently fixed to label=135 degrees\n");
283 out.append("%% can be adjusted so that they do not cover arcs\n");301 out.append("%% can be adjusted so that they do not cover arcs\n");
284 out.append("%% similarly the curving of arcs can be done by adjusting bend left/right=XX\n");302 out.append("%% similarly the curving of arcs can be done by adjusting bend left/right=XX\n");
285 out.append("%% arc labels may be slightly skewed compared to the tapaal drawing due to rounding.\n");303 out.append("%% labels may be slightly skewed compared to the tapaal drawing due to rounding.\n");
286 out.append("%% This can be adjusted by tuning the coordinates of the label of the respective arc\n");304 out.append("%% This can be adjusted by tuning the coordinates of the label\n");
287 out.append("\\tikzstyle{arc}=[->,>=stealth,thick]\n");305 out.append("\\tikzstyle{arc}=[->,>=stealth,thick]\n");
288306
289 if (!net.netType().equals(NetType.UNTIMED)) out.append("\\tikzstyle{transportArc}=[->,>=diamond,thick]\n");307 if (!net.netType().equals(NetType.UNTIMED)) out.append("\\tikzstyle{transportArc}=[->,>=diamond,thick]\n");
@@ -294,7 +312,7 @@
294 out.append("\\tikzstyle{every token}=[fill=white,text=black]\n");312 out.append("\\tikzstyle{every token}=[fill=white,text=black]\n");
295 out.append("\\tikzstyle{sharedplace}=[place,minimum size=7.5mm,dashed,thin]\n");313 out.append("\\tikzstyle{sharedplace}=[place,minimum size=7.5mm,dashed,thin]\n");
296 out.append("\\tikzstyle{sharedtransition}=[transition, fill opacity=0, minimum width=3.5mm, minimum height=6.5mm,dashed]\n");314 out.append("\\tikzstyle{sharedtransition}=[transition, fill opacity=0, minimum width=3.5mm, minimum height=6.5mm,dashed]\n");
297 out.append("\\tikzstyle{urgenttransition}=[place,fill=white,minimum size=2.0mm,thin]");315 out.append("\\tikzstyle{urgenttransition}=[place,fill=white,minimum size=2.0mm,thin]");
298 return out;316 return out;
299 }317 }
300318

Subscribers

People subscribed via source and target branches