Commit bdfbf052 authored by Daniel Lehmberg's avatar Daniel Lehmberg
Browse files

Merge branches 'change_dataprocessing_text' and 'master' of gitlab.lrz.de:vadere/vadere

parents 12046d17 2a34665d
...@@ -51,7 +51,7 @@ DataProcessingView.msgFileEmpty=File name can't be empty ...@@ -51,7 +51,7 @@ DataProcessingView.msgFileEmpty=File name can't be empty
DataProcessingView.msgFileInUse=File name is already in use DataProcessingView.msgFileInUse=File name is already in use
DataProcessingView.dialogInvalidFile.label=Invalid file name DataProcessingView.dialogInvalidFile.label=Invalid file name
DataProcessingView.dialogOutputDataKeySelection.label=Data Key DataProcessingView.dialogOutputDataKeySelection.label=Data Key
DataProcessingView.dialogOutputHeaderSelection.label=Header DataProcessingView.dialogOutputIndicesSelection.label=Index
ProgressPanelDone.text=Done ProgressPanelDone.text=Done
ProgressPanelWorking.text=Working... ProgressPanelWorking.text=Working...
...@@ -325,7 +325,7 @@ Tab.Model.insertModelNameSubMenu.title=Main models ...@@ -325,7 +325,7 @@ Tab.Model.insertModelNameSubMenu.title=Main models
Tab.Pedestrians.title=Pedestrians Tab.Pedestrians.title=Pedestrians
Tab.Topography.title=Topography Tab.Topography.title=Topography
Tab.Event.title=Events Tab.Event.title=Events
Tab.OutputProcessors.title=Data processing GUI Tab.OutputProcessors.title=Data processing
Tab.TopographyCreator.title=Topography creator Tab.TopographyCreator.title=Topography creator
Tab.PostVisualization.title=Post-Visualization Tab.PostVisualization.title=Post-Visualization
......
...@@ -50,7 +50,7 @@ DataProcessingView.msgFileEmpty=Datei darf nicht leer sein ...@@ -50,7 +50,7 @@ DataProcessingView.msgFileEmpty=Datei darf nicht leer sein
DataProcessingView.msgFileInUse=Dateiname bereits vorhanden DataProcessingView.msgFileInUse=Dateiname bereits vorhanden
DataProcessingView.dialogInvalidFile.label=Ung\u00FCltiger Dateiname DataProcessingView.dialogInvalidFile.label=Ung\u00FCltiger Dateiname
DataProcessingView.dialogOutputDataKeySelection.label=Rubrik DataProcessingView.dialogOutputDataKeySelection.label=Rubrik
DataProcessingView.dialogOutputHeaderSelection.label=Kopfzeile DataProcessingView.dialogOutputIndicesSelection.label=index
ProgressPanelDone.text=Fertig ProgressPanelDone.text=Fertig
ProgressPanelWorking.text=Arbeite... ProgressPanelWorking.text=Arbeite...
......
...@@ -580,11 +580,11 @@ class DataProcessingView extends JPanel implements IJsonView { ...@@ -580,11 +580,11 @@ class DataProcessingView extends JPanel implements IJsonView {
c.gridx = 0; c.gridx = 0;
c.gridy = 2; c.gridy = 2;
panel.add(new JLabel(Messages.getString("DataProcessingView.dialogOutputHeaderSelection.label")+":"), c); panel.add(new JLabel(Messages.getString("DataProcessingView.dialogOutputIndicesSelection.label")+":"), c);
c.gridx = 1; c.gridx = 1;
c.gridy = 2; c.gridy = 2;
panel.add(new JLabel(outputFile.getHeader()), c); panel.add(new JLabel(outputFile.getIndices()), c);
c.gridx = 0; c.gridx = 0;
c.gridy = 3; c.gridy = 3;
......
...@@ -29,7 +29,12 @@ import java.util.stream.Stream; ...@@ -29,7 +29,12 @@ import java.util.stream.Stream;
*/ */
public abstract class OutputFile<K extends DataKey<K>> { public abstract class OutputFile<K extends DataKey<K>> {
private String[] keyHeaders;
//Note: Only header information from data keys are written in this, therefore, these are the indices
// Each processor attached to this processor itself attaches also headers, but they are not listed in this
// attribute.
private String[] dataIndices;
/** /**
* The file name without the path to the file * The file name without the path to the file
...@@ -48,8 +53,8 @@ public abstract class OutputFile<K extends DataKey<K>> { ...@@ -48,8 +53,8 @@ public abstract class OutputFile<K extends DataKey<K>> {
private VadereWriterFactory writerFactory; private VadereWriterFactory writerFactory;
private VadereWriter writer; private VadereWriter writer;
protected OutputFile(final String... keyHeaders) { protected OutputFile(final String... dataIndices) {
this.keyHeaders = keyHeaders; this.dataIndices = dataIndices;
this.dataProcessors = new ArrayList<>(); this.dataProcessors = new ArrayList<>();
this.writerFactory = VadereWriterFactory.getFileWriterFactory(); this.writerFactory = VadereWriterFactory.getFileWriterFactory();
} }
...@@ -84,7 +89,7 @@ public abstract class OutputFile<K extends DataKey<K>> { ...@@ -84,7 +89,7 @@ public abstract class OutputFile<K extends DataKey<K>> {
if (!isEmpty()) { if (!isEmpty()) {
try (VadereWriter out = writerFactory.create(absoluteFileName)) { try (VadereWriter out = writerFactory.create(absoluteFileName)) {
writer = out; writer = out;
printHeader(out); printIndices(out);
this.dataProcessors.stream().flatMap(p -> p.getKeys().stream()) this.dataProcessors.stream().flatMap(p -> p.getKeys().stream())
.distinct().sorted() .distinct().sorted()
...@@ -101,16 +106,16 @@ public abstract class OutputFile<K extends DataKey<K>> { ...@@ -101,16 +106,16 @@ public abstract class OutputFile<K extends DataKey<K>> {
return this.dataProcessors.isEmpty(); return this.dataProcessors.isEmpty();
} }
private List<String> getFieldHeaders() { private List<String> getDataIndices() {
return composeLine(keyHeaders, p -> Arrays.stream(p.getHeaders())); return composeLine(dataIndices, p -> Arrays.stream(p.getHeaders()));
} }
public void printHeader(VadereWriter out) { public void printIndices(VadereWriter out) {
writeLine(out, getFieldHeaders()); writeLine(out, getDataIndices());
} }
public String getHeader() { public String getIndices() {
return String.join(this.separator, getFieldHeaders()); return String.join(this.separator, getDataIndices());
} }
private void printRow(final VadereWriter out, final K key) { private void printRow(final VadereWriter out, final K key) {
...@@ -133,7 +138,7 @@ public abstract class OutputFile<K extends DataKey<K>> { ...@@ -133,7 +138,7 @@ public abstract class OutputFile<K extends DataKey<K>> {
} }
/** /**
* Return the column headers as string or the empty array. * Return the column indices as string or the empty array.
*/ */
public String[] toStrings(K key) { public String[] toStrings(K key) {
return new String[]{key.toString()}; return new String[]{key.toString()};
......
...@@ -40,19 +40,19 @@ public class TestOutputFileAfterMultipleRuns { ...@@ -40,19 +40,19 @@ public class TestOutputFileAfterMultipleRuns {
@Test() @Test()
public void testFileFormatAfterMultipleSimulationRuns() { public void testFileFormatAfterMultipleSimulationRuns() {
ArrayList<String> headerAfterFirstRun = new ArrayList<>(); ArrayList<String> indicesAfterFirstRun = new ArrayList<>();
ArrayList<String> headerAfterSecondRun = new ArrayList<>(); ArrayList<String> indicesAfterSecondRun = new ArrayList<>();
ProcessorManager manager = testScenario.getDataProcessingJsonManager() ProcessorManager manager = testScenario.getDataProcessingJsonManager()
.createProcessorManager(mainModel); .createProcessorManager(mainModel);
manager.initOutputFiles(); manager.initOutputFiles();
List<OutputFile<?>> outputFiles = testScenario.getDataProcessingJsonManager().getOutputFiles(); List<OutputFile<?>> outputFiles = testScenario.getDataProcessingJsonManager().getOutputFiles();
outputFiles.forEach(f -> headerAfterFirstRun.add(f.getHeader())); outputFiles.forEach(f -> indicesAfterFirstRun.add(f.getIndices()));
manager.initOutputFiles(); manager.initOutputFiles();
outputFiles.forEach(f -> headerAfterSecondRun.add(f.getHeader())); outputFiles.forEach(f -> indicesAfterSecondRun.add(f.getIndices()));
assertEquals("Duplicated Processors in OutputFile after multiple Simulations", assertEquals("Duplicated Processors in OutputFile after multiple Simulations",
headerAfterFirstRun, headerAfterSecondRun); indicesAfterFirstRun, indicesAfterSecondRun);
} }
} }
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