[Pixelle-commit] SF.net SVN: pixelle:[319] trunk/pixelle
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2012-03-11 17:06:10
|
Revision: 319
http://pixelle.svn.sourceforge.net/pixelle/?rev=319&view=rev
Author: dbrosius
Date: 2012-03-11 17:06:02 +0000 (Sun, 11 Mar 2012)
Log Message:
-----------
merge from github repository
Modified Paths:
--------------
trunk/pixelle/.classpath
trunk/pixelle/build.xml
trunk/pixelle/etc/Pixelle.g
trunk/pixelle/src/com/mebigfatguy/pixelle/Pixelle.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleBundle.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleFrame.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java
trunk/pixelle/src/com/mebigfatguy/pixelle/actions/NewFileAction.java
trunk/pixelle/src/com/mebigfatguy/pixelle/actions/OpenFileAction.java
trunk/pixelle/src/com/mebigfatguy/pixelle/actions/TransformAction.java
trunk/pixelle/src/com/mebigfatguy/pixelle/dialogs/AlgorithmEditor.java
trunk/pixelle/src/com/mebigfatguy/pixelle/dialogs/PixelleOptionsDialog.java
trunk/pixelle/src/com/mebigfatguy/pixelle/resources/pixelle.properties
Modified: trunk/pixelle/.classpath
===================================================================
--- trunk/pixelle/.classpath 2012-01-16 00:00:58 UTC (rev 318)
+++ trunk/pixelle/.classpath 2012-03-11 17:06:02 UTC (rev 319)
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="lib" path="lib/antlr-2.7.7.jar"/>
- <classpathentry kind="lib" path="lib/asm-3.1.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib" path="lib/antlr-3.1.3.jar"/>
- <classpathentry kind="lib" path="lib/antlr-runtime-3.1.3.jar"/>
- <classpathentry kind="lib" path="lib/stringtemplate-3.2.1.jar"/>
+ <classpathentry kind="lib" path="lib/antlr-3.4.jar"/>
+ <classpathentry kind="lib" path="lib/antlr-runtime-3.4.jar"/>
+ <classpathentry kind="lib" path="lib/asm-3.3.1.jar"/>
+ <classpathentry kind="lib" path="lib/stringtemplate-4.0.2.jar"/>
<classpathentry kind="output" path="classes"/>
</classpath>
Modified: trunk/pixelle/build.xml
===================================================================
--- trunk/pixelle/build.xml 2012-01-16 00:00:58 UTC (rev 318)
+++ trunk/pixelle/build.xml 2012-03-11 17:06:02 UTC (rev 319)
@@ -38,13 +38,11 @@
<property name="pixelle.version" value="1.1.0"/>
- <property name="antlr-old.version" value="2.7.7"/>
- <property name="antlr.version" value="3.1.3"/>
- <property name="antlr-runtime.version" value="3.1.3"/>
- <property name="stringtemplate.version" value="3.2.1"/>
- <property name="asm.version" value="3.1"/>
+ <property name="antlr.version" value="3.4"/>
+ <property name="antlr-runtime.version" value="3.4"/>
+ <property name="stringtemplate.version" value="4.0.2"/>
+ <property name="asm.version" value="3.3.1"/>
- <property name="antlr-old-url" value="http://repo1.maven.org/maven2/antlr/antlr/${antlr-old.version}/antlr-${antlr-old.version}.jar"/>
<property name="antlr-url" value="http://repo1.maven.org/maven2/org/antlr/antlr/${antlr.version}/antlr-${antlr.version}.jar"/>
<property name="antlr-runtime-url" value="http://repo1.maven.org/maven2/org/antlr/antlr-runtime/${antlr-runtime.version}/antlr-runtime-${antlr-runtime.version}.jar"/>
<property name="stringtemplate-url" value="http://repo1.maven.org/maven2/org/antlr/stringtemplate/${stringtemplate.version}/stringtemplate-${stringtemplate.version}.jar"/>
@@ -76,10 +74,6 @@
<echo message="pixelle.version = ${pixelle.version}" file="${src.dir}/com/mebigfatguy/pixelle/resources/version.properties"/>
</target>
- <target name="antlr-old-check">
- <available file="${basedir}/lib/antlr-${antlr-old.version}.jar" property="antlr-old-exists"/>
- </target>
-
<target name="antlr-check">
<available file="${basedir}/lib/antlr-${antlr.version}.jar" property="antlr-exists"/>
</target>
@@ -96,10 +90,6 @@
<available file="${basedir}/lib/asm-${asm.version}.jar" property="asm-exists"/>
</target>
- <target name="install-antlr-old" depends="antlr-old-check" unless="antlr-old-exists" description="installs antlr-old.jar into lib">
- <get src="${antlr-old-url}" dest="${basedir}/lib/antlr-${antlr-old.version}.jar" verbose="true" ignoreerrors="true"/>
- </target>
-
<target name="install-antlr" depends="antlr-check" unless="antlr-exists" description="installs antlr.jar into lib">
<get src="${antlr-url}" dest="${basedir}/lib/antlr-${antlr.version}.jar" verbose="true" ignoreerrors="true"/>
</target>
@@ -116,12 +106,12 @@
<get src="${asm-url}" dest="${basedir}/lib/asm-${asm.version}.jar" verbose="true" ignoreerrors="true"/>
</target>
- <target name="pull" depends="install-antlr-old, install-antlr, install-antlr-runtime, install-stringtemplate, install-asm" description="pull 3rdparty jars to the lib directory"/>
+ <target name="pull" depends="install-antlr, install-antlr-runtime, install-stringtemplate, install-asm" description="pull 3rdparty jars to the lib directory"/>
<target name="-gen" depends="pull" description="generate antlr files">
<exec executable="java" failonerror="true">
<arg value="-classpath"/>
- <arg value="${lib.dir}/antlr-${antlr-old.version}.jar:${lib.dir}/antlr-${antlr.version}.jar:${lib.dir}/antlr-runtime-${antlr-runtime.version}.jar:${lib.dir}/stringtemplate-${stringtemplate.version}.jar"/>
+ <arg value="${lib.dir}/antlr-${antlr.version}.jar:${lib.dir}/antlr-runtime-${antlr-runtime.version}.jar:${lib.dir}/stringtemplate-${stringtemplate.version}.jar"/>
<arg value="org.antlr.Tool"/>
<arg value="-target"/>
<arg value="${etc.dir}/Pixelle.g"/>
Modified: trunk/pixelle/etc/Pixelle.g
===================================================================
--- trunk/pixelle/etc/Pixelle.g 2012-01-16 00:00:58 UTC (rev 318)
+++ trunk/pixelle/etc/Pixelle.g 2012-03-11 17:06:02 UTC (rev 319)
@@ -1,6 +1,6 @@
/*
* pixelle - Graphics algorithmic editor
- * Copyright (C) 2008 Dave Brosius
+ * Copyright (C) 2008-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -44,10 +44,16 @@
cw.visitField(Opcodes.ACC_PRIVATE, "width", "I", null, Integer.valueOf(0));
cw.visitField(Opcodes.ACC_PRIVATE, "height", "I", null, Integer.valueOf(0));
+ cw.visitField(Opcodes.ACC_PRIVATE, "stack", "Ljava/util/List;", "Ljava/lang/List<Ljava/lang/Double;>;", null);
mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, new String[0]);
mv.visitVarInsn(Opcodes.ALOAD, 0);
mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
+ mv.visitVarInsn(Opcodes.ALOAD, 0);
+ mv.visitTypeInsn(Opcodes.NEW, "java/util/ArrayList");
+ mv.visitInsn(Opcodes.DUP);
+ mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/util/ArrayList", "<init>", "()V");
+ mv.visitFieldInsn(Opcodes.PUTFIELD, clz, "stack", "Ljava/util/List;");
mv.visitInsn(Opcodes.RETURN);
mv.visitMaxs(0,0);
@@ -275,8 +281,8 @@
}
)* ;
-unaryExpression :
- '!' unaryExpression
+unaryExpression
+ : '!' unaryExpression
{
Label falseLabel = new Label();
Label continueLabel = new Label();
@@ -296,129 +302,355 @@
| factor ;
factor
- : NUMBER
+ : NUMBER
{
mv.visitLdcInsn(Double.valueOf($NUMBER.text));
}
| '(' expr ')'
- | 'p'
- {
- mv.visitVarInsn(Opcodes.ALOAD, 1);
- }
- ( '(' selector=expr ')' )?
- {
- if ($selector.text == null)
- mv.visitInsn(Opcodes.ICONST_0);
- else
- {
- mv.visitInsn(Opcodes.D2I);
- mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "abs", "(I)I");
- }
+ | functionExpr
+ | specialExpr
+ | pixelExpr
+ | locationExpr;
+
+pixelExpr
+ : P
+ {
+ mv.visitVarInsn(Opcodes.ALOAD, 1);
+ }
+ ( '(' selector=expr ')' )?
+ {
+ if ($selector.text == null)
+ mv.visitInsn(Opcodes.ICONST_0);
+ else
+ {
+ mv.visitInsn(Opcodes.D2I);
+ mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "abs", "(I)I");
+ }
- mv.visitVarInsn(Opcodes.ILOAD, 4);
- mv.visitInsn(Opcodes.IREM);
- mv.visitInsn(Opcodes.AALOAD);
- }
- '[' expr
- {
- mv.visitInsn(Opcodes.D2I);
- }
- ',' expr
- {
- mv.visitInsn(Opcodes.D2I);
- }
- ']' '.' spec=('r'|'g'|'b'|'t'|'s')
- {
- String s = $spec.text;
- mv.visitLdcInsn(Character.valueOf(s.charAt(0)));
- mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "com/mebigfatguy/pixelle/PixelleEval", "getValue", "(IIC)D" );
- }
- | 'x'
- {
- mv.visitVarInsn(Opcodes.ILOAD, 2);
- mv.visitInsn(Opcodes.I2D);
- }
- | 'y'
- {
- mv.visitVarInsn(Opcodes.ILOAD, 3);
- mv.visitInsn(Opcodes.I2D);
- }
- | 'width'
- {
- mv.visitVarInsn(Opcodes.ALOAD, 0);
- mv.visitFieldInsn(Opcodes.GETFIELD, clz, "width", "I");
- mv.visitInsn(Opcodes.I2D);
- }
- | 'height'
- {
- mv.visitVarInsn(Opcodes.ALOAD, 0);
- mv.visitFieldInsn(Opcodes.GETFIELD, clz, "height", "I");
- mv.visitInsn(Opcodes.I2D);
- }
- | 'abs' '(' expr ')'
- {
- mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "abs", "(D)D");
- }
- | 'max' '(' expr ',' expr ')'
- {
- mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "max", "(DD)D");
- }
- | 'min' '(' expr ',' expr ')'
- {
- mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "min", "(DD)D");
- }
- | 'pow' '(' expr ',' expr ')'
- {
- mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "pow", "(DD)D");
- }
- | 'sqrt' '(' expr ')'
- {
- mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "sqrt", "(D)D");
- }
- | 'sin' '(' expr ')'
- {
- mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "sin", "(D)D");
- }
- | 'cos' '(' expr ')'
- {
- mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "cos", "(D)D");
- }
- | 'tan' '(' expr ')'
- {
- mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "tan", "(D)D");
- }
- | 'asin' '(' expr ')'
- {
- mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "asin", "(D)D");
- }
- | 'acos' '(' expr ')'
- {
- mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "acos", "(D)D");
- }
- | 'atan' '(' expr ')'
- {
- mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "atan", "(D)D");
- }
- | 'log' '(' expr ')'
- {
- mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "log", "(D)D");
- }
- | 'exp' '(' expr ')'
- {
- mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "exp", "(D)D");
- }
- | 'e' '(' ')'
- {
- mv.visitLdcInsn(Double.valueOf(Math.E));
- }
- | 'pi' '(' ')'
- {
- mv.visitLdcInsn(Double.valueOf(Math.PI));
- }
- | 'random' '(' ')'
- {
- mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "random", "()D");
- } ;
+ mv.visitVarInsn(Opcodes.ILOAD, 4);
+ mv.visitInsn(Opcodes.IREM);
+ mv.visitInsn(Opcodes.AALOAD);
+ }
+ '[' expr
+ {
+ mv.visitInsn(Opcodes.D2I);
+ }
+ ',' expr
+ {
+ mv.visitInsn(Opcodes.D2I);
+ }
+ ']' '.' spec=(R|G|B|T|S)
+ {
+ String s = $spec.text;
+ mv.visitLdcInsn(Character.valueOf(s.charAt(0)));
+ mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "com/mebigfatguy/pixelle/PixelleEval", "getValue", "(IIC)D" );
+ };
+
+locationExpr
+ : X
+ {
+ mv.visitVarInsn(Opcodes.ILOAD, 2);
+ mv.visitInsn(Opcodes.I2D);
+ }
+ | Y
+ {
+ mv.visitVarInsn(Opcodes.ILOAD, 3);
+ mv.visitInsn(Opcodes.I2D);
+ }
+ | WIDTH
+ {
+ mv.visitVarInsn(Opcodes.ALOAD, 0);
+ mv.visitFieldInsn(Opcodes.GETFIELD, clz, "width", "I");
+ mv.visitInsn(Opcodes.I2D);
+ }
+ | HEIGHT
+ {
+ mv.visitVarInsn(Opcodes.ALOAD, 0);
+ mv.visitFieldInsn(Opcodes.GETFIELD, clz, "height", "I");
+ mv.visitInsn(Opcodes.I2D);
+ };
+
+functionExpr
+ : ABS '(' expr ')'
+ {
+ mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "abs", "(D)D");
+ }
+ | MAX '(' expr ',' expr ')'
+ {
+ mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "max", "(DD)D");
+ }
+ | MIN '(' expr ',' expr ')'
+ {
+ mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "min", "(DD)D");
+ }
+ | POW '(' expr ',' expr ')'
+ {
+ mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "pow", "(DD)D");
+ }
+ | SQRT '(' expr ')'
+ {
+ mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "sqrt", "(D)D");
+ }
+ | SIN '(' expr ')'
+ {
+ mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "sin", "(D)D");
+ }
+ | COS '(' expr ')'
+ {
+ mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "cos", "(D)D");
+ }
+ | TAN '(' expr ')'
+ {
+ mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "tan", "(D)D");
+ }
+ | ASIN '(' expr ')'
+ {
+ mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "asin", "(D)D");
+ }
+ | ACOS '(' expr ')'
+ {
+ mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "acos", "(D)D");
+ }
+ | ATAN '(' expr ')'
+ {
+ mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "atan", "(D)D");
+ }
+ | LOG '(' expr ')'
+ {
+ mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "log", "(D)D");
+ }
+ | EXP '(' expr ')'
+ {
+ mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "exp", "(D)D");
+ }
+ | E '(' ')'
+ {
+ mv.visitLdcInsn(Double.valueOf(Math.E));
+ }
+ | PI '(' ')'
+ {
+ mv.visitLdcInsn(Double.valueOf(Math.PI));
+ }
+ | RANDOM '(' ')'
+ {
+ mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Math", "random", "()D");
+ } ;
+
+specialExpr
+ @init
+ {
+ Label leftLabel = null;
+ Label rightLabel = null;
+ Label topLabel = null;
+ Label bottomLabel = null;
+ Label failureLabel = null;
+ Label successLabel = null;
+ Label exitLabel = null;
+ }
+ : PIXELINRECT '(' expr ',' expr ',' expr ',' expr ')'
+ {
+ exitLabel = new Label();
+ leftLabel = new Label();
+ rightLabel = new Label();
+ topLabel = new Label();
+ bottomLabel = new Label();
+ successLabel = new Label();
+
+ mv.visitLabel(rightLabel);
+ mv.visitVarInsn(Opcodes.ILOAD, 3);
+ mv.visitInsn(Opcodes.I2D);
+ mv.visitInsn(Opcodes.DCMPG);
+ mv.visitJumpInsn(Opcodes.IFGE, bottomLabel);
+ mv.visitInsn(Opcodes.POP2);
+ mv.visitInsn(Opcodes.POP2);
+ mv.visitInsn(Opcodes.POP2);
+ mv.visitInsn(Opcodes.DCONST_0);
+ mv.visitJumpInsn(Opcodes.GOTO, exitLabel);
+
+ mv.visitLabel(bottomLabel);
+ mv.visitVarInsn(Opcodes.ILOAD, 2);
+ mv.visitInsn(Opcodes.I2D);
+ mv.visitInsn(Opcodes.DCMPG);
+ mv.visitJumpInsn(Opcodes.IFGE, leftLabel);
+ mv.visitInsn(Opcodes.POP2);
+ mv.visitInsn(Opcodes.POP2);
+ mv.visitInsn(Opcodes.DCONST_0);
+ mv.visitJumpInsn(Opcodes.GOTO, exitLabel);
+
+ mv.visitLabel(leftLabel);
+ mv.visitVarInsn(Opcodes.ILOAD, 3);
+ mv.visitInsn(Opcodes.I2D);
+ mv.visitInsn(Opcodes.DCMPG);
+ mv.visitJumpInsn(Opcodes.IFLT, topLabel);
+ mv.visitInsn(Opcodes.POP2);
+ mv.visitInsn(Opcodes.DCONST_0);
+ mv.visitJumpInsn(Opcodes.GOTO, exitLabel);
+
+ mv.visitLabel(topLabel);
+ mv.visitVarInsn(Opcodes.ILOAD, 2);
+ mv.visitInsn(Opcodes.I2D);
+ mv.visitInsn(Opcodes.DCMPG);
+ mv.visitJumpInsn(Opcodes.IFLT, successLabel);
+ mv.visitInsn(Opcodes.DCONST_0);
+ mv.visitJumpInsn(Opcodes.GOTO, exitLabel);
+
+ mv.visitLabel(successLabel);
+ mv.visitInsn(Opcodes.DCONST_1);
+ mv.visitLabel(exitLabel);
+ }
+ | PIXELINCIRCLE '(' expr ',' expr ',' expr ')'
+ {
+ successLabel = new Label();
+ exitLabel = new Label();
+
+ mv.visitInsn(Opcodes.DUP2);
+ mv.visitInsn(Opcodes.DMUL);
+ mv.visitVarInsn(Opcodes.ALOAD, 0);
+ mv.visitFieldInsn(Opcodes.GETFIELD, clz, "stack", "Ljava/util/List;");
+ mv.visitInsn(Opcodes.DUP_X2);
+ mv.visitInsn(Opcodes.POP);
+ mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;");
+ mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "add", "(Ljava/lang/Object;)Z");
+ mv.visitInsn(Opcodes.POP);
+
+ mv.visitVarInsn(Opcodes.ILOAD, 3);
+ mv.visitInsn(Opcodes.I2D);
+ mv.visitInsn(Opcodes.DSUB);
+ mv.visitInsn(Opcodes.DUP2);
+ mv.visitInsn(Opcodes.DMUL);
+ mv.visitInsn(Opcodes.DUP2_X2);
+ mv.visitInsn(Opcodes.POP2);
+
+ mv.visitVarInsn(Opcodes.ILOAD, 2);
+ mv.visitInsn(Opcodes.I2D);
+ mv.visitInsn(Opcodes.DSUB);
+ mv.visitInsn(Opcodes.DUP2);
+ mv.visitInsn(Opcodes.DMUL);
+ mv.visitInsn(Opcodes.DADD);
+
+ mv.visitVarInsn(Opcodes.ALOAD, 0);
+ mv.visitFieldInsn(Opcodes.GETFIELD, clz, "stack", "Ljava/util/List;");
+ mv.visitInsn(Opcodes.DUP);
+ mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "size", "()I");
+ mv.visitInsn(Opcodes.ICONST_1);
+ mv.visitInsn(Opcodes.ISUB);
+ mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "remove", "(I)Ljava/lang/Object;");
+ mv.visitTypeInsn(Opcodes.CHECKCAST, "java/lang/Double");
+ mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Double", "doubleValue", "()D");
+ mv.visitInsn(Opcodes.DCMPG);
+ mv.visitJumpInsn(Opcodes.IFLT, successLabel);
+ mv.visitInsn(Opcodes.DCONST_0);
+ mv.visitJumpInsn(Opcodes.GOTO, exitLabel);
+
+ mv.visitLabel(successLabel);
+ mv.visitInsn(Opcodes.DCONST_1);
+ mv.visitLabel(exitLabel);
+ }
+ | PIXELONEDGE '(' expr ')'
+ {
+ exitLabel = new Label();
+ leftLabel = new Label();
+ rightLabel = new Label();
+ topLabel = new Label();
+ bottomLabel = new Label();
+ failureLabel = new Label();
+
+ mv.visitLabel(leftLabel);
+ mv.visitInsn(Opcodes.DUP2);
+ mv.visitVarInsn(Opcodes.ILOAD, 2);
+ mv.visitInsn(Opcodes.I2D);
+ mv.visitInsn(Opcodes.DCMPG);
+ mv.visitJumpInsn(Opcodes.IFLE, rightLabel);
+ mv.visitInsn(Opcodes.POP2);
+ mv.visitInsn(Opcodes.DCONST_1);
+ mv.visitJumpInsn(Opcodes.GOTO, exitLabel);
+
+ mv.visitLabel(rightLabel);
+ mv.visitInsn(Opcodes.DUP2);
+ mv.visitVarInsn(Opcodes.ALOAD, 0);
+ mv.visitFieldInsn(Opcodes.GETFIELD, clz, "width", "I");
+ mv.visitInsn(Opcodes.I2D);
+ mv.visitInsn(Opcodes.DSUB);
+ mv.visitInsn(Opcodes.DNEG);
+ mv.visitVarInsn(Opcodes.ILOAD, 2);
+ mv.visitInsn(Opcodes.I2D);
+ mv.visitInsn(Opcodes.DCMPG);
+ mv.visitJumpInsn(Opcodes.IFGE, topLabel);
+ mv.visitInsn(Opcodes.POP2);
+ mv.visitInsn(Opcodes.DCONST_1);
+ mv.visitJumpInsn(Opcodes.GOTO, exitLabel);
+
+ mv.visitLabel(topLabel);
+ mv.visitInsn(Opcodes.DUP2);
+ mv.visitVarInsn(Opcodes.ILOAD, 3);
+ mv.visitInsn(Opcodes.I2D);
+ mv.visitInsn(Opcodes.DCMPG);
+ mv.visitJumpInsn(Opcodes.IFLE, bottomLabel);
+ mv.visitInsn(Opcodes.POP2);
+ mv.visitInsn(Opcodes.DCONST_1);
+ mv.visitJumpInsn(Opcodes.GOTO, exitLabel);
+
+ mv.visitLabel(bottomLabel);
+ mv.visitInsn(Opcodes.DUP2);
+ mv.visitVarInsn(Opcodes.ALOAD, 0);
+ mv.visitFieldInsn(Opcodes.GETFIELD, clz, "height", "I");
+ mv.visitInsn(Opcodes.I2D);
+ mv.visitInsn(Opcodes.DSUB);
+ mv.visitInsn(Opcodes.DNEG);
+ mv.visitVarInsn(Opcodes.ILOAD, 3);
+ mv.visitInsn(Opcodes.I2D);
+ mv.visitInsn(Opcodes.DCMPG);
+ mv.visitJumpInsn(Opcodes.IFGE, failureLabel);
+ mv.visitInsn(Opcodes.POP2);
+ mv.visitInsn(Opcodes.DCONST_1);
+ mv.visitJumpInsn(Opcodes.GOTO, exitLabel);
+
+ mv.visitLabel(failureLabel);
+ mv.visitInsn(Opcodes.POP2);
+ mv.visitInsn(Opcodes.DCONST_0);
+
+ mv.visitLabel(exitLabel);
+ }
+ | PIXELAVERAGE '(' expr ',' expr ',' expr ')'
+ {
+ mv.visitInsn(Opcodes.POP);
+ mv.visitInsn(Opcodes.POP);
+ mv.visitInsn(Opcodes.POP);
+ mv.visitInsn(Opcodes.DCONST_0);
+ } ;
+
+
+ABS : 'ABS';
+MAX : 'MAX';
+MIN : 'MIN';
+POW : 'POW';
+SQRT : 'SQRT';
+SIN : 'SIN';
+COS : 'COS';
+TAN : 'TAN';
+ASIN : 'ASIN';
+ACOS : 'ACOS';
+ATAN : 'ATAN';
+LOG : 'LOG';
+EXP : 'EXP';
+E : 'E';
+PI : 'PI';
+RANDOM : 'RANDOM';
+PIXELINRECT : 'PIXELINRECT';
+PIXELINCIRCLE : 'PIXELINCIRCLE';
+PIXELONEDGE : 'PIXELONEDGE';
+PIXELAVERAGE : 'PIXELAVERAGE';
+X : 'X';
+Y : 'Y';
+WIDTH : 'WIDTH';
+HEIGHT : 'HEIGHT';
+P : 'P';
+R : 'R';
+G : 'G';
+B : 'B';
+T : 'T';
+S : 'S';
+
NUMBER : '0'..'9'+ ( '.' ('0'..'9'+))?;
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/Pixelle.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/Pixelle.java 2012-01-16 00:00:58 UTC (rev 318)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/Pixelle.java 2012-03-11 17:06:02 UTC (rev 319)
@@ -42,6 +42,7 @@
String title = MessageFormat.format(PixelleBundle.getString(PixelleBundle.TITLE), PixelleBundle.getString(PixelleBundle.UNTITLED));
pf.setTitle(title);
Rectangle bounds = GuiUtils.getScreenBounds();
+ bounds.grow(-200, -200);
pf.setBounds(bounds);
pf.setVisible(true);
} catch (PixelleTransformException pte) {
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleBundle.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleBundle.java 2012-01-16 00:00:58 UTC (rev 318)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleBundle.java 2012-03-11 17:06:02 UTC (rev 319)
@@ -142,6 +142,11 @@
public static final String E = "label.e";
public static final String PI = "label.pi";
public static final String RANDOM = "label.random";
+ public static final String SPECIAL = "label.special";
+ public static final String PIXEL_IN_RECT = "label.pixelInRect";
+ public static final String PIXEL_IN_CIRCLE = "label.pixelInCircle";
+ public static final String PIXEL_ON_EDGE = "label.pixelOnEdge";
+ public static final String PIXEL_AVERAGE = "label.pixelAverage";
private static ResourceBundle rb = ResourceBundle.getBundle("com/mebigfatguy/pixelle/resources/pixelle");
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleFrame.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleFrame.java 2012-01-16 00:00:58 UTC (rev 318)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleFrame.java 2012-03-11 17:06:02 UTC (rev 319)
@@ -276,6 +276,10 @@
}
}
+ public ZoomLevel getZoom() {
+ return panel.getZoom();
+ }
+
public final void setZoom(final ZoomLevel zoom) {
panel.setZoom(zoom);
panel.invalidate();
@@ -373,6 +377,10 @@
}
}
+ public ZoomLevel getZoom() {
+ return zoom;
+ }
+
public void setZoom(ZoomLevel zoomLevel) {
zoom = zoomLevel;
}
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java 2012-01-16 00:00:58 UTC (rev 318)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleTransformer.java 2012-03-11 17:06:02 UTC (rev 319)
@@ -116,7 +116,7 @@
currentComponent = entry.getKey().name();
currentAlgorithm = entry.getValue();
- CharStream cs = new ANTLRStringStream(currentAlgorithm);
+ CharStream cs = new ANTLRCaseInsensitiveStringStream(currentAlgorithm);
PixelleLexer pl = new PixelleLexer(cs);
CommonTokenStream tokens = new CommonTokenStream();
tokens.setTokenSource(pl);
@@ -179,5 +179,27 @@
}
}
}
+
+ class ANTLRCaseInsensitiveStringStream extends ANTLRStringStream
+ {
+ public ANTLRCaseInsensitiveStringStream(String text) throws IOException {
+ super(text);
+ }
+
+ public int LA(int i) {
+ if ( i==0 ) {
+ return 0;
+ }
+ if ( i<0 ) {
+ i++;
+ }
+
+ if ( (p+i-1) >= n ) {
+
+ return CharStream.EOF;
+ }
+ return Character.toUpperCase(data[p+i-1]);
+ }
+ }
}
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/actions/NewFileAction.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/actions/NewFileAction.java 2012-01-16 00:00:58 UTC (rev 318)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/actions/NewFileAction.java 2012-03-11 17:06:02 UTC (rev 319)
@@ -18,6 +18,7 @@
*/
package com.mebigfatguy.pixelle.actions;
+import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
@@ -45,7 +46,9 @@
public void actionPerformed(ActionEvent e) {
try {
PixelleFrame pf = new PixelleFrame();
- pf.setBounds(GuiUtils.getScreenBounds());
+ Rectangle bounds = GuiUtils.getScreenBounds();
+ bounds.grow(-200, -200);
+ pf.setBounds(bounds);
pf.setVisible(true);
FrameMgr.getInstance().add(pf);
} catch (PixelleTransformException pte) {
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/actions/OpenFileAction.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/actions/OpenFileAction.java 2012-01-16 00:00:58 UTC (rev 318)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/actions/OpenFileAction.java 2012-03-11 17:06:02 UTC (rev 319)
@@ -1,6 +1,6 @@
/*
* pixelle - Graphics algorithmic editor
- * Copyright (C) 2008 Dave Brosius
+ * Copyright (C) 2008-2012 Dave Brosius
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -18,6 +18,7 @@
*/
package com.mebigfatguy.pixelle.actions;
+import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.io.File;
import java.util.Locale;
@@ -80,7 +81,9 @@
lastDir = f.getParentFile();
PixelleFrame pf = new PixelleFrame();
pf.openFile(f);
- pf.setBounds(GuiUtils.getScreenBounds());
+ Rectangle bounds = GuiUtils.getScreenBounds();
+ bounds.grow(-200, -200);
+ pf.setBounds(bounds);
pf.setVisible(true);
FrameMgr.getInstance().add(pf);
} catch (PixelleTransformException pte) {
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/actions/TransformAction.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/actions/TransformAction.java 2012-01-16 00:00:58 UTC (rev 318)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/actions/TransformAction.java 2012-03-11 17:06:02 UTC (rev 319)
@@ -18,6 +18,7 @@
*/
package com.mebigfatguy.pixelle.actions;
+import java.awt.Point;
import java.awt.event.ActionEvent;
import java.text.MessageFormat;
@@ -59,6 +60,12 @@
if (dstImage != null) {
if (frame.createNewWindow()) {
PixelleFrame f = new PixelleFrame(dstImage);
+ f.setSize(frame.getSize());
+ Point location = frame.getLocation();
+ location.x += 20;
+ location.y += 20;
+ f.setLocation(location);
+ f.setZoom(((PixelleFrame) frame).getZoom());
String title = MessageFormat.format(PixelleBundle.getString(PixelleBundle.TITLE), PixelleBundle.getString(PixelleBundle.UNTITLED));
f.setTitle(title);
f.setVisible(true);
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/dialogs/AlgorithmEditor.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/dialogs/AlgorithmEditor.java 2012-01-16 00:00:58 UTC (rev 318)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/dialogs/AlgorithmEditor.java 2012-03-11 17:06:02 UTC (rev 319)
@@ -248,6 +248,19 @@
functionMenu.add(randomItem);
shortcuts.add(functionMenu);
+
+ JMenu specialMenu = new JMenu(PixelleBundle.getString(PixelleBundle.SPECIAL));
+ JMenuItem pixelInRectItem = new JMenuItem(PixelleBundle.getString(PixelleBundle.PIXEL_IN_RECT));
+ JMenuItem pixelInCircleItem = new JMenuItem(PixelleBundle.getString(PixelleBundle.PIXEL_IN_CIRCLE));
+ JMenuItem pixelOnEdgeItem = new JMenuItem(PixelleBundle.getString(PixelleBundle.PIXEL_ON_EDGE));
+ JMenuItem pixelAverageItem = new JMenuItem(PixelleBundle.getString(PixelleBundle.PIXEL_AVERAGE));
+
+ specialMenu.add(pixelInRectItem);
+ specialMenu.add(pixelInCircleItem);
+ specialMenu.add(pixelOnEdgeItem);
+ specialMenu.add(pixelAverageItem);
+
+ shortcuts.add(specialMenu);
addSimpleShortCutListener(redSpecItem, "p(0)[x,y].r");
addSimpleShortCutListener(greenSpecItem, "p(0)[x,y].g");
@@ -294,6 +307,11 @@
addSimpleShortCutListener(eItem, "e()");
addSimpleShortCutListener(piItem, "pi()");
addSimpleShortCutListener(randomItem, "random()");
+
+ addSimpleShortCutListener(pixelInRectItem, "pixelInRect(t,l,b.r)");
+ addSimpleShortCutListener(pixelInCircleItem, "pixelInCircle(x,y,r)");
+ addSimpleShortCutListener(pixelOnEdgeItem, "pixelOnEdge(e)");
+ addSimpleShortCutListener(pixelOnEdgeItem, "pixelAverage(x,y,s)");
}
private void addSimpleShortCutListener(JMenuItem mi, final String sc) {
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/dialogs/PixelleOptionsDialog.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/dialogs/PixelleOptionsDialog.java 2012-01-16 00:00:58 UTC (rev 318)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/dialogs/PixelleOptionsDialog.java 2012-03-11 17:06:02 UTC (rev 319)
@@ -31,10 +31,11 @@
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
-import javax.swing.JCheckBox;
import javax.swing.JColorChooser;
import javax.swing.JDialog;
import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.border.EmptyBorder;
import com.mebigfatguy.pixelle.ColorOutOfBoundsOption;
import com.mebigfatguy.pixelle.IndexOutOfBoundsOption;
@@ -46,14 +47,14 @@
private static final long serialVersionUID = -2593224982080676492L;
- private JCheckBox colorBox = new JCheckBox(PixelleBundle.getString(PixelleBundle.STATIC_COLOR));
- private JCheckBox borderColorBox = new JCheckBox(PixelleBundle.getString(PixelleBundle.BORDER_COLOR));
- private JCheckBox wrappedColorBox = new JCheckBox(PixelleBundle.getString(PixelleBundle.WRAPPED_COLOR));
+ private JRadioButton colorRadio = new JRadioButton(PixelleBundle.getString(PixelleBundle.STATIC_COLOR));
+ private JRadioButton borderColorRadio = new JRadioButton(PixelleBundle.getString(PixelleBundle.BORDER_COLOR));
+ private JRadioButton wrappedColorRadio = new JRadioButton(PixelleBundle.getString(PixelleBundle.WRAPPED_COLOR));
private ColorButton colorButton = new ColorButton(Color.WHITE);
- private JCheckBox clipBox = new JCheckBox(PixelleBundle.getString(PixelleBundle.CLIP_COLOR));
- private JCheckBox rollBox = new JCheckBox(PixelleBundle.getString(PixelleBundle.ROLL_COLOR));
- private JCheckBox waveBox = new JCheckBox(PixelleBundle.getString(PixelleBundle.WAVE_COLOR));
+ private JRadioButton clipRadio = new JRadioButton(PixelleBundle.getString(PixelleBundle.CLIP_COLOR));
+ private JRadioButton rollRadio = new JRadioButton(PixelleBundle.getString(PixelleBundle.ROLL_COLOR));
+ private JRadioButton waveRadio = new JRadioButton(PixelleBundle.getString(PixelleBundle.WAVE_COLOR));
private JButton ok = new JButton(PixelleBundle.getString(PixelleBundle.OK));
private JButton cancel = new JButton(PixelleBundle.getString(PixelleBundle.CANCEL));
@@ -73,18 +74,18 @@
}
public boolean isOK() {
- if (clipBox.isSelected())
+ if (clipRadio.isSelected())
coobOption = ColorOutOfBoundsOption.Clip;
- else if (rollBox.isSelected())
+ else if (rollRadio.isSelected())
coobOption = ColorOutOfBoundsOption.Roll;
else
coobOption = ColorOutOfBoundsOption.Wave;
- if (colorBox.isSelected()) {
+ if (colorRadio.isSelected()) {
ioobOption = IndexOutOfBoundsOption.SpecifiedColor;
ioobOption.setColor(color);
}
- else if (borderColorBox.isSelected())
+ else if (borderColorRadio.isSelected())
ioobOption = IndexOutOfBoundsOption.BorderColor;
else
ioobOption = IndexOutOfBoundsOption.WrapColor;
@@ -101,90 +102,93 @@
private void initComponents() {
Container cp = getContentPane();
- cp.setLayout(new BoxLayout(cp, BoxLayout.Y_AXIS));
- cp.add(Box.createVerticalStrut(5));
+ JPanel mainPanel = new JPanel();
+ mainPanel.setBorder(new EmptyBorder(10, 10, 5, 10));
+ mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
+
+ mainPanel.add(Box.createVerticalStrut(5));
{
JPanel p = new JPanel();
p.setLayout(new GridLayout(3, 1));
p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), PixelleBundle.getString(PixelleBundle.COLOR_OUT_OF_BOUNDS_PIXELS)));
- GuiUtils.sizeUniformly(GuiUtils.Sizing.Height, clipBox, rollBox, waveBox);
+ GuiUtils.sizeUniformly(GuiUtils.Sizing.Height, clipRadio, rollRadio, waveRadio);
- p.add(clipBox);
- p.add(rollBox);
- p.add(waveBox);
+ p.add(clipRadio);
+ p.add(rollRadio);
+ p.add(waveRadio);
ButtonGroup g = new ButtonGroup();
- g.add(clipBox);
- g.add(rollBox);
- g.add(waveBox);
+ g.add(clipRadio);
+ g.add(rollRadio);
+ g.add(waveRadio);
switch (coobOption) {
case Clip:
- clipBox.setSelected(true);
+ clipRadio.setSelected(true);
break;
case Roll:
- rollBox.setSelected(true);
+ rollRadio.setSelected(true);
break;
case Wave:
- waveBox.setSelected(true);
+ waveRadio.setSelected(true);
break;
}
- cp.add(p);
+ mainPanel.add(p);
}
- cp.add(Box.createVerticalStrut(5));
- cp.add(Box.createVerticalGlue());
+ mainPanel.add(Box.createVerticalStrut(5));
+ mainPanel.add(Box.createVerticalGlue());
{
JPanel p = new JPanel();
p.setLayout(new GridLayout(3, 1));
p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), PixelleBundle.getString(PixelleBundle.INDEX_OUT_OF_BOUNDS_PIXELS)));
- GuiUtils.sizeUniformly(GuiUtils.Sizing.Height, colorBox, colorButton, borderColorBox, wrappedColorBox);
+ GuiUtils.sizeUniformly(GuiUtils.Sizing.Height, colorRadio, colorButton, borderColorRadio, wrappedColorRadio);
colorButton.setColor(color);
JPanel colorP = new JPanel();
colorP.setLayout(new BoxLayout(colorP, BoxLayout.X_AXIS));
- colorP.add(colorBox);
+ colorP.add(colorRadio);
colorP.add(Box.createHorizontalStrut(5));
colorP.add(colorButton);
colorP.add(Box.createHorizontalGlue());
p.add(colorP);
- p.add(borderColorBox);
- p.add(wrappedColorBox);
+ p.add(borderColorRadio);
+ p.add(wrappedColorRadio);
ButtonGroup g = new ButtonGroup();
- g.add(colorBox);
- g.add(borderColorBox);
- g.add(wrappedColorBox);
+ g.add(colorRadio);
+ g.add(borderColorRadio);
+ g.add(wrappedColorRadio);
switch (ioobOption) {
case SpecifiedColor:
- colorBox.setSelected(true);
+ colorRadio.setSelected(true);
break;
case BorderColor:
- borderColorBox.setSelected(true);
+ borderColorRadio.setSelected(true);
break;
case WrapColor:
- wrappedColorBox.setSelected(true);
+ wrappedColorRadio.setSelected(true);
break;
}
- cp.add(p);
+ mainPanel.add(p);
}
- cp.add(Box.createVerticalStrut(5));
- cp.add(Box.createVerticalGlue());
+ mainPanel.add(Box.createVerticalStrut(5));
+ mainPanel.add(Box.createVerticalGlue());
{
JPanel p = new JPanel();
@@ -197,10 +201,12 @@
p.add(Box.createHorizontalStrut(10));
p.add(cancel);
p.add(Box.createHorizontalGlue());
- cp.add(p);
+ mainPanel.add(p);
}
- cp.add(Box.createVerticalStrut(5));
+ mainPanel.add(Box.createVerticalStrut(5));
+
+ cp.add(mainPanel);
}
private void initListeners() {
@@ -228,7 +234,7 @@
colorButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
- colorBox.setSelected(true);
+ colorRadio.setSelected(true);
Color chosenColor = JColorChooser.showDialog(PixelleOptionsDialog.this, PixelleBundle.getString(PixelleBundle.PICK_COLOR), color);
if (chosenColor != null) {
color = chosenColor;
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/resources/pixelle.properties
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/resources/pixelle.properties 2012-01-16 00:00:58 UTC (rev 318)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/resources/pixelle.properties 2012-03-11 17:06:02 UTC (rev 319)
@@ -94,7 +94,6 @@
label.x = x
label.y = y
-label.color = color
tooltip.inspector = Click in the frame's window to freeze the inspector value, and click again to unfreeze
@@ -156,4 +155,12 @@
label.pi = pi()
label.random = random()
+label.special = Special
+label.pixelInRect = pixelInRect(t, l, b, r)
+label.pixelInCircle = pixelInCircle(cx, cy, r)
+label.pixelOnEdge = pixelOnEdge(e)
+label.pixelAverage = pixelAverage(x, y, s)
+
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|