Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NetworkedGraphicsMV3500
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Savage
NetworkedGraphicsMV3500
Commits
3f8c4369
Commit
3f8c4369
authored
3 years ago
by
Brutzman, Don
Browse files
Options
Downloads
Patches
Plain Diff
upgrade to java.time
parent
f9dde04c
No related branches found
No related tags found
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/src/OpenDis7Examples/PduTrack.java
+28
-20
28 additions, 20 deletions
examples/src/OpenDis7Examples/PduTrack.java
examples/src/OpenDis7Examples/PduTrackLog.txt
+47
-47
47 additions, 47 deletions
examples/src/OpenDis7Examples/PduTrackLog.txt
with
75 additions
and
67 deletions
examples/src/OpenDis7Examples/PduTrack.java
+
28
−
20
View file @
3f8c4369
...
...
@@ -49,13 +49,13 @@ import java.io.ByteArrayOutputStream;
import
java.io.DataOutputStream
;
import
java.io.IOException
;
import
java.nio.ByteBuffer
;
import
java.text.DateFormat
;
import
java.text.SimpleDateFormat
;
import
java.time.Instant
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.time.Instant
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
/**
* Create a track from DIS ESPDUs
...
...
@@ -63,11 +63,11 @@ import java.util.Date;
*/
public
class
PduTrack
{
private
String
descriptor
=
new
String
();
private
ArrayList
<
Pdu
>
pduList
=
new
ArrayList
<>();
private
EntityStatePdu
initialEspdu
;
private
String
descriptor
=
new
String
();
private
ArrayList
<
Pdu
>
pduList
=
new
ArrayList
<>();
private
EntityStatePdu
initialEspdu
;
private
EntityStatePdu
latestEspdu
;
private
Vector3Double
initialLocation
;
private
Vector3Double
initialLocation
;
private
Vector3Double
latestLocation
;
/** waypoint timelineList in seconds */
...
...
@@ -85,18 +85,29 @@ public class PduTrack
private
String
x3dOrientationInterpolatorDEF
=
new
String
();
private
boolean
addLineBreaksWithinKeyValues
=
false
;
protected
PduFactory
pduFactory
=
new
PduFactory
();
DisTime
.
TimestampStyle
timestampStyle
=
DisTime
.
TimestampStyle
.
IEEE_ABSOLUTE
;
protected
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
protected
DataOutputStream
dataOutputStream
=
new
DataOutputStream
(
byteArrayOutputStream
);
private
String
TRACE_PREFIX
=
"["
+
(
PduTrack
.
class
.
getSimpleName
())
+
"] "
;
protected
PduFactory
pduFactory
=
new
PduFactory
();
public
DisTime
.
TimestampStyle
timestampStyle
=
DisTime
.
TimestampStyle
.
IEEE_ABSOLUTE
;
private
LocalDateTime
recordingStart
;
private
LocalDateTime
recordingStop
;
private
String
todaysDateString
=
new
String
();
protected
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
protected
DataOutputStream
dataOutputStream
=
new
DataOutputStream
(
byteArrayOutputStream
);
private
String
TRACE_PREFIX
=
"["
+
(
PduTrack
.
class
.
getSimpleName
())
+
"] "
;
/**
* Constructor for PduTrack
*/
public
PduTrack
()
{
// can place initialization code here
// initialization code here
// https://docs.oracle.com/javase/tutorial/datetime/TOC.html
// https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/package-summary.html
// https://stackoverflow.com/questions/5175728/how-to-get-the-current-date-time-in-java/5175900 (scroll down to java.time)
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"d MMMM yyyy"
);
todaysDateString
=
LocalDate
.
now
().
format
(
formatter
);
// System.out.println(TRACE_PREFIX + "today=" + todayString);
}
/**
...
...
@@ -107,6 +118,7 @@ public class PduTrack
{
timestampStyle
=
newTimestampStyle
;
DisTime
.
setTimestampStyle
(
newTimestampStyle
);
// automatic super invocation: return PduTrack();
}
/**
...
...
@@ -642,7 +654,7 @@ public class PduTrack
* @return X3D PositionInterpolator as string
*/
public
String
createX3dModelHeaderString
()
{
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
).
append
(
"\n"
);
...
...
@@ -653,12 +665,8 @@ public class PduTrack
sb
.
append
(
" <meta content='"
).
append
(
getX3dModelName
()).
append
(
"' name='title'/>"
).
append
(
"\n"
);
sb
.
append
(
" <meta content='Conversion of ESPDU track into X3D animation interpolators and LineSet.' name='description'/>"
).
append
(
"\n"
);
// https://docs.oracle.com/javase/tutorial/datetime/TOC.html
// https://stackoverflow.com/questions/5175728/how-to-get-the-current-date-time-in-java/5175900
DateFormat
dateFormat
=
new
SimpleDateFormat
(
"d MMMM yyyy"
);
Date
date
=
new
Date
();
sb
.
append
(
" <meta content='1 January 2022' name='created'/>"
).
append
(
"\n"
);
sb
.
append
(
" <meta content='"
).
append
(
dateFormat
.
format
(
date
)
).
append
(
"' name='modified'/>"
).
append
(
"\n"
);
sb
.
append
(
" <meta content='"
).
append
(
todaysDateString
).
append
(
"' name='modified'/>"
).
append
(
"\n"
);
if
(!
getAuthor
().
isEmpty
())
sb
.
append
(
" <meta content='"
).
append
(
getAuthor
()).
append
(
"' name='creator'/>"
).
append
(
"\n"
);
if
(!
getX3dModelIdentifier
().
isEmpty
())
...
...
This diff is collapsed.
Click to expand it.
examples/src/OpenDis7Examples/PduTrackLog.txt
+
47
−
47
View file @
3f8c4369
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment