polycasso-commit Mailing List for polycasso (Page 4)
Brought to you by:
dbrosius
You can subscribe to this list here.
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(115) |
Dec
(92) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2010 |
Jan
(6) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
(1) |
Oct
(4) |
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(13) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2012 |
Jan
(2) |
Feb
|
Mar
(2) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <dbr...@us...> - 2009-12-10 05:48:32
|
Revision: 175
http://polycasso.svn.sourceforge.net/polycasso/?rev=175&view=rev
Author: dbrosius
Date: 2009-12-10 05:48:26 +0000 (Thu, 10 Dec 2009)
Log Message:
-----------
move on to 1.3.0
Modified Paths:
--------------
trunk/polycasso/build.xml
Modified: trunk/polycasso/build.xml
===================================================================
--- trunk/polycasso/build.xml 2009-12-10 05:43:12 UTC (rev 174)
+++ trunk/polycasso/build.xml 2009-12-10 05:48:26 UTC (rev 175)
@@ -35,7 +35,7 @@
<property name="javac.deprecation" value="on"/>
<property name="javac.debug" value="on"/>
- <property name="polycasso.version" value="1.2.0"/>
+ <property name="polycasso.version" value="1.3.0"/>
<target name="clean" description="removes all generated collateral">
<delete dir="${classes.dir}"/>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-10 05:43:22
|
Revision: 174
http://polycasso.svn.sourceforge.net/polycasso/?rev=174&view=rev
Author: dbrosius
Date: 2009-12-10 05:43:12 +0000 (Thu, 10 Dec 2009)
Log Message:
-----------
tag version 1.2.0
Added Paths:
-----------
tags/v1_2_0/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-10 05:38:43
|
Revision: 173
http://polycasso.svn.sourceforge.net/polycasso/?rev=173&view=rev
Author: dbrosius
Date: 2009-12-10 05:38:35 +0000 (Thu, 10 Dec 2009)
Log Message:
-----------
get ready for the 1.2.0 release
Modified Paths:
--------------
trunk/polycasso/build.xml
Modified: trunk/polycasso/build.xml
===================================================================
--- trunk/polycasso/build.xml 2009-12-10 05:05:25 UTC (rev 172)
+++ trunk/polycasso/build.xml 2009-12-10 05:38:35 UTC (rev 173)
@@ -35,7 +35,7 @@
<property name="javac.deprecation" value="on"/>
<property name="javac.debug" value="on"/>
- <property name="polycasso.version" value="1.1.0"/>
+ <property name="polycasso.version" value="1.2.0"/>
<target name="clean" description="removes all generated collateral">
<delete dir="${classes.dir}"/>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-10 05:05:32
|
Revision: 172
http://polycasso.svn.sourceforge.net/polycasso/?rev=172&view=rev
Author: dbrosius
Date: 2009-12-10 05:05:25 +0000 (Thu, 10 Dec 2009)
Log Message:
-----------
adjust default settings a little
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java 2009-12-10 05:03:19 UTC (rev 171)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java 2009-12-10 05:05:25 UTC (rev 172)
@@ -38,9 +38,9 @@
*/
public Settings() {
maxImageSize = new Dimension(800, 600);
- maxPolygons = 50;
+ maxPolygons = 100;
numCompetingImages = 20;
- maxPoints = 8;
+ maxPoints = 7;
maxPtMovement = 20;
maxColorChange = 40;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-10 05:03:32
|
Revision: 171
http://polycasso.svn.sourceforge.net/polycasso/?rev=171&view=rev
Author: dbrosius
Date: 2009-12-10 05:03:19 +0000 (Thu, 10 Dec 2009)
Log Message:
-----------
add an overwrite confirm dialog
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java
trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java 2009-12-10 04:12:46 UTC (rev 170)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java 2009-12-10 05:03:19 UTC (rev 171)
@@ -26,6 +26,7 @@
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
+import java.io.File;
import java.io.IOException;
import java.text.MessageFormat;
@@ -249,6 +250,13 @@
FileSelector selector = new FileSelector(type);
String fileName = selector.getFileName();
if (fileName != null) {
+ File f = new File(fileName);
+ if (f.exists()) {
+ String message = MessageFormat.format(PolycassoBundle.getString(PolycassoBundle.Key.OverwriteWarning), fileName);
+ int choice = JOptionPane.showConfirmDialog(PainterFrame.this, message, PolycassoBundle.getString(PolycassoBundle.Key.SaveAs), JOptionPane.YES_NO_OPTION);
+ if (choice != JOptionPane.YES_OPTION)
+ return;
+ }
type.getSaver().save(fileName, generator.getImageSize(), generator.getBestData());
}
} catch (IOException ioe) {
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java 2009-12-10 04:12:46 UTC (rev 170)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java 2009-12-10 05:03:19 UTC (rev 171)
@@ -57,7 +57,8 @@
MaximumPointMovement("pc.maximumpointmovement"),
MaximumColorChange("pc.maximumcolorchange"),
BadSetting("pc.badsetting"),
- SaveFailure("pc.savefailure");
+ SaveFailure("pc.savefailure"),
+ OverwriteWarning("pc.overwritewarning");
String id;
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties 2009-12-10 04:12:46 UTC (rev 170)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties 2009-12-10 05:03:19 UTC (rev 171)
@@ -45,3 +45,4 @@
pc.maximumcolorchange = Maximum Color Change
pc.badsetting = The setting specified was too small to properly function
pc.savefailure = Failed saving file: {0}
+pc.overwritewarning = The file {0} already exists, do you wish to overwrite it?
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-10 04:12:53
|
Revision: 170
http://polycasso.svn.sourceforge.net/polycasso/?rev=170&view=rev
Author: dbrosius
Date: 2009-12-10 04:12:46 +0000 (Thu, 10 Dec 2009)
Log Message:
-----------
javadoc
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java 2009-12-10 04:11:12 UTC (rev 169)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java 2009-12-10 04:12:46 UTC (rev 170)
@@ -27,9 +27,18 @@
import java.io.PrintWriter;
import org.apache.commons.io.IOUtils;
-
+/**
+ * generates an svg file from the set of polygons
+ */
public class SVGSaver implements Saver {
+ /**
+ * saves the set of polygons in an svg file
+ *
+ * @param fileName the name of the file to write to
+ * @param imageSize the dimension of the image
+ * @param data the polygons to draw
+ */
@Override
public void save(String fileName, Dimension imageSize, PolygonData[] data)
throws IOException {
@@ -80,6 +89,12 @@
}
}
+ /**
+ * converts a color to an html encoded color string ie #003322
+ *
+ * @param color the color to convert
+ * @return the hex (html) string version of the color
+ */
private String toHexColor(Color color) {
String r = Integer.toHexString(color.getRed());
if (r.length() == 1)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-10 04:11:20
|
Revision: 169
http://polycasso.svn.sourceforge.net/polycasso/?rev=169&view=rev
Author: dbrosius
Date: 2009-12-10 04:11:12 +0000 (Thu, 10 Dec 2009)
Log Message:
-----------
javadoc
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/Saver.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Saver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Saver.java 2009-12-10 04:09:58 UTC (rev 168)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Saver.java 2009-12-10 04:11:12 UTC (rev 169)
@@ -21,7 +21,17 @@
import java.awt.Dimension;
import java.io.IOException;
+/**
+ * describes how the polygon data is to be save to a file in any one of a number of formats
+ */
public interface Saver {
+ /**
+ * saves the set of polygons to some file
+ *
+ * @param fileName the name of the file to write to
+ * @param imageSize the dimension of the image
+ * @param data the polygons to draw
+ */
void save(String fileName, Dimension imageSize, PolygonData[] data) throws IOException;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-10 04:10:05
|
Revision: 168
http://polycasso.svn.sourceforge.net/polycasso/?rev=168&view=rev
Author: dbrosius
Date: 2009-12-10 04:09:58 +0000 (Thu, 10 Dec 2009)
Log Message:
-----------
javadoc
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java 2009-12-10 04:08:45 UTC (rev 167)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java 2009-12-10 04:09:58 UTC (rev 168)
@@ -30,8 +30,18 @@
import org.apache.commons.io.IOUtils;
+/**
+ * generates a png file from the set of polygons
+ */
public class PNGSaver implements Saver {
+ /**
+ * saves the set of polygons in a png file
+ *
+ * @param fileName the name of the file to write to
+ * @param imageSize the dimension of the image
+ * @param data the polygons to draw
+ */
@Override
public void save(String fileName, Dimension imageSize, PolygonData[] data)
throws IOException {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-10 04:08:55
|
Revision: 167
http://polycasso.svn.sourceforge.net/polycasso/?rev=167&view=rev
Author: dbrosius
Date: 2009-12-10 04:08:45 +0000 (Thu, 10 Dec 2009)
Log Message:
-----------
javadoc
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java 2009-12-09 05:09:57 UTC (rev 166)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java 2009-12-10 04:08:45 UTC (rev 167)
@@ -31,11 +31,21 @@
import org.apache.commons.io.IOUtils;
+/**
+ * generates a java source code that draws the image with polygons in a JFrame
+ */
public class JavaSaver implements Saver {
private static final String EXTENSION = ".java";
private static final String TABS = "\t\t\t\t\t\t";
+ /**
+ * saves the polygon data as a java file that opens a JFrame and draws the polygons
+ *
+ * @param fileName the name of the file to write to
+ * @param imageSize the dimension of the image
+ * @param data the polygons to draw
+ */
@Override
public void save(String fileName, Dimension imageSize, PolygonData[] data)
throws IOException {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-09 05:43:05
|
Revision: 166
http://polycasso.svn.sourceforge.net/polycasso/?rev=166&view=rev
Author: dbrosius
Date: 2009-12-09 05:09:57 +0000 (Wed, 09 Dec 2009)
Log Message:
-----------
fcbl
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageSizer.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageSizer.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageSizer.java 2009-12-09 05:03:24 UTC (rev 165)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageSizer.java 2009-12-09 05:09:57 UTC (rev 166)
@@ -27,7 +27,6 @@
public class ImageSizer implements ImageObserver {
private Object lock = new Object();
- private Image image;
private int imageWidth = -1;
private int imageHeight = -1;
@@ -37,9 +36,8 @@
* @param loadedImage the image to get the width and height of
*/
public ImageSizer(Image loadedImage) {
- image = loadedImage;
- imageWidth = image.getWidth(this);
- imageHeight = image.getHeight(this);
+ imageWidth = loadedImage.getWidth(this);
+ imageHeight = loadedImage.getHeight(this);
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-09 05:03:35
|
Revision: 165
http://polycasso.svn.sourceforge.net/polycasso/?rev=165&view=rev
Author: dbrosius
Date: 2009-12-09 05:03:24 +0000 (Wed, 09 Dec 2009)
Log Message:
-----------
svg end tag
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java 2009-12-08 07:19:33 UTC (rev 164)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java 2009-12-09 05:03:24 UTC (rev 165)
@@ -74,7 +74,7 @@
pw.println("\"/>");
}
- pw.println("<svg>");
+ pw.println("</svg>");
} finally {
IOUtils.closeQuietly(pw);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-08 07:19:39
|
Revision: 164
http://polycasso.svn.sourceforge.net/polycasso/?rev=164&view=rev
Author: dbrosius
Date: 2009-12-08 07:19:33 +0000 (Tue, 08 Dec 2009)
Log Message:
-----------
should start with black
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java 2009-12-08 07:14:39 UTC (rev 163)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java 2009-12-08 07:19:33 UTC (rev 164)
@@ -46,11 +46,12 @@
pw.print(imageSize.height);
pw.println("px\" version=\"1.2\">");
-// pw.print("\t<rect x=\"0\" y=\"0\" width=\"");
-// pw.print(imageSize.width);
-// pw.print("px\" height=\"");
-// pw.print(imageSize.height);
-// pw.println("px\" fill=\"black\"/>");
+ pw.print("\t<rect x=\"0\" y=\"0\" width=\"");
+ pw.print(imageSize.width);
+ pw.print("px\" height=\"");
+ pw.print(imageSize.height);
+ pw.println("px\" fill=\"black\"/>");
+
for (PolygonData pd : data) {
Polygon polygon = pd.getPolygon();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-08 07:14:52
|
Revision: 163
http://polycasso.svn.sourceforge.net/polycasso/?rev=163&view=rev
Author: dbrosius
Date: 2009-12-08 07:14:39 +0000 (Tue, 08 Dec 2009)
Log Message:
-----------
impl png saver
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java 2009-12-08 07:07:16 UTC (rev 162)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java 2009-12-08 07:14:39 UTC (rev 163)
@@ -18,17 +18,42 @@
*/
package com.mebigfatguy.polycasso;
+import java.awt.Color;
import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.io.BufferedOutputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
-import javax.swing.JOptionPane;
+import javax.imageio.ImageIO;
+import org.apache.commons.io.IOUtils;
+
public class PNGSaver implements Saver {
@Override
public void save(String fileName, Dimension imageSize, PolygonData[] data)
throws IOException {
- JOptionPane.showMessageDialog(null, "Not Implemented yet");
+
+ BufferedOutputStream bos = null;
+ try {
+ bos = new BufferedOutputStream(new FileOutputStream(fileName));
+
+ BufferedImage image = new BufferedImage(imageSize.width, imageSize.height, BufferedImage.TYPE_4BYTE_ABGR);
+ Graphics2D g2d = (Graphics2D)image.getGraphics();
+ g2d.setColor(Color.BLACK);
+ g2d.fillRect(0, 0, imageSize.width, imageSize.height);
+
+ for (PolygonData pd : data) {
+ pd.draw(g2d);
+ }
+
+ ImageIO.write(image, "png", bos);
+
+ } finally {
+ IOUtils.closeQuietly(bos);
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-08 07:07:25
|
Revision: 162
http://polycasso.svn.sourceforge.net/polycasso/?rev=162&view=rev
Author: dbrosius
Date: 2009-12-08 07:07:16 +0000 (Tue, 08 Dec 2009)
Log Message:
-----------
try to use 1.2
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java 2009-12-08 06:44:51 UTC (rev 161)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java 2009-12-08 07:07:16 UTC (rev 162)
@@ -39,22 +39,29 @@
try {
pw = new PrintWriter(new BufferedWriter(new FileWriter(fileName)));
- pw.println("<?xml version=\"1.0\" standalone=\"no\"?>");
- pw.println("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">");
- pw.println("<svg width=\"" + imageSize.width + "\" height=\"" + imageSize.height + "\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">");
+ pw.print("<svg xmlns=\"http://www.w3.org/2000/svg\"");
+ pw.print(" width=\"");
+ pw.print(imageSize.width);
+ pw.print("px\" height=\"");
+ pw.print(imageSize.height);
+ pw.println("px\" version=\"1.2\">");
- //pw.println("\t<rect width=\"" + imageSize.width + "\" height=\"" + imageSize.height + "\" style=\"fill:#000000;\"/>");
+// pw.print("\t<rect x=\"0\" y=\"0\" width=\"");
+// pw.print(imageSize.width);
+// pw.print("px\" height=\"");
+// pw.print(imageSize.height);
+// pw.println("px\" fill=\"black\"/>");
for (PolygonData pd : data) {
Polygon polygon = pd.getPolygon();
Color color = pd.getColor();
float alpha = pd.getAlpha();
- pw.print("\t<polygon comp-op=\"src-over\" style=\"fill:#");
+ pw.print("\t<polygon comp-op=\"src-over\" fill=\"#");
pw.print(toHexColor(color));
- pw.print("; fill-opacity: ");
+ pw.print("\" fill-opacity=\"");
pw.print(alpha);
- pw.print(";\" points=\"");
+ pw.print("\" points=\"");
String space = "";
for (int p = 0; p < polygon.npoints; p++) {
pw.print(space);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-08 06:45:00
|
Revision: 161
http://polycasso.svn.sourceforge.net/polycasso/?rev=161&view=rev
Author: dbrosius
Date: 2009-12-08 06:44:51 +0000 (Tue, 08 Dec 2009)
Log Message:
-----------
a first attempt at svg saving
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java 2009-12-07 14:23:35 UTC (rev 160)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java 2009-12-08 06:44:51 UTC (rev 161)
@@ -18,17 +18,71 @@
*/
package com.mebigfatguy.polycasso;
+import java.awt.Color;
import java.awt.Dimension;
+import java.awt.Polygon;
+import java.io.BufferedWriter;
+import java.io.FileWriter;
import java.io.IOException;
+import java.io.PrintWriter;
-import javax.swing.JOptionPane;
+import org.apache.commons.io.IOUtils;
public class SVGSaver implements Saver {
@Override
public void save(String fileName, Dimension imageSize, PolygonData[] data)
throws IOException {
- JOptionPane.showMessageDialog(null, "Not Implemented yet");
+
+ PrintWriter pw = null;
+
+ try {
+ pw = new PrintWriter(new BufferedWriter(new FileWriter(fileName)));
+
+ pw.println("<?xml version=\"1.0\" standalone=\"no\"?>");
+ pw.println("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">");
+ pw.println("<svg width=\"" + imageSize.width + "\" height=\"" + imageSize.height + "\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">");
+
+ //pw.println("\t<rect width=\"" + imageSize.width + "\" height=\"" + imageSize.height + "\" style=\"fill:#000000;\"/>");
+ for (PolygonData pd : data) {
+
+ Polygon polygon = pd.getPolygon();
+ Color color = pd.getColor();
+ float alpha = pd.getAlpha();
+
+ pw.print("\t<polygon comp-op=\"src-over\" style=\"fill:#");
+ pw.print(toHexColor(color));
+ pw.print("; fill-opacity: ");
+ pw.print(alpha);
+ pw.print(";\" points=\"");
+ String space = "";
+ for (int p = 0; p < polygon.npoints; p++) {
+ pw.print(space);
+ pw.print(polygon.xpoints[p]);
+ pw.print(",");
+ pw.print(polygon.ypoints[p]);
+ space = " ";
+ }
+ pw.println("\"/>");
+
+ }
+ pw.println("<svg>");
+ } finally {
+ IOUtils.closeQuietly(pw);
+ }
}
+
+ private String toHexColor(Color color) {
+ String r = Integer.toHexString(color.getRed());
+ if (r.length() == 1)
+ r = "0" + r;
+ String g = Integer.toHexString(color.getGreen());
+ if (g.length() == 1)
+ g = "0" + g;
+ String b = Integer.toHexString(color.getBlue());
+ if (b.length() == 1)
+ b = "0" + b;
+ return r + g + b;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-07 14:23:43
|
Revision: 160
http://polycasso.svn.sourceforge.net/polycasso/?rev=160&view=rev
Author: dbrosius
Date: 2009-12-07 14:23:35 +0000 (Mon, 07 Dec 2009)
Log Message:
-----------
add not implemented message
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java 2009-12-07 14:22:56 UTC (rev 159)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java 2009-12-07 14:23:35 UTC (rev 160)
@@ -21,13 +21,14 @@
import java.awt.Dimension;
import java.io.IOException;
+import javax.swing.JOptionPane;
+
public class SVGSaver implements Saver {
@Override
public void save(String fileName, Dimension imageSize, PolygonData[] data)
throws IOException {
- // TODO Auto-generated method stub
-
+ JOptionPane.showMessageDialog(null, "Not Implemented yet");
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-07 14:23:04
|
Revision: 159
http://polycasso.svn.sourceforge.net/polycasso/?rev=159&view=rev
Author: dbrosius
Date: 2009-12-07 14:22:56 +0000 (Mon, 07 Dec 2009)
Log Message:
-----------
add not impled yet message
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java 2009-12-07 14:21:59 UTC (rev 158)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java 2009-12-07 14:22:56 UTC (rev 159)
@@ -21,13 +21,14 @@
import java.awt.Dimension;
import java.io.IOException;
+import javax.swing.JOptionPane;
+
public class PNGSaver implements Saver {
@Override
public void save(String fileName, Dimension imageSize, PolygonData[] data)
throws IOException {
- // TODO Auto-generated method stub
-
+ JOptionPane.showMessageDialog(null, "Not Implemented yet");
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-07 14:22:08
|
Revision: 158
http://polycasso.svn.sourceforge.net/polycasso/?rev=158&view=rev
Author: dbrosius
Date: 2009-12-07 14:21:59 +0000 (Mon, 07 Dec 2009)
Log Message:
-----------
finish the java saver
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java 2009-12-07 14:21:37 UTC (rev 157)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java 2009-12-07 14:21:59 UTC (rev 158)
@@ -18,16 +18,103 @@
*/
package com.mebigfatguy.polycasso;
+import java.awt.Color;
import java.awt.Dimension;
+import java.awt.Polygon;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import org.apache.commons.io.IOUtils;
+
public class JavaSaver implements Saver {
-
+
+ private static final String EXTENSION = ".java";
+ private static final String TABS = "\t\t\t\t\t\t";
+
@Override
public void save(String fileName, Dimension imageSize, PolygonData[] data)
throws IOException {
- // TODO Auto-generated method stub
+ InputStream templateStream = null;
+ PrintWriter pw = null;
+
+ int sep = fileName.lastIndexOf(File.separator);
+ String className;
+ if (sep >= 0)
+ className = fileName.substring(sep + 1);
+ else
+ className = fileName;
+
+ if (className.endsWith(EXTENSION)) {
+ className = className.substring(0, className.length() - EXTENSION.length());
+ }
+
+ try {
+ pw = new PrintWriter(new BufferedWriter(new FileWriter(fileName)));
+
+ templateStream = getClass().getResourceAsStream("/com/mebigfatguy/polycasso/JavaSaver.template");
+ String template = IOUtils.toString(templateStream);
+ StringWriter insert = new StringWriter();
+ PrintWriter polyWriter = new PrintWriter(insert);
+ for (PolygonData pd : data) {
+ polyWriter.print(TABS);
+ polyWriter.println("poly.reset();");
+ Polygon poly = pd.getPolygon();
+
+ for (int p = 0; p < poly.npoints; p++) {
+ polyWriter.print(TABS);
+ polyWriter.print("poly.addPoint(");
+ polyWriter.print(poly.xpoints[p]);
+ polyWriter.print(", ");
+ polyWriter.print(poly.ypoints[p]);
+ polyWriter.println(");");
+ }
+ Color c = pd.getColor();
+ polyWriter.print(TABS);
+ polyWriter.print("color = new Color(");
+ polyWriter.print(c.getRed());
+ polyWriter.print(", ");
+ polyWriter.print(c.getGreen());
+ polyWriter.print(", ");
+ polyWriter.print(c.getBlue());
+ polyWriter.println(");");
+
+ polyWriter.print(TABS);
+ polyWriter.println("g2d.setColor(color);");
+
+ polyWriter.print(TABS);
+ polyWriter.print("composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, ");
+ polyWriter.print(pd.getAlpha());
+ polyWriter.println("f);");
+
+ polyWriter.print(TABS);
+ polyWriter.println("g2d.setComposite(composite);");
+
+ polyWriter.print(TABS);
+ polyWriter.println("g2d.fillPolygon(poly);");
+ }
+ polyWriter.flush();
+
+ /* All the curly braces confuses MessageFormat, so just do it manually */
+ template = template.replaceAll("\\{0\\}", className);
+ template = template.replaceAll("\\{1\\}", String.valueOf(imageSize.width));
+ template = template.replaceAll("\\{2\\}", String.valueOf(imageSize.height));
+ template = template.replaceAll("\\{3\\}", insert.toString());
+
+ pw.println(template);
+
+ } catch (IOException ioe) {
+
+ } finally {
+ IOUtils.closeQuietly(templateStream);
+ IOUtils.closeQuietly(pw);
+ }
+
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-07 14:21:48
|
Revision: 157
http://polycasso.svn.sourceforge.net/polycasso/?rev=157&view=rev
Author: dbrosius
Date: 2009-12-07 14:21:37 +0000 (Mon, 07 Dec 2009)
Log Message:
-----------
complete the template
Added Paths:
-----------
trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.template
Copied: trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.template (from rev 155, trunk/polycasso/src/JavaSaver.template)
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.template (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.template 2009-12-07 14:21:37 UTC (rev 157)
@@ -0,0 +1,55 @@
+/*
+ * polycasso - Cubism Artwork generator
+ * Copyright 2009 MeBigFatGuy.com
+ * Copyright 2009 Dave Brosius
+ * Inspired by work by Roger Alsing
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ */
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Container;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Polygon;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+public class {0} {
+
+ public static void main(String[] args) {
+ JFrame frame = new JFrame() {
+ {
+ Container cp = getContentPane();
+ cp.add(new JPanel() {
+ @Override
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ Graphics2D g2d = (Graphics2D) g;
+ g2d.setColor(Color.BLACK);
+ g2d.fillRect(0, 0, {1}, {2});
+ Polygon poly = new Polygon();
+ AlphaComposite composite;
+ Color color;
+{3}
+ }
+ });
+ pack();
+ }
+ };
+ frame.setSize({1}, {2} + 20);
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-07 06:46:52
|
Revision: 156
http://polycasso.svn.sourceforge.net/polycasso/?rev=156&view=rev
Author: dbrosius
Date: 2009-12-07 06:46:44 +0000 (Mon, 07 Dec 2009)
Log Message:
-----------
add getAlpha
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java 2009-12-07 05:59:19 UTC (rev 155)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java 2009-12-07 06:46:44 UTC (rev 156)
@@ -59,7 +59,14 @@
}
/**
- * sets the transparency of this polygon; 0.0 is transparent, 1.0 is opaque
+ * gets the transparency of this polygon: 0.0 is transparent, 1.0 is opaque
+ * @return the transparency value
+ */
+ public float getAlpha() {
+ return alpha;
+ }
+ /**
+ * sets the transparency of this polygon: 0.0 is transparent, 1.0 is opaque
* @param xpar the transparency value
*/
public void setAlpha(float xpar) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-07 05:59:27
|
Revision: 155
http://polycasso.svn.sourceforge.net/polycasso/?rev=155&view=rev
Author: dbrosius
Date: 2009-12-07 05:59:19 +0000 (Mon, 07 Dec 2009)
Log Message:
-----------
stub in a JavaSaver template
Added Paths:
-----------
trunk/polycasso/src/JavaSaver.template
Added: trunk/polycasso/src/JavaSaver.template
===================================================================
--- trunk/polycasso/src/JavaSaver.template (rev 0)
+++ trunk/polycasso/src/JavaSaver.template 2009-12-07 05:59:19 UTC (rev 155)
@@ -0,0 +1,51 @@
+/*
+ * polycasso - Cubism Artwork generator
+ * Copyright 2009 MeBigFatGuy.com
+ * Copyright 2009 Dave Brosius
+ * Inspired by work by Roger Alsing
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ */
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Container;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+public class {0} {
+
+ public static void main(String[] args) {
+ JFrame frame = new JFrame() {
+ {
+ Container cp = getContentPane();
+ cp.add(new JPanel() {
+ @Override
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ Graphics2D g2d = (Graphics2D) g;
+ g2d.setColor(Color.BLACK);
+ g2d.fillRect(0, 0, {1}, {2});
+ AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1);
+ {3}100
+ }
+ });
+ }
+ };
+ frame.setSize({1}, {2} + 20);
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ }
+}
\ No newline at end of file
Property changes on: trunk/polycasso/src/JavaSaver.template
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-07 05:21:13
|
Revision: 154
http://polycasso.svn.sourceforge.net/polycasso/?rev=154&view=rev
Author: dbrosius
Date: 2009-12-07 05:21:07 +0000 (Mon, 07 Dec 2009)
Log Message:
-----------
more save implementation
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java
trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java
trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java 2009-12-07 05:08:22 UTC (rev 153)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java 2009-12-07 05:21:07 UTC (rev 154)
@@ -21,6 +21,7 @@
import java.io.File;
import javax.swing.JFileChooser;
+import javax.swing.filechooser.FileFilter;
public class FileSelector {
@@ -32,6 +33,8 @@
public String getFileName() {
JFileChooser chooser = new JFileChooser();
+ chooser.setFileFilter(new PolyFilter());
+ chooser.setDialogTitle(PolycassoBundle.getString(PolycassoBundle.Key.SaveAs));
int option = chooser.showSaveDialog(null);
if (option == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
@@ -46,4 +49,22 @@
return null;
}
+
+ class PolyFilter extends FileFilter {
+
+ @Override
+ public boolean accept(File file) {
+ if (file.isDirectory()) {
+ return true;
+ }
+
+ return (file.getPath().endsWith(fileType.getExtension()));
+ }
+
+ @Override
+ public String getDescription() {
+ return fileType.getDescription();
+ }
+
+ }
}
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java 2009-12-07 05:08:22 UTC (rev 153)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java 2009-12-07 05:21:07 UTC (rev 154)
@@ -20,31 +20,37 @@
public enum FileType {
- PNG(".png") {
+ PNG(".png", PolycassoBundle.Key.PNGDescription) {
public Saver getSaver() {
return new PNGSaver();
}
},
- SVG(".svg") {
+ SVG(".svg", PolycassoBundle.Key.SVGDescription) {
public Saver getSaver() {
return new SVGSaver();
}
},
- Java(".java") {
+ Java(".java", PolycassoBundle.Key.JAVADescription) {
public Saver getSaver() {
return new JavaSaver();
}
};
private String extension;
+ private PolycassoBundle.Key descriptionKey;
- FileType(String ext) {
+ FileType(String ext, PolycassoBundle.Key descKey) {
extension = ext;
+ descriptionKey = descKey;
}
public String getExtension() {
return extension;
}
+ public String getDescription() {
+ return PolycassoBundle.getString(descriptionKey);
+ }
+
public abstract Saver getSaver();
}
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java 2009-12-07 05:08:22 UTC (rev 153)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java 2009-12-07 05:21:07 UTC (rev 154)
@@ -38,8 +38,11 @@
CompleteImage("pc.completeimage"),
SaveAs("pc.saveas"),
PNG("pc.png"),
+ PNGDescription("pc.pngdescription"),
SVG("pc.svg"),
+ SVGDescription("pc.svgdescription"),
JAVA("pc.java"),
+ JAVADescription("pc.javadescription"),
Quit("pc.quit"),
Edit("pc.edit"),
Settings("pc.settings"),
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties 2009-12-07 05:08:22 UTC (rev 153)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties 2009-12-07 05:21:07 UTC (rev 154)
@@ -25,8 +25,11 @@
pc.completeimage = Complete Image
pc.saveas = Save as
pc.png = PNG
+pc.pngdescription = (*.png) PNG Image files
pc.svg = SVG
+pc.svgdescription = (*.svg) Scalable Vector Graphics files
pc.java = Java class
+pc.javadescription = (*.java) Java Class files
pc.quit = Quit
pc.edit = Edit
pc.settings = Settings
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-07 05:08:30
|
Revision: 153
http://polycasso.svn.sourceforge.net/polycasso/?rev=153&view=rev
Author: dbrosius
Date: 2009-12-07 05:08:22 +0000 (Mon, 07 Dec 2009)
Log Message:
-----------
stub in a file selector dialog
Added Paths:
-----------
trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java 2009-12-07 05:08:22 UTC (rev 153)
@@ -0,0 +1,49 @@
+/*
+ * polycasso - Cubism Artwork generator
+ * Copyright 2009 MeBigFatGuy.com
+ * Copyright 2009 Dave Brosius
+ * Inspired by work by Roger Alsing
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ */
+package com.mebigfatguy.polycasso;
+
+import java.io.File;
+
+import javax.swing.JFileChooser;
+
+public class FileSelector {
+
+ FileType fileType;
+
+ public FileSelector(FileType type) {
+ fileType = type;
+ }
+
+ public String getFileName() {
+ JFileChooser chooser = new JFileChooser();
+ int option = chooser.showSaveDialog(null);
+ if (option == JFileChooser.APPROVE_OPTION) {
+ File file = chooser.getSelectedFile();
+ String path = file.getPath();
+ String ext = fileType.getExtension();
+ if (!path.endsWith(ext)) {
+ path += ext;
+ }
+
+ return path;
+ }
+
+ return null;
+ }
+}
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-07 05:06:55
|
Revision: 152
http://polycasso.svn.sourceforge.net/polycasso/?rev=152&view=rev
Author: dbrosius
Date: 2009-12-07 05:06:44 +0000 (Mon, 07 Dec 2009)
Log Message:
-----------
add saver menus
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java 2009-12-07 05:06:19 UTC (rev 151)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java 2009-12-07 05:06:44 UTC (rev 152)
@@ -27,6 +27,7 @@
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
+import java.text.MessageFormat;
import javax.swing.JFrame;
import javax.swing.JMenu;
@@ -43,6 +44,10 @@
private PainterPanel panel;
private JMenuItem paintImage;
private JMenuItem completeImage;
+ private JMenu saveAsMenu;
+ private JMenuItem saveAsPNGItem;
+ private JMenuItem saveAsSVGItem;
+ private JMenuItem saveAsJavaItem;
private JMenuItem quitItem;
private JMenuItem aboutItem;
private JMenuItem settingsItem;
@@ -85,6 +90,16 @@
completeImage.setEnabled(false);
fileMenu.add(completeImage);
fileMenu.addSeparator();
+ saveAsMenu = new JMenu(PolycassoBundle.getString(PolycassoBundle.Key.SaveAs));
+ fileMenu.add(saveAsMenu);
+ saveAsPNGItem = new JMenuItem(PolycassoBundle.getString(PolycassoBundle.Key.PNG));
+ saveAsMenu.add(saveAsPNGItem);
+ saveAsSVGItem = new JMenuItem(PolycassoBundle.getString(PolycassoBundle.Key.SVG));
+ saveAsMenu.add(saveAsSVGItem);
+ saveAsJavaItem = new JMenuItem(PolycassoBundle.getString(PolycassoBundle.Key.JAVA));
+ saveAsMenu.add(saveAsJavaItem);
+ saveAsMenu.setEnabled(false);
+ fileMenu.addSeparator();
quitItem = new JMenuItem(PolycassoBundle.getString(PolycassoBundle.Key.Quit));
fileMenu.add(quitItem);
mb.add(fileMenu);
@@ -137,6 +152,7 @@
generator.addImageGeneratedListener(PainterFrame.this);
generator.startGenerating();
completeImage.setEnabled(true);
+ saveAsMenu.setEnabled(true);
} catch (IOException ioe) {
JOptionPane.showMessageDialog(null, ioe.getMessage());
@@ -154,6 +170,27 @@
}
});
+ saveAsPNGItem.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ saveImage(FileType.PNG);
+ }
+ });
+
+ saveAsSVGItem.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ saveImage(FileType.SVG);
+ }
+ });
+
+ saveAsJavaItem.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ saveImage(FileType.Java);
+ }
+ });
+
quitItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
@@ -201,4 +238,22 @@
public void imageGenerated(ImageGeneratedEvent event) {
panel.setImage(event.getImage());
}
+
+ /**
+ * save the image to what ever format was chosen
+ *
+ * @param type the chosen file type to save as
+ */
+ public void saveImage(FileType type) {
+ try {
+ FileSelector selector = new FileSelector(type);
+ String fileName = selector.getFileName();
+ if (fileName != null) {
+ type.getSaver().save(fileName, generator.getImageSize(), generator.getBestData());
+ }
+ } catch (IOException ioe) {
+ String message = MessageFormat.format(PolycassoBundle.getString(PolycassoBundle.Key.SaveFailure), ioe.getMessage());
+ JOptionPane.showMessageDialog(PainterFrame.this, message);
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-12-07 05:06:30
|
Revision: 151
http://polycasso.svn.sourceforge.net/polycasso/?rev=151&view=rev
Author: dbrosius
Date: 2009-12-07 05:06:19 +0000 (Mon, 07 Dec 2009)
Log Message:
-----------
add saver methods
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java 2009-12-07 05:05:52 UTC (rev 150)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java 2009-12-07 05:06:19 UTC (rev 151)
@@ -20,9 +20,21 @@
public enum FileType {
- PNG(".png"),
- SVG(".svg"),
- Java(".java");
+ PNG(".png") {
+ public Saver getSaver() {
+ return new PNGSaver();
+ }
+ },
+ SVG(".svg") {
+ public Saver getSaver() {
+ return new SVGSaver();
+ }
+ },
+ Java(".java") {
+ public Saver getSaver() {
+ return new JavaSaver();
+ }
+ };
private String extension;
@@ -33,4 +45,6 @@
public String getExtension() {
return extension;
}
+
+ public abstract Saver getSaver();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|