polycasso-commit Mailing List for polycasso (Page 7)
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-11-28 23:45:49
|
Revision: 100
http://polycasso.svn.sourceforge.net/polycasso/?rev=100&view=rev
Author: dbrosius
Date: 2009-11-28 23:45:42 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
add forms lib
Modified Paths:
--------------
trunk/polycasso/polycasso.fb
Modified: trunk/polycasso/polycasso.fb
===================================================================
--- trunk/polycasso/polycasso.fb 2009-11-28 23:45:09 UTC (rev 99)
+++ trunk/polycasso/polycasso.fb 2009-11-28 23:45:42 UTC (rev 100)
@@ -4,5 +4,6 @@
./src
[Aux classpath entries]
./lib/commons-io-1.4.jar
+./lib/forms-1.2.1.jar
[Options]
relative_paths=true
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-28 23:45:21
|
Revision: 99
http://polycasso.svn.sourceforge.net/polycasso/?rev=99&view=rev
Author: dbrosius
Date: 2009-11-28 23:45:09 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
add for FormLayout
Added Paths:
-----------
trunk/polycasso/lib/forms-1.2.1.jar
Added: trunk/polycasso/lib/forms-1.2.1.jar
===================================================================
(Binary files differ)
Property changes on: trunk/polycasso/lib/forms-1.2.1.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-28 23:43:02
|
Revision: 98
http://polycasso.svn.sourceforge.net/polycasso/?rev=98&view=rev
Author: dbrosius
Date: 2009-11-28 23:42:55 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
add serialver
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java 2009-11-28 23:42:24 UTC (rev 97)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java 2009-11-28 23:42:55 UTC (rev 98)
@@ -38,6 +38,8 @@
public class SettingsDialog extends JDialog {
+ private static final long serialVersionUID = 5044661806014080056L;
+
Settings dlgSettings;
private JButton okButton;
private JButton cancelButton;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-28 23:42:30
|
Revision: 97
http://polycasso.svn.sourceforge.net/polycasso/?rev=97&view=rev
Author: dbrosius
Date: 2009-11-28 23:42:24 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
javadoc
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-28 23:41:42 UTC (rev 96)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-28 23:42:24 UTC (rev 97)
@@ -50,7 +50,7 @@
/**
* creates an ImageGenerator for the given target image, and size
- * @param settings the configuration settings
+ * @param confSettings the configuration settings
* @param image the target image
* @param size the dimension of the image
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-28 23:41:51
|
Revision: 96
http://polycasso.svn.sourceforge.net/polycasso/?rev=96&view=rev
Author: dbrosius
Date: 2009-11-28 23:41:42 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
push settings to the improver to use for maxpolys and maxptmovement
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-28 23:37:18 UTC (rev 95)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-28 23:41:42 UTC (rev 96)
@@ -166,7 +166,7 @@
BufferedImage image = new BufferedImage(imageSize.width, imageSize.height, BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D g2d = (Graphics2D)image.getGraphics();
Composite srcOpaque = AlphaComposite.getInstance(AlphaComposite.SRC, 1.0f);
- Improver improver = new Improver(imageSize);
+ Improver improver = new Improver(null, imageSize);
while (!Thread.interrupted()) {
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2009-11-28 23:37:18 UTC (rev 95)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2009-11-28 23:41:42 UTC (rev 96)
@@ -33,9 +33,7 @@
* polygons have had success being transformed.
*/
public class Improver {
- public static final int NUM_POLYS = 50;
- public static final int MAX_PT_MOVEMENT = 20;
-
+ private Settings settings;
private Dimension imageSize;
private List<PolygonData> polygons = null;
private ImprovementTypeStats stats;
@@ -43,10 +41,11 @@
/**
* create an improver using a specified image size
- *
+ * @param confSettings the settings to be used
* @param size the size of the image
*/
- public Improver(Dimension size) {
+ public Improver(Settings confSettings, Dimension size) {
+ settings = confSettings;
imageSize = size;
stats = new ImprovementTypeStats();
r = new Random();
@@ -96,7 +95,7 @@
switch (type) {
case AddPolygon: {
- if (polygons.size() < NUM_POLYS) {
+ if (polygons.size() < settings.getMaxPolygons()) {
PolygonData pd = PolygonData.randomPoly(imageSize);
polygons.add(pd);
} else {
@@ -121,8 +120,9 @@
polygon.addPoint(0, 0);
int insPos = r.nextInt(polygon.npoints);
int lastPt = (insPos + polygon.npoints - 1) % polygon.npoints;
- int maxX = Math.max(MAX_PT_MOVEMENT, Math.abs(polygon.xpoints[lastPt] - polygon.xpoints[insPos]));
- int maxY = Math.max(MAX_PT_MOVEMENT, Math.abs(polygon.ypoints[lastPt] - polygon.ypoints[insPos]));
+ int maxMovement = settings.getMaxPtMovement();
+ int maxX = Math.max(maxMovement, Math.abs(polygon.xpoints[lastPt] - polygon.xpoints[insPos]));
+ int maxY = Math.max(maxMovement, Math.abs(polygon.ypoints[lastPt] - polygon.ypoints[insPos]));
int x = r.nextInt(maxX) + Math.min(polygon.xpoints[lastPt], polygon.xpoints[insPos]);
int y = r.nextInt(maxY) + Math.min(polygon.ypoints[lastPt], polygon.ypoints[insPos]);
@@ -165,8 +165,9 @@
PolygonData pd = (PolygonData)polygons.get(idx).clone();
Polygon polygon = pd.getPolygon();
int movePos = r.nextInt(polygon.npoints);
- int moveX = r.nextInt(MAX_PT_MOVEMENT * 2) - MAX_PT_MOVEMENT;
- int moveY = r.nextInt(MAX_PT_MOVEMENT * 2) - MAX_PT_MOVEMENT;
+ int maxMovement = settings.getMaxPtMovement();
+ int moveX = r.nextInt(maxMovement * 2) - maxMovement;
+ int moveY = r.nextInt(maxMovement * 2) - maxMovement;
polygon.xpoints[movePos] += moveX;
polygon.ypoints[movePos] += moveY;
clipToRange(0, imageSize.width, polygon.xpoints[movePos]);
@@ -213,7 +214,7 @@
double midX = bbox.getCenterX();
double midY = bbox.getCenterY();
- int shrinkFactor = r.nextInt(MAX_PT_MOVEMENT);
+ int shrinkFactor = r.nextInt(settings.getMaxPtMovement());
for (int i = 0; i < polygon.npoints; i++) {
polygon.xpoints[i] += (polygon.xpoints[i] < midX) ? shrinkFactor : -shrinkFactor;
polygon.ypoints[i] += (polygon.ypoints[i] < midY) ? shrinkFactor : -shrinkFactor;
@@ -231,7 +232,7 @@
double midX = bbox.getCenterX();
double midY = bbox.getCenterY();
- int expandFactor = r.nextInt(MAX_PT_MOVEMENT);
+ int expandFactor = r.nextInt(settings.getMaxPtMovement());
for (int i = 0; i < polygon.npoints; i++) {
polygon.xpoints[i] += (polygon.xpoints[i] < midX) ? -expandFactor : expandFactor;
polygon.ypoints[i] += (polygon.ypoints[i] < midY) ? -expandFactor : expandFactor;
@@ -246,8 +247,9 @@
int idx = r.nextInt(polygons.size());
PolygonData pd = (PolygonData)polygons.get(idx).clone();
Polygon polygon = pd.getPolygon();
- int shiftX = r.nextInt(2 * MAX_PT_MOVEMENT) + MAX_PT_MOVEMENT;
- int shiftY = r.nextInt(2 * MAX_PT_MOVEMENT) + MAX_PT_MOVEMENT;
+ int maxMovement = settings.getMaxPtMovement();
+ int shiftX = r.nextInt(2 * maxMovement) + maxMovement;
+ int shiftY = r.nextInt(2 * maxMovement) + maxMovement;
for (int i = 0; i < polygon.npoints; i++) {
polygon.xpoints[i] += shiftX;
polygon.ypoints[i] += shiftY;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-28 23:37:24
|
Revision: 95
http://polycasso.svn.sourceforge.net/polycasso/?rev=95&view=rev
Author: dbrosius
Date: 2009-11-28 23:37:18 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
limit image size to the settings limit
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-28 23:32:38 UTC (rev 94)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-28 23:37:18 UTC (rev 95)
@@ -38,6 +38,7 @@
public class ImageGenerator implements Runnable {
private static int attempt = 0;
private Set<ImageGeneratedListener> listeners = new HashSet<ImageGeneratedListener>();
+ private Settings settings;
private BufferedImage targetImage;
private PolygonData[] bestData;
private double bestScore = Double.MAX_VALUE;
@@ -49,20 +50,31 @@
/**
* creates an ImageGenerator for the given target image, and size
+ * @param settings the configuration settings
* @param image the target image
- *
* @param size the dimension of the image
*/
- public ImageGenerator(Image image, Dimension size) {
- targetImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_4BYTE_ABGR);
+ public ImageGenerator(Settings confSettings, Image image, Dimension size) {
+ settings = confSettings;
+ imageSize = trimSize(size, settings.getMaxImageSize());
+ targetImage = new BufferedImage(imageSize.width, imageSize.height, BufferedImage.TYPE_4BYTE_ABGR);
Graphics g = targetImage.getGraphics();
- g.drawImage(image, 0, 0, size.width, size.height, Color.WHITE, null);
+ g.drawImage(image, 0, 0, imageSize.width, imageSize.height, Color.WHITE, null);
feedback = new Feedback(targetImage);
- imageSize = size;
bestData = new PolygonData[0];
}
/**
+ * returns the image size that is being generated. This size might be different the original image
+ * if the size is bigger then the max setting.
+ *
+ * @return the image size
+ */
+ public Dimension getImageSize() {
+ return imageSize;
+ }
+
+ /**
* allows interested parties to register to receive events when a new best image has been
* found.
*
@@ -204,4 +216,16 @@
e.printStackTrace();
}
}
+
+ private Dimension trimSize(Dimension origSize, Dimension maxSize) {
+ if ((origSize.width < maxSize.width) && (origSize.height < maxSize.height))
+ return origSize;
+
+ double hFrac = (double)maxSize.width / (double)origSize.width;
+ double vFrac = (double)maxSize.height/ (double)origSize.height;
+
+ double frac = (hFrac < vFrac) ? hFrac : vFrac;
+
+ return new Dimension((int)(frac * origSize.width), (int)(frac * origSize.height));
+ }
}
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java 2009-11-28 23:32:38 UTC (rev 94)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java 2009-11-28 23:37:18 UTC (rev 95)
@@ -132,7 +132,7 @@
wSize.height *= 2;
}
setSize(wSize);
- generator = new ImageGenerator(targetImage, size);
+ generator = new ImageGenerator(settings, targetImage, size);
generator.addImageGeneratedListener(PainterFrame.this);
generator.startGenerating();
completeImage.setEnabled(true);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-28 23:32:45
|
Revision: 94
http://polycasso.svn.sourceforge.net/polycasso/?rev=94&view=rev
Author: dbrosius
Date: 2009-11-28 23:32:38 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
return isOK when asked
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java 2009-11-28 23:31:01 UTC (rev 93)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java 2009-11-28 23:32:38 UTC (rev 94)
@@ -56,7 +56,7 @@
}
public boolean isOK() {
- return false;
+ return isOK;
}
public Settings getSettings() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-28 23:31:08
|
Revision: 93
http://polycasso.svn.sourceforge.net/polycasso/?rev=93&view=rev
Author: dbrosius
Date: 2009-11-28 23:31:01 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
set fields on ok
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java 2009-11-28 23:21:28 UTC (rev 92)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java 2009-11-28 23:31:01 UTC (rev 93)
@@ -20,6 +20,7 @@
import java.awt.BorderLayout;
import java.awt.Container;
+import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -134,6 +135,9 @@
okButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
+ dlgSettings.setMaxImageSize(new Dimension(Integer.parseInt(widthField.getText()), Integer.parseInt(heightField.getText())));
+ dlgSettings.setMaxPolygons(Integer.parseInt(maxPolygonField.getText()));
+ dlgSettings.setMaxPtMovement(Integer.parseInt(maxPtMoveField.getText()));
isOK = true;
dispose();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-28 23:21:35
|
Revision: 92
http://polycasso.svn.sourceforge.net/polycasso/?rev=92&view=rev
Author: dbrosius
Date: 2009-11-28 23:21:28 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
add a settings dialog (those settings are not used at present)
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-11-28 23:20:40 UTC (rev 91)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java 2009-11-28 23:21:28 UTC (rev 92)
@@ -45,7 +45,9 @@
private JMenuItem completeImage;
private JMenuItem quitItem;
private JMenuItem aboutItem;
- ImageGenerator generator;
+ private JMenuItem settingsItem;
+ private ImageGenerator generator;
+ private Settings settings;
/**
* creates the main window, setups up menus and listeners
@@ -56,6 +58,7 @@
initMenus();
initListeners();
pack();
+ settings = new Settings();
generator = null;
}
@@ -85,6 +88,12 @@
quitItem = new JMenuItem(PolycassoBundle.getString(PolycassoBundle.Key.Quit));
fileMenu.add(quitItem);
mb.add(fileMenu);
+
+ JMenu editMenu = new JMenu(PolycassoBundle.getString(PolycassoBundle.Key.Edit));
+ settingsItem = new JMenuItem(PolycassoBundle.getString(PolycassoBundle.Key.Settings));
+ editMenu.add(settingsItem);
+ mb.add(editMenu);
+
JMenu aboutMenu = new JMenu(PolycassoBundle.getString(PolycassoBundle.Key.About));
aboutItem = new JMenuItem(PolycassoBundle.getString(PolycassoBundle.Key.AboutPolycasso));
aboutMenu.add(aboutItem);
@@ -154,6 +163,22 @@
}
});
+ settingsItem.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ SettingsDialog dialog = new SettingsDialog(settings);
+ dialog.setLocationRelativeTo(PainterFrame.this);
+ dialog.setModal(true);
+ dialog.setVisible(true);
+ if (dialog.isOK()) {
+ Settings dlgSettings = dialog.getSettings();
+ settings.setMaxImageSize(dlgSettings.getMaxImageSize());
+ settings.setMaxPolygons(dlgSettings.getMaxPolygons());
+ settings.setMaxPtMovement(dlgSettings.getMaxPtMovement());
+ }
+ }
+ });
+
aboutItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java 2009-11-28 23:20:40 UTC (rev 91)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java 2009-11-28 23:21:28 UTC (rev 92)
@@ -30,13 +30,22 @@
*/
enum Key {
Title("pc.title"),
+ OK("pc.ok"),
+ Cancel("pc.cancel"),
Info("pc.info"),
File("pc.file"),
PaintImage("pc.paintimage"),
CompleteImage("pc.completeimage"),
Quit("pc.quit"),
+ Edit("pc.edit"),
+ Settings("pc.settings"),
About("pc.about"),
- AboutPolycasso("pc.aboutpolycasso");
+ AboutPolycasso("pc.aboutpolycasso"),
+ MaxImageSize("pc.maximagesize"),
+ Width("pc.width"),
+ Height("pc.height"),
+ MaximumPolygons("pc.maximumpolygons"),
+ MaximumPointMovement("pc.maximumpointmovement");
String id;
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties 2009-11-28 23:20:40 UTC (rev 91)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties 2009-11-28 23:21:28 UTC (rev 92)
@@ -17,10 +17,19 @@
# * under the License.
# */
pc.title = Polycasso
+pc.ok = OK
+pc.cancel = Cancel
pc.info = A cubism-style artwork generator that layers semi-transparent polygon \nvia a training feedback loop. Produces increasingly \nrealistic work though hill climbing.
pc.file = File
pc.paintimage = Start Generating Image
pc.completeimage = Complete Image
pc.quit = Quit
+pc.edit = Edit
+pc.settings = Settings
pc.about = About
pc.aboutpolycasso = About Polycasso
+pc.maximagesize = Maximum Image Size
+pc.width = Width
+pc.height = Height
+pc.maximumpolygons = Maximum Polygons
+pc.maximumpointmovement = Maximum Point Movement
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-28 23:20:48
|
Revision: 91
http://polycasso.svn.sourceforge.net/polycasso/?rev=91&view=rev
Author: dbrosius
Date: 2009-11-28 23:20:40 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
a dialog for configuring settings
Added Paths:
-----------
trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java 2009-11-28 23:20:40 UTC (rev 91)
@@ -0,0 +1,152 @@
+/*
+ * 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.awt.BorderLayout;
+import java.awt.Container;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import com.jgoodies.forms.layout.CellConstraints;
+import com.jgoodies.forms.layout.FormLayout;
+
+public class SettingsDialog extends JDialog {
+
+ Settings dlgSettings;
+ private JButton okButton;
+ private JButton cancelButton;
+ private JTextField widthField;
+ private JTextField heightField;
+ private JTextField maxPolygonField;
+ private JTextField maxPtMoveField;
+ private boolean isOK;
+
+ public SettingsDialog(Settings settings) {
+ setTitle(PolycassoBundle.getString(PolycassoBundle.Key.Settings));
+ dlgSettings = (Settings)settings.clone();
+ initComponents();
+ initListeners();
+ isOK = false;
+ }
+
+ public boolean isOK() {
+ return false;
+ }
+
+ public Settings getSettings() {
+ return dlgSettings;
+ }
+
+ private void initComponents() {
+ Container cp = getContentPane();
+ cp.setLayout(new BorderLayout(4, 4));
+
+ cp.add(createOptionsPanel(), BorderLayout.CENTER);
+ cp.add(createControlPanel(), BorderLayout.SOUTH);
+ pack();
+ }
+
+ private JPanel createOptionsPanel() {
+ JPanel optPanel = new JPanel();
+ optPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ optPanel.setLayout(new FormLayout("pref, 3dlu, 100px, 5dlu, pref, 3dlu, 100px", "pref, 1dlu, pref, 15dlu, pref, 1dlu, pref"));
+ CellConstraints cc = new CellConstraints();
+
+ JLabel maxSizeLabel = new JLabel(PolycassoBundle.getString(PolycassoBundle.Key.MaxImageSize));
+ optPanel.add(maxSizeLabel, cc.xyw(1, 1, 7));
+
+ JLabel widthLabel = new JLabel(PolycassoBundle.getString(PolycassoBundle.Key.Width));
+ optPanel.add(widthLabel, cc.xy(1, 3));
+ widthField = new JTextField(4);
+ widthField.setDocument(new IntegerDocument());
+ widthLabel.setLabelFor(widthField);
+ widthField.setText(String.valueOf(dlgSettings.getMaxImageSize().width));
+ optPanel.add(widthField, cc.xy(3, 3));
+
+ JLabel heightLabel = new JLabel(PolycassoBundle.getString(PolycassoBundle.Key.Height));
+ optPanel.add(heightLabel, cc.xy(5, 3));
+ heightField = new JTextField(4);
+ heightField.setDocument(new IntegerDocument());
+ heightLabel.setLabelFor(heightField);
+ heightField.setText(String.valueOf(dlgSettings.getMaxImageSize().height));
+ optPanel.add(heightField, cc.xy(7, 3));
+
+ JLabel maxPolyLabel = new JLabel(PolycassoBundle.getString(PolycassoBundle.Key.MaximumPolygons));
+ optPanel.add(maxPolyLabel, cc.xyw(1, 5, 5));
+ maxPolygonField = new JTextField(4);
+ maxPolygonField.setDocument(new IntegerDocument());
+ maxPolyLabel.setLabelFor(maxPolygonField);
+ maxPolygonField.setText(String.valueOf(dlgSettings.getMaxPolygons()));
+ optPanel.add(maxPolygonField, cc.xy(7, 5));
+
+ JLabel maxPtMoveLabel = new JLabel(PolycassoBundle.getString(PolycassoBundle.Key.MaximumPointMovement));
+ optPanel.add(maxPtMoveLabel, cc.xyw(1, 7, 5));
+ maxPtMoveField = new JTextField(4);
+ maxPtMoveField.setDocument(new IntegerDocument());
+ maxPtMoveLabel.setLabelFor(maxPtMoveField);
+ maxPtMoveField.setText(String.valueOf(dlgSettings.getMaxPtMovement()));
+ optPanel.add(maxPtMoveField, cc.xy(7, 7));
+ return optPanel;
+ }
+
+ private JPanel createControlPanel() {
+ JPanel ctrlPanel = new JPanel();
+ ctrlPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ ctrlPanel.setLayout(new BoxLayout(ctrlPanel, BoxLayout.X_AXIS));
+ ctrlPanel.add(Box.createHorizontalGlue());
+
+ okButton = new JButton(PolycassoBundle.getString(PolycassoBundle.Key.OK));
+ cancelButton = new JButton(PolycassoBundle.getString(PolycassoBundle.Key.Cancel));
+
+ ctrlPanel.add(okButton);
+ ctrlPanel.add(Box.createHorizontalStrut(10));
+ ctrlPanel.add(cancelButton);
+ ctrlPanel.add(Box.createHorizontalStrut(10));
+ return ctrlPanel;
+ }
+
+ private void initListeners() {
+ okButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ isOK = true;
+ dispose();
+ }
+ });
+
+ cancelButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ isOK = false;
+ dispose();
+ }
+ });
+ }
+
+
+}
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.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-11-28 23:19:54
|
Revision: 90
http://polycasso.svn.sourceforge.net/polycasso/?rev=90&view=rev
Author: dbrosius
Date: 2009-11-28 23:19:44 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
a simple bean for holding configuration settings
Added Paths:
-----------
trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java 2009-11-28 23:19:44 UTC (rev 90)
@@ -0,0 +1,67 @@
+/*
+ * 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.awt.Dimension;
+
+public class Settings implements Cloneable {
+
+ private Dimension maxImageSize;
+ private int maxPolygons;
+ private int maxPtMovement;
+
+ public Settings() {
+ maxImageSize = new Dimension(800, 600);
+ maxPolygons = 50;
+ maxPtMovement = 20;
+ }
+
+ @Override
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException cnse) {
+ return new Settings();
+ }
+ }
+
+ public void setMaxImageSize(Dimension imageSize) {
+ maxImageSize = imageSize;
+ }
+
+ public Dimension getMaxImageSize() {
+ return maxImageSize;
+ }
+
+ public void setMaxPolygons(int maxPolys) {
+ maxPolygons = maxPolys;
+ }
+
+ public int getMaxPolygons() {
+ return maxPolygons;
+ }
+
+ public void setMaxPtMovement(int maxPointMovement) {
+ maxPtMovement = maxPointMovement;
+ }
+
+ public int getMaxPtMovement() {
+ return maxPtMovement;
+ }
+}
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.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-11-28 23:18:54
|
Revision: 89
http://polycasso.svn.sourceforge.net/polycasso/?rev=89&view=rev
Author: dbrosius
Date: 2009-11-28 23:18:46 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
a document that only allows integer characters
Added Paths:
-----------
trunk/polycasso/src/com/mebigfatguy/polycasso/IntegerDocument.java
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/IntegerDocument.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/IntegerDocument.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/IntegerDocument.java 2009-11-28 23:18:46 UTC (rev 89)
@@ -0,0 +1,43 @@
+/*
+ * 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.awt.Toolkit;
+
+import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.PlainDocument;
+
+public class IntegerDocument extends PlainDocument {
+
+ private static final long serialVersionUID = -6755728406523769124L;
+
+ @Override
+ public void insertString(int pos, String insertStr, AttributeSet atts) throws BadLocationException {
+ StringBuilder text = new StringBuilder(getText(0, getLength()));
+ try {
+ text.insert(pos, insertStr);
+ Integer.parseInt(text.toString());
+ super.insertString(pos, insertStr, atts);
+ } catch (Exception e) {
+ Toolkit.getDefaultToolkit().beep();
+ }
+ }
+
+}
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/IntegerDocument.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-11-28 19:51:47
|
Revision: 88
http://polycasso.svn.sourceforge.net/polycasso/?rev=88&view=rev
Author: dbrosius
Date: 2009-11-28 19:51:38 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
surprisingly, you get a lot of ties, so remove the <= for progress
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-28 05:51:48 UTC (rev 87)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-28 19:51:38 UTC (rev 88)
@@ -179,7 +179,7 @@
boolean newBest = false;
synchronized(lock) {
attempt++;
- if (delta <= bestScore) {
+ if (delta < bestScore) {
bestData = data.toArray(new PolygonData[data.size()]);
bestScore = delta;
if (Polycasso.DEBUG)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-28 05:51:54
|
Revision: 87
http://polycasso.svn.sourceforge.net/polycasso/?rev=87&view=rev
Author: dbrosius
Date: 2009-11-28 05:51:48 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
use isEmpty
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2009-11-28 05:36:28 UTC (rev 86)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2009-11-28 05:51:48 UTC (rev 87)
@@ -87,8 +87,7 @@
* @return the improvement type used to alter the data
*/
public ImprovementType improveRandomly() {
- int numPolys = polygons.size();
- if (numPolys == 0) {
+ if (polygons.isEmpty()) {
polygons.add(PolygonData.randomPoly(imageSize));
return ImprovementType.AddPolygon;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-28 05:36:36
|
Revision: 86
http://polycasso.svn.sourceforge.net/polycasso/?rev=86&view=rev
Author: dbrosius
Date: 2009-11-28 05:36:28 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
add about box
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-11-28 05:35:54 UTC (rev 85)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java 2009-11-28 05:36:28 UTC (rev 86)
@@ -44,6 +44,7 @@
private JMenuItem paintImage;
private JMenuItem completeImage;
private JMenuItem quitItem;
+ private JMenuItem aboutItem;
ImageGenerator generator;
/**
@@ -84,6 +85,10 @@
quitItem = new JMenuItem(PolycassoBundle.getString(PolycassoBundle.Key.Quit));
fileMenu.add(quitItem);
mb.add(fileMenu);
+ JMenu aboutMenu = new JMenu(PolycassoBundle.getString(PolycassoBundle.Key.About));
+ aboutItem = new JMenuItem(PolycassoBundle.getString(PolycassoBundle.Key.AboutPolycasso));
+ aboutMenu.add(aboutItem);
+ mb.add(aboutMenu);
setJMenuBar(mb);
}
@@ -148,6 +153,16 @@
System.exit(0);
}
});
+
+ aboutItem.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ AboutDialog ad = new AboutDialog();
+ ad.setLocationRelativeTo(PainterFrame.this);
+ ad.setModal(true);
+ ad.setVisible(true);
+ }
+ });
}
/**
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java 2009-11-28 05:35:54 UTC (rev 85)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java 2009-11-28 05:36:28 UTC (rev 86)
@@ -30,10 +30,13 @@
*/
enum Key {
Title("pc.title"),
+ Info("pc.info"),
File("pc.file"),
PaintImage("pc.paintimage"),
CompleteImage("pc.completeimage"),
- Quit("pc.quit");
+ Quit("pc.quit"),
+ About("pc.about"),
+ AboutPolycasso("pc.aboutpolycasso");
String id;
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties 2009-11-28 05:35:54 UTC (rev 85)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties 2009-11-28 05:36:28 UTC (rev 86)
@@ -17,7 +17,10 @@
# * under the License.
# */
pc.title = Polycasso
+pc.info = A cubism-style artwork generator that layers semi-transparent polygon \nvia a training feedback loop. Produces increasingly \nrealistic work though hill climbing.
pc.file = File
pc.paintimage = Start Generating Image
pc.completeimage = Complete Image
-pc.quit = Quit
\ No newline at end of file
+pc.quit = Quit
+pc.about = About
+pc.aboutpolycasso = About Polycasso
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-28 05:36:06
|
Revision: 85
http://polycasso.svn.sourceforge.net/polycasso/?rev=85&view=rev
Author: dbrosius
Date: 2009-11-28 05:35:54 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
add an about box
Added Paths:
-----------
trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.java
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.java 2009-11-28 05:35:54 UTC (rev 85)
@@ -0,0 +1,60 @@
+/*
+ * 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.awt.BorderLayout;
+import java.awt.Container;
+
+import javax.swing.BorderFactory;
+import javax.swing.BoxLayout;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+
+public class AboutDialog extends JDialog {
+
+ private static final long serialVersionUID = -686787510942505991L;
+
+ public AboutDialog() {
+ setTitle(PolycassoBundle.getString(PolycassoBundle.Key.AboutPolycasso));
+ initComponents();
+ pack();
+ }
+
+ private void initComponents() {
+ Container cp = getContentPane();
+
+ JPanel mainPanel = new JPanel();
+ mainPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10), BorderFactory.createEtchedBorder()));
+ mainPanel.setLayout(new BorderLayout(4, 4));
+
+ JTextArea info = new JTextArea(PolycassoBundle.getString(PolycassoBundle.Key.Info));
+ info.setEditable(false);
+ info.setBackground(mainPanel.getBackground());
+ mainPanel.add(info, BorderLayout.CENTER);
+
+ JPanel cpPanel = new JPanel();
+ cpPanel.setLayout(new BoxLayout(cpPanel, BoxLayout.Y_AXIS));
+ cpPanel.add(new JLabel("©MeBigFatGuy.com"));
+ cpPanel.add(new JLabel("©Dave Brosius"));
+ mainPanel.add(cpPanel, BorderLayout.SOUTH);
+ cp.add(mainPanel);
+ }
+}
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.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-11-28 04:40:44
|
Revision: 84
http://polycasso.svn.sourceforge.net/polycasso/?rev=84&view=rev
Author: dbrosius
Date: 2009-11-28 04:40:34 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
fix setting window size
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-11-28 04:37:00 UTC (rev 83)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java 2009-11-28 04:40:34 UTC (rev 84)
@@ -111,10 +111,13 @@
Image targetImage = RandomImageFinder.findImage();
panel.setTarget(targetImage);
Dimension size = new Dimension(targetImage.getWidth(PainterFrame.this), targetImage.getHeight(PainterFrame.this));
+
+ Dimension wSize = new Dimension(size);
+ wSize.height += 2 * PainterFrame.this.getJMenuBar().getHeight();
if (Polycasso.DEBUG){
- Dimension wSize = new Dimension(size.width, size.height * 2);
- setSize(wSize);
+ wSize.height *= 2;
}
+ setSize(wSize);
generator = new ImageGenerator(targetImage, size);
generator.addImageGeneratedListener(PainterFrame.this);
generator.startGenerating();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-28 04:37:06
|
Revision: 83
http://polycasso.svn.sourceforge.net/polycasso/?rev=83&view=rev
Author: dbrosius
Date: 2009-11-28 04:37:00 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-28 04:35:16 UTC (rev 82)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-28 04:37:00 UTC (rev 83)
@@ -38,6 +38,7 @@
public class ImageGenerator implements Runnable {
private static int attempt = 0;
private Set<ImageGeneratedListener> listeners = new HashSet<ImageGeneratedListener>();
+ private BufferedImage targetImage;
private PolygonData[] bestData;
private double bestScore = Double.MAX_VALUE;
private Dimension imageSize;
@@ -53,7 +54,7 @@
* @param size the dimension of the image
*/
public ImageGenerator(Image image, Dimension size) {
- BufferedImage targetImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_4BYTE_ABGR);
+ targetImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_4BYTE_ABGR);
Graphics g = targetImage.getGraphics();
g.drawImage(image, 0, 0, size.width, size.height, Color.WHITE, null);
feedback = new Feedback(targetImage);
@@ -131,6 +132,20 @@
}
/**
+ * completes the image by transforming the polygon image to the real image
+ */
+ public void complete() {
+ synchronized(startStopLock) {
+ if (t != null) {
+ stopGenerating();
+ t = new Thread[1];
+ t[0] = new Thread(new ImageCompleter(this, targetImage, bestData, imageSize));
+ t[0].start();
+ }
+ }
+ }
+
+ /**
* the runnable interface implementation to repeatedly improve upon the image and check to
* see if it is closer to the target image.
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-28 04:35:22
|
Revision: 82
http://polycasso.svn.sourceforge.net/polycasso/?rev=82&view=rev
Author: dbrosius
Date: 2009-11-28 04:35:16 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
smooth, and speed up the transition
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java 2009-11-28 04:21:07 UTC (rev 81)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java 2009-11-28 04:35:16 UTC (rev 82)
@@ -32,8 +32,8 @@
* a time lapse blend transformation of the images
*/
public class ImageCompleter implements Runnable {
- private static final int NUMTRANSITIONS = 30;
- private static final int TRANSITION_DELAY = 1000;
+ private static final int NUMTRANSITIONS = 500;
+ private static final int TRANSITION_DELAY = 80;
private ImageGenerator imageGenerator;
private BufferedImage targetImage;
@@ -43,7 +43,7 @@
/**
* create a completer to move the image from polygon form to real form
*
- * @param generator the iage generator that this completer is working for
+ * @param generator the image generator that this completer is working for
* @param image the target image that will eventually be drawn
* @param bestData the best proximation the program reached
* @param size the image size
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-28 04:21:20
|
Revision: 81
http://polycasso.svn.sourceforge.net/polycasso/?rev=81&view=rev
Author: dbrosius
Date: 2009-11-28 04:21:07 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
javadoc
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java 2009-11-28 01:54:25 UTC (rev 80)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java 2009-11-28 04:21:07 UTC (rev 81)
@@ -43,9 +43,10 @@
/**
* create a completer to move the image from polygon form to real form
*
+ * @param generator the iage generator that this completer is working for
* @param image the target image that will eventually be drawn
* @param bestData the best proximation the program reached
- * @param imageSize the image size
+ * @param size the image size
*/
public ImageCompleter(ImageGenerator generator, BufferedImage image, PolygonData[] bestData, Dimension size) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-28 01:54:32
|
Revision: 80
http://polycasso.svn.sourceforge.net/polycasso/?rev=80&view=rev
Author: dbrosius
Date: 2009-11-28 01:54:25 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
add an image completor
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-11-28 01:54:03 UTC (rev 79)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java 2009-11-28 01:54:25 UTC (rev 80)
@@ -42,6 +42,7 @@
private static final long serialVersionUID = 7729602294481171194L;
private PainterPanel panel;
private JMenuItem paintImage;
+ private JMenuItem completeImage;
private JMenuItem quitItem;
ImageGenerator generator;
@@ -76,6 +77,10 @@
JMenu fileMenu = new JMenu(PolycassoBundle.getString(PolycassoBundle.Key.File));
paintImage = new JMenuItem(PolycassoBundle.getString(PolycassoBundle.Key.PaintImage));
fileMenu.add(paintImage);
+ completeImage = new JMenuItem(PolycassoBundle.getString(PolycassoBundle.Key.CompleteImage));
+ completeImage.setEnabled(false);
+ fileMenu.add(completeImage);
+ fileMenu.addSeparator();
quitItem = new JMenuItem(PolycassoBundle.getString(PolycassoBundle.Key.Quit));
fileMenu.add(quitItem);
mb.add(fileMenu);
@@ -113,6 +118,7 @@
generator = new ImageGenerator(targetImage, size);
generator.addImageGeneratedListener(PainterFrame.this);
generator.startGenerating();
+ completeImage.setEnabled(true);
} catch (IOException ioe) {
JOptionPane.showMessageDialog(null, ioe.getMessage());
@@ -120,9 +126,21 @@
}
});
+ completeImage.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ if (generator != null)
+ generator.complete();
+
+ completeImage.setEnabled(false);
+ }
+ });
+
quitItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
+ if (generator != null)
+ generator.stopGenerating();
dispose();
System.exit(0);
}
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java 2009-11-28 01:54:03 UTC (rev 79)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java 2009-11-28 01:54:25 UTC (rev 80)
@@ -32,6 +32,7 @@
Title("pc.title"),
File("pc.file"),
PaintImage("pc.paintimage"),
+ CompleteImage("pc.completeimage"),
Quit("pc.quit");
String id;
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties 2009-11-28 01:54:03 UTC (rev 79)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties 2009-11-28 01:54:25 UTC (rev 80)
@@ -19,4 +19,5 @@
pc.title = Polycasso
pc.file = File
pc.paintimage = Start Generating Image
+pc.completeimage = Complete Image
pc.quit = Quit
\ 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-11-28 01:54:11
|
Revision: 79
http://polycasso.svn.sourceforge.net/polycasso/?rev=79&view=rev
Author: dbrosius
Date: 2009-11-28 01:54:03 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
a class that will complete the image, so that you can see what the target was
Added Paths:
-----------
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java 2009-11-28 01:54:03 UTC (rev 79)
@@ -0,0 +1,105 @@
+/*
+ * 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.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Composite;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBufferByte;
+import java.awt.image.WritableRaster;
+
+/**
+ * a class that transforms the current best polygon representation to the real image thru
+ * a time lapse blend transformation of the images
+ */
+public class ImageCompleter implements Runnable {
+ private static final int NUMTRANSITIONS = 30;
+ private static final int TRANSITION_DELAY = 1000;
+
+ private ImageGenerator imageGenerator;
+ private BufferedImage targetImage;
+ private BufferedImage srcImage;
+ private Dimension imageSize;
+
+ /**
+ * create a completer to move the image from polygon form to real form
+ *
+ * @param image the target image that will eventually be drawn
+ * @param bestData the best proximation the program reached
+ * @param imageSize the image size
+ */
+
+ public ImageCompleter(ImageGenerator generator, BufferedImage image, PolygonData[] bestData, Dimension size) {
+ imageGenerator = generator;
+ targetImage = image;
+ imageSize = size;
+
+ srcImage = new BufferedImage(imageSize.width, imageSize.height, BufferedImage.TYPE_4BYTE_ABGR);
+ Graphics2D g2d = (Graphics2D)srcImage.getGraphics();
+ Composite srcOpaque = AlphaComposite.getInstance(AlphaComposite.SRC, 1.0f);
+ g2d.setColor(Color.BLACK);
+ g2d.setComposite(srcOpaque);
+ g2d.fillRect(0, 0, imageSize.width, imageSize.height);
+
+ for (PolygonData pd : bestData) {
+ pd.draw(g2d);
+ }
+ }
+
+ @Override
+ public void run() {
+ try {
+ WritableRaster sRaster = srcImage.getRaster();
+ DataBufferByte sDBB = (DataBufferByte)sRaster.getDataBuffer();
+ byte[] sData = sDBB.getData();
+
+ WritableRaster tRaster = targetImage.getRaster();
+ DataBufferByte tDBB = (DataBufferByte)tRaster.getDataBuffer();
+ byte[] tData = tDBB.getData();
+
+ int transition = 0;
+ do {
+ Thread.sleep(TRANSITION_DELAY);
+ transition++;
+
+ BufferedImage intermediateImage = new BufferedImage(imageSize.width, imageSize.height, BufferedImage.TYPE_4BYTE_ABGR);
+ WritableRaster iRaster= intermediateImage.getRaster();
+ DataBufferByte iDBB = (DataBufferByte)iRaster.getDataBuffer();
+ byte[] iData = iDBB.getData();
+
+ for (int i = 0; i < sData.length; ) {
+ iData[i++] = (byte)0xFF;
+ for (int c = 0; c < 3; c++) {
+ int sC = sData[i] & 0x00FF;
+ int tC = tData[i] & 0x00FF;
+ int iC = sC + (((tC - sC) * transition) / NUMTRANSITIONS);
+ iData[i] = (byte)iC;
+ ++i;
+ }
+ }
+ imageGenerator.fireImageGenerated(intermediateImage);
+
+ } while ((transition < NUMTRANSITIONS) && !Thread.interrupted());
+ } catch (InterruptedException ie) {
+ }
+ }
+}
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.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-11-28 00:56:13
|
Revision: 78
http://polycasso.svn.sourceforge.net/polycasso/?rev=78&view=rev
Author: dbrosius
Date: 2009-11-28 00:56:07 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
move to development of version 0.3.0
Modified Paths:
--------------
trunk/polycasso/build.xml
Modified: trunk/polycasso/build.xml
===================================================================
--- trunk/polycasso/build.xml 2009-11-28 00:54:54 UTC (rev 77)
+++ trunk/polycasso/build.xml 2009-11-28 00:56:07 UTC (rev 78)
@@ -35,7 +35,7 @@
<property name="javac.deprecation" value="on"/>
<property name="javac.debug" value="on"/>
- <property name="polycasso.version" value="0.1.0"/>
+ <property name="polycasso.version" value="0.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-11-28 00:55:02
|
Revision: 77
http://polycasso.svn.sourceforge.net/polycasso/?rev=77&view=rev
Author: dbrosius
Date: 2009-11-28 00:54:54 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
tag for version 0.2.0
Added Paths:
-----------
tags/v0_2_0/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2009-11-28 00:52:47
|
Revision: 76
http://polycasso.svn.sourceforge.net/polycasso/?rev=76&view=rev
Author: dbrosius
Date: 2009-11-28 00:52:39 +0000 (Sat, 28 Nov 2009)
Log Message:
-----------
top directory for branches
Added Paths:
-----------
branches/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|