Skip to content

Commit

Permalink
Replaces an == comparison between Strings by equals
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisDrogoul committed Jul 25, 2021
1 parent d57d08b commit 71907c4
Showing 1 changed file with 9 additions and 13 deletions.
Expand Up @@ -16,7 +16,6 @@
import msi.gama.common.util.ImageUtils;
import msi.gama.outputs.IDisplayOutput;
import msi.gama.outputs.LayeredDisplayData;
import msi.gama.outputs.LayeredDisplayOutput;
import msi.gama.runtime.GAMA;
import msi.gama.runtime.IScope;
import msi.gama.runtime.exceptions.GamaRuntimeException;
Expand All @@ -26,7 +25,7 @@
public class SnapshotMaker {

void doSnapshot(final IDisplayOutput output, final IDisplaySurface surface, final Control composite) {
if (output == null || surface == null || composite == null) { return; }
if (output == null || surface == null || composite == null) return;
final IScope scope = surface.getScope();
final String snapshotFile = FileUtils.constructAbsoluteFilePath(scope,
IDisplaySurface.SNAPSHOT_FOLDER_NAME + "/" + GAMA.getModel().getName() + "_display_" + output.getName(),
Expand All @@ -37,10 +36,11 @@ void doSnapshot(final IDisplayOutput output, final IDisplaySurface surface, fina

final int width = w == -1 ? surface.getWidth() : w;
final int height = h == -1 ? surface.getHeight() : h;
final String autosavePath=data.getAutosavePath();
final String file =autosavePath!=""?autosavePath:(snapshotFile + "_size_" + width + "x" + height + "_cycle_" + scope.getClock().getCycle()
+ "_time_" + java.lang.System.currentTimeMillis() + ".png");
System.out.println("xxx "+file);
final String autosavePath = data.getAutosavePath();
final String file = autosavePath != null && !autosavePath.isEmpty() ? autosavePath
: snapshotFile + "_size_" + width + "x" + height + "_cycle_" + scope.getClock().getCycle() + "_time_"
+ java.lang.System.currentTimeMillis() + ".png";
// System.out.println("xxx " + file);
BufferedImage image = null;
if (GamaPreferences.Displays.DISPLAY_FAST_SNAPSHOT.getValue()) {
try {
Expand All @@ -54,10 +54,8 @@ void doSnapshot(final IDisplayOutput output, final IDisplaySurface surface, fina
}
}
// in case it has not worked, snapshot is still null
if (image == null) {
image = surface.getImage(width, height);
}
if (scope.interrupted() || image == null) { return; }
if (image == null) { image = surface.getImage(width, height); }
if (scope.interrupted() || image == null) return;
// Intentionnaly passing GAMA.getRuntimeScope() to errors in order to
// prevent the exceptions from being masked.
try {
Expand All @@ -80,9 +78,7 @@ void doSnapshot(final IDisplayOutput output, final IDisplaySurface surface, fina
GAMA.reportError(GAMA.getRuntimeScope(), e, false);
} finally {
try {
if (os != null) {
os.close();
}
if (os != null) { os.close(); }
} catch (final Exception ex) {
final GamaRuntimeException e = GamaRuntimeException.create(ex, scope);
e.addContext("Unable to close output stream for snapshot image");
Expand Down

0 comments on commit 71907c4

Please sign in to comment.