Gridarta Editor
BatchPngCommand.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.commands;
21 
22 import java.io.File;
23 import java.io.IOException;
24 import java.util.ArrayList;
25 import java.util.List;
27 import org.jetbrains.annotations.NotNull;
28 
34 @SuppressWarnings("UseOfSystemOutOrSystemErr")
35 public class BatchPngCommand implements Command {
36 
40  @NotNull
41  private final Iterable<File> args;
42 
46  @NotNull
48 
54  public BatchPngCommand(@NotNull final List<File> args, @NotNull final ImageCreator<?, ?, ?> imageCreator) {
55  this.args = new ArrayList<>(args);
56  this.imageCreator = imageCreator;
57  }
58 
59  @Override
60  public int execute() {
61  for (final File in : args) {
62  final File out = new File(in.getParentFile(), in.getName() + ".png");
63  try {
64  imageCreator.makeImage(in, out);
65  } catch (final IOException ex) {
66  System.err.println(out + ": " + ex.getMessage());
67  return 1;
68  }
69  }
70  return 0;
71  }
72 
73 }
net.sf.gridarta
Base package of all Gridarta classes.
net.sf
net.sf.gridarta.commands.BatchPngCommand.execute
int execute()
Executes the command.
Definition: BatchPngCommand.java:60
net.sf.gridarta.commands.BatchPngCommand.args
final Iterable< File > args
The files to convert.
Definition: BatchPngCommand.java:41
net.sf.gridarta.gui.map.renderer
Definition: AbstractIsoMapRenderer.java:20
net.sf.gridarta.commands.BatchPngCommand.BatchPngCommand
BatchPngCommand(@NotNull final List< File > args, @NotNull final ImageCreator<?, ?, ?> imageCreator)
Creates a new instance.
Definition: BatchPngCommand.java:54
net.sf.gridarta.gui
Graphical User Interface of Gridarta.
net
net.sf.gridarta.gui.map.renderer.ImageCreator.makeImage
void makeImage(@NotNull final File in, @NotNull final File out)
Definition: ImageCreator.java:90
net.sf.gridarta.gui.map.renderer.ImageCreator
Creates images from map instances.
Definition: ImageCreator.java:41
net.sf.gridarta.commands.BatchPngCommand
Run in batch png mode.
Definition: BatchPngCommand.java:35
net.sf.gridarta.gui.map
Base classes for rendering maps.
Definition: AbstractPerMapDialogManager.java:20
net.sf.gridarta.commands.BatchPngCommand.imageCreator
final ImageCreator<?, ?, ?> imageCreator
The ImageCreator to use.
Definition: BatchPngCommand.java:47
net.sf.gridarta.commands.Command
Interface for command-line commands.
Definition: Command.java:26