From: <chr...@us...> - 2007-01-26 17:25:28
|
Revision: 1720 http://svn.sourceforge.net/gridarta/?rev=1720&view=rev Author: christianhujer Date: 2007-01-26 09:25:26 -0800 (Fri, 26 Jan 2007) Log Message: ----------- Minor change to createImage() so it creates less objects. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-26 17:03:33 UTC (rev 1719) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-26 17:25:26 UTC (rev 1720) @@ -1047,39 +1047,39 @@ strImageDir = mapDir.getAbsolutePath(); } - String filename = strImageDir + "/" + mapControl.getMapFileName() + ".png"; - try { - final JFileChooser fileChooser = new JFileChooser(strImageDir); - fileChooser.setDialogTitle("Save Image As"); - fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - fileChooser.setMultiSelectionEnabled(false); - fileChooser.setSelectedFile(new File(filename)); - // set a file filter for "*.png" files - fileChooser.setFileFilter(new FileFilter() { - @Override public String getDescription() { - return "*.png"; - } + String startFilename = strImageDir + "/" + mapControl.getMapFileName() + ".png"; + final JFileChooser fileChooser = new JFileChooser(strImageDir); + fileChooser.setDialogTitle("Save Image As"); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + fileChooser.setMultiSelectionEnabled(false); + fileChooser.setSelectedFile(new File(startFilename)); + // set a file filter for "*.png" files + fileChooser.setFileFilter(new FileFilter() { + @Override public String getDescription() { + return "*.png"; + } - @Override public boolean accept(final File f) { - return f.isDirectory() || f.getName().endsWith(".png"); - } - }); + @Override public boolean accept(final File f) { + return f.isDirectory() || f.getName().endsWith(".png"); + } + }); - final int returnVal = fileChooser.showSaveDialog(mainView); - if (returnVal == JFileChooser.APPROVE_OPTION) { - // got the filepath, now create image - filename = fileChooser.getSelectedFile().getAbsolutePath(); - strImageDir = fileChooser.getSelectedFile().getParentFile().getAbsolutePath(); - if (!filename.endsWith(".png")) { - filename += ".png"; + final int returnVal = fileChooser.showSaveDialog(mainView); + if (returnVal == JFileChooser.APPROVE_OPTION) { + // got the filepath, now create image + File imageFile = fileChooser.getSelectedFile(); + final String filename = imageFile.getAbsolutePath(); + if (!filename.endsWith(".png")) { + imageFile = new File(filename + ".png"); + } + strImageDir = imageFile.getParentFile().getAbsolutePath(); + if (!imageFile.exists() || ACTION_FACTORY.showConfirmDialog(mainView, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, "overwriteOtherFile", imageFile) == JOptionPane.YES_OPTION) { + try { + mapControl.getMapViewFrame().printFullImage(imageFile); + } catch (final IOException e) { + ACTION_FACTORY.showMessageDialog(mainView, "createImageIOException", imageFile, e.getMessage()); } - 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(new File(filename)); - } } - } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(mainView, "createImageIOException", filename, e.getMessage()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |