Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
61ede76d
Commit
61ede76d
authored
Jan 22, 2019
by
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
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
VadereGui/src/org/vadere/gui/components/control/simulation/ActionGenerateTikz.java
View file @
61ede76d
...
...
@@ -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
);
}
}
...
...
VadereGui/src/org/vadere/gui/postvisualization/utils/TikzGenerator.java
View file @
61ede76d
...
...
@@ -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
(
o
utput
);
out
.
write
(
tikzO
utput
);
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=%f
cm
];\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=%f
cm
];\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=%f
cm
];\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
());
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment