Commit 98b4bf62 authored by Benedikt Zoennchen's avatar Benedikt Zoennchen
Browse files

bug fix in movie recorder.

parent df8b7ca8
......@@ -36,23 +36,35 @@ public class ActionRecording extends ActionVisualization {
@Override
public void actionPerformed(ActionEvent e) {
try {
if (button != null) {
if (model.config.isRecording()) {
button.setIcon(resources.getIcon("record.png", iconWidth, iconHeight));
if (button != null) {
if (model.config.isRecording()) {
try {
recorder.stopRecording();
} else {
ImageSizeDialog imageSizeDialog = new ImageSizeDialog(model);
if (imageSizeDialog.getState() == ImageSizeDialog.State.Ok) {
button.setIcon(resources.getIcon("stop_record.png", iconWidth, iconHeight));
} catch (IOException e1) {
e1.printStackTrace();
logger.warn("recording failed.");
}
finally {
button.setIcon(resources.getIcon("record.png", iconWidth, iconHeight));
model.config.setRecording(!model.config.isRecording());
}
} else {
ImageSizeDialog imageSizeDialog = new ImageSizeDialog(model);
if (imageSizeDialog.getState() == ImageSizeDialog.State.Ok) {
try {
recorder.startRecording(imageSizeDialog.getImageBound());
} catch (IOException e1) {
e1.printStackTrace();
logger.warn("start recording failed.");
}
finally {
button.setIcon(resources.getIcon("stop_record.png", iconWidth, iconHeight));
model.config.setRecording(!model.config.isRecording());
}
}
model.config.setRecording(!model.config.isRecording());
}
} catch (IOException ioe) {
ioe.printStackTrace();
logger.error(ioe.getMessage());
}
}
......
......@@ -38,6 +38,7 @@ public class MovRecorder implements IRecorder {
this.viewport = model.getViewportBound();
this.generator = new ImageGenerator(renderer, renderer.getModel());
this.step = 0;
this.enc = null;
}
@Override
......@@ -68,20 +69,27 @@ public class MovRecorder implements IRecorder {
try {
enc.finish();
} catch (IndexOutOfBoundsException error) {
logger.log(Priority.DEBUG, "Nothing recorded! " + error.getMessage());
logger.debug("Nothing recorded! " + error.getMessage());
throw error;
}
logger.info(this + " stop recording");
}
@Override
public synchronized void startRecording(final Rectangle2D.Double imageSize) throws IOException {
this.imageSize = imageSize;
this.viewport = model.getViewportBound();
startRecording();
try {
this.imageSize = imageSize;
this.viewport = model.getViewportBound();
startRecording();
logger.info(this + " start recording");
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage());
}
}
@Override
public synchronized void startRecording() {
public synchronized void startRecording() throws IOException {
Date todaysDate = new java.util.Date();
SimpleDateFormat formatter = new SimpleDateFormat(resources.getProperty("SettingsDialog.dataFormat"));
String formattedDate = formatter.format(todaysDate);
......@@ -96,14 +104,12 @@ public class MovRecorder implements IRecorder {
outputFile = fileChooser.getSelectedFile().toString().endsWith(".mov") ? fileChooser.getSelectedFile()
: new File(fileChooser.getSelectedFile().toString() + ".mov");
try {
this.enc = new SequenceEncoder(outputFile);
enc = new SequenceEncoder(outputFile);
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage());
enc = null;
throw e;
}
logger.info(this + " start recording");
}
}
@Override
......
......@@ -118,7 +118,7 @@
"obstacles" : [ {
"shape" : {
"x" : 4.0,
"y" : 1.0,
"y" : 2.0,
"width" : 2.0,
"height" : 3.0,
"type" : "RECTANGLE"
......
......@@ -2,7 +2,6 @@
"name" : "group_OSM_1Source1Place",
"description" : "",
"release" : "0.6",
"commithash" : "warning: no commit hash",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
......@@ -85,7 +84,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" : 0
"simulationSeed" : 1
},
"topography" : {
"attributes" : {
......@@ -139,6 +138,7 @@
"groupSizeDistribution" : [ 0.0, 0.0, 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
......@@ -163,8 +163,7 @@
"x" : 1.0,
"y" : 0.0
}
},
"dynamicElements" : [ ]
}
}
}
}
\ No newline at end of file
......@@ -2,7 +2,6 @@
"name" : "group_OSM_1Source1Place_noGroup",
"description" : "",
"release" : "0.6",
"commithash" : "warning: no commit hash",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
......@@ -78,7 +77,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" : 0
"simulationSeed" : 1
},
"topography" : {
"attributes" : {
......@@ -132,6 +131,7 @@
"groupSizeDistribution" : [ 0.0, 0.0, 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
......@@ -156,8 +156,7 @@
"x" : 1.0,
"y" : 0.0
}
},
"dynamicElements" : [ ]
}
}
}
}
\ No newline at end of file
......@@ -2,7 +2,6 @@
"name" : "group_OSM_1Source2Places",
"description" : "",
"release" : "0.6",
"commithash" : "warning: no commit hash",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
......@@ -85,7 +84,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" : 0
"simulationSeed" : 1
},
"topography" : {
"attributes" : {
......@@ -195,6 +194,7 @@
"groupSizeDistribution" : [ 0.0, 0.0, 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
......@@ -219,8 +219,7 @@
"x" : 1.0,
"y" : 0.0
}
},
"dynamicElements" : [ ]
}
}
}
}
\ No newline at end of file
......@@ -2,7 +2,6 @@
"name" : "group_OSM_1Source2Places_noGroups",
"description" : "",
"release" : "0.6",
"commithash" : "warning: no commit hash",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
......@@ -78,7 +77,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" : 0
"simulationSeed" : 1
},
"topography" : {
"attributes" : {
......@@ -206,6 +205,7 @@
"groupSizeDistribution" : [ 0.0, 0.0, 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
......@@ -230,8 +230,7 @@
"x" : 1.0,
"y" : 0.0
}
},
"dynamicElements" : [ ]
}
}
}
}
\ No newline at end of file
......@@ -2,7 +2,6 @@
"name" : "group_OSM_2Sources1Place",
"description" : "",
"release" : "0.6",
"commithash" : "warning: no commit hash",
"processWriters" : {
"files" : [ {
"type" : "org.vadere.simulator.projects.dataprocessing.outputfile.TimestepPedestrianIdOutputFile",
......@@ -85,7 +84,7 @@
"digitsPerCoordinate" : 2,
"useFixedSeed" : true,
"fixedSeed" : 1,
"simulationSeed" : 0
"simulationSeed" : 1
},
"topography" : {
"attributes" : {
......@@ -177,6 +176,7 @@
"groupSizeDistribution" : [ 0.0, 0.0, 1.0 ],
"dynamicElementType" : "PEDESTRIAN"
} ],
"dynamicElements" : [ ],
"attributesPedestrian" : {
"radius" : 0.195,
"densityDependentSpeed" : false,
......@@ -201,8 +201,7 @@
"x" : 1.0,
"y" : 0.0
}
},
"dynamicElements" : [ ]
}
}
}
}
\ No newline at end of file
Supports Markdown
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