[Pixelle-commit] SF.net SVN: pixelle: [118] trunk/pixelle/src/com/mebigfatguy/pixelle
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2008-06-29 00:58:05
|
Revision: 118
http://pixelle.svn.sourceforge.net/pixelle/?rev=118&view=rev
Author: dbrosius
Date: 2008-06-28 17:58:13 -0700 (Sat, 28 Jun 2008)
Log Message:
-----------
give a 'pleasing' sample on new
Modified Paths:
--------------
trunk/pixelle/src/com/mebigfatguy/pixelle/Pixelle.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleFrame.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java
trunk/pixelle/src/com/mebigfatguy/pixelle/actions/NewFileAction.java
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/Pixelle.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/Pixelle.java 2008-06-29 00:44:52 UTC (rev 117)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/Pixelle.java 2008-06-29 00:58:13 UTC (rev 118)
@@ -20,6 +20,8 @@
import java.awt.Rectangle;
+import javax.swing.JOptionPane;
+
import com.mebigfatguy.pixelle.utils.GuiUtils;
/**
@@ -34,9 +36,14 @@
* @param args command line arguments
*/
public static void main(String[] args) {
- PixelleFrame pf = new PixelleFrame();
- Rectangle bounds = GuiUtils.getScreenBounds();
- pf.setBounds(bounds);
- pf.setVisible(true);
+ try {
+ PixelleFrame pf = new PixelleFrame();
+ Rectangle bounds = GuiUtils.getScreenBounds();
+ pf.setBounds(bounds);
+ pf.setVisible(true);
+ } catch (PixelleTransformException pte) {
+ JOptionPane.showMessageDialog(null, pte.getMessage());
+ pte.printStackTrace();
+ }
}
}
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleFrame.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleFrame.java 2008-06-29 00:44:52 UTC (rev 117)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleFrame.java 2008-06-29 00:58:13 UTC (rev 118)
@@ -87,8 +87,8 @@
transient PixelleImage image;
boolean doNewWindow;
- public PixelleFrame() {
- this(new PixelleImage(), false);
+ public PixelleFrame() throws PixelleTransformException {
+ this(new PixelleTransformer(new PixelleImage(), PixelleTransformer.getSampleTransform()).transform());
}
public PixelleFrame(PixelleImage srcImage) {
@@ -109,7 +109,7 @@
JMenuBar mb = new JMenuBar();
fileMenu = new JMenu(PixelleBundle.getString(PixelleBundle.FILE_MENU));
- newItem = new JMenuItem(new NewFileAction());
+ newItem = new JMenuItem(new NewFileAction(this));
fileMenu.add(newItem);
openItem = new JMenuItem(new OpenFileAction(this));
fileMenu.add(openItem);
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java 2008-06-29 00:44:52 UTC (rev 117)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java 2008-06-29 00:58:13 UTC (rev 118)
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.util.HashMap;
import java.util.Map;
import org.antlr.runtime.ANTLRStringStream;
@@ -53,6 +54,20 @@
}
/**
+ * builds a sample set of algorithms that creates a 'pleasing' image
+ *
+ * @return a set of transformation algorithms
+ */
+ public static Map<PixelleComponent, String> getSampleTransform() {
+ Map<PixelleComponent, String> algorithms = new HashMap<PixelleComponent, String>();
+ algorithms.put(PixelleComponent.RED, "x");
+ algorithms.put(PixelleComponent.GREEN, "y");
+ algorithms.put(PixelleComponent.BLUE, "abs((width/2) - x)");
+ algorithms.put(PixelleComponent.TRANSPARENCY, "((x < 10) || (x >= (width - 10)) || (y < 10) || (y >= (height - 10))) ? 180 : 255");
+ algorithms.put(PixelleComponent.SELECTION, "0");
+ return algorithms;
+ }
+ /**
* transforms the image into a destination image based on the algorithms supplied.
* It does this by generating classes that implement the PixelleExpr interface, and
* dynamically loads them to create the new pixel values.
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/actions/NewFileAction.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/actions/NewFileAction.java 2008-06-29 00:44:52 UTC (rev 117)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/actions/NewFileAction.java 2008-06-29 00:58:13 UTC (rev 118)
@@ -21,24 +21,33 @@
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
+import javax.swing.JOptionPane;
import com.mebigfatguy.pixelle.FrameMgr;
import com.mebigfatguy.pixelle.PixelleBundle;
import com.mebigfatguy.pixelle.PixelleFrame;
+import com.mebigfatguy.pixelle.PixelleTransformException;
import com.mebigfatguy.pixelle.utils.GuiUtils;
public class NewFileAction extends AbstractAction {
- private static final long serialVersionUID = 7977411917585137527L;
-
- public NewFileAction() {
+ private static final long serialVersionUID = 2300557759679077906L;
+ PixelleFrame frame;
+
+ public NewFileAction(PixelleFrame pf) {
super(PixelleBundle.getString(PixelleBundle.NEW_ITEM));
+ frame = pf;
}
public void actionPerformed(ActionEvent e) {
- PixelleFrame pf = new PixelleFrame();
- pf.setBounds(GuiUtils.getScreenBounds());
- pf.setVisible(true);
- FrameMgr.getInstance().add(pf);
+ try {
+ PixelleFrame pf = new PixelleFrame();
+ pf.setBounds(GuiUtils.getScreenBounds());
+ pf.setVisible(true);
+ FrameMgr.getInstance().add(pf);
+ } catch (PixelleTransformException pte) {
+ JOptionPane.showMessageDialog(frame, pte.getMessage());
+ pte.printStackTrace();
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|