Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
V
vadere
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
110
Issues
110
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
3
Merge Requests
3
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vadere
vadere
Commits
fddbac91
Commit
fddbac91
authored
Oct 02, 2017
by
Benedikt Zoennchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix path problem in DataProcessingView
parent
b39e6733
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
53 additions
and
38 deletions
+53
-38
VadereGui/src/org/vadere/gui/projectview/model/ProjectViewModel.java
...rc/org/vadere/gui/projectview/model/ProjectViewModel.java
+7
-13
VadereGui/src/org/vadere/gui/projectview/view/DataProcessingView.java
...c/org/vadere/gui/projectview/view/DataProcessingView.java
+3
-3
VadereSimulator/src/org/vadere/simulator/projects/ScenarioRun.java
...ulator/src/org/vadere/simulator/projects/ScenarioRun.java
+5
-3
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/DataProcessingJsonManager.java
...or/projects/dataprocessing/DataProcessingJsonManager.java
+1
-1
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/ProcessorManager.java
...e/simulator/projects/dataprocessing/ProcessorManager.java
+9
-1
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/outputfile/OutputFile.java
...ulator/projects/dataprocessing/outputfile/OutputFile.java
+12
-6
VadereSimulator/src/org/vadere/simulator/projects/io/IOOutput.java
...ulator/src/org/vadere/simulator/projects/io/IOOutput.java
+15
-9
VadereSimulator/src/org/vadere/simulator/projects/io/TrajectoryReader.java
...rc/org/vadere/simulator/projects/io/TrajectoryReader.java
+1
-2
No files found.
VadereGui/src/org/vadere/gui/projectview/model/ProjectViewModel.java
View file @
fddbac91
...
...
@@ -18,6 +18,9 @@ import javax.swing.*;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.*
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.stream.Collectors
;
public
class
ProjectViewModel
{
...
...
@@ -29,7 +32,8 @@ public class ProjectViewModel {
private
final
OutputFileTableModel
outputTableModel
;
private
final
VadereScenarioTableModel
scenarioTableModel
;
private
String
currentProjectPath
;
private
Thread
refreshOutputThread
;
private
ExecutorService
refreshOutputExecutor
;
// these are also part of the model, because only they know the current selected row
private
VTable
scenarioTable
;
...
...
@@ -45,7 +49,7 @@ public class ProjectViewModel {
this
.
outputRefreshListeners
=
new
LinkedList
<>();
this
.
projectChangeListeners
=
new
LinkedList
<>();
this
.
project
=
null
;
this
.
refreshOutput
Thread
=
null
;
this
.
refreshOutput
Executor
=
Executors
.
newSingleThreadExecutor
()
;
}
public
void
deleteOutputFiles
(
final
int
[]
rows
)
throws
IOException
{
...
...
@@ -123,17 +127,7 @@ public class ProjectViewModel {
}
public
void
refreshOutputTable
()
{
if
(
refreshOutputThread
!=
null
&&
refreshOutputThread
.
isAlive
())
{
try
{
logger
.
info
(
"wait for output refresh to be finished, before restart again"
);
refreshOutputThread
.
join
();
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
logger
.
error
(
e
.
getLocalizedMessage
());
}
}
refreshOutputThread
=
new
Thread
(
new
OutputRefresher
());
refreshOutputThread
.
start
();
refreshOutputExecutor
.
execute
(
new
OutputRefresher
());
}
public
void
addScenario
(
final
Scenario
scenario
)
{
...
...
VadereGui/src/org/vadere/gui/projectview/view/DataProcessingView.java
View file @
fddbac91
...
...
@@ -492,9 +492,9 @@ class DataProcessingView extends JPanel implements IJsonView {
c
.
gridx
=
1
;
c
.
gridy
=
0
;
JTextField
nameField
=
new
JTextField
(
outputFile
.
getFileName
());
JTextField
nameField
=
new
JTextField
(
outputFile
.
toString
());
nameField
.
addActionListener
(
ae
->
{
String
oldName
=
outputFile
.
getFileName
();
String
oldName
=
outputFile
.
toString
();
String
newName
=
nameField
.
getText
();
if
(!
oldName
.
equals
(
newName
))
{
String
msg
=
""
;
...
...
@@ -505,7 +505,7 @@ class DataProcessingView extends JPanel implements IJsonView {
msg
=
"File name is already in use"
;
}
if
(
msg
.
isEmpty
())
{
outputFile
.
setFileName
(
newName
);
outputFile
.
set
Relative
FileName
(
newName
);
outputFilesTable
.
repaint
();
refreshGUI
();
}
else
{
...
...
VadereSimulator/src/org/vadere/simulator/projects/ScenarioRun.java
View file @
fddbac91
...
...
@@ -74,9 +74,11 @@ public class ScenarioRun implements Runnable {
// prepare processors and simulation data writer
processorManager
=
dataProcessingJsonManager
.
createProcessorManager
(
mainModel
);
createAndSetOutputDirectory
();
scenario
.
saveToOutputPath
(
outputPath
);
// Only create output directory and write .scenario file if there is any output.
if
(!
processorManager
.
isEmpty
())
{
createAndSetOutputDirectory
();
scenario
.
saveToOutputPath
(
outputPath
);
}
sealAllAttributes
();
...
...
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/DataProcessingJsonManager.java
View file @
fddbac91
...
...
@@ -90,7 +90,7 @@ public class DataProcessingJsonManager {
private
OutputFile
<?>
instantiateOutputFile
(
final
OutputFileStore
fileStore
)
{
OutputFile
<?>
file
=
outputFileInstantiator
.
createObject
(
fileStore
.
getType
());
file
.
setFileName
(
fileStore
.
getFilename
());
file
.
set
Absolute
FileName
(
fileStore
.
getFilename
());
file
.
setProcessorIds
(
fileStore
.
getProcessors
());
file
.
setSeparator
(
fileStore
.
getSeparator
());
return
file
;
...
...
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/ProcessorManager.java
View file @
fddbac91
...
...
@@ -69,7 +69,7 @@ public class ProcessorManager {
}
public
void
setOutputPath
(
String
directory
)
{
this
.
outputFiles
.
forEach
(
file
->
file
.
setFileName
(
Paths
.
get
(
directory
,
String
.
format
(
"%s"
,
new
File
(
file
.
getFileName
()).
getName
())).
toString
()));
this
.
outputFiles
.
forEach
(
file
->
file
.
set
Absolute
FileName
(
Paths
.
get
(
directory
,
String
.
format
(
"%s"
,
new
File
(
file
.
getFileName
()).
getName
())).
toString
()));
}
public
void
writeOutput
()
{
...
...
@@ -80,6 +80,14 @@ public class ProcessorManager {
return
this
.
jsonManager
.
serializeToNode
();
}
/**
* Returns true if there is no output to write, otherwise false.
* @return
*/
public
boolean
isEmpty
()
{
return
processorMap
.
isEmpty
();
}
public
void
sealAllAttributes
()
{
processorMap
.
values
().
forEach
(
p
->
p
.
sealAttributes
());
}
...
...
VadereSimulator/src/org/vadere/simulator/projects/dataprocessing/outputfile/OutputFile.java
View file @
fddbac91
...
...
@@ -4,10 +4,8 @@ import org.vadere.simulator.projects.dataprocessing.ProcessorManager;
import
org.vadere.simulator.projects.dataprocessing.datakey.DataKey
;
import
org.vadere.simulator.projects.dataprocessing.processor.DataProcessor
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.io.UncheckedIOException
;
import
java.io.*
;
import
java.nio.file.Path
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.LinkedList
;
...
...
@@ -42,10 +40,14 @@ public abstract class OutputFile<K extends DataKey<K>> {
this
.
dataProcessors
=
new
ArrayList
<>();
}
public
void
setFileName
(
final
String
fileName
)
{
public
void
set
Absolute
FileName
(
final
String
fileName
)
{
this
.
fileName
=
fileName
;
}
public
void
setRelativeFileName
(
final
String
fileName
)
{
this
.
fileName
=
new
File
(
this
.
fileName
).
getParentFile
().
toPath
().
resolve
(
fileName
).
toString
();
}
public
void
setProcessorIds
(
final
List
<
Integer
>
processorIds
)
{
this
.
processorIds
=
processorIds
;
this
.
dataProcessors
.
clear
();
...
...
@@ -78,6 +80,10 @@ public abstract class OutputFile<K extends DataKey<K>> {
}
}
public
boolean
isEmpty
()
{
return
this
.
dataProcessors
.
isEmpty
();
}
private
List
<
String
>
getFieldHeaders
()
{
return
composeLine
(
keyHeaders
,
p
->
Arrays
.
stream
(
p
.
getHeaders
()));
}
...
...
@@ -125,6 +131,6 @@ public abstract class OutputFile<K extends DataKey<K>> {
@Override
public
String
toString
()
{
return
fileName
;
return
new
File
(
fileName
).
getName
()
;
}
}
VadereSimulator/src/org/vadere/simulator/projects/io/IOOutput.java
View file @
fddbac91
...
...
@@ -47,8 +47,7 @@ public abstract class IOOutput {
* Returns all valid output directories of the project.
*/
public
static
List
<
File
>
listAllOutputDirs
(
final
VadereProject
project
)
{
return
listAllDirs
(
project
).
stream
().
filter
(
f
->
isValidOutputDirectory
(
project
,
f
))
.
collect
(
Collectors
.
toList
());
return
listAllDirs
(
project
).
stream
().
filter
(
f
->
isValidOutputDirectory
(
project
,
f
)).
collect
(
Collectors
.
toList
());
}
/**
...
...
@@ -59,20 +58,27 @@ public abstract class IOOutput {
.
forEach
(
dir
->
cleanDirectory
(
project
,
dir
));
}
public
static
Map
<
Step
,
List
<
Agent
>>
readTrajectories
(
final
VadereProject
project
,
final
Scenario
scenario
,
final
String
directoryName
)
throws
IOException
{
TrajectoryReader
reader
=
new
TrajectoryReader
(
getPathToOutputFile
(
project
,
directoryName
,
IOUtils
.
TRAJECTORY_FILE_EXTENSION
),
scenario
);
public
static
Map
<
Step
,
List
<
Agent
>>
readTrajectories
(
final
VadereProject
project
,
final
Scenario
scenario
,
final
String
directoryName
)
throws
IOException
{
TrajectoryReader
reader
=
new
TrajectoryReader
(
getPathToOutputFile
(
project
,
directoryName
,
IOUtils
.
TRAJECTORY_FILE_EXTENSION
),
scenario
);
return
reader
.
readFile
();
}
public
static
Map
<
Step
,
List
<
Agent
>>
readTrajectories
(
final
Path
trajectoryFilePath
,
final
Scenario
scenario
)
throws
IOException
{
public
static
Map
<
Step
,
List
<
Agent
>>
readTrajectories
(
final
Path
trajectoryFilePath
,
final
Scenario
scenario
)
throws
IOException
{
TrajectoryReader
reader
=
new
TrajectoryReader
(
trajectoryFilePath
,
scenario
);
Map
<
Step
,
List
<
Agent
>>
result
=
reader
.
readFile
();
return
result
;
}
private
static
Optional
<
Map
<
Step
,
List
<
Agent
>>>
readTrajectories
(
final
VadereProject
project
,
final
File
directory
)
{
try
{
TrajectoryReader
reader
=
new
TrajectoryReader
(
getPathToOutputFile
(
project
,
directory
.
getName
(),
IOUtils
.
TRAJECTORY_FILE_EXTENSION
));
return
Optional
.
of
(
reader
.
readFile
());
}
catch
(
IOException
|
VadereClassNotFoundException
e
)
{
logger
.
error
(
"Error in output file "
+
directory
.
getName
());
return
Optional
.
empty
();
}
}
public
static
Scenario
readScenarioRunManager
(
final
VadereProject
project
,
final
String
directoryName
)
throws
IOException
{
String
snapshotString
=
IOUtils
...
...
@@ -190,7 +196,7 @@ public abstract class IOOutput {
}
private
static
boolean
isValidOutputDirectory
(
final
VadereProject
project
,
final
File
directory
)
{
return
readOutputFile
(
project
,
directory
).
isPresent
();
return
readOutputFile
(
project
,
directory
).
isPresent
()
&&
readTrajectories
(
project
,
directory
).
isPresent
()
;
}
private
static
boolean
isMatchingOutputDirectory
(
final
VadereProject
project
,
final
File
directory
,
...
...
VadereSimulator/src/org/vadere/simulator/projects/io/TrajectoryReader.java
View file @
fddbac91
package
org.vadere.simulator.projects.io
;
import
com.sun.xml.internal.ws.policy.privateutil.PolicyUtils
;
import
org.apache.commons.math3.util.Pair
;
import
org.apache.log4j.LogManager
;
import
org.apache.log4j.Logger
;
...
...
@@ -103,7 +102,7 @@ public class TrajectoryReader {
return
Files
.
lines
(
this
.
trajectoryFilePath
)
.
skip
(
1
)
// Skip header line
.
map
(
line
->
line
.
split
(
" "
))
.
map
(
line
->
line
.
split
(
SPLITTER
))
.
map
(
cells
->
{
int
step
=
Integer
.
parseInt
(
cells
[
stepIndex
]);
int
pedestrianId
=
Integer
.
parseInt
(
cells
[
pedIdIndex
]);
...
...
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