[Pixelle-commit] SF.net SVN: pixelle: [128] trunk/pixelle/src/com/mebigfatguy/pixelle
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2008-06-30 02:43:19
|
Revision: 128
http://pixelle.svn.sourceforge.net/pixelle/?rev=128&view=rev
Author: dbrosius
Date: 2008-06-29 19:43:23 -0700 (Sun, 29 Jun 2008)
Log Message:
-----------
implement save
Modified Paths:
--------------
trunk/pixelle/src/com/mebigfatguy/pixelle/Pixelle.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleBundle.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleFrame.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleImage.java
trunk/pixelle/src/com/mebigfatguy/pixelle/actions/OpenFileAction.java
trunk/pixelle/src/com/mebigfatguy/pixelle/actions/SaveFileAction.java
trunk/pixelle/src/com/mebigfatguy/pixelle/actions/SaveFileAsAction.java
trunk/pixelle/src/com/mebigfatguy/pixelle/resources/pixelle.properties
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/Pixelle.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/Pixelle.java 2008-06-30 01:55:46 UTC (rev 127)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/Pixelle.java 2008-06-30 02:43:23 UTC (rev 128)
@@ -19,6 +19,7 @@
package com.mebigfatguy.pixelle;
import java.awt.Rectangle;
+import java.text.MessageFormat;
import javax.swing.JOptionPane;
@@ -38,6 +39,8 @@
public static void main(String[] args) {
try {
PixelleFrame pf = new PixelleFrame();
+ String title = MessageFormat.format(PixelleBundle.getString(PixelleBundle.TITLE), PixelleBundle.getString(PixelleBundle.UNKNOWN));
+ pf.setTitle(title);
Rectangle bounds = GuiUtils.getScreenBounds();
pf.setBounds(bounds);
pf.setVisible(true);
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleBundle.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleBundle.java 2008-06-30 01:55:46 UTC (rev 127)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleBundle.java 2008-06-30 02:43:23 UTC (rev 128)
@@ -29,6 +29,7 @@
public static final String CANCEL = "cancel";
public static final String RESET = "reset";
public static final String TITLE = "pixelle.title";
+ public static final String UNKNOWN = "pixelle.unknown";
public static final String FILE_MENU = "menu.file.title";
public static final String NEW_ITEM = "menu.file.new";
public static final String OPEN_ITEM = "menu.file.open";
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleFrame.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleFrame.java 2008-06-30 01:55:46 UTC (rev 127)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleFrame.java 2008-06-30 02:43:23 UTC (rev 128)
@@ -26,6 +26,7 @@
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
+import java.text.MessageFormat;
import javax.imageio.ImageIO;
import javax.swing.ButtonGroup;
@@ -55,8 +56,9 @@
import com.mebigfatguy.pixelle.utils.ZoomLevel;
public class PixelleFrame extends JFrame {
- private static final long serialVersionUID = 3252160042874627103L;
+ private static final long serialVersionUID = -2993532609001467136L;
+
JMenu fileMenu;
JMenuItem newItem;
JMenuItem openItem;
@@ -82,6 +84,7 @@
JMenuItem optionsItem;
JMenuItem transformItem;
+ File imageFile;
JScrollPane scroll;
ImagePanel panel;
transient PixelleImage image;
@@ -96,12 +99,12 @@
}
private PixelleFrame(PixelleImage srcImage, boolean transformInNewWindow) {
+ imageFile = null;
image = srcImage;
doNewWindow = transformInNewWindow;
initComponents();
initListeners();
- setTitle(PixelleBundle.getString(PixelleBundle.TITLE));
FrameMgr.getInstance().add(this);
}
@@ -117,9 +120,9 @@
closeItem = new JMenuItem(new CloseFileAction(this));
fileMenu.add(closeItem);
fileMenu.addSeparator();
- saveItem = new JMenuItem(new SaveFileAction(this));
+ saveAsItem = new JMenuItem(new SaveFileAsAction(this));
+ saveItem = new JMenuItem(new SaveFileAction(this, (SaveFileAsAction)saveAsItem.getAction()));
fileMenu.add(saveItem);
- saveAsItem = new JMenuItem(new SaveFileAsAction(this));
fileMenu.add(saveAsItem);
fileMenu.addSeparator();
pageSetupItem = new JMenuItem(new PageSetupAction(this));
@@ -222,10 +225,16 @@
panel.repaint();
}
+ public File getImageFile() {
+ return imageFile;
+ }
+
public void openFile(File f) {
- setTitle(f.getName());
+ String title = MessageFormat.format(PixelleBundle.getString(PixelleBundle.TITLE), f.getName());
+ setTitle(title);
try {
image = new PixelleImage(ImageIO.read(f));
+ imageFile = f;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Container cp = getContentPane();
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleImage.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleImage.java 2008-06-30 01:55:46 UTC (rev 127)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleImage.java 2008-06-30 02:43:23 UTC (rev 128)
@@ -54,6 +54,10 @@
g.fillRect(0, 0, getWidth(), getHeight());
}
+ public BufferedImage getSaveImage() {
+ return image;
+ }
+
public int getType() {
return image.getType();
}
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/actions/OpenFileAction.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/actions/OpenFileAction.java 2008-06-30 01:55:46 UTC (rev 127)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/actions/OpenFileAction.java 2008-06-30 02:43:23 UTC (rev 128)
@@ -20,6 +20,7 @@
import java.awt.event.ActionEvent;
import java.io.File;
+import java.util.Locale;
import javax.swing.AbstractAction;
import javax.swing.JFileChooser;
@@ -48,7 +49,7 @@
if (f.isDirectory())
return true;
- String path = f.getPath();
+ String path = f.getPath().toLowerCase(Locale.getDefault());
return (path.endsWith(".gif") || path.endsWith(".jpg") || path.endsWith(".png") || path.endsWith(".bmp"));
}
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/actions/SaveFileAction.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/actions/SaveFileAction.java 2008-06-30 01:55:46 UTC (rev 127)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/actions/SaveFileAction.java 2008-06-30 02:43:23 UTC (rev 128)
@@ -19,20 +19,42 @@
package com.mebigfatguy.pixelle.actions;
import java.awt.event.ActionEvent;
+import java.io.File;
+import java.io.IOException;
+import javax.imageio.ImageIO;
import javax.swing.AbstractAction;
+import javax.swing.JOptionPane;
import com.mebigfatguy.pixelle.PixelleBundle;
import com.mebigfatguy.pixelle.PixelleFrame;
public class SaveFileAction extends AbstractAction {
- private static final long serialVersionUID = 4019520448443204442L;
+ private static final long serialVersionUID = -8339987202623985741L;
+
+ private PixelleFrame frame;
+ private SaveFileAsAction saveAsAction;
- public SaveFileAction(PixelleFrame pf) {
+ public SaveFileAction(PixelleFrame pf, SaveFileAsAction action) {
super(PixelleBundle.getString(PixelleBundle.SAVE_ITEM));
+ frame = pf;
+ saveAsAction = action;
}
public void actionPerformed(ActionEvent e) {
+ try {
+ File f = frame.getImageFile();
+ if (f == null)
+ saveAsAction.actionPerformed(e);
+ else {
+ String ext = f.getName();
+ ext = ext.substring(ext.lastIndexOf('.') + 1);
+ ImageIO.write(frame.getImage().getSaveImage(), ext, f);
+ }
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ JOptionPane.showMessageDialog(frame, ioe.getMessage());
+ }
}
}
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/actions/SaveFileAsAction.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/actions/SaveFileAsAction.java 2008-06-30 01:55:46 UTC (rev 127)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/actions/SaveFileAsAction.java 2008-06-30 02:43:23 UTC (rev 128)
@@ -27,12 +27,16 @@
public class SaveFileAsAction extends AbstractAction {
- private static final long serialVersionUID = -5814929763886809475L;
+ private static final long serialVersionUID = 548030636198842553L;
+
+ private PixelleFrame frame;
public SaveFileAsAction(PixelleFrame pf) {
super(PixelleBundle.getString(PixelleBundle.SAVEAS_ITEM));
+ frame = pf;
}
public void actionPerformed(ActionEvent e) {
+
}
}
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/resources/pixelle.properties
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/resources/pixelle.properties 2008-06-30 01:55:46 UTC (rev 127)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/resources/pixelle.properties 2008-06-30 02:43:23 UTC (rev 128)
@@ -19,7 +19,8 @@
cancel = CANCEL
reset = RESET
-pixelle.title = Pixelle
+pixelle.title = Pixelle - {0}
+pixelle.unknown = Unknown
menu.file.title = File
menu.file.new = New
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|