Merge lp:~tapaal-contributor/tapaal/cpn-gui-TikZ-support into lp:~tapaal-contributor/tapaal/cpn-gui-dev

Proposed by Kristian Morsing Pedersen
Status: Superseded
Proposed branch: lp:~tapaal-contributor/tapaal/cpn-gui-TikZ-support
Merge into: lp:~tapaal-contributor/tapaal/cpn-gui-dev
Diff against target: 461 lines (+199/-136)
1 file modified
src/net/tapaal/export/TikZExporter.java (+199/-136)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/cpn-gui-TikZ-support
Reviewer Review Type Date Requested Status
Jiri Srba Needs Fixing
Kenneth Yrke Jørgensen code Approve
Review via email: mp+415749@code.launchpad.net

This proposal supersedes a proposal from 2022-02-17.

This proposal has been superseded by a proposal from 2022-02-21.

Commit message

Added TikZ support for colored nets.
Added a framed box to the Tikz output for global variables/constants/color types.
Removed subscripiting from transition- and place names
Changed \mathrm to \mathit
Added more adjustment options for transitions, places and arcs
Merged with cpn-gui-dev

Description of the change

The TikZ export now shows all of the new features associated with colored nets.
Also added a framed box that contains all the global variables, constants and/or color types for a given net.
Subscripting from transition- and place names have been removed, so it looks more like the GUI.
\mathrm has also been replaces with \mathit.

To post a comment you must log in.
Revision history for this message
Kenneth Yrke Jørgensen (yrke) :
review: Approve (code)
Revision history for this message
Jiri Srba (srba) wrote :

It would be nice if instead of (in referendum colored timed):

1′v[1, 2]Voters1 → [1, 4]

one would print:

1′v
[1, 2]
Voters1 → [1, 4]

(on three sepratate lines).

review: Needs Fixing
1575. By Kristian Morsing Pedersen <email address hidden>

Labels with multiple lines on arcs now displays correctly

1576. By Kristian Morsing Pedersen <email address hidden>

Changed default pos of arc labels to 0.5

1577. By Kristian Morsing Pedersen <email address hidden>

Resolved merge conflicts

1578. By Kristian Morsing Pedersen <email address hidden>

Removed redundant \\ and changed 0,0 -> 0.0 for age of tokens in initial markings

1579. By Kristian Morsing Pedersen <email address hidden>

