Thread: [Polycasso-commit] SF.net SVN: polycasso:[3] trunk/polycasso
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2009-11-23 15:16:43
|
Revision: 3
http://polycasso.svn.sourceforge.net/polycasso/?rev=3&view=rev
Author: dbrosius
Date: 2009-11-23 15:16:33 +0000 (Mon, 23 Nov 2009)
Log Message:
-----------
initial checkin
Added Paths:
-----------
trunk/polycasso/src/
trunk/polycasso/src/com/
trunk/polycasso/src/com/mebigfatguy/
trunk/polycasso/src/com/mebigfatguy/polycasso/
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PainterPanel.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java
trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java
trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java 2009-11-23 15:16:33 UTC (rev 3)
@@ -0,0 +1,19 @@
+package com.mebigfatguy.polycasso;
+
+import java.awt.Image;
+import java.util.EventObject;
+
+public class ImageGeneratedEvent extends EventObject {
+
+ private static final long serialVersionUID = 1478846574394938989L;
+ private Image bestImage;
+
+ public ImageGeneratedEvent(Object source, Image image) {
+ super(source);
+ bestImage = image;
+ }
+
+ public Image getImage() {
+ return bestImage;
+ }
+}
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java 2009-11-23 15:16:33 UTC (rev 3)
@@ -0,0 +1,6 @@
+package com.mebigfatguy.polycasso;
+
+public interface ImageGeneratedListener {
+
+ public void imageGenerated(ImageGeneratedEvent event);
+}
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-11-23 15:16:33 UTC (rev 3)
@@ -0,0 +1,164 @@
+package com.mebigfatguy.polycasso;
+
+import java.awt.Color;
+import java.awt.Composite;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBufferByte;
+import java.awt.image.WritableRaster;
+import java.util.HashSet;
+import java.util.Set;
+
+public class ImageGenerator implements Runnable {
+ private static final int NUM_THREADS = 10;
+
+
+ private static int attempt = 0;
+ private Set<ImageGeneratedListener> listeners = new HashSet<ImageGeneratedListener>();
+ private PolygonData[] bestData;
+ private double bestScore = Double.MAX_VALUE;
+ private BufferedImage targetImage;
+ private Dimension imageSize;
+ private Thread[] t = null;
+ private Object lock = new Object();
+
+ public ImageGenerator(Image image, Dimension size) {
+ 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);
+ imageSize = size;
+ bestData = PolygonData.randomPolys(size);
+ }
+
+ public void addImageGeneratedListener(ImageGeneratedListener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeImageGeneratedListener(ImageGeneratedListener listener) {
+ listeners.remove(listener);
+ }
+
+ public void fireImageGenerated(Image image) {
+ ImageGeneratedEvent event = new ImageGeneratedEvent(this, image);
+ for (ImageGeneratedListener listener : listeners) {
+ listener.imageGenerated(event);
+ }
+
+ }
+
+ public void startGenerating() {
+ synchronized(lock) {
+ if (t == null) {
+ t = new Thread[NUM_THREADS];
+ for (int i = 0; i < NUM_THREADS; i++) {
+ t[i] = new Thread(this);
+ t[i].start();
+ }
+ }
+ }
+ }
+
+ public void stopGenerating() {
+ synchronized(lock) {
+ if (t != null) {
+ try {
+ for (int i = 0; i < NUM_THREADS; i++) {
+ t[i].interrupt();
+ }
+ for (int i = 0; i < NUM_THREADS; i++) {
+ t[i].join();
+ }
+ } catch (InterruptedException ie) {
+ } finally {
+ t = null;
+ }
+ }
+ }
+ }
+
+ public void run() {
+ try {
+ while (!Thread.interrupted()) {
+ PolygonData[] data;
+
+ synchronized(lock) {
+ data = bestData.clone();
+ }
+
+
+ ImprovementType type = PolygonData.improveRandomly(data, imageSize);
+
+ 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);
+ Color saveColor = g2d.getColor();
+ Composite saveComposite = g2d.getComposite();
+ try {
+ for (PolygonData pd : data) {
+ pd.draw(g2d);
+ }
+ } finally {
+ g2d.setColor(saveColor);
+ g2d.setComposite(saveComposite);
+ }
+
+ double delta = calculateDelta(image, targetImage);
+
+ //String message = null;
+ synchronized(lock) {
+ attempt++;
+ if (delta < bestScore) {
+ bestData = data;
+ bestScore = delta;
+ //message = "Attempt: " + attempt + " BestScore: " + bestScore + " type: " + type.name();
+ fireImageGenerated(image);
+ }
+ }
+ //if (message != null)
+ // System.out.println(message);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private double calculateDelta(BufferedImage image1, BufferedImage image2) {
+ WritableRaster raster1 = image1.getRaster();
+ WritableRaster raster2 = image2.getRaster();
+
+ DataBufferByte db1 = (DataBufferByte)raster1.getDataBuffer();
+ DataBufferByte db2 = (DataBufferByte)raster2.getDataBuffer();
+
+ byte[] buffer1 = db1.getData();
+ byte[] buffer2 = db2.getData();
+
+ int size = db1.getSize();
+ double error = 0.0;
+
+ for (int i = 0; i < size; i+=4) {
+ int blue1 = buffer1[i+1] & 0x0FF;
+ int blue2 = buffer2[i+1] & 0x0FF;
+ double blueError = blue1 - blue2;
+ blueError *= blueError;
+
+ int green1 = buffer1[i+2] & 0x0FF;
+ int green2 = buffer2[i+2] & 0x0FF;
+ double greenError = green1 - green2;
+ greenError *= greenError;
+
+ int red1 = buffer1[i+3] & 0x0FF;
+ int red2 = buffer2[i+3] & 0x0FF;
+ double redError = red1 - red2;
+ redError *= redError;
+
+ error += redError + greenError + blueError;
+ }
+
+ return error;
+ }
+
+}
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java 2009-11-23 15:16:33 UTC (rev 3)
@@ -0,0 +1,19 @@
+package com.mebigfatguy.polycasso;
+
+
+public enum ImprovementType {
+ AddPoint,
+ RemovePoint,
+ MovePoint,
+ ReorderPoly,
+ ShrinkPoly,
+ EnlargePoly,
+ ChangeColor,
+ ChangeAlpha,
+ CompleteChange;
+
+ public static ImprovementType getRandomImprovement() {
+ ImprovementType[] types = ImprovementType.values();
+ return types[(int)((int)(Math.random() * types.length))];
+ }
+}
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java 2009-11-23 15:16:33 UTC (rev 3)
@@ -0,0 +1,100 @@
+package com.mebigfatguy.polycasso;
+
+import java.awt.BorderLayout;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Image;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.IOException;
+
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+
+public class PainterFrame extends JFrame implements ImageGeneratedListener {
+
+ private static final long serialVersionUID = 7729602294481171194L;
+ private PainterPanel panel;
+ private JMenuItem paintImage;
+ private JMenuItem quitItem;
+ ImageGenerator generator;
+
+ public PainterFrame() {
+ setTitle(PolycassoBundle.getString(PolycassoBundle.Key.Title));
+ initComponents();
+ initMenus();
+ initListeners();
+ pack();
+ generator = null;
+ }
+
+ private void initComponents() {
+
+ Container cp = getContentPane();
+ cp.setLayout(new BorderLayout(4, 4));
+ panel = new PainterPanel();
+ cp.add(panel, BorderLayout.CENTER);
+
+ }
+
+ private void initMenus() {
+ JMenuBar mb = new JMenuBar();
+ JMenu fileMenu = new JMenu(PolycassoBundle.getString(PolycassoBundle.Key.File));
+ paintImage = new JMenuItem(PolycassoBundle.getString(PolycassoBundle.Key.PaintImage));
+ fileMenu.add(paintImage);
+ quitItem = new JMenuItem(PolycassoBundle.getString(PolycassoBundle.Key.Quit));
+ fileMenu.add(quitItem);
+ mb.add(fileMenu);
+
+ setJMenuBar(mb);
+ }
+
+ private void initListeners() {
+
+ addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent we) {
+ dispose();
+ System.exit(0);
+ }
+ });
+
+ paintImage.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ try {
+ if (generator != null)
+ generator.stopGenerating();
+
+ Image targetImage = RandomImageFinder.findImage();
+ panel.setTarget(targetImage);
+ Dimension size = new Dimension(targetImage.getWidth(PainterFrame.this), targetImage.getHeight(PainterFrame.this));
+ setSize(size);
+ generator = new ImageGenerator(targetImage, size);
+ generator.addImageGeneratedListener(PainterFrame.this);
+ generator.startGenerating();
+
+ } catch (IOException ioe) {
+ JOptionPane.showMessageDialog(null, ioe.getMessage());
+ }
+ }
+ });
+
+ quitItem.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ dispose();
+ System.exit(0);
+ }
+ });
+ }
+
+ public void imageGenerated(ImageGeneratedEvent event) {
+ panel.setImage(event.getImage());
+ }
+}
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/PainterPanel.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PainterPanel.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PainterPanel.java 2009-11-23 15:16:33 UTC (rev 3)
@@ -0,0 +1,40 @@
+package com.mebigfatguy.polycasso;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Image;
+
+import javax.swing.JPanel;
+
+public class PainterPanel extends JPanel {
+
+ private static final long serialVersionUID = -4005448126783525299L;
+ private Object lock = new Object();
+ private Image targetImage;
+ private Image bestImage;
+
+ public void setTarget(Image image) {
+ synchronized(lock) {
+ targetImage = image;
+ setSize(targetImage.getWidth(PainterPanel.this), targetImage.getHeight(PainterPanel.this));
+ }
+ }
+
+ public void setImage(Image image) {
+ synchronized(lock) {
+ bestImage = image;
+ }
+ invalidate();
+ repaint();
+ }
+
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ synchronized(lock) {
+ if (bestImage != null)
+ g.drawImage(bestImage, 0, 0, bestImage.getWidth(this), bestImage.getHeight(this), Color.WHITE, this);
+// if (targetImage != null)
+// g.drawImage(targetImage, 0, targetImage.getHeight(this), targetImage.getWidth(this), targetImage.getHeight(this), Color.WHITE, this);
+ }
+ }
+}
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/PainterPanel.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java 2009-11-23 15:16:33 UTC (rev 3)
@@ -0,0 +1,17 @@
+package com.mebigfatguy.polycasso;
+
+import java.awt.Dimension;
+import java.awt.Toolkit;
+
+public class Polycasso {
+
+ public static void main(String[] args) {
+ PainterFrame pf = new PainterFrame();
+
+ Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
+ pf.setPreferredSize(dim);
+ pf.setSize(dim);
+ pf.setLocationRelativeTo(null);
+ pf.setVisible(true);
+ }
+}
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java 2009-11-23 15:16:33 UTC (rev 3)
@@ -0,0 +1,33 @@
+package com.mebigfatguy.polycasso;
+
+import java.util.ResourceBundle;
+
+public class PolycassoBundle {
+
+ enum Key {
+ Title("pc.title"),
+ File("pc.file"),
+ PaintImage("pc.paintimage"),
+ Quit("pc.quit");
+
+ String id;
+
+ Key(String id) {
+ this.id = id;
+ }
+
+ public String id() {
+ return id;
+ }
+ };
+
+ private static ResourceBundle bundle = ResourceBundle.getBundle("com/mebigfatguy/polycasso/resource");
+
+ private PolycassoBundle() {
+
+ }
+
+ public static String getString(Key key) {
+ return bundle.getString(key.id());
+ }
+}
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java 2009-11-23 15:16:33 UTC (rev 3)
@@ -0,0 +1,210 @@
+package com.mebigfatguy.polycasso;
+
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.Polygon;
+import java.util.Random;
+
+public class PolygonData implements Cloneable {
+ public static final int NUM_POLYS = 50;
+ public static final int MAX_POINTS = 8;
+
+ private Color color;
+ private float alpha;
+ private Polygon polygon;
+
+ public PolygonData(Color c, float xpar, Polygon poly) {
+ color = c;
+ alpha = xpar;
+ polygon = poly;
+ }
+
+ public static PolygonData randomPoly(Dimension size) {
+ Random r = new Random();
+ Polygon polygon = new Polygon();
+ int numPoints = r.nextInt(MAX_POINTS - 3) + 3;
+
+ for (int i = 0; i < numPoints; i++) {
+ polygon.addPoint(r.nextInt(size.width), r.nextInt(size.height));
+ }
+
+ Color c = new Color(r.nextFloat(), r.nextFloat(), r.nextFloat());
+
+ return new PolygonData(c, r.nextFloat(), polygon);
+ }
+
+ public static PolygonData[] randomPolys(Dimension size) {
+ PolygonData[] data = new PolygonData[NUM_POLYS];
+
+ for (int i = 0; i < NUM_POLYS; i++) {
+ data[i] = randomPoly(size);
+ }
+
+ return data;
+ }
+
+ public Object clone() {
+ try {
+ PolygonData clone = (PolygonData)super.clone();
+ clone.color = new Color(color.getRed(), color.getGreen(), color.getBlue());
+ clone.polygon = new Polygon(polygon.xpoints, polygon.ypoints, polygon.npoints);
+
+ return clone;
+ } catch (CloneNotSupportedException cnse) {
+ return randomPoly(new Dimension(100, 100));
+ }
+ }
+
+ public static ImprovementType improveRandomly(PolygonData[] data, Dimension size) {
+ Random r = new Random();
+ int idx = r.nextInt(data.length);
+ PolygonData pd = data[idx] = (PolygonData)data[idx].clone();
+
+ ImprovementType type = ImprovementType.getRandomImprovement();
+ switch (type) {
+ case AddPoint: {
+ if (pd.polygon.npoints <= MAX_POINTS) {
+ pd.polygon.addPoint(0, 0);
+ int insPos = r.nextInt(pd.polygon.npoints);
+ int x = r.nextInt(size.width);
+ int y = r.nextInt(size.height);
+
+ System.arraycopy(pd.polygon.xpoints, insPos, pd.polygon.xpoints, insPos + 1, pd.polygon.npoints - insPos - 1);
+ pd.polygon.xpoints[insPos] = x;
+ System.arraycopy(pd.polygon.ypoints, insPos, pd.polygon.ypoints, insPos + 1, pd.polygon.npoints - insPos - 1);
+ pd.polygon.ypoints[insPos] = y;
+ } else {
+ type = ImprovementType.CompleteChange;
+ PolygonData sd = PolygonData.randomPoly(size);
+ pd.polygon = sd.polygon;
+ pd.color = sd.color;
+ pd.alpha = sd.alpha;
+ }
+ }
+ break;
+
+ case RemovePoint:
+ if (pd.polygon.npoints > 3) {
+ int delPos = r.nextInt(pd.polygon.npoints);
+
+ System.arraycopy(pd.polygon.xpoints, delPos+1, pd.polygon.xpoints, delPos, pd.polygon.npoints - delPos - 1);
+ System.arraycopy(pd.polygon.ypoints, delPos+1, pd.polygon.ypoints, delPos, pd.polygon.npoints - delPos - 1);
+ pd.polygon.npoints--;
+ } else {
+ type = ImprovementType.CompleteChange;
+ PolygonData sd = PolygonData.randomPoly(size);
+ pd.polygon = sd.polygon;
+ pd.color = sd.color;
+ pd.alpha = sd.alpha;
+ }
+ break;
+
+ case MovePoint:
+ int movePos = r.nextInt(pd.polygon.npoints);
+ pd.polygon.xpoints[movePos] = r.nextInt(size.width);
+ pd.polygon.ypoints[movePos] = r.nextInt(size.height);
+ break;
+
+ case ReorderPoly:
+ System.arraycopy(data, idx+1, data, idx, NUM_POLYS - idx - 1);
+ idx = r.nextInt(NUM_POLYS);
+ System.arraycopy(data, idx, data, idx+1, NUM_POLYS - idx - 1);
+ data[idx] = pd;
+
+ break;
+
+ case ShrinkPoly: {
+ double midX = pd.polygon.xpoints[0];
+ double midY = pd.polygon.ypoints[0];
+ for (int i = 1; i < pd.polygon.npoints; i++) {
+ midX += pd.polygon.xpoints[i];
+ midY += pd.polygon.ypoints[i];
+ }
+ midX /= pd.polygon.npoints;
+ midY /= pd.polygon.npoints;
+
+ int shrinkFactor = r.nextInt(5);
+ for (int i = 0; i < pd.polygon.npoints; i++) {
+ pd.polygon.xpoints[i] += (pd.polygon.xpoints[i] < midX) ? shrinkFactor : -shrinkFactor;
+ pd.polygon.ypoints[i] += (pd.polygon.ypoints[i] < midY) ? shrinkFactor : -shrinkFactor;
+ }
+ }
+ break;
+
+ case EnlargePoly: {
+ double midX = pd.polygon.xpoints[0];
+ double midY = pd.polygon.ypoints[0];
+ for (int i = 1; i < pd.polygon.npoints; i++) {
+ midX += pd.polygon.xpoints[i];
+ midY += pd.polygon.ypoints[i];
+ }
+ midX /= pd.polygon.npoints;
+ midY /= pd.polygon.npoints;
+
+ int expandFactor = r.nextInt(5);
+ for (int i = 0; i < pd.polygon.npoints; i++) {
+ pd.polygon.xpoints[i] += (pd.polygon.xpoints[i] < midX) ? -expandFactor : expandFactor;
+ pd.polygon.ypoints[i] += (pd.polygon.ypoints[i] < midY) ? -expandFactor : expandFactor;
+ pd.polygon.xpoints[i] = clipToRange(0, size.width, pd.polygon.xpoints[i]);
+ pd.polygon.ypoints[i] = clipToRange(0, size.height, pd.polygon.ypoints[i]);
+ }
+ }
+ break;
+
+ case ChangeColor:
+ int comp = r.nextInt(3);
+ switch (comp) {
+ case 0: {
+ int newColor = pd.color.getRed() + (r.nextInt(10) - 5);
+ newColor = clipToRange(0, 255, newColor);
+ pd.color = new Color(newColor, pd.color.getGreen(), pd.color.getBlue());
+ }
+ break;
+
+ case 1: {
+ int newColor = pd.color.getGreen() + (r.nextInt(10) - 5);
+ newColor = clipToRange(0, 255, newColor);
+ pd.color = new Color(pd.color.getRed(), newColor, pd.color.getBlue());
+ }
+ break;
+
+ case 2: {
+ int newColor = pd.color.getBlue() + (r.nextInt(10) - 5);
+ newColor = clipToRange(0, 255, newColor);
+ pd.color = new Color(pd.color.getRed(), pd.color.getGreen(), r.nextInt(255));
+ }
+ break;
+ }
+ break;
+
+ case ChangeAlpha:
+ pd.alpha = r.nextFloat();
+ break;
+
+ case CompleteChange:
+ PolygonData sd = PolygonData.randomPoly(size);
+ pd.polygon = sd.polygon;
+ pd.color = sd.color;
+ pd.alpha = sd.alpha;
+ break;
+ }
+
+ return type;
+ }
+
+ public void draw(Graphics2D g) {
+ g.setColor(color);
+ g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
+ g.fillPolygon(polygon);
+ }
+
+ private static int clipToRange(int min, int max, int value) {
+ if (value < min)
+ return min;
+ else if (value > max)
+ return max;
+ return value;
+ }
+}
\ No newline at end of file
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java 2009-11-23 15:16:33 UTC (rev 3)
@@ -0,0 +1,84 @@
+package com.mebigfatguy.polycasso;
+
+import java.awt.Image;
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.swing.ImageIcon;
+
+import org.apache.commons.io.IOUtils;
+
+public class RandomImageFinder {
+
+ private static final String ROOTURL = "http://search.lycos.com/";
+ private static final String URL = ROOTURL + "?tab=multi&loc=searchbox&sortMode=&safeSearch=&cat=images&query={0}&x=0&y=0";
+ private static final Pattern IMAGE_HTML_PATTERN = Pattern.compile("<div\\s+class=\"imageResult\"><a\\s+href=\"([^\"]*)\"");
+ private static final Pattern IMAGE_PATTERN = Pattern.compile("image_url=([^&]*)&");
+ private static final int NAMELEN = 3;
+
+ private RandomImageFinder() {
+ }
+
+ public static Image findImage() throws IOException {
+
+ char[] ranName = new char[NAMELEN];
+ Random ran = new Random(System.currentTimeMillis());
+ for (int i = 0; i < NAMELEN; i++) {
+ ranName[i] = (char)('A' + ran.nextInt(26));
+ }
+
+ String html = new String(getUrlData(MessageFormat.format(URL, new String(ranName))), "UTF-8");
+
+ List<String> images = new ArrayList<String>();
+
+ Matcher m = IMAGE_HTML_PATTERN.matcher(html);
+ while (m.find()) {
+ images.add(m.group(1));
+ }
+
+ html = new String(getUrlData(ROOTURL + images.get((int)(Math.random() * images.size()))), "UTF-8");
+
+ m = IMAGE_PATTERN.matcher(html);
+ if (m.find()) {
+ String url = URLDecoder.decode(m.group(1), "UTF-8");
+
+ return new ImageIcon(getUrlData(url)).getImage();
+ }
+
+ throw new IOException("Failed to find image");
+ }
+
+ private static byte[] getUrlData(String url) throws IOException {
+ HttpURLConnection con = null;
+ InputStream is = null;
+
+ try {
+ URL u = new URL(url);
+ con = (HttpURLConnection)u.openConnection();
+ con.addRequestProperty("User-Agent", "Mozilla/4.76");
+ con.setDoInput(true);
+ con.setDoOutput(false);
+ con.connect();
+
+ is = new BufferedInputStream(con.getInputStream());
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ IOUtils.copy(is, baos);
+ return baos.toByteArray();
+ } finally {
+ IOUtils.closeQuietly(is);
+ if (con != null)
+ con.disconnect();
+ }
+ }
+}
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties 2009-11-23 15:16:33 UTC (rev 3)
@@ -0,0 +1,4 @@
+pc.title = Polycasso
+pc.file = File
+pc.paintimage = Start Generating Image
+pc.quit = Quit
\ No newline at end of file
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties
___________________________________________________________________
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...> - 2010-01-01 01:04:02
|
Revision: 216
http://polycasso.svn.sourceforge.net/polycasso/?rev=216&view=rev
Author: dbrosius
Date: 2010-01-01 01:03:50 +0000 (Fri, 01 Jan 2010)
Log Message:
-----------
(c) 2010
Modified Paths:
--------------
trunk/polycasso/build.xml
trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Feedback.java
trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java
trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageSizer.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/IntegerDocument.java
trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.template
trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PainterPanel.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java
trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java
trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Saver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java
trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java
trunk/polycasso/src/com/mebigfatguy/polycasso/URLFetcher.java
trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties
trunk/polycasso/src/com/mebigfatguy/polycasso/resource_de.properties
Modified: trunk/polycasso/build.xml
===================================================================
--- trunk/polycasso/build.xml 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/build.xml 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,8 +1,8 @@
<!--
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -123,7 +123,7 @@
destdir="${javadoc.dir}"
windowtitle="polycasso api">
<doctitle><![CDATA[<h1>polycasso javadoc</h1>]]></doctitle>
- <bottom><![CDATA[<i>Copyright © 2009 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom>
+ <bottom><![CDATA[<i>Copyright © 2009-2010 MeBigFatGuy.com. All Rights Reserved.</i>]]></bottom>
</javadoc>
</target>
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Feedback.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Feedback.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Feedback.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageSizer.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageSizer.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageSizer.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/IntegerDocument.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/IntegerDocument.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/IntegerDocument.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.template
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.template 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.template 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PainterPanel.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PainterPanel.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PainterPanel.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Saver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Saver.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Saver.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/URLFetcher.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/URLFetcher.java 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/URLFetcher.java 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009 MeBigFatGuy.com
- * Copyright 2009 Dave Brosius
+ * Copyright 2010 MeBigFatGuy.com
+ * Copyright 2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
#/*
# * polycasso - Cubism Artwork generator
-# * Copyright 2009 MeBigFatGuy.com
-# * Copyright 2009 Dave Brosius
+# * Copyright 2010 MeBigFatGuy.com
+# * Copyright 2010 Dave Brosius
# * Inspired by work by Roger Alsing
# *
# * Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/resource_de.properties
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/resource_de.properties 2009-12-31 07:54:11 UTC (rev 215)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/resource_de.properties 2010-01-01 01:03:50 UTC (rev 216)
@@ -1,7 +1,7 @@
#/*
# * polycasso - Cubism Artwork generator
-# * Copyright 2009 MeBigFatGuy.com
-# * Copyright 2009 Dave Brosius
+# * Copyright 2010 MeBigFatGuy.com
+# * Copyright 2010 Dave Brosius
# * Inspired by work by Roger Alsing
# *
# * Licensed under the Apache License, Version 2.0 (the "License");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2010-01-01 01:19:38
|
Revision: 217
http://polycasso.svn.sourceforge.net/polycasso/?rev=217&view=rev
Author: dbrosius
Date: 2010-01-01 01:19:31 +0000 (Fri, 01 Jan 2010)
Log Message:
-----------
(c) 2010
Modified Paths:
--------------
trunk/polycasso/build.xml
trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Feedback.java
trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java
trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageSizer.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/IntegerDocument.java
trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PainterPanel.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java
trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java
trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Saver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java
trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java
trunk/polycasso/src/com/mebigfatguy/polycasso/URLFetcher.java
trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties
trunk/polycasso/src/com/mebigfatguy/polycasso/resource_de.properties
Modified: trunk/polycasso/build.xml
===================================================================
--- trunk/polycasso/build.xml 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/build.xml 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,8 +1,8 @@
<!--
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Feedback.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Feedback.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Feedback.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageSizer.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageSizer.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageSizer.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/IntegerDocument.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/IntegerDocument.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/IntegerDocument.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PainterPanel.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PainterPanel.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PainterPanel.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Saver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Saver.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Saver.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/URLFetcher.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/URLFetcher.java 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/URLFetcher.java 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2010 MeBigFatGuy.com
- * Copyright 2010 Dave Brosius
+ * Copyright 2009-2010 MeBigFatGuy.com
+ * Copyright 2009-2010 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
#/*
# * polycasso - Cubism Artwork generator
-# * Copyright 2010 MeBigFatGuy.com
-# * Copyright 2010 Dave Brosius
+# * Copyright 2009-2010 MeBigFatGuy.com
+# * Copyright 2009-2010 Dave Brosius
# * Inspired by work by Roger Alsing
# *
# * Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/resource_de.properties
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/resource_de.properties 2010-01-01 01:03:50 UTC (rev 216)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/resource_de.properties 2010-01-01 01:19:31 UTC (rev 217)
@@ -1,7 +1,7 @@
#/*
# * polycasso - Cubism Artwork generator
-# * Copyright 2010 MeBigFatGuy.com
-# * Copyright 2010 Dave Brosius
+# * Copyright 2009-2010 MeBigFatGuy.com
+# * Copyright 2009-2010 Dave Brosius
# * Inspired by work by Roger Alsing
# *
# * Licensed under the Apache License, Version 2.0 (the "License");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2011-07-26 02:09:04
|
Revision: 236
http://polycasso.svn.sourceforge.net/polycasso/?rev=236&view=rev
Author: dbrosius
Date: 2011-07-26 02:08:58 +0000 (Tue, 26 Jul 2011)
Log Message:
-----------
turn DEBUG off
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java
Added Paths:
-----------
trunk/polycasso/etc/polycasso.png
Added: trunk/polycasso/etc/polycasso.png
===================================================================
(Binary files differ)
Property changes on: trunk/polycasso/etc/polycasso.png
___________________________________________________________________
Added: svn:mime-type
+ image/png
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java 2011-07-25 07:08:03 UTC (rev 235)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java 2011-07-26 02:08:58 UTC (rev 236)
@@ -28,7 +28,7 @@
/**
* enable some console debugging, and show the target image
*/
- public static final boolean DEBUG = true;
+ public static final boolean DEBUG = false;
/**
* the main entry point to the web start app
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dbr...@us...> - 2011-07-28 00:07:50
|
Revision: 238
http://polycasso.svn.sourceforge.net/polycasso/?rev=238&view=rev
Author: dbrosius
Date: 2011-07-28 00:07:42 +0000 (Thu, 28 Jul 2011)
Log Message:
-----------
update from git
Modified Paths:
--------------
trunk/polycasso/build.xml
trunk/polycasso/lib/forms-1.2.1.jar
trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.java
trunk/polycasso/src/com/mebigfatguy/polycasso/DoubleDocument.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Feedback.java
trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java
trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java
trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationHandler.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageSizer.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementResult.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/IntegerDocument.java
trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PainterPanel.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java
trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java
trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Saver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java
trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java
trunk/polycasso/src/com/mebigfatguy/polycasso/URLFetcher.java
Added Paths:
-----------
trunk/polycasso/htdocs/girl.svg
trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultImageGenerator.java
Modified: trunk/polycasso/build.xml
===================================================================
--- trunk/polycasso/build.xml 2011-07-26 02:29:14 UTC (rev 237)
+++ trunk/polycasso/build.xml 2011-07-28 00:07:42 UTC (rev 238)
@@ -1,8 +1,8 @@
<!--
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2010 MeBigFatGuy.com
- * Copyright 2009-2010 Dave Brosius
+ * Copyright 2009-2011 MeBigFatGuy.com
+ * Copyright 2009-2011 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,6 +35,9 @@
<property name="javac.deprecation" value="on"/>
<property name="javac.debug" value="on"/>
+ <property name="forms.version" value="1.2.1"/>
+ <property name="commons-io.version" value="1.4"/>
+
<property name="polycasso.version" value="1.5.0"/>
<target name="clean" description="removes all generated collateral">
@@ -55,12 +58,35 @@
<mkdir dir="${classes.dir}"/>
<mkdir dir="${javadoc.dir}"/>
<path id="polycasso.classpath">
- <pathelement location="${lib.dir}/commons-io-1.4.jar"/>
- <pathelement location="${lib.dir}/forms-1.2.1.jar"/>
+ <pathelement location="${lib.dir}/commons-io-${commons-io.version}.jar"/>
+ <pathelement location="${lib.dir}/forms-${forms.version}.jar"/>
</path>
</target>
+
+
+ <property name="forms_url" value="http://repo1.maven.org/maven2/com/jgoodies/forms/${forms.version}/forms-${forms.version}.jar"/>
+ <property name="commonsio_url" value="http://repo1.maven.org/maven2/commons-io/commons-io/${commons-io.version}/commons-io-${commons-io.version}.jar"/>
+
+ <target name="forms_check">
+ <available file="${basedir}/lib/forms-${forms.version}.jar" property="forms_exists"/>
+ </target>
+
+ <target name="commonsio_check">
+ <available file="${basedir}/lib/commons-io-${commons-io.version}.jar" property="commonsio.exists"/>
+ </target>
+
+ <target name="install_forms" depends="forms_check" unless="forms_exists" description="installs forms.jar into lib">
+ <get src="${forms_url}" dest="${basedir}/lib/forms-${forms.version}.jar" verbose="true" ignoreerrors="true"/>
+ </target>
+
+ <target name="install_commonsio" depends="commonsio_check" unless="commonsio.exists" description="installs commons-io.jar into lib">
+ <get src="${commonsio_url}" dest="${basedir}/lib/commons-io-${commons-io.version}.jar" verbose="true" ignoreerrors="true"/>
+ </target>
+
+ <target name="pull" depends="install_forms, install_commonsio" description="pulls in the 3rd party jars">
+ </target>
- <target name="compile" depends="-init" description="compiles java files">
+ <target name="compile" depends="-init, pull" description="compiles java files">
<javac srcdir="${src.dir}"
destdir="${classes.dir}"
source="${javac.source}"
@@ -107,7 +133,7 @@
<manifest>
<attribute name="polycasso-version" value="${polycasso.version}"/>
<attribute name="Main-Class" value="com.mebigfatguy.polycasso.Polycasso"/>
- <attribute name="Class-Path" value="commons-io-1.4.jar forms-1.2.1.jar"/>
+ <attribute name="Class-Path" value="commons-io-${commons-io.version}.jar forms-${forms.version}.jar"/>
</manifest>
</jar>
</target>
@@ -174,7 +200,7 @@
<target name="binzip" depends="build" description="zips up all jars">
<zip destfile="${basedir}/polycasso-bin-${polycasso.version}.zip"
basedir="${jnlp.dir}"
- includes="polycasso-${polycasso.version}.jar commons-io-1.4.jar forms-1.2.1.jar"/>
+ includes="polycasso-${polycasso.version}.jar commons-io-${commons-io.version}.jar forms-${forms.version}.jar"/>
</target>
<target name="release" depends="build, jnlp, binzip, srczip, javadoc" description="prepares everything for a release"/>
Added: trunk/polycasso/htdocs/girl.svg
===================================================================
(Binary files differ)
Property changes on: trunk/polycasso/htdocs/girl.svg
___________________________________________________________________
Added: svn:mime-type
+ image/svg
Added: svn:eol-style
+ native
Modified: trunk/polycasso/lib/forms-1.2.1.jar
===================================================================
(Binary files differ)
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.java 2011-07-26 02:29:14 UTC (rev 237)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.java 2011-07-28 00:07:42 UTC (rev 238)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2010 MeBigFatGuy.com
- * Copyright 2009-2010 Dave Brosius
+ * Copyright 2009-2011 MeBigFatGuy.com
+ * Copyright 2009-2011 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultImageGenerator.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultImageGenerator.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultImageGenerator.java 2011-07-28 00:07:42 UTC (rev 238)
@@ -0,0 +1,272 @@
+/*
+ * polycasso - Cubism Artwork generator
+ * Copyright 2009-2011 MeBigFatGuy.com
+ * Copyright 2009-2011 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.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * class that generates test images iteratively looking for the best image that matches a target.
+ * The images are generated from semi-transparent polygons that are improved upon over time.
+ * This class generates multiple images in parallel to keep multicore processors busy.
+ */
+public class DefaultImageGenerator implements ImageGenerator, Runnable {
+ private Set<ImageGeneratedListener> listeners = new HashSet<ImageGeneratedListener>();
+ private Settings settings;
+ private BufferedImage targetImage;
+ private GenerationHandler generationHandler;
+ private Dimension imageSize;
+ private Feedback feedback;
+ private Thread[] t = null;
+ private Object startStopLock = new Object();
+
+ /**
+ * creates an ImageGenerator for the given target image, and size
+ * @param confSettings the configuration settings
+ * @param image the target image
+ * @param size the dimension of the image
+ */
+ public DefaultImageGenerator(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();
+ try {
+ g.drawImage(image, 0, 0, imageSize.width, imageSize.height, Color.WHITE, null);
+ generationHandler = new GenerationHandler(settings, imageSize);
+ feedback = new Feedback(targetImage);
+ } finally {
+ g.dispose();
+ }
+ }
+
+ /**
+ * retrieves the scaled target iamge
+ *
+ * @return the target image
+ */
+ public BufferedImage getTargetImage() {
+ return targetImage;
+ }
+
+ /**
+ * 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.
+ *
+ * @param listener the listener that is interested in events
+ */
+ public void addImageGeneratedListener(ImageGeneratedListener listener) {
+ listeners.add(listener);
+ }
+
+ /**
+ * allows uninterested parties to unregister to receive events when a new best image is
+ * found
+ *
+ * @param listener the listener that is no longer needed
+ */
+ public void removeImageGeneratedListener(ImageGeneratedListener listener) {
+ listeners.remove(listener);
+ }
+
+ /**
+ * informs all listeners that a new best image has been found
+ *
+ * @param image the new best image
+ */
+ public void fireImageGenerated(Image image) {
+ ImageGeneratedEvent event = new ImageGeneratedEvent(this, image);
+ for (ImageGeneratedListener listener : listeners) {
+ listener.imageGenerated(event);
+ }
+ }
+
+ /**
+ * starts up threads to start looking for images that are closest to the target
+ */
+ public void startGenerating() {
+ synchronized(startStopLock) {
+ if (t == null) {
+
+ populateGenerationZeroElite();
+ t = new Thread[Runtime.getRuntime().availableProcessors() + 1];
+ for (int i = 0; i < t.length; i++) {
+ t[i] = new Thread(this);
+ t[i].setName("Improver : " + i);
+ t[i].start();
+ }
+ }
+ }
+ }
+
+ /**
+ * shuts down threads that were looking for images
+ */
+ public void stopGenerating() {
+ synchronized(startStopLock) {
+ if (t != null) {
+ try {
+ for (int i = 0; i < t.length; i++) {
+ t[i].interrupt();
+ }
+ for (int i = 0; i < t.length; i++) {
+ t[i].join();
+ }
+ } catch (InterruptedException ie) {
+ } finally {
+ t = null;
+ }
+ }
+ }
+ }
+
+ /**
+ * 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, generationHandler.getBestMember().data, imageSize));
+ t[0].start();
+ }
+ }
+ }
+
+ /**
+ * retrieves the best set of polygons for drawing the image so far
+ *
+ * @return the best set of polygons
+ */
+ public PolygonData[] getBestData() {
+ return generationHandler.getBestMember().data;
+ }
+ /**
+ * the runnable interface implementation to repeatedly improve upon the image and check to
+ * see if it is closer to the target image. Images are created in batches of settings.numCompetingImages
+ * and the best one (if better than the parent) is selected as the new best.
+ */
+ public void run() {
+ try {
+ BufferedImage image = new BufferedImage(imageSize.width, imageSize.height, BufferedImage.TYPE_4BYTE_ABGR);
+ Graphics2D g2d = (Graphics2D)image.getGraphics();
+ try {
+ Composite srcOpaque = AlphaComposite.getInstance(AlphaComposite.SRC, 1.0f);
+ Improver improver = new Improver(settings, generationHandler, imageSize);
+
+ while (!Thread.interrupted()) {
+ ImprovementType type = improver.improveRandomly();
+
+ List<PolygonData> data = improver.getData();
+ imagePolygonData(g2d, data, srcOpaque);
+
+ long delta = feedback.calculateDelta(image);
+
+ boolean wasSuccessful;
+
+ ImprovementResult result = generationHandler.addPolygonData(delta, data.toArray(new PolygonData[data.size()]));
+ switch (result) {
+ case BEST:
+ fireImageGenerated(image);
+ wasSuccessful = true;
+ image = new BufferedImage(imageSize.width, imageSize.height, BufferedImage.TYPE_4BYTE_ABGR);
+ g2d.dispose();
+ g2d = (Graphics2D)image.getGraphics();
+ break;
+
+ case ELITE:
+ wasSuccessful = true;
+ break;
+
+ default:
+ wasSuccessful = false;
+ }
+
+ improver.typeWasSuccessful(type, wasSuccessful);
+ }
+ } finally {
+ g2d.dispose();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void imagePolygonData(Graphics2D g2d, List<PolygonData> polygonData, Composite srcOpaque) {
+ g2d.setColor(Color.BLACK);
+ g2d.setComposite(srcOpaque);
+ g2d.fillRect(0, 0, imageSize.width, imageSize.height);
+
+ for (PolygonData pd : polygonData) {
+ pd.draw(g2d);
+ }
+ }
+
+ private void populateGenerationZeroElite() {
+ Composite srcOpaque = AlphaComposite.getInstance(AlphaComposite.SRC, 1.0f);
+ for (int i = 0; i < settings.getEliteSize(); i++) {
+ BufferedImage image = new BufferedImage(imageSize.width, imageSize.height, BufferedImage.TYPE_4BYTE_ABGR);
+ List<PolygonData> polygons = new ArrayList<PolygonData>();
+ PolygonData pd = PolygonData.randomPoly(imageSize, settings.getMaxPoints());
+ polygons.add(pd);
+ Graphics2D g2d = (Graphics2D)image.getGraphics();
+ try {
+ imagePolygonData(g2d, polygons, srcOpaque);
+ long delta = feedback.calculateDelta(image);
+ generationHandler.addPolygonData(delta, polygons.toArray(new PolygonData[polygons.size()]));
+ } finally {
+ g2d.dispose();
+ }
+ }
+ }
+
+ 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));
+ }
+}
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultImageGenerator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/DoubleDocument.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/DoubleDocument.java 2011-07-26 02:29:14 UTC (rev 237)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/DoubleDocument.java 2011-07-28 00:07:42 UTC (rev 238)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2010 MeBigFatGuy.com
- * Copyright 2009-2010 Dave Brosius
+ * Copyright 2009-2011 MeBigFatGuy.com
+ * Copyright 2009-2011 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Feedback.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Feedback.java 2011-07-26 02:29:14 UTC (rev 237)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Feedback.java 2011-07-28 00:07:42 UTC (rev 238)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2010 MeBigFatGuy.com
- * Copyright 2009-2010 Dave Brosius
+ * Copyright 2009-2011 MeBigFatGuy.com
+ * Copyright 2009-2011 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -50,28 +50,28 @@
* @param testImage the image to score
* @return a value that represents its closeness to ideal
*/
- public double calculateDelta(BufferedImage testImage) {
+ public long calculateDelta(BufferedImage testImage) {
WritableRaster raster = testImage.getRaster();
DataBufferByte dbb = (DataBufferByte)raster.getDataBuffer();
byte[] testBuffer = dbb.getData();
- double error = 0.0;
+ long error = 0L;
//index 0 is alpha, start at 1 (blue)
for (int i = 1; i < size; i++) {
int blue1 = targetBuffer[i] & 0x0FF;
int blue2 = testBuffer[i++] & 0x0FF;
- double blueError = blue1 - blue2;
+ long blueError = blue1 - blue2;
blueError *= blueError;
int green1 = targetBuffer[i] & 0x0FF;
int green2 = testBuffer[i++] & 0x0FF;
- double greenError = green1 - green2;
+ long greenError = green1 - green2;
greenError *= greenError;
int red1 = targetBuffer[i] & 0x0FF;
int red2 = testBuffer[i++] & 0x0FF;
- double redError = red1 - red2;
+ long redError = red1 - red2;
redError *= redError;
error += redError + greenError + blueError;
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java 2011-07-26 02:29:14 UTC (rev 237)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java 2011-07-28 00:07:42 UTC (rev 238)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2010 MeBigFatGuy.com
- * Copyright 2009-2010 Dave Brosius
+ * Copyright 2009-2011 MeBigFatGuy.com
+ * Copyright 2009-2011 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java 2011-07-26 02:29:14 UTC (rev 237)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java 2011-07-28 00:07:42 UTC (rev 238)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2010 MeBigFatGuy.com
- * Copyright 2009-2010 Dave Brosius
+ * Copyright 2009-2011 MeBigFatGuy.com
+ * Copyright 2009-2011 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationHandler.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationHandler.java 2011-07-26 02:29:14 UTC (rev 237)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationHandler.java 2011-07-28 00:07:42 UTC (rev 238)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2010 MeBigFatGuy.com
- * Copyright 2009-2010 Dave Brosius
+ * Copyright 2009-2011 MeBigFatGuy.com
+ * Copyright 2009-2011 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,10 +35,10 @@
*/
public static class Member implements Comparable<Member> {
- double score;
+ long score;
PolygonData[] data;
- Member(double polyScore, PolygonData[] polyData) {
+ Member(long polyScore, PolygonData[] polyData) {
score = polyScore;
data = polyData;
}
@@ -49,7 +49,8 @@
return 1;
else if (score < o.score)
return -1;
- return 0;
+
+ return data.length - o.data.length;
}
@Override
@@ -91,8 +92,8 @@
random = new Random();
generationNumber = 0;
settings = confSettings;
- bestMember = new Member(Double.MAX_VALUE, new PolygonData[0]);
- eliteCutOff = Double.MAX_VALUE;
+ bestMember = new Member(Long.MAX_VALUE, new PolygonData[0]);
+ eliteCutOff = Long.MAX_VALUE;
generation = new ArrayList<Member>(settings.getGenerationSize() + 10);
annealingValue = settings.getStartTemperature() * settings.getStartTemperature() * imageSize.height * imageSize.width;
generationBests = 0;
@@ -108,7 +109,7 @@
*
* @return whether this is the best polygon set so far
*/
- public ImprovementResult addPolygonData(double score, PolygonData[] polygonData) {
+ public ImprovementResult addPolygonData(long score, PolygonData[] polygonData) {
synchronized(generation) {
Member newMember = new Member(score, polygonData);
generation.add(newMember);
@@ -181,7 +182,7 @@
int candidateIndex = random.nextInt(sz - eliteSize) + eliteSize;
Member candidate = generation.get(candidateIndex);
Member elite = generation.get(i);
- double delta = candidate.score - elite.score;
+ long delta = candidate.score - elite.score;
if (delta < annealingValue) {
nextGeneration.set(i, candidate);
annealingReplacements++;
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java 2011-07-26 02:29:14 UTC (rev 237)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java 2011-07-28 00:07:42 UTC (rev 238)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2010 MeBigFatGuy.com
- * Copyright 2009-2010 Dave Brosius
+ * Copyright 2009-2011 MeBigFatGuy.com
+ * Copyright 2009-2011 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -45,7 +45,7 @@
*
* @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 bestData the best approximation the program reached
* @param size the image size
*/
@@ -56,13 +56,17 @@
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);
+ try {
+ 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);
+ }
+ } finally {
+ g2d.dispose();
}
}
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java 2011-07-26 02:29:14 UTC (rev 237)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java 2011-07-28 00:07:42 UTC (rev 238)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2010 MeBigFatGuy.com
- * Copyright 2009-2010 Dave Brosius
+ * Copyright 2009-2011 MeBigFatGuy.com
+ * Copyright 2009-2011 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java 2011-07-26 02:29:14 UTC (rev 237)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java 2011-07-28 00:07:42 UTC (rev 238)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2010 MeBigFatGuy.com
- * Copyright 2009-2010 Dave Brosius
+ * Copyright 2009-2011 MeBigFatGuy.com
+ * Copyright 2009-2011 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2011-07-26 02:29:14 UTC (rev 237)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2011-07-28 00:07:42 UTC (rev 238)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2010 MeBigFatGuy.com
- * Copyright 2009-2010 Dave Brosius
+ * Copyright 2009-2011 MeBigFatGuy.com
+ * Copyright 2009-2011 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,241 +18,31 @@
*/
package com.mebigfatguy.polycasso;
-import java.awt.AlphaComposite;
-import java.awt.Color;
-import java.awt.Composite;
import java.awt.Dimension;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
/**
- * class that generates test images iteratively looking for the best image that matches a target.
- * The images are generated from semi-transparent polygons that are improved upon over time.
- * This class generates multiple images in parallel to keep multicore processors busy.
+ * interface that generates test images iteratively looking for the best image that matches a target.
*/
-public class ImageGenerator implements Runnable {
- private Set<ImageGeneratedListener> listeners = new HashSet<ImageGeneratedListener>();
- private Settings settings;
- private BufferedImage targetImage;
- private GenerationHandler generationHandler;
- private Dimension imageSize;
- private Feedback feedback;
- private Thread[] t = null;
- private Object startStopLock = new Object();
-
- /**
- * creates an ImageGenerator for the given target image, and size
- * @param confSettings the configuration settings
- * @param image the target image
- * @param size the dimension of the image
- */
- 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, imageSize.width, imageSize.height, Color.WHITE, null);
- generationHandler = new GenerationHandler(settings, imageSize);
- feedback = new Feedback(targetImage);
- }
-
- /**
- * retrieves the scaled target iamge
- *
- * @return the target image
- */
- public BufferedImage getTargetImage() {
- return targetImage;
- }
-
- /**
- * 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.
- *
- * @param listener the listener that is interested in events
- */
- public void addImageGeneratedListener(ImageGeneratedListener listener) {
- listeners.add(listener);
- }
-
- /**
- * allows uninterested parties to unregister to receive events when a new best image is
- * found
- *
- * @param listener the listener that is no longer needed
- */
- public void removeImageGeneratedListener(ImageGeneratedListener listener) {
- listeners.remove(listener);
- }
-
- /**
- * informs all listeners that a new best image has been found
- *
- * @param image the new best image
- */
- public void fireImageGenerated(Image image) {
- ImageGeneratedEvent event = new ImageGeneratedEvent(this, image);
- for (ImageGeneratedListener listener : listeners) {
- listener.imageGenerated(event);
- }
- }
-
- /**
- * starts up threads to start looking for images that are closes...
[truncated message content] |
|
From: <dbr...@us...> - 2011-08-03 06:00:45
|
Revision: 243
http://polycasso.svn.sourceforge.net/polycasso/?rev=243&view=rev
Author: dbrosius
Date: 2011-08-03 06:00:34 +0000 (Wed, 03 Aug 2011)
Log Message:
-----------
add support for proxies
Modified Paths:
--------------
trunk/polycasso/.classpath
trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultImageGenerator.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Feedback.java
trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationHandler.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementResult.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java
trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java
trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java
trunk/polycasso/src/com/mebigfatguy/polycasso/URLFetcher.java
trunk/polycasso/src/com/mebigfatguy/polycasso/resource.properties
Added Paths:
-----------
trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultFeedback.java
trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultScore.java
trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationMember.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ProxyDialog.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Score.java
trunk/polycasso/src/com/mebigfatguy/polycasso/SwingUtils.java
Modified: trunk/polycasso/.classpath
===================================================================
--- trunk/polycasso/.classpath 2011-07-29 03:36:02 UTC (rev 242)
+++ trunk/polycasso/.classpath 2011-08-03 06:00:34 UTC (rev 243)
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/commons-io-1.4.jar"/>
<classpathentry kind="lib" path="lib/forms-1.2.1.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="classes"/>
</classpath>
Copied: trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultFeedback.java (from rev 238, trunk/polycasso/src/com/mebigfatguy/polycasso/Feedback.java)
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultFeedback.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultFeedback.java 2011-08-03 06:00:34 UTC (rev 243)
@@ -0,0 +1,140 @@
+/*
+ * polycasso - Cubism Artwork generator
+ * Copyright 2009-2011 MeBigFatGuy.com
+ * Copyright 2009-2011 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.Rectangle;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBufferByte;
+import java.awt.image.WritableRaster;
+
+/**
+ * an immutable class for processing a test image against target image for closeness.
+ */
+public class DefaultFeedback implements Feedback {
+
+ private byte[] targetBuffer;
+ private int width, height;
+
+ /**
+ * creates a feedback object with a given targetImage. Caches the image bytes in
+ * member variables.
+ */
+ public DefaultFeedback() {
+ }
+
+ /**
+ * caches information about the target image
+ *
+ * @param targetImage the target image that will be the judge of test images
+ */
+ @Override
+ public void setTargetImage(BufferedImage targetImage) {
+ WritableRaster raster = targetImage.getRaster();
+ width = targetImage.getWidth();
+ height = targetImage.getHeight();
+ DataBufferByte dbb = (DataBufferByte)raster.getDataBuffer();
+ targetBuffer = dbb.getData();
+ }
+
+ /**
+ * returns a score of how close the test image is to the target
+ * which is the square of the error to the target image
+ *
+ * @param testImage the image to score
+ * @param previousScore the score of the generated image from which this image was created
+ * @param changedArea the area of changed between the parent generated image and this one
+ *
+ * @return a score that represents its closeness to ideal
+ */
+ @Override
+ public Score calculateScore(BufferedImage testImage, Score previousScore, Rectangle changedArea) {
+
+ DefaultScore score = (previousScore != null) ? (DefaultScore)previousScore.clone() : new DefaultScore();
+
+ WritableRaster raster = testImage.getRaster();
+ DataBufferByte dbb = (DataBufferByte)raster.getDataBuffer();
+ byte[] testBuffer = dbb.getData();
+
+ boolean needAutoRecalc = (previousScore == null) || (changedArea == null);
+ score.overallScore = 0L;
+
+ for (int y = 0; y < DefaultScore.NUM_DIVISIONS; y++) {
+ int gridHeight = (height / DefaultScore.NUM_DIVISIONS);
+ int gridTop = y * gridHeight;
+ int gridBottom;
+ if (y < (DefaultScore.NUM_DIVISIONS - 1)) {
+ gridBottom = gridTop + gridHeight;
+ } else {
+ gridBottom = height;
+ }
+
+ if (needAutoRecalc || ((changedArea.y <= gridBottom) && ((changedArea.y + changedArea.height) >= gridTop))) {
+ for (int x = 0; x < DefaultScore.NUM_DIVISIONS; x++) {
+ int gridWidth = (width / DefaultScore.NUM_DIVISIONS);
+ int gridLeft = x * gridWidth;
+ int gridRight;
+ if (x < (DefaultScore.NUM_DIVISIONS - 1)) {
+ gridRight = gridLeft + gridWidth;
+ } else {
+ gridRight = width;
+ }
+
+ if (needAutoRecalc || ((changedArea.x <= gridRight) && ((changedArea.x + changedArea.width) >= gridLeft))) {
+
+ long gridError = 0L;
+ for (int gy = gridTop; gy < gridBottom; gy++) {
+ int pixelStart = (gy * width * 4) + (gridLeft * 4);
+ int pixelEnd = pixelStart + (gridRight - gridLeft) * 4;
+
+ //index 0 is alpha, start at 1 (blue)
+ for (int i = pixelStart + 1; i < pixelEnd; i++) {
+ int blue1 = targetBuffer[i] & 0x0FF;
+ int blue2 = testBuffer[i++] & 0x0FF;
+ long blueError = blue1 - blue2;
+ blueError *= blueError;
+
+ int green1 = targetBuffer[i] & 0x0FF;
+ int green2 = testBuffer[i++] & 0x0FF;
+ long greenError = green1 - green2;
+ greenError *= greenError;
+
+ int red1 = targetBuffer[i] & 0x0FF;
+ int red2 = testBuffer[i++] & 0x0FF;
+ long redError = red1 - red2;
+ redError *= redError;
+
+ gridError += redError + greenError + blueError;
+ }
+ }
+ score.gridScores[x][y] = gridError;
+ score.overallScore += gridError;
+ } else {
+ score.overallScore += score.gridScores[x][y];
+ }
+ }
+ } else {
+ for (int x = 0; x < DefaultScore.NUM_DIVISIONS; x++) {
+ score.overallScore += score.gridScores[x][y];
+ }
+ }
+ }
+
+ return score;
+ }
+}
\ No newline at end of file
Property changes on: trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultFeedback.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:mimetype
+ text/plain
Added: svn:eol-style
+ native
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultImageGenerator.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultImageGenerator.java 2011-07-29 03:36:02 UTC (rev 242)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultImageGenerator.java 2011-08-03 06:00:34 UTC (rev 243)
@@ -4,17 +4,17 @@
* Copyright 2009-2011 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
+ * 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.
+ * 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;
@@ -33,240 +33,253 @@
/**
* class that generates test images iteratively looking for the best image that matches a target.
- * The images are generated from semi-transparent polygons that are improved upon over time.
+ * The images are generated from semi-transparent polygons that are improved upon over time.
* This class generates multiple images in parallel to keep multicore processors busy.
*/
public class DefaultImageGenerator implements ImageGenerator, Runnable {
- private Set<ImageGeneratedListener> listeners = new HashSet<ImageGeneratedListener>();
- private Settings settings;
- private BufferedImage targetImage;
- private GenerationHandler generationHandler;
- private Dimension imageSize;
- private Feedback feedback;
- private Thread[] t = null;
- private Object startStopLock = new Object();
-
- /**
- * creates an ImageGenerator for the given target image, and size
- * @param confSettings the configuration settings
- * @param image the target image
- * @param size the dimension of the image
- */
- public DefaultImageGenerator(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();
- try {
- g.drawImage(image, 0, 0, imageSize.width, imageSize.height, Color.WHITE, null);
- generationHandler = new GenerationHandler(settings, imageSize);
- feedback = new Feedback(targetImage);
- } finally {
- g.dispose();
- }
- }
-
- /**
- * retrieves the scaled target iamge
- *
- * @return the target image
- */
- public BufferedImage getTargetImage() {
- return targetImage;
- }
-
- /**
- * 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.
- *
- * @param listener the listener that is interested in events
- */
- public void addImageGeneratedListener(ImageGeneratedListener listener) {
- listeners.add(listener);
- }
-
- /**
- * allows uninterested parties to unregister to receive events when a new best image is
- * found
- *
- * @param listener the listener that is no longer needed
- */
- public void removeImageGeneratedListener(ImageGeneratedListener listener) {
- listeners.remove(listener);
- }
-
- /**
- * informs all listeners that a new best image has been found
- *
- * @param image the new best image
- */
- public void fireImageGenerated(Image image) {
- ImageGeneratedEvent event = new ImageGeneratedEvent(this, image);
- for (ImageGeneratedListener listener : listeners) {
- listener.imageGenerated(event);
- }
- }
-
- /**
- * starts up threads to start looking for images that are closest to the target
- */
- public void startGenerating() {
- synchronized(startStopLock) {
- if (t == null) {
-
- populateGenerationZeroElite();
- t = new Thread[Runtime.getRuntime().availableProcessors() + 1];
- for (int i = 0; i < t.length; i++) {
- t[i] = new Thread(this);
- t[i].setName("Improver : " + i);
- t[i].start();
- }
- }
- }
- }
-
- /**
- * shuts down threads that were looking for images
- */
- public void stopGenerating() {
- synchronized(startStopLock) {
- if (t != null) {
- try {
- for (int i = 0; i < t.length; i++) {
- t[i].interrupt();
- }
- for (int i = 0; i < t.length; i++) {
- t[i].join();
- }
- } catch (InterruptedException ie) {
- } finally {
- t = null;
- }
- }
- }
- }
-
- /**
- * 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, generationHandler.getBestMember().data, imageSize));
- t[0].start();
- }
- }
- }
-
- /**
- * retrieves the best set of polygons for drawing the image so far
- *
- * @return the best set of polygons
- */
- public PolygonData[] getBestData() {
- return generationHandler.getBestMember().data;
- }
- /**
- * the runnable interface implementation to repeatedly improve upon the image and check to
- * see if it is closer to the target image. Images are created in batches of settings.numCompetingImages
- * and the best one (if better than the parent) is selected as the new best.
- */
- public void run() {
- try {
- BufferedImage image = new BufferedImage(imageSize.width, imageSize.height, BufferedImage.TYPE_4BYTE_ABGR);
- Graphics2D g2d = (Graphics2D)image.getGraphics();
- try {
- Composite srcOpaque = AlphaComposite.getInstance(AlphaComposite.SRC, 1.0f);
- Improver improver = new Improver(settings, generationHandler, imageSize);
-
- while (!Thread.interrupted()) {
- ImprovementType type = improver.improveRandomly();
-
- List<PolygonData> data = improver.getData();
- imagePolygonData(g2d, data, srcOpaque);
-
- long delta = feedback.calculateDelta(image);
-
- boolean wasSuccessful;
-
- ImprovementResult result = generationHandler.addPolygonData(delta, data.toArray(new PolygonData[data.size()]));
- switch (result) {
- case BEST:
- fireImageGenerated(image);
- wasSuccessful = true;
- image = new BufferedImage(imageSize.width, imageSize.height, BufferedImage.TYPE_4BYTE_ABGR);
- g2d.dispose();
- g2d = (Graphics2D)image.getGraphics();
- break;
-
- case ELITE:
- wasSuccessful = true;
- break;
-
- default:
- wasSuccessful = false;
- }
-
- improver.typeWasSuccessful(type, wasSuccessful);
- }
- } finally {
- g2d.dispose();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private void imagePolygonData(Graphics2D g2d, List<PolygonData> polygonData, Composite srcOpaque) {
- g2d.setColor(Color.BLACK);
+ private final Set<ImageGeneratedListener> listeners = new HashSet<ImageGeneratedListener>();
+ private final Settings settings;
+ private final BufferedImage targetImage;
+ private GenerationHandler generationHandler;
+ private final Dimension imageSize;
+ private Feedback feedback;
+ private Thread[] t = null;
+ private final Object startStopLock = new Object();
+
+ /**
+ * creates an ImageGenerator for the given target image, and size
+ * @param confSettings the configuration settings
+ * @param image the target image
+ * @param size the dimension of the image
+ */
+ public DefaultImageGenerator(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();
+ try {
+ g.drawImage(image, 0, 0, imageSize.width, imageSize.height, Color.WHITE, null);
+ generationHandler = new GenerationHandler(settings, imageSize);
+ feedback = new DefaultFeedback();
+ feedback.setTargetImage(targetImage);
+ } finally {
+ g.dispose();
+ }
+ }
+
+ /**
+ * retrieves the scaled target iamge
+ *
+ * @return the target image
+ */
+ @Override
+ public BufferedImage getTargetImage() {
+ return targetImage;
+ }
+
+ /**
+ * 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
+ */
+ @Override
+ public Dimension getImageSize() {
+ return imageSize;
+ }
+
+ /**
+ * allows interested parties to register to receive events when a new best image has been
+ * found.
+ *
+ * @param listener the listener that is interested in events
+ */
+ @Override
+ public void addImageGeneratedListener(ImageGeneratedListener listener) {
+ listeners.add(listener);
+ }
+
+ /**
+ * allows uninterested parties to unregister to receive events when a new best image is
+ * found
+ *
+ * @param listener the listener that is no longer needed
+ */
+ @Override
+ public void removeImageGeneratedListener(ImageGeneratedListener listener) {
+ listeners.remove(listener);
+ }
+
+ /**
+ * informs all listeners that a new best image has been found
+ *
+ * @param image the new best image
+ */
+ @Override
+ public void fireImageGenerated(Image image) {
+ ImageGeneratedEvent event = new ImageGeneratedEvent(this, image);
+ for (ImageGeneratedListener listener : listeners) {
+ listener.imageGenerated(event);
+ }
+ }
+
+ /**
+ * starts up threads to start looking for images that are closest to the target
+ */
+ @Override
+ public void startGenerating() {
+ synchronized(startStopLock) {
+ if (t == null) {
+
+ populateGenerationZeroElite();
+ t = new Thread[Runtime.getRuntime().availableProcessors() + 1];
+ for (int i = 0; i < t.length; i++) {
+ t[i] = new Thread(this);
+ t[i].setName("Improver : " + i);
+ t[i].start();
+ }
+ }
+ }
+ }
+
+ /**
+ * shuts down threads that were looking for images
+ */
+ @Override
+ public void stopGenerating() {
+ synchronized(startStopLock) {
+ if (t != null) {
+ try {
+ for (Thread element : t) {
+ element.interrupt();
+ }
+ for (Thread element : t) {
+ element.join();
+ }
+ } catch (InterruptedException ie) {
+ } finally {
+ t = null;
+ }
+ }
+ }
+ }
+
+ /**
+ * completes the image by transforming the polygon image to the real image
+ */
+ @Override
+ public void complete() {
+ synchronized(startStopLock) {
+ if (t != null) {
+ stopGenerating();
+ t = new Thread[1];
+ t[0] = new Thread(new ImageCompleter(this, targetImage, generationHandler.getBestMember().getData(), imageSize));
+ t[0].start();
+ }
+ }
+ }
+
+ /**
+ * retrieves the best set of polygons for drawing the image so far
+ *
+ * @return the best set of polygons
+ */
+ @Override
+ public PolygonData[] getBestData() {
+ return generationHandler.getBestMember().getData();
+ }
+ /**
+ * the runnable interface implementation to repeatedly improve upon the image and check to
+ * see if it is closer to the target image. Images are created in batches of settings.numCompetingImages
+ * and the best one (if better than the parent) is selected as the new best.
+ */
+ @Override
+ public void run() {
+ try {
+ BufferedImage image = new BufferedImage(imageSize.width, imageSize.height, BufferedImage.TYPE_4BYTE_ABGR);
+ Graphics2D g2d = (Graphics2D)image.getGraphics();
+ try {
+ Composite srcOpaque = AlphaComposite.getInstance(AlphaComposite.SRC, 1.0f);
+ Improver improver = new Improver(settings, generationHandler, imageSize);
+
+ while (!Thread.interrupted()) {
+ ImprovementType type = improver.improveRandomly();
+
+ List<PolygonData> data = improver.getData();
+ imagePolygonData(g2d, data, srcOpaque);
+
+ GenerationMember parentMember = improver.getParentGenerationMember();
+ Score delta = feedback.calculateScore(image, (parentMember != null) ? parentMember.getScore() : null, improver.getChangedArea());
+
+ boolean wasSuccessful;
+
+ ImprovementResult result = generationHandler.addPolygonData(delta, data.toArray(new PolygonData[data.size()]));
+ switch (result) {
+ case BEST:
+ fireImageGenerated(image);
+ wasSuccessful = true;
+ image = new BufferedImage(imageSize.width, imageSize.height, BufferedImage.TYPE_4BYTE_ABGR);
+ g2d.dispose();
+ g2d = (Graphics2D)image.getGraphics();
+ break;
+
+ case ELITE:
+ wasSuccessful = true;
+ break;
+
+ default:
+ wasSuccessful = false;
+ }
+
+ improver.typeWasSuccessful(type, wasSuccessful);
+ }
+ } finally {
+ g2d.dispose();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void imagePolygonData(Graphics2D g2d, List<PolygonData> polygonData, Composite srcOpaque) {
+ g2d.setColor(Color.BLACK);
g2d.setComposite(srcOpaque);
g2d.fillRect(0, 0, imageSize.width, imageSize.height);
-
+
for (PolygonData pd : polygonData) {
pd.draw(g2d);
}
- }
-
- private void populateGenerationZeroElite() {
+ }
+
+ private void populateGenerationZeroElite() {
Composite srcOpaque = AlphaComposite.getInstance(AlphaComposite.SRC, 1.0f);
- for (int i = 0; i < settings.getEliteSize(); i++) {
- BufferedImage image = new BufferedImage(imageSize.width, imageSize.height, BufferedImage.TYPE_4BYTE_ABGR);
- List<PolygonData> polygons = new ArrayList<PolygonData>();
- PolygonData pd = PolygonData.randomPoly(imageSize, settings.getMaxPoints());
- polygons.add(pd);
- Graphics2D g2d = (Graphics2D)image.getGraphics();
- try {
+ for (int i = 0; i < settings.getEliteSize(); i++) {
+ BufferedImage image = new BufferedImage(imageSize.width, imageSize.height, BufferedImage.TYPE_4BYTE_ABGR);
+ List<PolygonData> polygons = new ArrayList<PolygonData>();
+ PolygonData pd = PolygonData.randomPoly(imageSize, settings.getMaxPoints());
+ polygons.add(pd);
+ Graphics2D g2d = (Graphics2D)image.getGraphics();
+ try {
imagePolygonData(g2d, polygons, srcOpaque);
- long delta = feedback.calculateDelta(image);
+ Score delta = feedback.calculateScore(image, null, null);
generationHandler.addPolygonData(delta, polygons.toArray(new PolygonData[polygons.size()]));
- } finally {
- g2d.dispose();
- }
- }
- }
-
- 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));
- }
+ } finally {
+ g2d.dispose();
+ }
+ }
+ }
+
+ 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));
+ }
}
Added: trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultScore.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultScore.java (rev 0)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultScore.java 2011-08-03 06:00:34 UTC (rev 243)
@@ -0,0 +1,112 @@
+package com.mebigfatguy.polycasso;
+
+/**
+ * a default implementation of a score for the error in a image against a target image
+ * this score maintains a grid of scores representing scores in sections of the image, and
+ * then rolls up these scores to an overall score
+ */
+public class DefaultScore implements Score {
+
+ static final int NUM_DIVISIONS = 4;
+
+ /**
+ * a worst case score
+ */
+ public static final DefaultScore MAX_SCORE = new DefaultScore(Long.MAX_VALUE);
+
+ long gridScores[][] = new long[NUM_DIVISIONS][NUM_DIVISIONS];
+ long overallScore;
+
+ /**
+ * constructs an empty score
+ */
+ public DefaultScore() {
+ overallScore = 0;
+ }
+
+ /**
+ * constructs a score with the specified delta, spreads the score across all grids
+ *
+ * @param delta the delta score
+ */
+ public DefaultScore(long delta) {
+ overallScore = delta;
+
+ long divider = NUM_DIVISIONS * NUM_DIVISIONS;
+ long gridScore = overallScore / divider;
+
+ for (int y = 0; y < NUM_DIVISIONS; y++) {
+ for (int x = 0; x < NUM_DIVISIONS; x++) {
+ gridScores[x][y] = gridScore;
+ }
+ }
+ }
+
+ /**
+ * returns the sum of the square of pixel errors
+ * @return the delta between a generate image and the target
+ */
+ @Override
+ public long getDelta() {
+ return overallScore;
+ }
+
+ /**
+ * compares this core to another
+ *
+ * @param o the score to compare to
+ * @return whether the two scores have the same delta
+ */
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof DefaultScore)) {
+ return false;
+ }
+
+ return getDelta() == ((DefaultScore) o).getDelta();
+ }
+
+ /**
+ * clones this object
+ *
+ * @return a clone
+ */
+ @Override
+ public Object clone() {
+ DefaultScore clonedScore;
+
+ try {
+ clonedScore = (DefaultScore) super.clone();
+ } catch (CloneNotSupportedException cnse) {
+ clonedScore = new DefaultScore();
+ clonedScore.overallScore = overallScore;
+ }
+
+ clonedScore.gridScores = new long[NUM_DIVISIONS][NUM_DIVISIONS];
+ for (int i = 0; i < NUM_DIVISIONS; i++) {
+ System.arraycopy(gridScores[i], 0, clonedScore.gridScores[i], 0, NUM_DIVISIONS);
+ }
+
+ return clonedScore;
+ }
+
+ /**
+ * generates a hash code for this score
+ *
+ * @return the hash code of this score
+ */
+ @Override
+ public int hashCode() {
+ return (int) overallScore;
+ }
+
+ /**
+ * returns a string representation of the score
+ *
+ * @return the score as a string
+ */
+ @Override
+ public String toString()...
[truncated message content] |
|
From: <dbr...@us...> - 2011-08-07 02:14:20
|
Revision: 244
http://polycasso.svn.sourceforge.net/polycasso/?rev=244&view=rev
Author: dbrosius
Date: 2011-08-07 02:14:13 +0000 (Sun, 07 Aug 2011)
Log Message:
-----------
use grid scoring
Modified Paths:
--------------
trunk/polycasso/build.xml
trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultFeedback.java
trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultScore.java
trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationHandler.java
trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationMember.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ProxyDialog.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Score.java
Modified: trunk/polycasso/build.xml
===================================================================
--- trunk/polycasso/build.xml 2011-08-03 06:00:34 UTC (rev 243)
+++ trunk/polycasso/build.xml 2011-08-07 02:14:13 UTC (rev 244)
@@ -92,7 +92,8 @@
source="${javac.source}"
target="${javac.target}"
deprecation="${javac.deprecation}"
- debug="${javac.debug}">
+ debug="${javac.debug}"
+ includeantruntime="false">
<classpath refid="polycasso.classpath"/>
</javac>
</target>
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultFeedback.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultFeedback.java 2011-08-03 06:00:34 UTC (rev 243)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultFeedback.java 2011-08-07 02:14:13 UTC (rev 244)
@@ -30,6 +30,7 @@
private byte[] targetBuffer;
private int width, height;
+ private int gridWidth, gridHeight;
/**
* creates a feedback object with a given targetImage. Caches the image bytes in
@@ -48,6 +49,8 @@
WritableRaster raster = targetImage.getRaster();
width = targetImage.getWidth();
height = targetImage.getHeight();
+ gridWidth = (width / DefaultScore.NUM_DIVISIONS);
+ gridHeight = (height / DefaultScore.NUM_DIVISIONS);
DataBufferByte dbb = (DataBufferByte)raster.getDataBuffer();
targetBuffer = dbb.getData();
}
@@ -65,18 +68,41 @@
@Override
public Score calculateScore(BufferedImage testImage, Score previousScore, Rectangle changedArea) {
- DefaultScore score = (previousScore != null) ? (DefaultScore)previousScore.clone() : new DefaultScore();
-
WritableRaster raster = testImage.getRaster();
DataBufferByte dbb = (DataBufferByte)raster.getDataBuffer();
byte[] testBuffer = dbb.getData();
- boolean needAutoRecalc = (previousScore == null) || (changedArea == null);
+ Score score;
+ if ((changedArea == null) || (changedArea.width > changedArea.height)) {
+ score = calculateYMajorScore(testBuffer, previousScore, changedArea);
+ } else {
+ score = calculateXMajorScore(testBuffer, previousScore, changedArea);
+ }
+
+ // uncomment to test whether the grid based scoring is accurate
+ // if (Math.random() < 0.05) {
+ // long realScore = calculateGridScore(testBuffer, 0, 0, width, height);
+ // if (realScore != score.getDelta()) {
+ // System.out.println("ERROR: Real: " + realScore + " calc: " + score.getDelta());
+ // Score s = calculateYMajorScore(testBuffer, null, null);
+ // System.out.println("Full Recalc: " + s.getDelta());
+ // calculateScore(testImage, previousScore, changedArea);
+ // }
+ // }
+
+ return score;
+
+ }
+
+ private Score calculateYMajorScore(byte[] testBuffer, Score previousScore, Rectangle changedArea) {
+
+ DefaultScore score = (previousScore != null) ? (DefaultScore)previousScore.clone() : new DefaultScore();
+
+ boolean needFullRecalc = (previousScore == null) || (changedArea == null);
score.overallScore = 0L;
+ int gridTop = 0;
for (int y = 0; y < DefaultScore.NUM_DIVISIONS; y++) {
- int gridHeight = (height / DefaultScore.NUM_DIVISIONS);
- int gridTop = y * gridHeight;
int gridBottom;
if (y < (DefaultScore.NUM_DIVISIONS - 1)) {
gridBottom = gridTop + gridHeight;
@@ -84,10 +110,9 @@
gridBottom = height;
}
- if (needAutoRecalc || ((changedArea.y <= gridBottom) && ((changedArea.y + changedArea.height) >= gridTop))) {
+ if (needFullRecalc || ((changedArea.y <= gridBottom) && ((changedArea.y + changedArea.height) >= gridTop))) {
+ int gridLeft = 0;
for (int x = 0; x < DefaultScore.NUM_DIVISIONS; x++) {
- int gridWidth = (width / DefaultScore.NUM_DIVISIONS);
- int gridLeft = x * gridWidth;
int gridRight;
if (x < (DefaultScore.NUM_DIVISIONS - 1)) {
gridRight = gridLeft + gridWidth;
@@ -95,46 +120,107 @@
gridRight = width;
}
- if (needAutoRecalc || ((changedArea.x <= gridRight) && ((changedArea.x + changedArea.width) >= gridLeft))) {
+ if (needFullRecalc || ((changedArea.x <= gridRight) && ((changedArea.x + changedArea.width) >= gridLeft))) {
- long gridError = 0L;
- for (int gy = gridTop; gy < gridBottom; gy++) {
- int pixelStart = (gy * width * 4) + (gridLeft * 4);
- int pixelEnd = pixelStart + (gridRight - gridLeft) * 4;
+ long gridError = calculateGridScore(testBuffer, gridLeft, gridTop, gridRight, gridBottom);
- //index 0 is alpha, start at 1 (blue)
- for (int i = pixelStart + 1; i < pixelEnd; i++) {
- int blue1 = targetBuffer[i] & 0x0FF;
- int blue2 = testBuffer[i++] & 0x0FF;
- long blueError = blue1 - blue2;
- blueError *= blueError;
+ score.gridScores[x][y] = gridError;
+ score.overallScore += gridError;
+ } else {
+ score.overallScore += score.gridScores[x][y];
+ }
- int green1 = targetBuffer[i] & 0x0FF;
- int green2 = testBuffer[i++] & 0x0FF;
- long greenError = green1 - green2;
- greenError *= greenError;
+ gridLeft = gridRight;
+ }
+ } else {
+ for (int x = 0; x < DefaultScore.NUM_DIVISIONS; x++) {
+ score.overallScore += score.gridScores[x][y];
+ }
+ }
- int red1 = targetBuffer[i] & 0x0FF;
- int red2 = testBuffer[i++] & 0x0FF;
- long redError = red1 - red2;
- redError *= redError;
+ gridTop = gridBottom;
+ }
- gridError += redError + greenError + blueError;
- }
- }
+ return score;
+ }
+
+ private Score calculateXMajorScore(byte[] testBuffer, Score previousScore, Rectangle changedArea) {
+
+ DefaultScore score = (previousScore != null) ? (DefaultScore)previousScore.clone() : new DefaultScore();
+
+ boolean needFullRecalc = (previousScore == null) || (changedArea == null);
+ score.overallScore = 0L;
+
+ int gridLeft = 0;
+ for (int x = 0; x < DefaultScore.NUM_DIVISIONS; x++) {
+ int gridRight;
+ if (x < (DefaultScore.NUM_DIVISIONS - 1)) {
+ gridRight = gridLeft + gridWidth;
+ } else {
+ gridRight = width;
+ }
+
+ if (needFullRecalc || ((changedArea.x <= gridRight) && ((changedArea.x + changedArea.width) >= gridLeft))) {
+ int gridTop = 0;
+ for (int y = 0; y < DefaultScore.NUM_DIVISIONS; y++) {
+ int gridBottom;
+ if (y < (DefaultScore.NUM_DIVISIONS - 1)) {
+ gridBottom = gridTop + gridHeight;
+ } else {
+ gridBottom = height;
+ }
+
+ if (needFullRecalc || ((changedArea.y <= gridBottom) && ((changedArea.y + changedArea.height) >= gridTop))) {
+
+ long gridError = calculateGridScore(testBuffer, gridLeft, gridTop, gridRight, gridBottom);
+
score.gridScores[x][y] = gridError;
score.overallScore += gridError;
} else {
score.overallScore += score.gridScores[x][y];
}
+
+ gridTop = gridBottom;
}
} else {
- for (int x = 0; x < DefaultScore.NUM_DIVISIONS; x++) {
+ for (int y = 0; y < DefaultScore.NUM_DIVISIONS; y++) {
score.overallScore += score.gridScores[x][y];
}
}
+
+ gridLeft = gridRight;
}
return score;
}
+
+ private long calculateGridScore(byte[] testBuffer, int gridLeft, int gridTop, int gridRight, int gridBottom) {
+ long gridError = 0L;
+ for (int gy = gridTop; gy < gridBottom; gy++) {
+ int pixelStart = (gy * width * 4) + (gridLeft * 4);
+ int pixelEnd = pixelStart + ((gridRight - gridLeft) * 4);
+
+ //index 0 is alpha, start at 1 (blue)
+ for (int i = pixelStart + 1; i < pixelEnd; i++) {
+ int blue1 = targetBuffer[i] & 0x0FF;
+ int blue2 = testBuffer[i++] & 0x0FF;
+ long blueError = blue1 - blue2;
+ blueError *= blueError;
+
+ int green1 = targetBuffer[i] & 0x0FF;
+ int green2 = testBuffer[i++] & 0x0FF;
+ long greenError = green1 - green2;
+ greenError *= greenError;
+
+ int red1 = targetBuffer[i] & 0x0FF;
+ int red2 = testBuffer[i++] & 0x0FF;
+ long redError = red1 - red2;
+ redError *= redError;
+
+ gridError += redError + greenError + blueError;
+ }
+ }
+
+ return gridError;
+ }
}
\ No newline at end of file
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultScore.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultScore.java 2011-08-03 06:00:34 UTC (rev 243)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultScore.java 2011-08-07 02:14:13 UTC (rev 244)
@@ -3,11 +3,12 @@
/**
* a default implementation of a score for the error in a image against a target image
* this score maintains a grid of scores representing scores in sections of the image, and
- * then rolls up these scores to an overall score
+ * then rolls up these scores to an overall score.
*/
public class DefaultScore implements Score {
- static final int NUM_DIVISIONS = 4;
+ private static final long serialVersionUID = 2603006530810631094L;
+ static final int NUM_DIVISIONS = 8;
/**
* a worst case score
@@ -52,7 +53,7 @@
}
/**
- * compares this core to another
+ * compares this score to another
*
* @param o the score to compare to
* @return whether the two scores have the same delta
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationHandler.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationHandler.java 2011-08-03 06:00:34 UTC (rev 243)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationHandler.java 2011-08-07 02:14:13 UTC (rev 244)
@@ -4,17 +4,17 @@
* Copyright 2009-2011 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
+ * 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.
+ * 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;
@@ -29,144 +29,145 @@
* class that maintains the set of polygon data for this generation of images
*/
public class GenerationHandler implements Serializable {
-
- private static final long serialVersionUID = 2375492293685052783L;
+ private static final long serialVersionUID = 2375492293685052783L;
+
private List<GenerationMember> generation;
- private Random random;
- private Settings settings;
- private int generationNumber;
- private double annealingValue;
- private GenerationMember bestMember;
- private double eliteCutOff;
- private int generationBests;
- private int generationElites;
-
- /**
- * constructs a handler for managing successive generations of image samples
- *
- * @param confSettings settings to use for generation and elite size
- * @param imageSize the size of the target image
- */
- public GenerationHandler(Settings confSettings, Dimension imageSize) {
- random = new Random();
- generationNumber = 0;
- settings = confSettings;
- bestMember = new GenerationMember(DefaultScore.MAX_SCORE, new PolygonData[0]);
- eliteCutOff = Long.MAX_VALUE;
- generation = new ArrayList<GenerationMember>(settings.getGenerationSize() + 10);
- annealingValue = settings.getStartTemperature() * settings.getStartTemperature() * imageSize.height * imageSize.width;
- generationBests = 0;
- generationElites = 0;
- }
-
- /**
- * add a sample polygon set to this generation with a given score
- *
- * @param score the deviation from perfection this set calculates
- *
- * @param polygonData the polygons that draw the image
- *
- * @return whether this is the best polygon set so far
- */
- public ImprovementResult addPolygonData(Score score, PolygonData[] polygonData) {
- synchronized(generation) {
- GenerationMember newMember = new GenerationMember(score, polygonData);
- generation.add(newMember);
- if (generation.size() >= settings.getGenerationSize()) {
- processGeneration();
- } else {
- Collections.sort(generation);
- }
- if (score.getDelta() < bestMember.getScore().getDelta()) {
- bestMember = newMember;
- generationBests++;
- return ImprovementResult.BEST;
- } else if (score.getDelta() < eliteCutOff) {
- generationElites++;
- return ImprovementResult.ELITE;
- }
-
- return ImprovementResult.FAIL;
- }
- }
-
- /**
+ private final Random random;
+ private final Settings settings;
+ private int generationNumber;
+ private double annealingValue;
+ private GenerationMember bestMember;
+ private double eliteCutOff;
+ private int generationBests;
+ private int generationElites;
+
+ /**
+ * constructs a handler for managing successive generations of image samples
+ *
+ * @param confSettings settings to use for generation and elite size
+ * @param imageSize the size of the target image
+ */
+ public GenerationHandler(Settings confSettings, Dimension imageSize) {
+ random = new Random();
+ generationNumber = 0;
+ settings = confSettings;
+ bestMember = new GenerationMember(DefaultScore.MAX_SCORE, new PolygonData[0]);
+ eliteCutOff = Long.MAX_VALUE;
+ generation = new ArrayList<GenerationMember>(settings.getGenerationSize() + 10);
+ annealingValue = settings.getStartTemperature() * settings.getStartTemperature() * imageSize.height * imageSize.width;
+ generationBests = 0;
+ generationElites = 0;
+ }
+
+ /**
+ * add a sample polygon set to this generation with a given score
+ *
+ * @param score the deviation from perfection this set calculates
+ *
+ * @param polygonData the polygons that draw the image
+ *
+ * @return whether this is the best polygon set so far
+ */
+ public ImprovementResult addPolygonData(Score score, PolygonData[] polygonData) {
+ GenerationMember newMember = new GenerationMember(score, polygonData);
+ synchronized(generation) {
+ generation.add(newMember);
+ if (generation.size() >= settings.getGenerationSize()) {
+ processGeneration();
+ } else {
+ Collections.sort(generation);
+ }
+ if (score.getDelta() < bestMember.getScore().getDelta()) {
+ bestMember = newMember;
+ generationBests++;
+ return ImprovementResult.BEST;
+ } else if (score.getDelta() < eliteCutOff) {
+ generationElites++;
+ return ImprovementResult.ELITE;
+ }
+
+ return ImprovementResult.FAIL;
+ }
+ }
+
+ /**
* pick a random member either from the general pool or elite pool
* skew the results towards the elite
*
* @param elite whether to pick from the elite pool or not
* @return a random member
*/
- public GenerationMember getRandomMember(boolean elite) {
- synchronized(generation) {
- int size = elite ? (settings.getEliteSize() % generation.size()) : generation.size();
+ public GenerationMember getRandomMember(boolean elite) {
+ synchronized(generation) {
+ int size = elite ? (settings.getEliteSize() % generation.size()) : generation.size();
- if (size == 0)
- return null;
-
- int r = random.nextInt(size);
-
- int idx = (int)(r * ((double) r / (double) size));
-
- return generation.get(idx);
- }
- }
-
- /**
- * returns the best polygon set to draw the picture
- *
- * @return the best polygon set
- */
- public GenerationMember getBestMember() {
- synchronized(generation) {
- return bestMember;
- }
- }
-
- private void processGeneration() {
- int eliteSize = settings.getEliteSize();
-
- Collections.<GenerationMember>sort(generation);
- int sz = generation.size();
-
- List<GenerationMember> nextGeneration = new ArrayList<GenerationMember>(settings.getGenerationSize() + 10);
- for (int i = 0; i < eliteSize; i++) {
- nextGeneration.add(generation.get(i));
- }
-
- if (settings.isUseAnnealing() && (annealingValue > 0.01)) {
+ if (size == 0) {
+ return null;
+ }
+
+ int r = random.nextInt(size);
+
+ int idx = (int)(r * ((double) r / (double) size));
+
+ return generation.get(idx);
+ }
+ }
+
+ /**
+ * returns the best polygon set to draw the picture
+ *
+ * @return the best polygon set
+ */
+ public GenerationMember getBestMember() {
+ synchronized(generation) {
+ return bestMember;
+ }
+ }
+
+ private void processGeneration() {
+ int eliteSize = settings.getEliteSize();
+
+ Collections.<GenerationMember>sort(generation);
+ int sz = generation.size();
+
+ List<GenerationMember> nextGeneration = new ArrayList<GenerationMember>(settings.getGenerationSize() + 10);
+ for (int i = 0; i < eliteSize; i++) {
+ nextGeneration.add(generation.get(i));
+ }
+
+ if (settings.isUseAnnealing() && (annealingValue > 0.01)) {
int annealingReplacements = 0;
-
- /* always keep the best, so start at 1 */
- for (int i = 1; i < eliteSize; i++) {
- int candidateIndex = random.nextInt(sz - eliteSize) + eliteSize;
- GenerationMember candidate = generation.get(candidateIndex);
- GenerationMember elite = generation.get(i);
- long delta = candidate.getScore().getDelta() - elite.getScore().getDelta();
- if (delta < annealingValue) {
- nextGeneration.set(i, candidate);
- if (Polycasso.DEBUG) {
- annealingReplacements++;
- }
- }
- }
-
+
+ /* always keep the best, so start at 1 */
+ for (int i = 1; i < eliteSize; i++) {
+ int candidateIndex = random.nextInt(sz - eliteSize) + eliteSize;
+ GenerationMember candidate = generation.get(candidateIndex);
+ GenerationMember elite = generation.get(i);
+ long delta = candidate.getScore().getDelta() - elite.getScore().getDelta();
+ if (delta < annealingValue) {
+ nextGeneration.set(i, candidate);
+ if (Polycasso.DEBUG) {
+ annealingReplacements++;
+ }
+ }
+ }
+
if (Polycasso.DEBUG) {
System.out.println("Generation " + generationNumber + " had " + annealingReplacements + " annealing replacements with annealing value: " + annealingValue);
}
- }
-
- generation = nextGeneration;
-
- eliteCutOff = generation.get(eliteSize-1).getScore().getDelta();
-
+ }
+
+ generation = nextGeneration;
+
+ eliteCutOff = generation.get(eliteSize-1).getScore().getDelta();
+
if (Polycasso.DEBUG) {
- System.out.println("Generation " + generationNumber + " had " + generationBests + " bests and " + generationElites + " elites. Best Score: " + generation.get(0).getScore());
+ System.out.println("Generation " + generationNumber + " had " + generationBests + " bests and " + generationElites + " elites. Best Score: " + generation.get(0).getScore());
}
generationBests = 0;
generationElites = 0;
- generationNumber++;
- annealingValue *= (1.0 - settings.getCoolingRate());
- }
+ generationNumber++;
+ annealingValue *= (1.0 - settings.getCoolingRate());
+ }
}
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationMember.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationMember.java 2011-08-03 06:00:34 UTC (rev 243)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationMember.java 2011-08-07 02:14:13 UTC (rev 244)
@@ -4,78 +4,82 @@
* Copyright 2009-2011 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
+ * 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.
+ * 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.Serializable;
import java.util.Arrays;
/**
* class that holds a sample set of polygons and it's score
*/
-public class GenerationMember implements Comparable<GenerationMember> {
-
- private Score score;
- private PolygonData[] data;
-
- GenerationMember(Score polyScore, PolygonData[] polyData) {
- score = polyScore;
- data = polyData;
- }
-
- /**
- * returns the score for this member
- * @return the score
- */
- public Score getScore() {
- return score;
- }
+public class GenerationMember implements Comparable<GenerationMember>, Serializable {
- /**
- * returns the polygon data for this member
- *
- * @return the polygon data
- */
- public PolygonData[] getData() {
- return data;
- }
+ private static final long serialVersionUID = 3227390661297952844L;
- @Override
- public int compareTo(GenerationMember o) {
- long delta = score.getDelta() - o.score.getDelta();
- if (delta > 0)
- return 1;
- else if (delta < 0)
- return -1;
-
- return data.length - o.data.length;
- }
-
- @Override
- public int hashCode() {
- return score.hashCode();
- }
-
- @Override
- public boolean equals(Object o) {
- if (o instanceof GenerationMember) {
- return score.getDelta() == ((GenerationMember)o).score.getDelta();
- }
- return false;
- }
-
- @Override
- public String toString() {
- return "(" + score + ": " + Arrays.toString(data) + ")";
- }
+ private final Score score;
+ private final PolygonData[] data;
+
+ GenerationMember(Score polyScore, PolygonData[] polyData) {
+ score = polyScore;
+ data = polyData;
+ }
+
+ /**
+ * returns the score for this member
+ * @return the score
+ */
+ public Score getScore() {
+ return score;
+ }
+
+ /**
+ * returns the polygon data for this member
+ *
+ * @return the polygon data
+ */
+ public PolygonData[] getData() {
+ return data;
+ }
+
+ @Override
+ public int compareTo(GenerationMember o) {
+ long delta = score.getDelta() - o.score.getDelta();
+ if (delta > 0) {
+ return 1;
+ } else if (delta < 0) {
+ return -1;
+ }
+
+ return data.length - o.data.length;
+ }
+
+ @Override
+ public int hashCode() {
+ return score.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof GenerationMember) {
+ return score.getDelta() == ((GenerationMember)o).score.getDelta();
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return "(" + score + ": " + Arrays.toString(data) + ")";
+ }
}
\ No newline at end of file
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2011-08-03 06:00:34 UTC (rev 243)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2011-08-07 02:14:13 UTC (rev 244)
@@ -4,17 +4,17 @@
* Copyright 2009-2011 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
+ * 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.
+ * 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;
@@ -24,417 +24,424 @@
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.Random;
/**
- * a class that applies various improvement attempts to a polygon, attempts to prioritize
+ * a class that applies various improvement attempts to a polygon, attempts to prioritize
* which algorithms to pick based on what has worked in the past, as well as priorities which
* polygons have had success being transformed.
*/
public class Improver {
- private Settings settings;
- private GenerationHandler generationHandler;
- private Dimension imageSize;
- private Random r;
- private List<PolygonData> polygons = null;
- private Rectangle changedArea;
- private GenerationMember changedMember;
- private ImprovementTypeStats stats;
-
- /**
- * create an improver using a specified image size
- * @param confSettings the settings to be used
- * @param genHandler the generation handler
- * @param size the size of the image
- */
- public Improver(Settings confSettings, Generation...
[truncated message content] |
|
From: <dbr...@us...> - 2012-01-16 20:36:34
|
Revision: 247
http://polycasso.svn.sourceforge.net/polycasso/?rev=247&view=rev
Author: dbrosius
Date: 2012-01-16 20:36:26 +0000 (Mon, 16 Jan 2012)
Log Message:
-----------
update from github
Modified Paths:
--------------
trunk/polycasso/build.xml
trunk/polycasso/htdocs/polylamp.svg
trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.java
trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultFeedback.java
trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultImageGenerator.java
trunk/polycasso/src/com/mebigfatguy/polycasso/DoubleDocument.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Feedback.java
trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java
trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java
trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationHandler.java
trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationMember.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImageSizer.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementResult.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/IntegerDocument.java
trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PainterPanel.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PolycassoBundle.java
trunk/polycasso/src/com/mebigfatguy/polycasso/PolygonData.java
trunk/polycasso/src/com/mebigfatguy/polycasso/ProxyDialog.java
trunk/polycasso/src/com/mebigfatguy/polycasso/RandomImageFinder.java
trunk/polycasso/src/com/mebigfatguy/polycasso/SVGSaver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Saver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Score.java
trunk/polycasso/src/com/mebigfatguy/polycasso/Settings.java
trunk/polycasso/src/com/mebigfatguy/polycasso/SettingsDialog.java
trunk/polycasso/src/com/mebigfatguy/polycasso/URLFetcher.java
Modified: trunk/polycasso/build.xml
===================================================================
--- trunk/polycasso/build.xml 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/build.xml 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,8 +1,8 @@
<!--
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -55,6 +55,7 @@
</target>
<target name="-init" description="prepares repository for a build">
+ <mkdir dir="${lib.dir}"/>
<mkdir dir="${classes.dir}"/>
<mkdir dir="${javadoc.dir}"/>
<path id="polycasso.classpath">
Modified: trunk/polycasso/htdocs/polylamp.svg
===================================================================
--- trunk/polycasso/htdocs/polylamp.svg 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/htdocs/polylamp.svg 2012-01-16 20:36:26 UTC (rev 247)
@@ -55,7 +55,7 @@
<polygon fill="#b8a296" fill-opacity="0.7066416" points="123,233 124,223 95,243"/>
<polygon fill="#ffe4ba" fill-opacity="0.08091611" points="123,393 102,363 138,320 126,303 116,350 69,350 50,386"/>
<polygon fill="#968a84" fill-opacity="0.70623696" points="105,181 134,228 116,225 116,223 111,254 98,301 33,153"/>
- <polygon fill="#00001a" fill-opacity="0.2011652" points="219,122 225,127 232,140 240,149 301,135 277,95 201,48"/>
+ <polygon fill="#00001a" fill-opacity="0.2012652" points="219,122 225,127 232,140 240,149 301,135 277,95 201,48"/>
<polygon fill="#0000b5" fill-opacity="0.26807457" points="45,213 45,226 21,228 21,240 21,256 28,259 36,261"/>
<polygon fill="#9a8d61" fill-opacity="0.22238308" points="103,176 166,189 189,197 229,174 278,265 253,317 242,283"/>
<polygon fill="#8d7869" fill-opacity="0.55219734" points="45,151 66,170 31,145 37,169 58,169 41,261"/>
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/AboutDialog.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultFeedback.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultFeedback.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultFeedback.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultImageGenerator.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultImageGenerator.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/DefaultImageGenerator.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/DoubleDocument.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/DoubleDocument.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/DoubleDocument.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Feedback.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Feedback.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Feedback.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/FileSelector.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/FileType.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationHandler.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationHandler.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationHandler.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -86,9 +86,8 @@
generationElites++;
return ImprovementResult.ELITE;
}
-
- return ImprovementResult.FAIL;
}
+ return ImprovementResult.FAIL;
}
/**
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationMember.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationMember.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/GenerationMember.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageCompleter.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedEvent.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGeneratedListener.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageGenerator.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImageSizer.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImageSizer.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImageSizer.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementResult.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementResult.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementResult.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementType.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/ImprovementTypeStats.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/Improver.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/IntegerDocument.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/IntegerDocument.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/IntegerDocument.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,20 +1,20 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 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
+ * 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.
+ * 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;
@@ -35,159 +35,154 @@
* 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";
-
- /**
- * 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 {
- 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);
-
- String polygonData = getPolygonData(data);
- String colorData = getColorData(data);
- String transparencyData = getTransparencyData(data);
-
- /* 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\\}", polygonData);
- template = template.replaceAll("\\{4\\}", colorData);
- template = template.replaceAll("\\{5\\}", transparencyData);
-
- pw.println(template);
-
- } catch (IOException ioe) {
-
- } finally {
- IOUtils.closeQuietly(templateStream);
- IOUtils.closeQuietly(pw);
- }
- }
-
- private String getPolygonData(PolygonData[] data) {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
-
- String outerComma = "";
- String innerComma;
- for (int i = 0; i < data.length; i++) {
-
- PolygonData pd = data[i];
-
- pw.println(outerComma);
- pw.print(TABS);
- pw.println("{");
-
- /* Xs */
- pw.print(TABS);
- pw.print("\t{");
-
- innerComma = "";
- Polygon poly = pd.getPolygon();
- for (int j = 0; j < poly.npoints; j++) {
- pw.print(innerComma);
- pw.print(poly.xpoints[j]);
- innerComma = ",";
- }
-
- pw.println("},");
-
- /* Ys */
- pw.print(TABS);
- pw.print("\t{");
-
- innerComma = "";
- poly = pd.getPolygon();
- for (int j = 0; j < poly.npoints; j++) {
- pw.print(innerComma);
- pw.print(poly.ypoints[j]);
- innerComma = ",";
- }
-
- pw.println("}");
-
- pw.print(TABS);
- pw.print("}");
- outerComma = ",";
- }
-
- pw.flush();
- return sw.toString();
- }
-
- private String getColorData(PolygonData[] data) {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
-
- String comma = "";
- for (int i = 0; i < data.length; i++) {
-
- PolygonData pd = data[i];
-
- pw.println(comma);
- pw.print(TABS);
- pw.print("{");
-
- Color color = pd.getColor();
- pw.print(color.getRed());
- pw.print(",");
- pw.print(color.getGreen());
- pw.print(",");
- pw.print(color.getBlue());
- pw.print("}");
- comma = ",";
- }
-
- pw.flush();
- return sw.toString();
- }
-
- private String getTransparencyData(PolygonData[] data) {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- pw.println();
- pw.print(TABS);
- String comma = "";
- for (int i = 0; i < data.length; i++) {
-
- PolygonData pd = data[i];
-
- pw.print(comma);
- pw.print(pd.getAlpha());
- pw.print("f");
- comma = ",";
- }
-
- pw.flush();
- return sw.toString();
- }
+ private static final String EXTENSION = ".java";
+ private static final String TABS = "\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 {
+
+ 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);
+
+ String polygonData = getPolygonData(data);
+ String colorData = getColorData(data);
+ String transparencyData = getTransparencyData(data);
+
+ /* 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\\}", polygonData);
+ template = template.replaceAll("\\{4\\}", colorData);
+ template = template.replaceAll("\\{5\\}", transparencyData);
+
+ pw.println(template);
+
+ } catch (IOException ioe) {
+
+ } finally {
+ IOUtils.closeQuietly(templateStream);
+ IOUtils.closeQuietly(pw);
+ }
+ }
+
+ private String getPolygonData(PolygonData[] data) {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+
+ String outerComma = "";
+ String innerComma;
+ for (PolygonData pd : data) {
+
+ pw.println(outerComma);
+ pw.print(TABS);
+ pw.println("{");
+
+ /* Xs */
+ pw.print(TABS);
+ pw.print("\t{");
+
+ innerComma = "";
+ Polygon poly = pd.getPolygon();
+ for (int j = 0; j < poly.npoints; j++) {
+ pw.print(innerComma);
+ pw.print(poly.xpoints[j]);
+ innerComma = ",";
+ }
+
+ pw.println("},");
+
+ /* Ys */
+ pw.print(TABS);
+ pw.print("\t{");
+
+ innerComma = "";
+ poly = pd.getPolygon();
+ for (int j = 0; j < poly.npoints; j++) {
+ pw.print(innerComma);
+ pw.print(poly.ypoints[j]);
+ innerComma = ",";
+ }
+
+ pw.println("}");
+
+ pw.print(TABS);
+ pw.print("}");
+ outerComma = ",";
+ }
+
+ pw.flush();
+ return sw.toString();
+ }
+
+ private String getColorData(PolygonData[] data) {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+
+ String comma = "";
+ for (PolygonData pd : data) {
+
+ pw.println(comma);
+ pw.print(TABS);
+ pw.print("{");
+
+ Color color = pd.getColor();
+ pw.print(color.getRed());
+ pw.print(",");
+ pw.print(color.getGreen());
+ pw.print(",");
+ pw.print(color.getBlue());
+ pw.print("}");
+ comma = ",";
+ }
+
+ pw.flush();
+ return sw.toString();
+ }
+
+ private String getTransparencyData(PolygonData[] data) {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ pw.println();
+ pw.print(TABS);
+ String comma = "";
+ for (PolygonData pd : data) {
+
+ pw.print(comma);
+ pw.print(pd.getAlpha());
+ pw.print("f");
+ comma = ",";
+ }
+
+ pw.flush();
+ return sw.toString();
+ }
+
}
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PNGSaver.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PainterFrame.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/PainterPanel.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/PainterPanel.java 2012-01-16 20:34:46 UTC (rev 246)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/PainterPanel.java 2012-01-16 20:36:26 UTC (rev 247)
@@ -1,7 +1,7 @@
/*
* polycasso - Cubism Artwork generator
- * Copyright 2009-2011 MeBigFatGuy.com
- * Copyright 2009-2011 Dave Brosius
+ * Copyright 2009-2012 MeBigFatGuy.com
+ * Copyright 2009-2012 Dave Brosius
* Inspired by work by Roger Alsing
*
* Licensed under the Apache License, Version 2.0 (the "License");
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/Polycasso.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/po...
[truncated message content] |
|
From: <dbr...@us...> - 2012-03-18 02:35:16
|
Revision: 249
http://polycasso.svn.sourceforge.net/polycasso/?rev=249&view=rev
Author: dbrosius
Date: 2012-03-18 02:35:10 +0000 (Sun, 18 Mar 2012)
Log Message:
-----------
pull from github
Modified Paths:
--------------
trunk/polycasso/build.xml
trunk/polycasso/polycasso.store
Modified: trunk/polycasso/build.xml
===================================================================
--- trunk/polycasso/build.xml 2012-03-18 02:19:37 UTC (rev 248)
+++ trunk/polycasso/build.xml 2012-03-18 02:35:10 UTC (rev 249)
@@ -37,6 +37,7 @@
<property name="forms.version" value="1.2.1"/>
<property name="commons-io.version" value="1.4"/>
+ <property name="junit.version" value="4.10"/>
<property name="polycasso.version" value="1.6.0"/>
@@ -67,6 +68,7 @@
<property name="forms_url" value="http://repo1.maven.org/maven2/com/jgoodies/forms/${forms.version}/forms-${forms.version}.jar"/>
<property name="commonsio_url" value="http://repo1.maven.org/maven2/commons-io/commons-io/${commons-io.version}/commons-io-${commons-io.version}.jar"/>
+ <property name="junit_url" value="http://repo1.maven.org/maven2/junit/junit/${junit.version}/junit-${junit.version}.jar"/>
<target name="forms_check">
<available file="${basedir}/lib/forms-${forms.version}.jar" property="forms_exists"/>
@@ -75,17 +77,25 @@
<target name="commonsio_check">
<available file="${basedir}/lib/commons-io-${commons-io.version}.jar" property="commonsio.exists"/>
</target>
+
+ <target name="junit_check">
+ <available file="${basedir}/lib/junit-${junit.version}.jar" property="junit.exists"/>
+ </target>
<target name="install_forms" depends="forms_check" unless="forms_exists" description="installs forms.jar into lib">
- <get src="${forms_url}" dest="${basedir}/lib/forms-${forms.version}.jar" verbose="true" ignoreerrors="true"/>
+ <get src="${forms_url}" dest="${lib.dir}/forms-${forms.version}.jar" verbose="true" ignoreerrors="true"/>
</target>
<target name="install_commonsio" depends="commonsio_check" unless="commonsio.exists" description="installs commons-io.jar into lib">
- <get src="${commonsio_url}" dest="${basedir}/lib/commons-io-${commons-io.version}.jar" verbose="true" ignoreerrors="true"/>
+ <get src="${commonsio_url}" dest="${lib.dir}/commons-io-${commons-io.version}.jar" verbose="true" ignoreerrors="true"/>
</target>
- <target name="pull" depends="install_forms, install_commonsio" description="pulls in the 3rd party jars">
+ <target name="install_junit" depends="junit_check" unless="junit.exists" description="installs junit.jar into lib">
+ <get src="${junit_url}" dest="${lib.dir}/junit-${junit.version}.jar" verbose="true" ignoreerrors="true"/>
</target>
+
+ <target name="pull" depends="install_forms, install_commonsio, install_junit" description="pulls in the 3rd party jars">
+ </target>
<target name="compile" depends="-init, pull" description="compiles java files">
<javac srcdir="${src.dir}"
@@ -160,6 +170,7 @@
<target name="test" depends="-init, compile, resources" description="runs unit tests">
<path id="polycassotest.classpath">
<pathelement location="${classes.dir}"/>
+ <pathelement location="${lib.dir}/junit-${junit.version}.jar"/>
</path>
<junit
printsummary="true"
@@ -168,7 +179,7 @@
showoutput="true"
fork="true">
- <classpath><path refid="polycasso.classpath"/></classpath>
+ <classpath><path refid="polycassotest.classpath"/></classpath>
<batchtest fork="true">
<fileset dir="${classes.dir}"
excludes="test/*$*"
Modified: trunk/polycasso/polycasso.store
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|