[Polycasso-commit] SF.net SVN: polycasso:[220] trunk/polycasso/src/com/mebigfatguy/polycasso
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2010-01-01 04:48:03
|
Revision: 220
http://polycasso.svn.sourceforge.net/polycasso/?rev=220&view=rev
Author: dbrosius
Date: 2010-01-01 04:47:53 +0000 (Fri, 01 Jan 2010)
Log Message:
-----------
draw the image polygon by polygon with a delay
Modified Paths:
--------------
trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java
trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.template
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java 2010-01-01 04:20:23 UTC (rev 219)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.java 2010-01-01 04:47:53 UTC (rev 220)
@@ -37,7 +37,7 @@
public class JavaSaver implements Saver {
private static final String EXTENSION = ".java";
- private static final String TABS = "\t\t\t\t\t\t";
+ 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
Modified: trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.template
===================================================================
--- trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.template 2010-01-01 04:20:23 UTC (rev 219)
+++ trunk/polycasso/src/com/mebigfatguy/polycasso/JavaSaver.template 2010-01-01 04:47:53 UTC (rev 220)
@@ -22,31 +22,49 @@
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Polygon;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
+import javax.swing.Timer;
/**
* generates an image by laying semi-transparent polygons on top of each other.
* Class generated by Polycasso (http://polycasso.sourceforge.net)
*/
public class {0} {
-
+ private static final int DEFAULT_DELAY = 500;
+
public static void main(String[] args) {
+ int inputDelay;
+ try {
+ inputDelay = Integer.parseInt(args[0]);
+ } catch (Exception e) {
+ inputDelay = DEFAULT_DELAY;
+ }
+
+ final int delay = inputDelay;
+
JFrame frame = new JFrame() {
+ private static final long serialVersionUID = 1L;
+
+ private Timer timer;
+ private int displayCount = 0;
+
+ private int[][][] polygonData = new int[][][]
+ {{3}
+ };
+
+ private int[][] colorData = new int[][]
+ {{4}
+ };
+
+ private float [] transparencyData = new float[]
+ {{5}
+ };
+
{
- final int[][][] polygonData = new int[][][]
- {{3}
- };
-
- final int[][] colorData = new int[][]
- {{4}
- };
-
- final float [] transparencyData = new float[]
- {{5}
- };
-
Container cp = getContentPane();
cp.add(new JPanel() {
private static final long serialVersionUID = 1L;
@@ -58,7 +76,12 @@
g2d.setColor(Color.BLACK);
g2d.fillRect(0, 0, {1}, {2});
- for (int i = 0; i < polygonData.length; i++) {
+ int limit;
+ synchronized(timer) {
+ limit = displayCount;
+ }
+
+ for (int i = 0; i < limit; i++) {
Polygon polygon = new Polygon(polygonData[i][0], polygonData[i][1], polygonData[i][0].length);
Color color = new Color(colorData[i][0], colorData[i][1], colorData[i][2]);
g2d.setColor(color);
@@ -69,6 +92,23 @@
}
});
pack();
+
+ timer = new Timer(delay, new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ synchronized(timer) {
+ if (displayCount < polygonData.length) {
+ displayCount++;
+ } else {
+ timer.stop();
+ }
+ repaint();
+ }
+
+ }
+ });
+ timer.setRepeats(true);
+ timer.start();
}
};
frame.setSize({1}, {2} + 20);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|