Changed x -> \times in inhibitor arcs

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/net/tapaal/export/TikZExporter.java'
--- src/net/tapaal/export/TikZExporter.java 2022-01-07 17:05:54 +0000
+++ src/net/tapaal/export/TikZExporter.java 2022-02-21 15:45:21 +0000
@@ -3,16 +3,17 @@
3import java.io.FileWriter;3import java.io.FileWriter;
4import java.io.IOException;4import java.io.IOException;
5import java.io.PrintWriter;5import java.io.PrintWriter;
6import java.util.List;6import java.util.*;
77
8import dk.aau.cs.model.CPN.ColorType;
9import dk.aau.cs.model.CPN.Variable;
10import dk.aau.cs.model.tapn.Constant;
8import dk.aau.cs.model.tapn.TimedToken;11import dk.aau.cs.model.tapn.TimedToken;
912
13import net.tapaal.gui.petrinet.Context;
10import pipe.gui.petrinet.dataLayer.DataLayer;14import pipe.gui.petrinet.dataLayer.DataLayer;
11import pipe.gui.TAPAALGUI;15import pipe.gui.TAPAALGUI;
12import pipe.gui.petrinet.graphicElements.Arc;16import pipe.gui.petrinet.graphicElements.*;
13import pipe.gui.petrinet.graphicElements.ArcPathPoint;
14import pipe.gui.petrinet.graphicElements.Place;
15import pipe.gui.petrinet.graphicElements.Transition;
16import pipe.gui.petrinet.graphicElements.tapn.TimedInhibitorArcComponent;17import pipe.gui.petrinet.graphicElements.tapn.TimedInhibitorArcComponent;
17import pipe.gui.petrinet.graphicElements.tapn.TimedInputArcComponent;18import pipe.gui.petrinet.graphicElements.tapn.TimedInputArcComponent;
18import pipe.gui.petrinet.graphicElements.tapn.TimedPlaceComponent;19import pipe.gui.petrinet.graphicElements.tapn.TimedPlaceComponent;
@@ -45,7 +46,7 @@
45 if (option == TikZOutputOption.FULL_LATEX) {46 if (option == TikZOutputOption.FULL_LATEX) {
46 out.println("\\documentclass[a4paper]{article}");47 out.println("\\documentclass[a4paper]{article}");
47 out.println("\\usepackage{tikz}");48 out.println("\\usepackage{tikz}");
48 out.println("\\usetikzlibrary{petri,arrows}");49 out.println("\\usetikzlibrary{petri,arrows,positioning}");
49 out.println("\\usepackage{amstext}");50 out.println("\\usepackage{amstext}");
50 out.println();51 out.println();
51 out.println("\\begin{document}");52 out.println("\\begin{document}");
@@ -62,6 +63,8 @@
62 out.print(exportTransitions(net.getTransitions()));63 out.print(exportTransitions(net.getTransitions()));
63 out.print(exportArcs(net.getArcs()));64 out.print(exportArcs(net.getArcs()));
6465
66 out.println(exportGlobalVariables());
67
65 out.println("\\end{tikzpicture}");68 out.println("\\end{tikzpicture}");
66 if (option == TikZOutputOption.FULL_LATEX) {69 if (option == TikZOutputOption.FULL_LATEX) {
67 out.println("\\end{document}");70 out.println("\\end{document}");
@@ -94,7 +97,7 @@
94 ArcPathPoint currentPoint = arc.getArcPath().getArcPathPoint(i);97 ArcPathPoint currentPoint = arc.getArcPath().getArcPathPoint(i);
9598
96 if(currentPoint.getPointType() == ArcPathPoint.STRAIGHT) {99 if(currentPoint.getPointType() == ArcPathPoint.STRAIGHT) {
97 arcPoints += "to[bend right=0] (" + (currentPoint.getX()) + "," + (currentPoint.getY() * (-1)) + ") ";100 arcPoints += "to [bend right=0] (" + (currentPoint.getX()) + "," + (currentPoint.getY() * (-1)) + ") ";
98 } else if (currentPoint.getPointType() == ArcPathPoint.CURVED) {101 } else if (currentPoint.getPointType() == ArcPathPoint.CURVED) {
99 double xCtrl1 = Math.round(currentPoint.getControl1().getX());102 double xCtrl1 = Math.round(currentPoint.getControl1().getX());
100 double yCtrl1 = Math.round(currentPoint.getControl1().getY() * (-1));103 double yCtrl1 = Math.round(currentPoint.getControl1().getY() * (-1));
@@ -109,21 +112,19 @@
109 }112 }
110113
111 String arrowType = getArcArrowType(arc);114 String arrowType = getArcArrowType(arc);
112 String arcLabel = getArcLabels(arc);
113115
116 out.append("% Arc between " + arc.getSource().getName() + " and " + arc.getTarget().getName() + "\n");
114 out.append("\\draw[");117 out.append("\\draw[");
115 out.append(arrowType);118 out.append(arrowType);
116 out.append("] (");119 out.append(",pos=0.0] (");
117 out.append(arc.getSource().getId());120 out.append(arc.getSource().getId());
118 out.append(") ");121 out.append(") ");
119 out.append(arcPoints);122 out.append(arcPoints);
120 out.append("to[bend right=0]");123 out.append("to node[bend right=0,auto,align=left]");
121 out.append(" (");124 out.append(" {");
122 out.append(arc.getTarget().getId());125 out.append(handleNameLabel(arc.getNameLabel().getText()));
123 out.append(") {};\n");126 out.append("} ");
124 if(!arcLabel.equals(""))127 out.append("(" + arc.getTarget().getId() + ");\n");
125 out.append("%% Label for arc between " + arc.getSource().getName() + " and " + arc.getTarget().getName() + "\n");
126 out.append(arcLabel);
127 }128 }
128 return out;129 return out;
129 }130 }
@@ -142,50 +143,6 @@
142 return arrowType;143 return arrowType;
143 }144 }
144145
145 protected String getArcLabels(Arc arc) {
146 String arcLabel = "";
147 String arcLabelPositionString = "\\draw (" + (arc.getNameLabel().getX()) + "," + (arc.getNameLabel().getY())*(-1) + ") node {";
148
149 if (arc instanceof TimedInputArcComponent) {
150 if (!(arc.getSource() instanceof TimedTransitionComponent)) {
151 arcLabel = arcLabelPositionString;
152 if (arc.getWeight().value() > 1) {
153 arcLabel += "$" + arc.getWeight().value() + "\\times$\\ ";
154 }
155
156 if(TAPAALGUI.getApp().getCurrentTab().getLens().isTimed()) {
157 arcLabel += "$\\mathrm{" + replaceWithMathLatex(getGuardAsStringIfNotHidden((TimedInputArcComponent) arc)) + "}$";
158 if (arc instanceof TimedTransportArcComponent)
159 arcLabel += ":" + ((TimedTransportArcComponent) arc).getGroupNr();
160 arcLabel += "};\n";
161 } else {
162 arcLabel += "};\n";
163 }
164
165 } else {
166 arcLabel = arcLabelPositionString;
167 if (arc.getWeight().value() > 1) {
168 arcLabel += "$" + arc.getWeight().value() + "\\times$\\ ";
169 }
170 arcLabel += ":" + ((TimedTransportArcComponent) arc).getGroupNr() + "};\n";
171 }
172
173 } else {
174 if (arc.getWeight().value() > 1) {
175 arcLabel += arcLabelPositionString + "$" + arc.getWeight().value() + "\\times$\\ };\n";
176 }
177 }
178 return arcLabel;
179 }
180
181 private String getGuardAsStringIfNotHidden(TimedInputArcComponent arc) {
182 if (!TAPAALGUI.getApp().showZeroToInfinityIntervals() && arc.getGuardAsString().equals("[0,inf)")){
183 return "";
184 } else {
185 return arc.getGuardAsString();
186 }
187 }
188
189 private StringBuffer exportTransitions(Transition[] transitions) {146 private StringBuffer exportTransitions(Transition[] transitions) {
190 StringBuffer out = new StringBuffer();147 StringBuffer out = new StringBuffer();
191 for (Transition trans : transitions) {148 for (Transition trans : transitions) {
@@ -195,7 +152,8 @@
195152
196153
197 out.append("\\node[transition");154 out.append("\\node[transition");
198 out.append(angle); 155 out.append(angle);
156 out.append(handlePlaceAndTransitionLabel(trans.getNameLabel().getText(), trans.getName(), trans.getAttributesVisible()));
199 out.append("] at (");157 out.append("] at (");
200 out.append((trans.getPositionX()));158 out.append((trans.getPositionX()));
201 out.append(',');159 out.append(',');
@@ -226,31 +184,30 @@
226 out.append(trans.getId());184 out.append(trans.getId());
227 out.append(".center) { };\n");185 out.append(".center) { };\n");
228 }186 }
229 if (trans.getAttributesVisible()){
230 boolean isLabelAboveTransition = trans.getY() > trans.getNameLabel().getY();
231 boolean isLabelBehindTrans = trans.getX() < trans.getNameLabel().getX();
232 double xOffset = trans.getName().length() > 5 && !isLabelAboveTransition && !isLabelBehindTrans ? trans.getLayerOffset() : 0;
233
234 out.append("%% label for transition " + trans.getName() + "\n");
235 out.append("\\draw (");
236 out.append(trans.getNameLabel().getX() + xOffset + "," + (trans.getNameLabel().getY() * -1) + ")");
237 out.append(" node ");
238 out.append(" {");
239 out.append(exportMathName(trans.getName()));
240 out.append("};\n");
241 }
242 }187 }
243 return out;188 return out;
244 }189 }
245190
191 private String handlePlaceAndTransitionLabel(String nameLabelText, String name, boolean isVisible) {
192 if(!isVisible)
193 return "";
194
195 String result = ", label={[align=left,label distance=0cm]90:";
196 result += "$\\mathrm{" + (name.replace("_","\\_")) + "}$";
197 result += handleNameLabel(nameLabelText);
198 result += "}";
199 return result;
200 }
201
246 private StringBuffer exportPlacesWithTokens(Place[] places) {202 private StringBuffer exportPlacesWithTokens(Place[] places) {
247 StringBuffer out = new StringBuffer();203 StringBuffer out = new StringBuffer();
248204
249 for (Place place : places) {205 for (Place place : places) {
250 String invariant = getPlaceInvariantString(place);206 String invariant = "$" + getPlaceInvariantString(place) + "$";
251 String tokensInPlace = getTokenListStringFor(place);207 String tokensInPlace = getTokenListStringFor(place);
252208
253 out.append("\\node[place");209 out.append("\\node[place");
210 out.append(handlePlaceAndTransitionLabel(place.getNameLabel().getText(), place.getName(), place.getAttributesVisible()));
254 out.append("] at (");211 out.append("] at (");
255 out.append(place.getPositionX());212 out.append(place.getPositionX());
256 out.append(',');213 out.append(',');
@@ -262,37 +219,38 @@
262 exportPlaceTokens(place, out, ((TimedPlaceComponent) place).underlyingPlace().tokens().size());219 exportPlaceTokens(place, out, ((TimedPlaceComponent) place).underlyingPlace().tokens().size());
263 220
264 if(((TimedPlaceComponent)place).underlyingPlace().isShared()){221 if(((TimedPlaceComponent)place).underlyingPlace().isShared()){
265 out.append("\\node[sharedplace] at (");222 out.append("\\node[sharedplace ");
223 out.append("] at (");
266 out.append(place.getId());224 out.append(place.getId());
267 out.append(".center) { };\n");225 out.append(".center) { };\n");
268 }226 }
269 if (place.getAttributesVisible() || !invariant.equals("")){
270 boolean isLabelAbovePlace = place.getY() > place.getNameLabel().getY();
271 boolean isLabelBehindPlace = place.getX() < place.getNameLabel().getX();
272 double xOffset = place.getName().length() > 6 && !isLabelAbovePlace && !isLabelBehindPlace ? place.getLayerOffset() : 0;
273 double yOffset = isLabelAbovePlace ? (place.getNameLabel().getHeight() / 2) : 0;
274
275 out.append("%% label for place " + place.getName() + "\n");
276 out.append("\\draw (");
277 out.append((place.getNameLabel().getX() + xOffset) + "," + ((place.getNameLabel().getY() * -1) + yOffset) +")");
278 out.append(" node[align=left] ");
279 out.append("{");
280 if(place.getAttributesVisible())
281 out.append(exportMathName(place.getName()));
282 if(!invariant.equals("")) {
283 if((place.getAttributesVisible()))
284 out.append("\\\\");
285 out.append(invariant);
286 }else {
287 out.append("};\n");
288 }
289
290 }
291 }227 }
292
293 return out;228 return out;
294 }229 }
295230
231 private String handleNameLabel(String nameLabel) {
232 String nameLabelsString = "";
233 String[] labelsInName = nameLabel.split("\n");
234 for(int i = 0; i < labelsInName.length; i++) {
235
236 if(labelsInName[i].contains("[")) {
237 nameLabelsString += escapeSpacesInAndOrNot(replaceWithMathLatex(labelsInName[i]));
238 nameLabelsString += "\\\\";
239 }
240 else if(!labelsInName[i].isEmpty()){
241 nameLabelsString += escapeSpacesInAndOrNot(replaceWithMathLatex(labelsInName[i]));
242 nameLabelsString += "\\\\";
243 } else {
244 nameLabelsString += "\\\\";
245 }
246 }
247 return nameLabelsString;
248 }
249
250 private String escapeSpacesInAndOrNot(String str) {
251 return str.replace(" and ", "\\ and\\ ").replace(" or", "\\ or\\ ").replace(" not", "\\ not\\ ");
252 }
253
296 private void exportPlaceTokens(Place place, StringBuffer out, int numOfTokens) {254 private void exportPlaceTokens(Place place, StringBuffer out, int numOfTokens) {
297 // Dot radius255 // Dot radius
298 final double tRadius = 1;256 final double tRadius = 1;
@@ -437,6 +395,124 @@
437 }395 }
438 }396 }
439397
398 private StringBuffer exportGlobalVariables() {
399 StringBuffer out = new StringBuffer();
400
401 Context context = new Context(TAPAALGUI.getCurrentTab());
402 List<ColorType> listColorTypes = context.network().colorTypes();
403 List<Constant> constantsList = new ArrayList<>(context.network().constants());
404 List<Variable> variableList = context.network().variables();
405
406 if(!context.network().isColored()) {
407 if(constantsList.isEmpty()) {
408 return out;
409 }
410 out.append("%%Global box which contains global color types, variables and/or constants.\n");
411 out.append("\\node [globalBox] (globalBox) at (current bounding box.north west) [anchor=south west] {");
412 exportConstants(constantsList, out);
413 out.append("};");
414 return out;
415 }
416
417 if((listColorTypes.isEmpty() && constantsList.isEmpty() && variableList.isEmpty()))
418 return out;
419
420 out.append("%%Global box which contains global color types, variables and/or constants.\n");
421 out.append("\\node [globalBox] (globalBox) at (current bounding box.north west) [anchor=south west] {");
422
423 exportColorTypes(listColorTypes, out);
424
425 if(listColorTypes.size() > 0 && (variableList.size() > 0 || constantsList.size() > 0)) {
426 out.append("\\\\");
427 }
428
429 exportVariables(variableList, out);
430
431 if(variableList.size() > 0 && !constantsList.isEmpty()) {
432 out.append("\\\\");
433 }
434
435 exportConstants(constantsList, out);
436
437 out.append("};");
438
439 return out;
440 }
441
442 private void exportColorTypes(List<ColorType> listColorTypes, StringBuffer out) {
443 String stringColorList = "";
444 for(int i = 0; i < listColorTypes.size(); i++) {
445 if(i == 0) {
446 out.append("Color Types:\\\\");
447 }
448 out.append("$\\mathit{" + listColorTypes.get(i).getName() + "}$ \\textbf{is} ");
449
450 if(listColorTypes.get(i).isProductColorType()) {
451 out.append("$\\mathit{<");
452 for(int x = 0; x < listColorTypes.get(i).getProductColorTypes().size(); x++) {
453 stringColorList += listColorTypes.get(i).getProductColorTypes().get(x).getName().replace("_", "\\_");
454
455 if(x != listColorTypes.get(i).getProductColorTypes().size() - 1){
456 stringColorList += ", ";
457 }
458 }
459 out.append(stringColorList + ">}$\\\\");
460 stringColorList = "";
461
462 } else if(listColorTypes.get(i).isIntegerRange()) {
463 out.append("$\\mathit{");
464 if(listColorTypes.get(i).size() > 1) {
465 int listSize = listColorTypes.get(i).size();
466 out.append("[" + listColorTypes.get(i).getColors().get(0).getColorName().replace("_","\\_") + ".." + listColorTypes.get(i).getColors().get(listSize - 1).getColorName().replace("_","\\_") + "]");
467 } else {
468 out.append("[" + listColorTypes.get(i).getFirstColor().getColorName().replace("_","\\_") + "]");
469 }
470 out.append("}$\\\\");
471
472 } else {
473 out.append("$\\mathit{[");
474 for(int x = 0; x < listColorTypes.get(i).getColors().size(); x++) {
475 stringColorList += listColorTypes.get(i).getColors().get(x).getName().replace("_","\\_");
476
477 if(x != listColorTypes.get(i).getColors().size() - 1){
478 stringColorList += ", ";
479 }
480 }
481 out.append(stringColorList + "]}$\\\\");
482 stringColorList = "";
483 }
484 }
485 }
486
487 private void exportVariables(List<Variable> variableList, StringBuffer out) {
488 String result = "";
489 for(int i = 0; i < variableList.size(); i++) {
490 if (i == 0) {
491 result += "Variables:\\\\ ";
492 }
493 result += "$\\mathit{" + variableList.get(i).getName().replace("_","\\_") + " \\textbf{ in } " + variableList.get(i).getColorType().getName().replace("_","\\_") + "}$";
494 if(i != variableList.size() - 1) {
495 result += "\\\\";
496 }
497 }
498 out.append(result);
499 }
500
501 private void exportConstants(List<Constant> constantsList, StringBuffer out) {
502 String result = "";
503
504 for(int i = 0; i < constantsList.size(); i++) {
505 if(i == 0) {
506 result += "Constants:\\\\";
507 }
508 result += "$\\mathit{" + constantsList.get(i).toString().replace("_","\\_") + "}$";
509 if(i != constantsList.size() - 1) {
510 result += "\\\\";
511 }
512 }
513 out.append(result);
514 }
515
440 protected String getTokenListStringFor(Place place) {516 protected String getTokenListStringFor(Place place) {
441 List<TimedToken> tokens = ((TimedPlaceComponent) place).underlyingPlace().tokens();517 List<TimedToken> tokens = ((TimedPlaceComponent) place).underlyingPlace().tokens();
442518
@@ -455,7 +531,7 @@
455 String invariant = "";531 String invariant = "";
456532
457 if (!((TimedPlaceComponent) place).getInvariantAsString().contains("inf"))533 if (!((TimedPlaceComponent) place).getInvariantAsString().contains("inf"))
458 invariant = "$\\mathrm{" + replaceWithMathLatex(((TimedPlaceComponent) place).getInvariantAsString()) + "}$};\n";534 invariant = replaceWithMathLatex(((TimedPlaceComponent) place).getInvariantAsString()) + "};\n";
459 return invariant;535 return invariant;
460 }536 }
461537
@@ -480,12 +556,14 @@
480 StringBuffer out = new StringBuffer();556 StringBuffer out = new StringBuffer();
481557
482 out.append("\\begin{tikzpicture}[font=\\scriptsize, xscale=0.45, yscale=0.45, x=1.33pt, y=1.33pt]\n");558 out.append("\\begin{tikzpicture}[font=\\scriptsize, xscale=0.45, yscale=0.45, x=1.33pt, y=1.33pt]\n");
483 out.append("%% the figure can be scaled by changing xscale and yscale\n");559 out.append("%% the figure can be scaled by changing xscale and yscale or the size of the x- and y-coordinates\n");
484 out.append("%% positions of place/transition labels that are currently fixed to label=135 degrees\n");560 out.append("%% positions of place/transition labels that are currently fixed to label=135 degrees\n");
485 out.append("%% can be adjusted so that they do not cover arcs\n");561 out.append("%% these can be adjusted by adjusting either the coordinates, the label distance or the label degree\n");
486 out.append("%% similarly the curving of arcs can be done by adjusting bend left/right=XX\n");562 out.append("%% that is placed right after the 'label-distance'. 90: is above (default), 180 is left, 270 is below etc.\n");
487 out.append("%% labels may be slightly skewed compared to the tapaal drawing due to rounding.\n");563 out.append("%% The curving of arcs can be done by adjusting bend left/right=XX\n");
488 out.append("%% This can be adjusted by tuning the coordinates of the label\n");564 out.append("%% labels may be slightly skewed compared to the Tapaal drawing due to rounding.\n");
565 out.append("%% This can be adjusted by tuning the coordinates of the label, or the degree (see above)\n");
566 out.append("%% The box containing global variables can also be moved by adjusting the anchor points / bounding box in the [globalBox] node at the end of the Tikz document\n");
489 out.append("\\tikzstyle{arc}=[->,>=stealth,thick]\n");567 out.append("\\tikzstyle{arc}=[->,>=stealth,thick]\n");
490568
491 out.append("\\tikzstyle{transportArc}=[->,>=diamond,thick]\n");569 out.append("\\tikzstyle{transportArc}=[->,>=diamond,thick]\n");
@@ -496,39 +574,24 @@
496 out.append("\\tikzstyle{every token}=[fill=white,text=black]\n");574 out.append("\\tikzstyle{every token}=[fill=white,text=black]\n");
497 out.append("\\tikzstyle{sharedplace}=[place,minimum size=7.5mm,dashed,thin]\n");575 out.append("\\tikzstyle{sharedplace}=[place,minimum size=7.5mm,dashed,thin]\n");
498 out.append("\\tikzstyle{sharedtransition}=[transition, fill opacity=0, minimum width=3.5mm, minimum height=6.5mm,dashed]\n");576 out.append("\\tikzstyle{sharedtransition}=[transition, fill opacity=0, minimum width=3.5mm, minimum height=6.5mm,dashed]\n");
499 out.append("\\tikzstyle{urgenttransition}=[place,fill=white,minimum size=2.0mm,thin]");577 out.append("\\tikzstyle{urgenttransition}=[place,fill=white,minimum size=2.0mm,thin]\n");
500 out.append("\\tikzstyle{uncontrollabletransition}=[transition,fill=white,draw=black,very thick]");578 out.append("\\tikzstyle{uncontrollabletransition}=[transition,fill=white,draw=black,very thick]\n");
579 out.append("\\tikzstyle{globalBox} = [draw,thick,align=left]");
501 return out;580 return out;
502 }581 }
503582
504 protected String replaceWithMathLatex(String text) {583 protected String replaceWithMathLatex(String text) {
505 return text.replace("inf", "\\infty").replace("<=", "\\leq ").replace("*", "\\cdot ");584 String[] stringList = text.split(" ");
506 }585 String result = "";
507586
508 private String exportMathName(String name) {587 for(int i = 0; i < stringList.length; i++) {
509 StringBuilder out = new StringBuilder("$\\mathrm{");588 result += "$\\mathit{" + replaceSpecialSymbols(stringList[i]) + "}$ ";
510 int subscripts = 0;589 }
511 for (int i = 0; i < name.length() - 1; i++) {590 return result;
512 char c = name.charAt(i);591 }
513 if (c == '_') {592
514 out.append("_{");593 protected String replaceSpecialSymbols(String text) {
515 subscripts++;594 return text.replace("inf", "\\infty").replace("<=", "\\leq").replace("*", "\\cdot")
516 } else {595 .replace("\u2192", "\\rightarrow").replace("\u221E", "\\infty");
517 out.append(c);596 }
518 }
519 }
520
521 char last = name.charAt(name.length() - 1);
522 if (last == '_') {
523 out.append("\\_");
524 } else
525 out.append(last);
526
527 for (int i = 0; i < subscripts; i++) {
528 out.append('}');
529 }
530 out.append("}$");
531 return out.toString();
532 }
533
534}597}

Subscribers

People subscribed via source and target branches

to all changes: