Commit 61ede76d authored by Daniel Lehmberg's avatar Daniel Lehmberg
Browse files

Merge branch 'master' into change_dataprocessing_text

parents 040b55db fbaa84dc
Pipeline #85964 passed with stages
in 101 minutes and 3 seconds
......@@ -50,8 +50,7 @@ public class ActionGenerateTikz extends AbstractAction implements IRendererChang
outputFile = fileChooser.getSelectedFile().toString().endsWith(".tex") ? fileChooser.getSelectedFile()
: new File(fileChooser.getSelectedFile().toString() + ".tex");
boolean completeDocument = true;
tikzGenerator.generateTikz(outputFile, completeDocument);
tikzGenerator.generateTikz(outputFile);
}
}
......
......@@ -67,27 +67,26 @@ public class TikzGenerator {
translationTable[SEG_CLOSE] = "";
}
public void generateTikz(final File file, final boolean generateCompleteDocument) {
String texTemplate = "" +
public void generateTikz(final File file) {
String tikzCodeColorDefinitions = generateTikzColorDefinitions(model);
String tikzCodeScenarioElements = convertScenarioElementsToTikz();
String tikzOutput = "" +
"\\documentclass{standalone}\n" +
"\\usepackage{tikz}\n\n" +
tikzCodeColorDefinitions +
"\\begin{document}\n" +
"\\begin{tikzpicture}\n" +
"%s" +
"% Change scaling to [x=1mm,y=1mm] if TeX reports \"Dimension too large\".\n" +
"\\begin{tikzpicture}[x=1cm,y=1cm]\n" +
tikzCodeScenarioElements +
"\\end{tikzpicture}\n" +
"\\end{document}\n";
String tikzCode = "";
tikzCode += generateTikzColorDefinitions(model);
tikzCode += convertScenarioElementsToTikz();
String output = (generateCompleteDocument) ? String.format(Locale.US, texTemplate, tikzCode) : tikzCode;
// TODO: maybe uses Java's resources notation (in general, writing the file should be done by the caller not here).
try {
file.createNewFile();
Writer out = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
out.write(output);
out.write(tikzOutput);
out.flush();
logger.info("generate new TikZ: " + file.getAbsolutePath());
} catch (IOException e1) {
......@@ -116,6 +115,8 @@ public class TikzGenerator {
Color agentColor = model.getConfig().getPedestrianDefaultColor();
colorDefinitions += String.format(Locale.US, colorTextPattern, "AgentColor", agentColor.getRed(), agentColor.getGreen(), agentColor.getBlue());
colorDefinitions += "\n";
return colorDefinitions;
}
......@@ -272,7 +273,7 @@ public class TikzGenerator {
cce.printStackTrace();
// Fall back to default rendering of agents.
String agentTextPattern = "\\fill[AgentColor] (%f,%f) circle [radius=%fcm];\n";
String agentTextPattern = "\\fill[AgentColor] (%f,%f) circle [radius=%f];\n";
generatedCode += String.format(Locale.US, agentTextPattern, agent.getPosition().x, agent.getPosition().y, agent.getRadius());
}
} else {
......@@ -281,12 +282,12 @@ public class TikzGenerator {
String colorString = String.format(Locale.US, "{rgb,255: red,%d; green,%d; blue,%d}", pedestrianColor.getRed(), pedestrianColor.getGreen(), pedestrianColor.getBlue());
// Do not draw agents as path for performance reasons. Usually, agents have a circular shape.
// generatedCode += String.format(Locale.US, "\\fill[AgentColor] %s\n", generatePathForScenarioElement(agent));
String agentTextPattern = "\\fill[fill=%s] (%f,%f) circle [radius=%fcm];\n";
String agentTextPattern = "\\fill[fill=%s] (%f,%f) circle [radius=%f];\n";
generatedCode += String.format(Locale.US, agentTextPattern, colorString, agent.getPosition().x, agent.getPosition().y, agent.getRadius());
}
if (model.isElementSelected() && model.getSelectedElement().equals(agent)) {
String agentTextPattern = "\\draw[magenta] (%f,%f) circle [radius=%fcm];\n";
String agentTextPattern = "\\draw[magenta] (%f,%f) circle [radius=%f];\n";
generatedCode += String.format(Locale.US, agentTextPattern, agent.getPosition().x, agent.getPosition().y, agent.getRadius());
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment