From: <aki...@us...> - 2006-12-12 03:39:26
|
Revision: 1018 http://svn.sourceforge.net/gridarta/?rev=1018&view=rev Author: akirschbaum Date: 2006-12-10 08:21:49 -0800 (Sun, 10 Dec 2006) Log Message: ----------- Use File instead of String filenames. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFJavaEditor.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/MapViewIFrame.java trunk/daimonin/src/daieditor/CFJavaEditor.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/MapViewIFrame.java Modified: trunk/crossfire/src/cfeditor/CFJavaEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/CFJavaEditor.java 2006-12-10 15:59:12 UTC (rev 1017) +++ trunk/crossfire/src/cfeditor/CFJavaEditor.java 2006-12-10 16:21:49 UTC (rev 1018) @@ -137,7 +137,7 @@ } if (outfile != null) { - mainControl.createImageWanted(outfile); // create map image + mainControl.createImageWanted(new File(outfile)); // create map image System.exit(0); // exit } @@ -145,14 +145,13 @@ } - private static void makeImage(final CMainControl mainControl, final String in, final String out) { + private static void makeImage(final CMainControl mainControl, final File in, final File out) { if (log.isInfoEnabled()) { log.info("converting " + in + " to " + out); } - final File f = new File(in); - if (f.canRead()) { - mainControl.openFile(f); + if (in.canRead()) { + mainControl.openFile(in); mainControl.createImageWanted(out); mainControl.close(); } @@ -169,7 +168,7 @@ log.info("done."); System.exit(0); } - makeImage(mainControl, in, out); + makeImage(mainControl, new File(in), new File(out)); } } catch (final IOException e) { log.info("done."); Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-10 15:59:12 UTC (rev 1017) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-10 16:21:49 UTC (rev 1018) @@ -1050,7 +1050,7 @@ if (!filename.endsWith(".png")) { filename += ".png"; } - mapControl.getMapViewFrame().printFullImage(filename); + mapControl.getMapViewFrame().printFullImage(new File(filename)); } } catch (final IOException e) { ACTION_FACTORY.showMessageDialog(mainView, "createImgIOException", filename, e.getMessage()); @@ -1062,32 +1062,32 @@ * Create an image of the current map and save it as file. * In this method, the filename is already given, so the image * is created directly (if possible). - * @param filename Name of the png image file to create. + * @param file the png image file to create */ - public void createImageWanted(final String filename) { - createImageWanted(currentMap, filename); + public void createImageWanted(final File file) { + createImageWanted(currentMap, file); } /** * Create an image of the specified map and save it as file. * In this method, the filename is already given, so the image * is created directly (if possible). - * @param filename Name of the png image file to create. - * @param mapControl The controller of map to save. + * @param mapControl the controller of map to save + * @param file the png image file to create */ - public void createImageWanted(final MapControl mapControl, final String filename) { + public void createImageWanted(final MapControl mapControl, final File file) { if (mapControl == null) { // there is no map open (should not happen due to disabled menus) ACTION_FACTORY.showMessageDialog(mainView, "createImgNoMap"); } else { try { - mapControl.getMapViewFrame().printFullImage(filename); + mapControl.getMapViewFrame().printFullImage(file); if (log.isInfoEnabled()) { - log.info(ACTION_FACTORY.format("imageCreated", filename, mapControl.getMapFileName())); + log.info(ACTION_FACTORY.format("imageCreated", file, mapControl.getMapFileName())); } } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(mainView, "createImgIOException", filename); + ACTION_FACTORY.showMessageDialog(mainView, "createImgIOException", file); } } } Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-10 15:59:12 UTC (rev 1017) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-10 16:21:49 UTC (rev 1018) @@ -295,11 +295,11 @@ /** * Convert the map into a png file. - * @param filename the file to write to + * @param file the file to write to * @throws IOException in case of I/O problems writing the image. */ - public void printFullImage(final String filename) throws IOException { - ImageIO.write(renderer.getFullImage(), "png", new File(filename)); + public void printFullImage(final File file) throws IOException { + ImageIO.write(renderer.getFullImage(), "png", file); } /** Refreshes the data in the view from the model. */ Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-10 15:59:12 UTC (rev 1017) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-10 16:21:49 UTC (rev 1018) @@ -32,6 +32,7 @@ import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Point; +import java.io.File; import java.io.IOException; import javax.swing.JInternalFrame; import javax.swing.JViewport; @@ -174,8 +175,8 @@ view.setHotspot(point); } - public void printFullImage(final String filename) throws IOException { - view.printFullImage(filename); + public void printFullImage(final File file) throws IOException { + view.printFullImage(file); } public void refreshDataFromModel() { Modified: trunk/daimonin/src/daieditor/CFJavaEditor.java =================================================================== --- trunk/daimonin/src/daieditor/CFJavaEditor.java 2006-12-10 15:59:12 UTC (rev 1017) +++ trunk/daimonin/src/daieditor/CFJavaEditor.java 2006-12-10 16:21:49 UTC (rev 1018) @@ -25,6 +25,7 @@ package daieditor; import static daieditor.CMainControl.PREFS_LANGUAGE; +import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -112,7 +113,7 @@ if (infiles.size() > 1) { System.err.println("Warning: you specified more than 1 map for creating an image. I will create an image for only one of them."); } - mainControl.createImageWanted(outfile); // create map image + mainControl.createImageWanted(new File(outfile)); // create map image } mainControl.refreshMenusAndToolbars(); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-10 15:59:12 UTC (rev 1017) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-10 16:21:49 UTC (rev 1018) @@ -1408,8 +1408,9 @@ if (!filename.endsWith(".png")) { filename += ".png"; } - if (!new File(filename).exists() || ACTION_FACTORY.showConfirmDialog(mainView, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, "overwriteOtherFile", filename) == JOptionPane.YES_OPTION) { - mapControl.getMapViewFrame().printFullImage(filename); + final File file = new File(filename); + if (!file.exists() || ACTION_FACTORY.showConfirmDialog(mainView, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, "overwriteOtherFile", filename) == JOptionPane.YES_OPTION) { + mapControl.getMapViewFrame().printFullImage(file); } } } catch (final IOException e) { @@ -1422,9 +1423,9 @@ * Create an image of the current map and save it as file. * In this method, the filename is already given, so the image * is created directly (if possible). - * @param filename Name of the png image file to create. + * @param file the png image file to create */ - public void createImageWanted(final String filename) { + public void createImageWanted(final File file) { final MapControl mapc = currentMap; // control of current map if (mapc == null) { @@ -1432,12 +1433,12 @@ ACTION_FACTORY.showMessageDialog(mainView, "createImgNoMap"); } else { try { - mapc.getMapViewFrame().printFullImage(filename); + mapc.getMapViewFrame().printFullImage(file); if (log.isInfoEnabled()) { - log.info(ACTION_FACTORY.format("imageCreated", filename, mapc.getMapFileName())); + log.info(ACTION_FACTORY.format("imageCreated", file, mapc.getMapFileName())); } } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(mainView, "createImgIOException", filename); + ACTION_FACTORY.showMessageDialog(mainView, "createImgIOException", file); } } } Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-10 15:59:12 UTC (rev 1017) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-10 16:21:49 UTC (rev 1018) @@ -310,11 +310,11 @@ /** * Saves an image of the entire view to a file. - * @param filename filename to write image file to + * @param file file to write image file to * @throws IOException in case of I/O problems */ - public void printFullImage(final String filename) throws IOException { - ImageIO.write(getFullImage(), "png", new File(filename)); + public void printFullImage(final File file) throws IOException { + ImageIO.write(getFullImage(), "png", file); } /** Modified: trunk/daimonin/src/daieditor/MapViewIFrame.java =================================================================== --- trunk/daimonin/src/daieditor/MapViewIFrame.java 2006-12-10 15:59:12 UTC (rev 1017) +++ trunk/daimonin/src/daieditor/MapViewIFrame.java 2006-12-10 16:21:49 UTC (rev 1018) @@ -29,6 +29,7 @@ import java.awt.Image; import java.awt.Point; import java.awt.event.ActionEvent; +import java.io.File; import java.io.IOException; import javax.swing.AbstractAction; import static javax.swing.Action.SMALL_ICON; @@ -123,8 +124,8 @@ view.setHotspot(pos); } - public void printFullImage(final String filename) throws IOException { - view.printFullImage(filename); + public void printFullImage(final File file) throws IOException { + view.printFullImage(file); } /** The Action to select this Window. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |