Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
vadere
vadere
Commits
c960e0f3
Commit
c960e0f3
authored
Apr 23, 2019
by
Benedikt Kleinmeier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
In "TikzGenerator", added method "drawVoronoiDiagram()".
parent
2925c5ab
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
0 deletions
+81
-0
VadereGui/src/org/vadere/gui/postvisualization/utils/TikzGenerator.java
...org/vadere/gui/postvisualization/utils/TikzGenerator.java
+81
-0
No files found.
VadereGui/src/org/vadere/gui/postvisualization/utils/TikzGenerator.java
View file @
c960e0f3
...
@@ -12,6 +12,10 @@ import org.vadere.state.simulation.Step;
...
@@ -12,6 +12,10 @@ import org.vadere.state.simulation.Step;
import
org.vadere.state.simulation.Trajectory
;
import
org.vadere.state.simulation.Trajectory
;
import
org.vadere.util.geometry.shapes.VPoint
;
import
org.vadere.util.geometry.shapes.VPoint
;
import
org.vadere.util.logging.Logger
;
import
org.vadere.util.logging.Logger
;
import
org.vadere.util.voronoi.Face
;
import
org.vadere.util.voronoi.HalfEdge
;
import
org.vadere.util.voronoi.RectangleLimits
;
import
org.vadere.util.voronoi.VoronoiDiagram
;
import
java.awt.*
;
import
java.awt.*
;
import
java.awt.geom.AffineTransform
;
import
java.awt.geom.AffineTransform
;
...
@@ -235,6 +239,13 @@ public class TikzGenerator {
...
@@ -235,6 +239,13 @@ public class TikzGenerator {
generatedCode
+=
"% Measurement Areas (not enabled in config)\n"
;
generatedCode
+=
"% Measurement Areas (not enabled in config)\n"
;
}
}
if
(
model
.
isVoronoiDiagramVisible
()
&&
model
.
isVoronoiDiagramAvailable
())
{
generatedCode
+=
"% Voronoi Diagram\n"
;
generatedCode
+=
drawVoronoiDiagram
(
model
.
getVoronoiDiagram
());
}
else
{
generatedCode
+=
"% Voronoi Diagram (not enabled in config)\n"
;
}
if
(
config
.
isShowTrajectories
())
{
if
(
config
.
isShowTrajectories
())
{
generatedCode
+=
"% Trajectories\n"
;
generatedCode
+=
"% Trajectories\n"
;
...
@@ -402,6 +413,76 @@ public class TikzGenerator {
...
@@ -402,6 +413,76 @@ public class TikzGenerator {
return
generatedPath
.
trim
();
return
generatedPath
.
trim
();
}
}
private
String
drawVoronoiDiagram
(
final
VoronoiDiagram
voronoiDiagram
)
{
String
voronoiDiagramAsTikz
=
""
;
synchronized
(
voronoiDiagram
)
{
if
(
voronoiDiagram
!=
null
)
{
RectangleLimits
limits
=
voronoiDiagram
.
getLimits
();
voronoiDiagramAsTikz
+=
String
.
format
(
Locale
.
US
,
"\\draw[black, line width=\\LineWidth] (%f,%f) rectangle (%f,%f);\n"
,
limits
.
xLow
,
limits
.
yLow
,
limits
.
xHigh
,
limits
.
yLow
);
}
if
(
voronoiDiagram
!=
null
&&
voronoiDiagram
.
getFaces
()
!=
null
)
{
for
(
Face
face
:
voronoiDiagram
.
getFaces
())
{
boolean
go
=
true
;
boolean
closed
=
false
;
HalfEdge
last
=
face
.
getOuterComponent
();
HalfEdge
next
=
last
.
getNext
();
HalfEdge
outerComponent
=
last
;
while
(
go
)
{
if
(
next
==
null
||
last
.
getOrigin
()
==
null
)
{
go
=
false
;
closed
=
true
;
}
else
{
voronoiDiagramAsTikz
+=
String
.
format
(
Locale
.
US
,
"\\draw[black, line width=\\LineWidth] (%f,%f) to (%f,%f);\n"
,
last
.
getOrigin
().
x
,
last
.
getOrigin
().
y
,
next
.
getOrigin
().
x
,
next
.
getOrigin
().
y
);
if
(
next
==
outerComponent
)
{
go
=
false
;
}
else
{
last
=
next
;
next
=
next
.
getNext
();
}
}
}
last
=
outerComponent
;
next
=
last
.
getPrevious
();
go
=
true
;
while
(
go
&&
!
closed
)
{
if
(
next
==
null
||
next
.
getOrigin
()
==
null
)
{
go
=
false
;
}
else
{
voronoiDiagramAsTikz
+=
String
.
format
(
Locale
.
US
,
"\\draw[black, line width=\\LineWidth] (%f,%f) to (%f,%f);\n"
,
last
.
getOrigin
().
x
,
last
.
getOrigin
().
y
,
next
.
getOrigin
().
x
,
next
.
getOrigin
().
y
);
if
(
next
==
outerComponent
)
{
go
=
false
;
}
else
{
last
=
next
;
next
=
next
.
getPrevious
();
}
}
}
}
}
}
return
voronoiDiagramAsTikz
;
}
private
String
convertJavaToTikzPath
(
int
type
,
float
[]
coords
)
{
private
String
convertJavaToTikzPath
(
int
type
,
float
[]
coords
)
{
if
(
type
<
SEG_MOVETO
||
type
>
SEG_CLOSE
)
{
if
(
type
<
SEG_MOVETO
||
type
>
SEG_CLOSE
)
{
throw
new
IllegalStateException
(
String
.
format
(
Locale
.
US
,
"Cannot process path segment type: %d (coordinates: %s)"
,
type
,
Arrays
.
toString
(
coords
)));
throw
new
IllegalStateException
(
String
.
format
(
Locale
.
US
,
"Cannot process path segment type: %d (coordinates: %s)"
,
type
,
Arrays
.
toString
(
coords
)));
...
...
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