Thread: [Patchanim-commit] SF.net SVN: patchanim: [192] trunk/patchanim/src/com/mebigfatguy/patchanim (Page 2)
Brought to you by:
dbrosius
From: <dbr...@us...> - 2008-02-15 07:01:51
|
Revision: 192 http://patchanim.svn.sourceforge.net/patchanim/?rev=192&view=rev Author: dbrosius Date: 2008-02-14 22:56:14 -0800 (Thu, 14 Feb 2008) Log Message: ----------- add linear blend menu item Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties Added Paths: ----------- trunk/patchanim/src/com/mebigfatguy/patchanim/BlendDirection.java Added: trunk/patchanim/src/com/mebigfatguy/patchanim/BlendDirection.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/BlendDirection.java (rev 0) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/BlendDirection.java 2008-02-15 06:56:14 UTC (rev 192) @@ -0,0 +1,39 @@ +/* + * patchanim - A bezier surface patch color blend gif builder + * Copyright (C) 2008 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.patchanim; + +import java.util.ResourceBundle; + +import com.mebigfatguy.patchanim.main.PatchAnimBundle; + +public enum BlendDirection { + LeftToRight, + TopToBottom, + RightToLeft, + BottomToTop; + + /** + * returns the localized value of the type + */ + @Override + public String toString() { + ResourceBundle rb = PatchAnimBundle.getBundle(); + return rb.getString(PatchAnimBundle.ROOT + name().toLowerCase()); + } +} Property changes on: trunk/patchanim/src/com/mebigfatguy/patchanim/BlendDirection.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-02-15 06:30:52 UTC (rev 191) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-02-15 06:56:14 UTC (rev 192) @@ -40,6 +40,7 @@ import javax.swing.JPopupMenu; import javax.swing.SwingUtilities; +import com.mebigfatguy.patchanim.BlendDirection; import com.mebigfatguy.patchanim.OutOfBoundsColor; import com.mebigfatguy.patchanim.PatchAnimDocument; import com.mebigfatguy.patchanim.PatchColor; @@ -247,7 +248,42 @@ } }); menu.add(darkenPatch); + + JMenu linearBlend = new JMenu(rb.getString(PatchAnimBundle.LINEARBLEND)); + JMenuItem leftToRight = new JMenuItem(rb.getString(PatchAnimBundle.LEFTTORIGHT)); + leftToRight.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + linearBlend(BlendDirection.LeftToRight); + } + }); + + JMenuItem topToBottom = new JMenuItem(rb.getString(PatchAnimBundle.TOPTOBOTTOM)); + topToBottom.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + linearBlend(BlendDirection.TopToBottom); + } + }); + + JMenuItem rightToLeft = new JMenuItem(rb.getString(PatchAnimBundle.RIGHTTOLEFT)); + rightToLeft.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + linearBlend(BlendDirection.RightToLeft); + } + }); + JMenuItem bottomToTop = new JMenuItem(rb.getString(PatchAnimBundle.BOTTOMTOTOP)); + bottomToTop.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + linearBlend(BlendDirection.BottomToTop); + } + }); + + linearBlend.add(leftToRight); + linearBlend.add(topToBottom); + linearBlend.add(rightToLeft); + linearBlend.add(bottomToTop); + menu.add(linearBlend); + JMenu copy = new JMenu(rb.getString(PatchAnimBundle.COPYPATCHFROM)); if (color != PatchColor.Red) { JMenuItem copyRed = new JMenuItem(rb.getString(PatchAnimBundle.REDPATCH)); @@ -329,6 +365,41 @@ mediator.setNewActivePatch(patch); } + private void linearBlend(BlendDirection direction) { + PatchPanelMediator mediator = PatchPanelMediator.getMediator(); + CombinedPatch patch = mediator.getActivePatch(); + PatchCoords coords = patch.getPatch(color); + int order = coords.getOrder(); + double color = 0.0; + + for (int i = 0; i < order; i++) { + for (int j = 0; j < order; j++) { + Coordinate c = coords.getCoordinate(i, j); + switch (direction) { + case LeftToRight: + color = (255.0 * i) / (order - 1); + break; + + case TopToBottom: + color = (255.0 * j) / (order - 1); + break; + + case RightToLeft: + color = (255.0 * (order - 1 - i)) / (order - 1); + break; + + case BottomToTop: + color = (255.0 * (order - 1 - j)) / (order - 1); + break; + } + + c.setColor(color); + coords.setCoordinate(i, j, c); + } + } + mediator.setNewActivePatch(patch); + } + @Override public void paintComponent(Graphics g) { Shape clip = g.getClip(); Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java 2008-02-15 06:30:52 UTC (rev 191) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java 2008-02-15 06:56:14 UTC (rev 192) @@ -78,6 +78,11 @@ public static final String VALUE="patchanim.value"; public static final String LIGHTENPATCH = "patchanim.lightenpatch"; public static final String DARKENPATCH = "patchanim.darkenpatch"; + public static final String LINEARBLEND = "patchanim.linearblend"; + public static final String LEFTTORIGHT = "patchanim.lefttoright"; + public static final String TOPTOBOTTOM = "patchanim.toptobottom"; + public static final String RIGHTTOLEFT = "patchanim.righttoleft"; + public static final String BOTTOMTOTOP = "patchanim.bottomtotop"; public static final String COPYPATCHFROM = "patchanim.copypatchfrom"; public static final String REDPATCH = "patchanim.redpatch"; public static final String GREENPATCH = "patchanim.greenpatch"; Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-02-15 06:30:52 UTC (rev 191) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-02-15 06:56:14 UTC (rev 192) @@ -71,6 +71,11 @@ patchanim.value = Value... patchanim.lightenpatch = Lighten Patch patchanim.darkenpatch = Darken Patch +patchanim.linearblend = Linear Blend... +patchanim.lefttoright = Left to Right +patchanim.toptobottom = Top to Bottom +patchanim.righttoleft = Right to Left +patchanim.bottomtotop = Bottom to Top patchanim.copypatchfrom = Copy patch from... patchanim.redpatch = Red Patch patchanim.greenpatch = Green Patch This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-02-16 04:25:47
|
Revision: 194 http://patchanim.svn.sourceforge.net/patchanim/?rev=194&view=rev Author: dbrosius Date: 2008-02-15 20:25:53 -0800 (Fri, 15 Feb 2008) Log Message: ----------- add invert to patch context menu Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-02-15 06:59:38 UTC (rev 193) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-02-16 04:25:53 UTC (rev 194) @@ -249,7 +249,7 @@ }); menu.add(darkenPatch); - JMenu linearBlend = new JMenu(rb.getString(PatchAnimBundle.LINEARBLEND)); + JMenu linearBlend = new JMenu(rb.getString(PatchAnimBundle.LINEARGRADIENT)); JMenuItem leftToRight = new JMenuItem(rb.getString(PatchAnimBundle.LEFTTORIGHT)); leftToRight.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { @@ -284,6 +284,14 @@ linearBlend.add(bottomToTop); menu.add(linearBlend); + JMenuItem invert = new JMenuItem(rb.getString(PatchAnimBundle.INVERT)); + invert.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + invertPatch(); + } + }); + menu.add(invert); + JMenu copy = new JMenu(rb.getString(PatchAnimBundle.COPYPATCHFROM)); if (color != PatchColor.Red) { JMenuItem copyRed = new JMenuItem(rb.getString(PatchAnimBundle.REDPATCH)); @@ -317,6 +325,21 @@ menu.show(JPatchSamplePanel.this, me.getX(), me.getY()); } + private void invertPatch() { + PatchPanelMediator mediator = PatchPanelMediator.getMediator(); + CombinedPatch patch = mediator.getActivePatch(); + PatchCoords coords = patch.getPatch(color); + int order = coords.getOrder(); + for (int i = 0; i < order; i++) { + for (int j = 0; j < order; j++) { + Coordinate c = coords.getCoordinate(i, j); + c.setColor(255 - c.getColor()); + coords.setCoordinate(i, j, c); + } + } + mediator.setNewActivePatch(patch); + } + private void copyPatch(PatchColor copyColor) { PatchPanelMediator mediator = PatchPanelMediator.getMediator(); CombinedPatch patch = mediator.getActivePatch(); Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java 2008-02-15 06:59:38 UTC (rev 193) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java 2008-02-16 04:25:53 UTC (rev 194) @@ -78,11 +78,12 @@ public static final String VALUE="patchanim.value"; public static final String LIGHTENPATCH = "patchanim.lightenpatch"; public static final String DARKENPATCH = "patchanim.darkenpatch"; - public static final String LINEARBLEND = "patchanim.linearblend"; + public static final String LINEARGRADIENT = "patchanim.lineargradient"; public static final String LEFTTORIGHT = "patchanim.lefttoright"; public static final String TOPTOBOTTOM = "patchanim.toptobottom"; public static final String RIGHTTOLEFT = "patchanim.righttoleft"; public static final String BOTTOMTOTOP = "patchanim.bottomtotop"; + public static final String INVERT = "patchanim.invert"; public static final String COPYPATCHFROM = "patchanim.copypatchfrom"; public static final String REDPATCH = "patchanim.redpatch"; public static final String GREENPATCH = "patchanim.greenpatch"; Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-02-15 06:59:38 UTC (rev 193) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-02-16 04:25:53 UTC (rev 194) @@ -71,11 +71,12 @@ patchanim.value = Value... patchanim.lightenpatch = Lighten Patch patchanim.darkenpatch = Darken Patch -patchanim.linearblend = Linear Blend... +patchanim.lineargradient = Linear Gradient... patchanim.lefttoright = Left to Right patchanim.toptobottom = Top to Bottom patchanim.righttoleft = Right to Left patchanim.bottomtotop = Bottom to Top +patchanim.invert = Invert patchanim.copypatchfrom = Copy patch from... patchanim.redpatch = Red Patch patchanim.greenpatch = Green Patch This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-02-18 02:31:39
|
Revision: 196 http://patchanim.svn.sourceforge.net/patchanim/?rev=196&view=rev Author: dbrosius Date: 2008-02-17 18:31:45 -0800 (Sun, 17 Feb 2008) Log Message: ----------- fix cycle so that the last frame blends into the first Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JTestFrame.java trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JTestFrame.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JTestFrame.java 2008-02-16 04:35:19 UTC (rev 195) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JTestFrame.java 2008-02-18 02:31:45 UTC (rev 196) @@ -90,8 +90,8 @@ for (int p = 0; p < lastPatch; p++) { CombinedPatch startPatch = patches.get(p); CombinedPatch endPatch = patches.get(p+1); - for (int t = 0; t < tweenCount; t++) { - CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)tweenCount); + for (int t = 0; t < tweenCount + 1; t++) { + CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)(tweenCount + 1)); PatchGenerator.recalcCombinedImage(tweenPatch, image, oob); long now = System.currentTimeMillis(); long sleepTime = 100 - (now - lastRedraw); @@ -102,15 +102,16 @@ } } - if (type == AnimationType.None) - return; - - if (type == AnimationType.Wave) { - for (int p = lastPatch; p > 0; p--) { - CombinedPatch startPatch = patches.get(p-1); - CombinedPatch endPatch = patches.get(p); - for (int t = tweenCount - 1; t >= 0; t--) { - CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)tweenCount); + switch (type) { + case None: { + return; + } + + case Cycle: { + CombinedPatch startPatch = patches.get(lastPatch); + CombinedPatch endPatch = patches.get(0); + for (int t = 0; t <= tweenCount + 1; t++) { + CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)(tweenCount + 1)); PatchGenerator.recalcCombinedImage(tweenPatch, image, oob); long now = System.currentTimeMillis(); long sleepTime = 100 - (now - lastRedraw); @@ -120,6 +121,25 @@ lastRedraw = now; } } + break; + + case Wave: { + for (int p = lastPatch; p > 0; p--) { + CombinedPatch startPatch = patches.get(p-1); + CombinedPatch endPatch = patches.get(p); + for (int t = tweenCount + 1; t > 0; t--) { + CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)(tweenCount + 1)); + PatchGenerator.recalcCombinedImage(tweenPatch, image, oob); + long now = System.currentTimeMillis(); + long sleepTime = 100 - (now - lastRedraw); + if (sleepTime > 0) + Thread.sleep(sleepTime); + testPanel.redraw(); + lastRedraw = now; + } + } + } + break; } } } catch (InterruptedException ie) { Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java 2008-02-16 04:35:19 UTC (rev 195) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java 2008-02-18 02:31:45 UTC (rev 196) @@ -116,25 +116,40 @@ writeSingleFile(image, imageIndex++, loc, baseName, type); } } + + switch (atype) { + case None: { + CombinedPatch patch = patches.get(lastPatch); + PatchGenerator.recalcCombinedImage(patch, image, oob); + writeSingleFile(image, imageIndex++, loc, baseName, type); + if (atype == AnimationType.None) + return; + } + break; - if ((atype == AnimationType.None) || (atype == AnimationType.Cycle)) { - CombinedPatch patch = patches.get(lastPatch); - PatchGenerator.recalcCombinedImage(patch, image, oob); - writeSingleFile(image, imageIndex++, loc, baseName, type); - if (atype == AnimationType.None) - return; - } - - if (atype == AnimationType.Wave) { - for (int p = lastPatch; p > 0; p--) { - CombinedPatch startPatch = patches.get(p-1); - CombinedPatch endPatch = patches.get(p); - for (int t = tweenCount + 1; t > 0; t--) { + case Cycle: { + CombinedPatch startPatch = patches.get(lastPatch); + CombinedPatch endPatch = patches.get(0); + for (int t = 0; t < tweenCount + 1; t++) { CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)(tweenCount + 1)); PatchGenerator.recalcCombinedImage(tweenPatch, image, oob); writeSingleFile(image, imageIndex++, loc, baseName, type); } } + break; + + case Wave: { + for (int p = lastPatch; p > 0; p--) { + CombinedPatch startPatch = patches.get(p-1); + CombinedPatch endPatch = patches.get(p); + for (int t = tweenCount + 1; t > 0; t--) { + CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)(tweenCount + 1)); + PatchGenerator.recalcCombinedImage(tweenPatch, image, oob); + writeSingleFile(image, imageIndex++, loc, baseName, type); + } + } + } + break; } } } finally { @@ -188,10 +203,19 @@ int numPatches = document.getPatches().size(); int total = (numPatches - 1) * document.getTweenCount() + (numPatches - 1); - if (document.getAnimationType() == AnimationType.Wave) - total = total * 2; - else - total++; + switch (document.getAnimationType()) { + case None: + total++; + break; + + case Cycle: + total += document.getTweenCount() + 1; + break; + + case Wave: + total = total * 2; + break; + } return total; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-02-18 03:04:25
|
Revision: 197 http://patchanim.svn.sourceforge.net/patchanim/?rev=197&view=rev Author: dbrosius Date: 2008-02-17 19:04:31 -0800 (Sun, 17 Feb 2008) Log Message: ----------- pull out the patch animation into a separate class and hook in the test pane thru listeners, so that the code can be shared with export. Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JTestFrame.java Added Paths: ----------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/PatchCompletionEvent.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/PatchCompletionListener.java trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchAnimator.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JTestFrame.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JTestFrame.java 2008-02-18 02:31:45 UTC (rev 196) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JTestFrame.java 2008-02-18 03:04:31 UTC (rev 197) @@ -25,7 +25,6 @@ import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; import java.lang.reflect.InvocationTargetException; -import java.util.List; import java.util.ResourceBundle; import javax.swing.JFrame; @@ -33,42 +32,24 @@ import javax.swing.SwingUtilities; import com.mebigfatguy.patchanim.AnimationType; -import com.mebigfatguy.patchanim.OutOfBoundsColor; import com.mebigfatguy.patchanim.PatchAnimDocument; +import com.mebigfatguy.patchanim.gui.events.PatchCompletionEvent; +import com.mebigfatguy.patchanim.gui.events.PatchCompletionListener; import com.mebigfatguy.patchanim.main.PatchAnimBundle; -import com.mebigfatguy.patchanim.surface.CombinedPatch; -import com.mebigfatguy.patchanim.surface.PatchGenerator; +import com.mebigfatguy.patchanim.surface.PatchAnimator; -public class JTestFrame extends JFrame { +public class JTestFrame extends JFrame implements PatchCompletionListener { private static final long serialVersionUID = -7975149184522257748L; private Thread animThread = null; private TestPanel testPanel = null; - private int tweenCount; - private int width; - private int height; - private AnimationType type; - private OutOfBoundsColor oob; - private List<CombinedPatch> patches; - private BufferedImage image; + private PatchAnimDocument document; + private long lastRedraw; public JTestFrame() { PatchPanelMediator mediator = PatchPanelMediator.getMediator(); - PatchAnimDocument document = mediator.getDocument(); - tweenCount = document.getTweenCount(); - width = document.getWidth(); - height = document.getHeight(); - type = document.getAnimationType(); - oob = document.getOutOfBoundsColor(); - patches = document.getPatches(); - - if (width == 0) - width = 100; - if (height == 0) - height = 100; - if (tweenCount == 0) - tweenCount = 1; + document = mediator.getDocument(); initComponents(); initListeners(); @@ -77,73 +58,16 @@ public synchronized void beginAnimation() { if (animThread != null) return; - image = PatchGenerator.buildImage(null, width, height); animThread = new Thread(new Runnable() { public void run() { try { - PatchGenerator.recalcCombinedImage(patches.get(0), image, oob); - while (!Thread.interrupted()) { - testPanel.redraw(); - int lastPatch = patches.size() - 1; - long lastRedraw = System.currentTimeMillis(); - for (int p = 0; p < lastPatch; p++) { - CombinedPatch startPatch = patches.get(p); - CombinedPatch endPatch = patches.get(p+1); - for (int t = 0; t < tweenCount + 1; t++) { - CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)(tweenCount + 1)); - PatchGenerator.recalcCombinedImage(tweenPatch, image, oob); - long now = System.currentTimeMillis(); - long sleepTime = 100 - (now - lastRedraw); - if (sleepTime > 0) - Thread.sleep(sleepTime); - testPanel.redraw(); - lastRedraw = now; - } - } - - switch (type) { - case None: { - return; - } - - case Cycle: { - CombinedPatch startPatch = patches.get(lastPatch); - CombinedPatch endPatch = patches.get(0); - for (int t = 0; t <= tweenCount + 1; t++) { - CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)(tweenCount + 1)); - PatchGenerator.recalcCombinedImage(tweenPatch, image, oob); - long now = System.currentTimeMillis(); - long sleepTime = 100 - (now - lastRedraw); - if (sleepTime > 0) - Thread.sleep(sleepTime); - testPanel.redraw(); - lastRedraw = now; - } - } - break; - - case Wave: { - for (int p = lastPatch; p > 0; p--) { - CombinedPatch startPatch = patches.get(p-1); - CombinedPatch endPatch = patches.get(p); - for (int t = tweenCount + 1; t > 0; t--) { - CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)(tweenCount + 1)); - PatchGenerator.recalcCombinedImage(tweenPatch, image, oob); - long now = System.currentTimeMillis(); - long sleepTime = 100 - (now - lastRedraw); - if (sleepTime > 0) - Thread.sleep(sleepTime); - testPanel.redraw(); - lastRedraw = now; - } - } - } - break; - } - } + PatchAnimator animator = new PatchAnimator(document); + animator.addPatchCompletionListener(JTestFrame.this); + AnimationType type = document.getAnimationType(); + while (type != AnimationType.None) + animator.animatePatches(); } catch (InterruptedException ie) { - //OK } } }); @@ -165,6 +89,15 @@ } } + public void patchCompleted(PatchCompletionEvent pce) throws InterruptedException { + long now = System.currentTimeMillis(); + long sleepTime = 100 - (now - lastRedraw); + if (sleepTime > 0) + Thread.sleep(sleepTime); + testPanel.redraw(pce.getImage()); + lastRedraw = now; + } + private void initComponents() { ResourceBundle rb = PatchAnimBundle.getBundle(); testPanel = new TestPanel(); @@ -185,9 +118,20 @@ } class TestPanel extends JPanel { - private static final long serialVersionUID = 6268304008663415749L; + private static final long serialVersionUID = -6464417075282170562L; + private BufferedImage image = null; + private int width; + private int height; public TestPanel() { + width = document.getWidth(); + height = document.getHeight(); + + if (width == 0) + width = 100; + if (height == 0) + height = 100; + Dimension d = new Dimension(width, height); setMinimumSize(d); setMaximumSize(d); @@ -195,8 +139,9 @@ setSize(width, height); } - public void redraw() throws InterruptedException { + public void redraw(BufferedImage redrawImage) throws InterruptedException { try { + image = redrawImage; SwingUtilities.invokeAndWait(new Runnable() { public void run() { invalidate(); @@ -213,7 +158,8 @@ @Override public void paintComponent(Graphics g) { - g.drawImage(image, 0, 0, width, height, 0, 0, width, height, null); + if (image != null) + g.drawImage(image, 0, 0, width, height, 0, 0, width, height, null); } } } Added: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/PatchCompletionEvent.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/PatchCompletionEvent.java (rev 0) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/PatchCompletionEvent.java 2008-02-18 03:04:31 UTC (rev 197) @@ -0,0 +1,19 @@ +package com.mebigfatguy.patchanim.gui.events; + +import java.awt.image.BufferedImage; +import java.util.EventObject; + +public class PatchCompletionEvent extends EventObject { + + private static final long serialVersionUID = -2446326623721576523L; + private BufferedImage image; + + public PatchCompletionEvent(Object src, BufferedImage animatedImage) { + super(src); + image = animatedImage; + } + + public BufferedImage getImage() { + return image; + } +} Property changes on: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/PatchCompletionEvent.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Added: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/PatchCompletionListener.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/PatchCompletionListener.java (rev 0) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/PatchCompletionListener.java 2008-02-18 03:04:31 UTC (rev 197) @@ -0,0 +1,5 @@ +package com.mebigfatguy.patchanim.gui.events; + +public interface PatchCompletionListener { + void patchCompleted(PatchCompletionEvent pce) throws InterruptedException; +} Property changes on: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/PatchCompletionListener.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Added: trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchAnimator.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchAnimator.java (rev 0) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchAnimator.java 2008-02-18 03:04:31 UTC (rev 197) @@ -0,0 +1,92 @@ +package com.mebigfatguy.patchanim.surface; + +import java.awt.image.BufferedImage; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import com.mebigfatguy.patchanim.AnimationType; +import com.mebigfatguy.patchanim.OutOfBoundsColor; +import com.mebigfatguy.patchanim.PatchAnimDocument; +import com.mebigfatguy.patchanim.gui.events.PatchCompletionEvent; +import com.mebigfatguy.patchanim.gui.events.PatchCompletionListener; + +public class PatchAnimator { + + private Set<PatchCompletionListener> pcListeners = new HashSet<PatchCompletionListener>(); + private PatchAnimDocument document; + + public PatchAnimator(PatchAnimDocument paDocument) { + document = paDocument; + } + + public void addPatchCompletionListener(PatchCompletionListener listener) { + pcListeners.add(listener); + } + + public void animatePatches() throws InterruptedException { + BufferedImage image = PatchGenerator.buildImage(null, document.getWidth(), document.getHeight()); + List<CombinedPatch> patches = document.getPatches(); + int lastPatch = patches.size() - 1; + int tweenCount = document.getTweenCount(); + OutOfBoundsColor oob = document.getOutOfBoundsColor(); + AnimationType atype = document.getAnimationType(); + + if (lastPatch == 0) { + PatchGenerator.recalcCombinedImage(patches.get(0), image, oob); + firePatchCompleted(image); + } else { + for(int p = 0; p < lastPatch; p++) { + CombinedPatch startPatch = patches.get(p); + CombinedPatch endPatch = patches.get(p+1); + for (int t = 0; t < tweenCount + 1; t++) { + CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)(tweenCount + 1)); + PatchGenerator.recalcCombinedImage(tweenPatch, image, oob); + firePatchCompleted(image); + } + } + + switch (atype) { + case None: { + CombinedPatch patch = patches.get(lastPatch); + PatchGenerator.recalcCombinedImage(patch, image, oob); + firePatchCompleted(image); + if (atype == AnimationType.None) + return; + } + break; + + case Cycle: { + CombinedPatch startPatch = patches.get(lastPatch); + CombinedPatch endPatch = patches.get(0); + for (int t = 0; t < tweenCount + 1; t++) { + CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)(tweenCount + 1)); + PatchGenerator.recalcCombinedImage(tweenPatch, image, oob); + firePatchCompleted(image); + } + } + break; + + case Wave: { + for (int p = lastPatch; p > 0; p--) { + CombinedPatch startPatch = patches.get(p-1); + CombinedPatch endPatch = patches.get(p); + for (int t = tweenCount + 1; t > 0; t--) { + CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)(tweenCount + 1)); + PatchGenerator.recalcCombinedImage(tweenPatch, image, oob); + firePatchCompleted(image); + } + } + } + break; + } + } + } + + private void firePatchCompleted(BufferedImage image) throws InterruptedException { + PatchCompletionEvent pce = new PatchCompletionEvent(this, image); + for (PatchCompletionListener listener : pcListeners) { + listener.patchCompleted(pce); + } + } +} Property changes on: trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchAnimator.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: 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...> - 2008-02-18 03:22:35
|
Revision: 199 http://patchanim.svn.sourceforge.net/patchanim/?rev=199&view=rev Author: dbrosius Date: 2008-02-17 19:22:40 -0800 (Sun, 17 Feb 2008) Log Message: ----------- add document name in title bar Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java 2008-02-18 03:16:18 UTC (rev 198) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java 2008-02-18 03:22:40 UTC (rev 199) @@ -27,6 +27,7 @@ import java.awt.event.WindowFocusListener; import java.io.File; import java.io.IOException; +import java.text.MessageFormat; import java.util.ResourceBundle; import javax.swing.ImageIcon; @@ -88,8 +89,10 @@ mediator.setDocument(document); cp.add(patchPanel, BorderLayout.CENTER); - setTitle(rb.getString(PatchAnimBundle.TITLE)); + String title = MessageFormat.format(rb.getString(PatchAnimBundle.NAMEDTITLE), rb.getString(PatchAnimBundle.UNTITLED)); + setTitle(title); + setIconImage(new ImageIcon(JPatchAnimFrame.class.getResource(ICON_URL)).getImage()); pack(); } @@ -204,6 +207,8 @@ saveItem.setEnabled(false); PatchPanelMediator mediator = PatchPanelMediator.getMediator(); mediator.setDocument(document); + String title = MessageFormat.format(rb.getString(PatchAnimBundle.NAMEDTITLE), rb.getString(PatchAnimBundle.UNTITLED)); + setTitle(title); } catch (IOException ioe) { JOptionPane.showMessageDialog(JPatchAnimFrame.this, rb.getString(PatchAnimBundle.SAVEFAILED)); } @@ -222,6 +227,11 @@ } } load(); + + ResourceBundle rb = PatchAnimBundle.getBundle(); + String title = MessageFormat.format(rb.getString(PatchAnimBundle.NAMEDTITLE), documentLocation.getName()); + setTitle(title); + } catch (IOException ioe) { ResourceBundle rb = PatchAnimBundle.getBundle(); JOptionPane.showMessageDialog(JPatchAnimFrame.this, rb.getString(PatchAnimBundle.LOADFAILED)); Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java 2008-02-18 03:16:18 UTC (rev 198) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java 2008-02-18 03:22:40 UTC (rev 199) @@ -24,6 +24,8 @@ public static final String ROOT = "patchanim."; public static final String TITLE = "patchanim.title"; + public static final String NAMEDTITLE = "patchanim.namedtitle"; + public static final String UNTITLED = "patchanim.untitled"; public static final String FILE = "patchanim.file"; public static final String NEW = "patchanim.new"; public static final String OPEN = "patchanim.open"; Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-02-18 03:16:18 UTC (rev 198) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-02-18 03:22:40 UTC (rev 199) @@ -17,6 +17,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ patchanim.title = PatchAnim +patchanim.namedtitle = PatchAnim - {0} +patchanim.untitled = Untitled patchanim.file = File patchanim.new = New patchanim.open = Open... This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-02-18 03:26:01
|
Revision: 202 http://patchanim.svn.sourceforge.net/patchanim/?rev=202&view=rev Author: dbrosius Date: 2008-02-17 19:26:07 -0800 (Sun, 17 Feb 2008) Log Message: ----------- add copyrights Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/ExportType.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/ExportEvent.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/ExportListener.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/PatchCompletionEvent.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/PatchCompletionListener.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/ExportType.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/ExportType.java 2008-02-18 03:24:01 UTC (rev 201) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/ExportType.java 2008-02-18 03:26:07 UTC (rev 202) @@ -1,3 +1,21 @@ +/* + * patchanim - A bezier surface patch color blend gif builder + * Copyright (C) 2008 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ package com.mebigfatguy.patchanim; import com.mebigfatguy.patchanim.main.PatchAnimBundle; Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/ExportEvent.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/ExportEvent.java 2008-02-18 03:24:01 UTC (rev 201) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/ExportEvent.java 2008-02-18 03:26:07 UTC (rev 202) @@ -1,3 +1,21 @@ +/* + * patchanim - A bezier surface patch color blend gif builder + * Copyright (C) 2008 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ package com.mebigfatguy.patchanim.gui.events; import java.util.EventObject; Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/ExportListener.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/ExportListener.java 2008-02-18 03:24:01 UTC (rev 201) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/ExportListener.java 2008-02-18 03:26:07 UTC (rev 202) @@ -1,3 +1,21 @@ +/* + * patchanim - A bezier surface patch color blend gif builder + * Copyright (C) 2008 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ package com.mebigfatguy.patchanim.gui.events; public interface ExportListener { Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/PatchCompletionEvent.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/PatchCompletionEvent.java 2008-02-18 03:24:01 UTC (rev 201) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/PatchCompletionEvent.java 2008-02-18 03:26:07 UTC (rev 202) @@ -1,3 +1,21 @@ +/* + * patchanim - A bezier surface patch color blend gif builder + * Copyright (C) 2008 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ package com.mebigfatguy.patchanim.gui.events; import java.awt.image.BufferedImage; Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/PatchCompletionListener.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/PatchCompletionListener.java 2008-02-18 03:24:01 UTC (rev 201) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/PatchCompletionListener.java 2008-02-18 03:26:07 UTC (rev 202) @@ -1,3 +1,21 @@ +/* + * patchanim - A bezier surface patch color blend gif builder + * Copyright (C) 2008 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ package com.mebigfatguy.patchanim.gui.events; public interface PatchCompletionListener { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-02-18 07:33:59
|
Revision: 207 http://patchanim.svn.sourceforge.net/patchanim/?rev=207&view=rev Author: dbrosius Date: 2008-02-17 23:34:04 -0800 (Sun, 17 Feb 2008) Log Message: ----------- rename oob roll to be cycle, and add roll (wave) Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/OutOfBoundsColor.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchControlPanel.java trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchGenerator.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/OutOfBoundsColor.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/OutOfBoundsColor.java 2008-02-18 06:53:28 UTC (rev 206) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/OutOfBoundsColor.java 2008-02-18 07:34:04 UTC (rev 207) @@ -26,11 +26,13 @@ * denotes how to render colors when they are outside the range of 0 - 255 * <ul> * <li><b>Clip</b> Clip high values to 255, and low values to 0</li> - * <li><b>Roll</b> Use the remainder from the color value and 255 to calculate a value</li> + * <li><b>Cycle</b> Uses the remainder of the color with 255</li> + * <li><b>Roll</b> Inverses the value at 255 and 0</li> * </ul> */ public enum OutOfBoundsColor { Clip, + Cycle, Roll; /** Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchControlPanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchControlPanel.java 2008-02-18 06:53:28 UTC (rev 206) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchControlPanel.java 2008-02-18 07:34:04 UTC (rev 207) @@ -113,6 +113,7 @@ { outOfBoundsLabel = new JLabel(rb.getString(PatchAnimBundle.OUTOFBOUNDSCOLOR)); outOfBoundsColorCB = new JComboBox(new Object[] { OutOfBoundsColor.Clip, + OutOfBoundsColor.Cycle, OutOfBoundsColor.Roll }); outOfBoundsColorCB.setToolTipText(rb.getString(PatchAnimBundle.OUTOFBOUNDSCOLOR_TT)); outOfBoundsLabel.setLabelFor(outOfBoundsColorCB); Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchGenerator.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchGenerator.java 2008-02-18 06:53:28 UTC (rev 206) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchGenerator.java 2008-02-18 07:34:04 UTC (rev 207) @@ -78,19 +78,7 @@ } for (int k = 0; k < 3; k++) { - iValue[k] = (int)value[k]; - if (iValue[k] > 255) { - if (oob == OutOfBoundsColor.Clip) - iValue[k] = 255; - else - iValue[k] = iValue[k] & 0x00FF; - } - else if (iValue[k] < 0) { - if (oob == OutOfBoundsColor.Clip) - iValue[k] = 0; - else - iValue[k] = iValue[k] & 0x00FF; - } + iValue[k] = adjustColor(value[k], oob); } db.setElem(pixel++, iValue[2]); @@ -133,25 +121,40 @@ value += coords.getCoordinate(i, j).getColor() * uCoeffs[i] * vCoeffs[j]; } } - - int iValue = (int)value; - if (iValue > 255) { - if (oob == OutOfBoundsColor.Clip) - iValue = 255; - else - iValue = iValue & 0x00FF; - } - else if (iValue < 0) { - if (oob == OutOfBoundsColor.Clip) - iValue = 0; - else - iValue = iValue & 0x00FF; - } - - db.setElem(pixel++, iValue); + + db.setElem(pixel++, adjustColor(value, oob)); } } } + + private static int adjustColor(double color, OutOfBoundsColor oob) { + int value = (int)color; + if ((value & 0xFFFFFF00) == 0) + return value; + + switch (oob) { + case Clip: + if (value < 0) + value = 0; + else + value = 255; + break; + + case Cycle: + value = value & 0x00FF; + break; + + case Roll: + int period = value / 256; + if ((period & 0x01) != 0) + value = 255 - value & 0x00FF; + else + value = value & 0x00FF; + break; + } + + return value; + } public static BufferedImage buildImage(Color color, int sampleSizeX, int sampleSizeY) { BufferedImage image = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-02-18 17:43:05
|
Revision: 213 http://patchanim.svn.sourceforge.net/patchanim/?rev=213&view=rev Author: dbrosius Date: 2008-02-18 09:43:09 -0800 (Mon, 18 Feb 2008) Log Message: ----------- make oob names more consistent with animation type constants as they are similar Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/OutOfBoundsColor.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchControlPanel.java trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsd trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchGenerator.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/OutOfBoundsColor.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/OutOfBoundsColor.java 2008-02-18 07:58:56 UTC (rev 212) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/OutOfBoundsColor.java 2008-02-18 17:43:09 UTC (rev 213) @@ -33,7 +33,7 @@ public enum OutOfBoundsColor { Clip, Cycle, - Roll; + Wave; /** * returns the localized value of the enum Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchControlPanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchControlPanel.java 2008-02-18 07:58:56 UTC (rev 212) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchControlPanel.java 2008-02-18 17:43:09 UTC (rev 213) @@ -114,7 +114,7 @@ outOfBoundsLabel = new JLabel(rb.getString(PatchAnimBundle.OUTOFBOUNDSCOLOR)); outOfBoundsColorCB = new JComboBox(new Object[] { OutOfBoundsColor.Clip, OutOfBoundsColor.Cycle, - OutOfBoundsColor.Roll }); + OutOfBoundsColor.Wave }); outOfBoundsColorCB.setToolTipText(rb.getString(PatchAnimBundle.OUTOFBOUNDSCOLOR_TT)); outOfBoundsLabel.setLabelFor(outOfBoundsColorCB); JPanel p = Utils.createFormPanel(outOfBoundsLabel, outOfBoundsColorCB); Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsd =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsd 2008-02-18 07:58:56 UTC (rev 212) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsd 2008-02-18 17:43:09 UTC (rev 213) @@ -45,7 +45,7 @@ <xsd:restriction base="xsd:string"> <xsd:enumeration value="Clip"/> <xsd:enumeration value="Cycle"/> - <xsd:enumeration value="Roll"/> + <xsd:enumeration value="Wave"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="ColorClass"> Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java 2008-02-18 07:58:56 UTC (rev 212) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java 2008-02-18 17:43:09 UTC (rev 213) @@ -55,13 +55,14 @@ public static final String HEIGHT_TT = "patchanim.tooltip.height"; public static final String ANIMATION = "patchanim.animation"; public static final String ANIMATION_TT = "patchanim.tooltip.animation"; - public static final String NONE = "patchanim.none"; - public static final String CYCLE = "patchanim.cycle"; - public static final String WAVE = "patchanim.wave"; + public static final String TYPENONE = "patchanim.type.none"; + public static final String TYPECYCLE = "patchanim.type.cycle"; + public static final String TYPEWAVE = "patchanim.type.wave"; public static final String OUTOFBOUNDSCOLOR = "patchanim.outofboundscolor"; public static final String OUTOFBOUNDSCOLOR_TT = "patchanim.tooltip.outofboundscolor"; - public static final String CLIP = "patchanim.clip"; - public static final String ROLL = "patchanim.roll"; + public static final String OOBCLIP = "patchanim.oob.clip"; + public static final String OOBROLL = "patchanim.oob.cycle"; + public static final String OOBWAVE = "patchanim.oob.wave"; public static final String TWEENFRAMES = "patchanim.tween"; public static final String TWEENFRAMES_TT = "patchanim.tooltip.tween"; public static final String TEST = "patchanim.test"; Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-02-18 07:58:56 UTC (rev 212) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-02-18 17:43:09 UTC (rev 213) @@ -48,13 +48,14 @@ patchanim.tooltip.height = The height of the exported animation patchanim.animation = Animation Repeat patchanim.tooltip.animation = The type of repetition that the animation uses -patchanim.none = None -patchanim.cycle = Cycle -patchanim.wave = Wave +patchanim.type.none = None +patchanim.type.cycle = Cycle +patchanim.type.wave = Wave patchanim.outofboundscolor = Out Of Bounds Color patchanim.tooltip.outofboundscolor = How colors that are out of the range of 0 - 255 are handled -patchanim.clip = Clip -patchanim.roll = Roll +patchanim.oob.clip = Clip +patchanim.oob.Cycle = Cycle +patchanim.oob.Wave = Wave patchanim.tween = In-between frames patchanim.tooltip.tween = How many frames are generated as transitions from one patch to the next patchanim.test = Test Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchGenerator.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchGenerator.java 2008-02-18 07:58:56 UTC (rev 212) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchGenerator.java 2008-02-18 17:43:09 UTC (rev 213) @@ -144,7 +144,7 @@ value = value & 0x00FF; break; - case Roll: + case Wave: int period = value / 256; if ((period & 0x01) != 0) { if (value > 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-02-18 18:16:35
|
Revision: 214 http://patchanim.svn.sourceforge.net/patchanim/?rev=214&view=rev Author: dbrosius Date: 2008-02-18 10:16:41 -0800 (Mon, 18 Feb 2008) Log Message: ----------- add radialGradient menu option to patch sample Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/AnimationType.java trunk/patchanim/src/com/mebigfatguy/patchanim/BlendDirection.java trunk/patchanim/src/com/mebigfatguy/patchanim/OutOfBoundsColor.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/AnimationType.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/AnimationType.java 2008-02-18 17:43:09 UTC (rev 213) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/AnimationType.java 2008-02-18 18:16:41 UTC (rev 214) @@ -35,12 +35,13 @@ Cycle, Wave; + private static final String TYPE = "type."; /** * returns the localized value of the type */ @Override public String toString() { ResourceBundle rb = PatchAnimBundle.getBundle(); - return rb.getString(PatchAnimBundle.ROOT + name().toLowerCase()); + return rb.getString(PatchAnimBundle.ROOT + TYPE + name().toLowerCase()); } } Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/BlendDirection.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/BlendDirection.java 2008-02-18 17:43:09 UTC (rev 213) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/BlendDirection.java 2008-02-18 18:16:41 UTC (rev 214) @@ -26,7 +26,9 @@ LeftToRight, TopToBottom, RightToLeft, - BottomToTop; + BottomToTop, + Outward, + Inward; /** * returns the localized value of the type Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/OutOfBoundsColor.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/OutOfBoundsColor.java 2008-02-18 17:43:09 UTC (rev 213) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/OutOfBoundsColor.java 2008-02-18 18:16:41 UTC (rev 214) @@ -35,6 +35,7 @@ Cycle, Wave; + private static final String OOB = "oob."; /** * returns the localized value of the enum * @return the localized display value @@ -42,6 +43,6 @@ @Override public String toString() { ResourceBundle rb = PatchAnimBundle.getBundle(); - return rb.getString(PatchAnimBundle.ROOT + name().toLowerCase()); + return rb.getString(PatchAnimBundle.ROOT + OOB + name().toLowerCase()); } } Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-02-18 17:43:09 UTC (rev 213) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-02-18 18:16:41 UTC (rev 214) @@ -172,6 +172,9 @@ redrawThread = new Thread(new Runnable() { public void run() { + if (oob == null) + oob = OutOfBoundsColor.Clip; + if (color == PatchColor.Combined) { PatchGenerator.recalcCombinedImage(patch, image, oob); } else { @@ -249,40 +252,59 @@ }); menu.add(darkenPatch); - JMenu linearBlend = new JMenu(rb.getString(PatchAnimBundle.LINEARGRADIENT)); + JMenu linearGradient = new JMenu(rb.getString(PatchAnimBundle.LINEARGRADIENT)); JMenuItem leftToRight = new JMenuItem(rb.getString(PatchAnimBundle.LEFTTORIGHT)); leftToRight.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { - linearBlend(BlendDirection.LeftToRight); + linearGradient(BlendDirection.LeftToRight); } }); JMenuItem topToBottom = new JMenuItem(rb.getString(PatchAnimBundle.TOPTOBOTTOM)); topToBottom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { - linearBlend(BlendDirection.TopToBottom); + linearGradient(BlendDirection.TopToBottom); } }); JMenuItem rightToLeft = new JMenuItem(rb.getString(PatchAnimBundle.RIGHTTOLEFT)); rightToLeft.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { - linearBlend(BlendDirection.RightToLeft); + linearGradient(BlendDirection.RightToLeft); } }); JMenuItem bottomToTop = new JMenuItem(rb.getString(PatchAnimBundle.BOTTOMTOTOP)); bottomToTop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { - linearBlend(BlendDirection.BottomToTop); + linearGradient(BlendDirection.BottomToTop); } }); - linearBlend.add(leftToRight); - linearBlend.add(topToBottom); - linearBlend.add(rightToLeft); - linearBlend.add(bottomToTop); - menu.add(linearBlend); + linearGradient.add(leftToRight); + linearGradient.add(topToBottom); + linearGradient.add(rightToLeft); + linearGradient.add(bottomToTop); + menu.add(linearGradient); + + JMenu radialGradient = new JMenu(rb.getString(PatchAnimBundle.RADIALGRADIENT)); + JMenuItem outward = new JMenuItem(rb.getString(PatchAnimBundle.OUTWARD)); + outward.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + radialGradient(BlendDirection.Outward); + } + }); + + JMenuItem inward = new JMenuItem(rb.getString(PatchAnimBundle.INWARD)); + inward.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + radialGradient(BlendDirection.Inward); + } + }); + + radialGradient.add(outward); + radialGradient.add(inward); + menu.add(radialGradient); JMenuItem invert = new JMenuItem(rb.getString(PatchAnimBundle.INVERT)); invert.addActionListener(new ActionListener() { @@ -388,7 +410,7 @@ mediator.setNewActivePatch(patch); } - private void linearBlend(BlendDirection direction) { + private void linearGradient(BlendDirection direction) { PatchPanelMediator mediator = PatchPanelMediator.getMediator(); CombinedPatch patch = mediator.getActivePatch(); PatchCoords coords = patch.getPatch(color); @@ -423,6 +445,35 @@ mediator.setNewActivePatch(patch); } + private void radialGradient(BlendDirection direction) { + PatchPanelMediator mediator = PatchPanelMediator.getMediator(); + CombinedPatch patch = mediator.getActivePatch(); + PatchCoords coords = patch.getPatch(color); + int order = coords.getOrder(); + double color = 0.0; + + double midOrder = (order - 1) / 2.0; + double midOrderSq = midOrder * midOrder; + for (int i = 0; i < order; i++) { + for (int j = 0; j < order; j++) { + Coordinate c = coords.getCoordinate(i, j); + switch (direction) { + case Outward: + color = (double)(int)((255.0 * Math.abs(i - midOrder) * Math.abs(j - midOrder)) / midOrderSq); + break; + + case Inward: + color = (double)(int)(255.0 - (255.0 * (Math.abs(i - midOrder) * Math.abs(j - midOrder))) / midOrderSq); + break; + } + + c.setColor(color); + coords.setCoordinate(i, j, c); + } + } + mediator.setNewActivePatch(patch); + } + @Override public void paintComponent(Graphics g) { Shape clip = g.getClip(); Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java 2008-02-18 17:43:09 UTC (rev 213) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java 2008-02-18 18:16:41 UTC (rev 214) @@ -86,6 +86,9 @@ public static final String TOPTOBOTTOM = "patchanim.toptobottom"; public static final String RIGHTTOLEFT = "patchanim.righttoleft"; public static final String BOTTOMTOTOP = "patchanim.bottomtotop"; + public static final String RADIALGRADIENT = "patchanim.radialgradient"; + public static final String OUTWARD = "patchanim.outward"; + public static final String INWARD = "patchanim.inward"; public static final String INVERT = "patchanim.invert"; public static final String COPYPATCHFROM = "patchanim.copypatchfrom"; public static final String REDPATCH = "patchanim.redpatch"; Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-02-18 17:43:09 UTC (rev 213) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-02-18 18:16:41 UTC (rev 214) @@ -54,8 +54,8 @@ patchanim.outofboundscolor = Out Of Bounds Color patchanim.tooltip.outofboundscolor = How colors that are out of the range of 0 - 255 are handled patchanim.oob.clip = Clip -patchanim.oob.Cycle = Cycle -patchanim.oob.Wave = Wave +patchanim.oob.cycle = Cycle +patchanim.oob.wave = Wave patchanim.tween = In-between frames patchanim.tooltip.tween = How many frames are generated as transitions from one patch to the next patchanim.test = Test @@ -79,6 +79,9 @@ patchanim.toptobottom = Top to Bottom patchanim.righttoleft = Right to Left patchanim.bottomtotop = Bottom to Top +patchanim.radialgradient = Radial Gradient +patchanim.outward = Outward +patchanim.inward = Inward patchanim.invert = Invert patchanim.copypatchfrom = Copy patch from... patchanim.redpatch = Red Patch This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-02-24 02:28:30
|
Revision: 225 http://patchanim.svn.sourceforge.net/patchanim/?rev=225&view=rev Author: dbrosius Date: 2008-02-23 18:28:36 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Stub in support for controlling transparency with patches Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/PatchAnimDocument.java trunk/patchanim/src/com/mebigfatguy/patchanim/PatchColor.java trunk/patchanim/src/com/mebigfatguy/patchanim/ShiftDirection.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimPanel.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsd trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsl trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimExtension.java trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties trunk/patchanim/src/com/mebigfatguy/patchanim/surface/CombinedPatch.java trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchCoords.java trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchGenerator.java Added Paths: ----------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/NewDocumentDialog.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/SourcePatchesPanel.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/PatchAnimDocument.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/PatchAnimDocument.java 2008-02-24 02:25:51 UTC (rev 224) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/PatchAnimDocument.java 2008-02-24 02:28:36 UTC (rev 225) @@ -33,6 +33,7 @@ private boolean dirty; private int order; + private boolean useAlpha; private List<CombinedPatch> patches; private int width; private int height; @@ -43,8 +44,9 @@ /** * constructs a new document for the New menu item */ - public PatchAnimDocument(int patchOrder) { + public PatchAnimDocument(int patchOrder, boolean alpha) { order = patchOrder; + useAlpha = alpha; patches = new ArrayList<CombinedPatch>(); CombinedPatch patch = new CombinedPatch(order, true); patches.add(patch); @@ -80,6 +82,14 @@ } /** + * returns whether to use the alpha channel + * @return the alpha channel option flag + */ + public boolean useAlpha() { + return useAlpha; + } + + /** * retrieves a list of all the bezier patches * @return the list of all the bezier patches */ Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/PatchColor.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/PatchColor.java 2008-02-24 02:25:51 UTC (rev 224) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/PatchColor.java 2008-02-24 02:28:36 UTC (rev 225) @@ -22,5 +22,6 @@ Red, Green, Blue, + Alpha, Combined; } Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/ShiftDirection.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/ShiftDirection.java 2008-02-24 02:25:51 UTC (rev 224) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/ShiftDirection.java 2008-02-24 02:28:36 UTC (rev 225) @@ -1,3 +1,21 @@ +/* + * patchanim - A bezier surface patch color blend gif builder + * Copyright (C) 2008 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ package com.mebigfatguy.patchanim; import java.util.ResourceBundle; Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java 2008-02-24 02:25:51 UTC (rev 224) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java 2008-02-24 02:28:36 UTC (rev 225) @@ -97,14 +97,16 @@ } private void initListeners() { - PatchPanelMediator mediator = PatchPanelMediator.getMediator(); + final PatchPanelMediator mediator = PatchPanelMediator.getMediator(); mediator.addActivePatchChangedListener(new ActivePatchChangedListener() { public void activePatchChanged(ActivePatchChangedEvent apce) { CombinedPatch currentPatch = apce.getActivePatch(); - coords = currentPatch.getPatch(color); - if (coords != null) { - setColorField(false); - sample.recalcImage(color, currentPatch); + if ((color != PatchColor.Alpha) || mediator.getDocument().useAlpha()) { + coords = currentPatch.getPatch(color); + if (coords != null) { + setColorField(false); + sample.recalcImage(color, currentPatch); + } } } }); Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java 2008-02-24 02:25:51 UTC (rev 224) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java 2008-02-24 02:28:36 UTC (rev 225) @@ -83,7 +83,7 @@ cp.setLayout(new BorderLayout(4, 4)); JPatchAnimPanel patchPanel = new JPatchAnimPanel(); - document = new PatchAnimDocument(4); + document = new PatchAnimDocument(4, false); documentLocation = null; PatchPanelMediator mediator = PatchPanelMediator.getMediator(); mediator.setDocument(document); @@ -185,24 +185,15 @@ } } - Integer choice = (Integer)JOptionPane.showInputDialog(JPatchAnimFrame.this, - rb.getString(PatchAnimBundle.SETORDER), - rb.getString(PatchAnimBundle.TITLE), - JOptionPane.QUESTION_MESSAGE, - new ImageIcon(JPatchAnimFrame.this.getIconImage()), - new Object[] { Integer.valueOf(2), - Integer.valueOf(3), - Integer.valueOf(4), - Integer.valueOf(5), - Integer.valueOf(6), - Integer.valueOf(7), - Integer.valueOf(8), - Integer.valueOf(9) }, - Integer.valueOf(4)); - if (choice == null) - choice = Integer.valueOf(4); + NewDocumentDialog newDialog = new NewDocumentDialog(); + newDialog.setModal(true); + newDialog.setLocationRelativeTo(JPatchAnimFrame.this); + newDialog.setVisible(true); - document = new PatchAnimDocument(choice.intValue()); + int order = newDialog.getOrder(); + boolean useAlpha = newDialog.useAlpha(); + + document = new PatchAnimDocument(order, useAlpha); documentLocation = null; saveItem.setEnabled(false); PatchPanelMediator mediator = PatchPanelMediator.getMediator(); @@ -229,7 +220,7 @@ load(); ResourceBundle rb = PatchAnimBundle.getBundle(); - String title = MessageFormat.format(rb.getString(PatchAnimBundle.NAMEDTITLE), documentLocation.getName()); + String title = MessageFormat.format(rb.getString(PatchAnimBundle.NAMEDTITLE), documentLocation == null ? "" : documentLocation.getName()); setTitle(title); } catch (IOException ioe) { @@ -365,7 +356,7 @@ ResourceBundle rb = PatchAnimBundle.getBundle(); JOptionPane.showMessageDialog(JPatchAnimFrame.this, rb.getString(PatchAnimBundle.LOADFAILED)); documentLocation = null; - document = new PatchAnimDocument(4); + document = new PatchAnimDocument(4, false); } finally { PatchPanelMediator mediator = PatchPanelMediator.getMediator(); mediator.setDocument(document); Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimPanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimPanel.java 2008-02-24 02:25:51 UTC (rev 224) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimPanel.java 2008-02-24 02:28:36 UTC (rev 225) @@ -31,6 +31,8 @@ private static final long serialVersionUID = 3030850111559417377L; + private SourcePatchesPanel sourcesPanel; + public JPatchAnimPanel() { initComponents(); } @@ -59,23 +61,9 @@ Utils.sizeUniformly(Utils.Sizing.Width, ctrl, listPanel ); - q = new JPanel(); - { - q.setLayout(new BoxLayout(q, BoxLayout.X_AXIS)); - JColorControlPatchPanel redPatch = new JColorControlPatchPanel(PatchColor.Red); - JColorControlPatchPanel greenPatch = new JColorControlPatchPanel(PatchColor.Green); - JColorControlPatchPanel bluePatch = new JColorControlPatchPanel(PatchColor.Blue); - - q.add(Box.createHorizontalGlue()); - q.add(redPatch); - q.add(Box.createHorizontalStrut(10)); - q.add(greenPatch); - q.add(Box.createHorizontalStrut(10)); - q.add(bluePatch); - q.add(Box.createHorizontalGlue()); - } + sourcesPanel = new SourcePatchesPanel(); - p.add(q, BorderLayout.CENTER); + p.add(sourcesPanel, BorderLayout.CENTER); p.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-02-24 02:25:51 UTC (rev 224) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-02-24 02:28:36 UTC (rev 225) @@ -79,6 +79,8 @@ rgb = Color.green; else if (c == PatchColor.Blue) rgb = Color.blue; + else if (c == PatchColor.Alpha) + rgb = Color.white; else rgb = null; @@ -146,14 +148,16 @@ PatchAnimDocument doc = dce.getDocument(); oob = doc.getOutOfBoundsColor(); PatchPanelMediator mediator = PatchPanelMediator.getMediator(); - recalcImage(color, mediator.getActivePatch()); + if ((color != PatchColor.Alpha) || mediator.getDocument().useAlpha()) + recalcImage(color, mediator.getActivePatch()); } }); mediator.addSettingsChangedListener(new SettingsChangedListener() { public void settingsChanged(SettingsChangedEvent sce) { oob = sce.getDocument().getOutOfBoundsColor(); PatchPanelMediator mediator = PatchPanelMediator.getMediator(); - recalcImage(color, mediator.getActivePatch()); + if ((color != PatchColor.Alpha) || mediator.getDocument().useAlpha()) + recalcImage(color, mediator.getActivePatch()); } }); } Added: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/NewDocumentDialog.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/NewDocumentDialog.java (rev 0) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/NewDocumentDialog.java 2008-02-24 02:28:36 UTC (rev 225) @@ -0,0 +1,142 @@ +/* + * patchanim - A bezier surface patch color blend gif builder + * Copyright (C) 2008 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.patchanim.gui; + +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.ResourceBundle; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.mebigfatguy.patchanim.main.PatchAnimBundle; + +public class NewDocumentDialog extends JDialog { + + private static final long serialVersionUID = 6141957372893989399L; + + private JComboBox orderCombo; + private JCheckBox useAlpha; + private JButton ok; + private JButton cancel; + private boolean isOk = false; + + public NewDocumentDialog() { + initComponents(); + initListeners(); + } + + private void initComponents() { + ResourceBundle rb = PatchAnimBundle.getBundle(); + Container cp = getContentPane(); + setTitle(rb.getString(PatchAnimBundle.NEWDOCUMENT)); + cp.setLayout(new BoxLayout(cp, BoxLayout.Y_AXIS)); + JLabel orderLabel = new JLabel(rb.getString(PatchAnimBundle.SETORDER)); + orderCombo = new JComboBox(new Object[] { Integer.valueOf(2), + Integer.valueOf(3), + Integer.valueOf(4), + Integer.valueOf(5), + Integer.valueOf(6), + Integer.valueOf(7), + Integer.valueOf(8), + Integer.valueOf(9) }); + orderCombo.setSelectedItem(Integer.valueOf(4)); + + JPanel p = new JPanel(); + p.setLayout(new BorderLayout(8, 8)); + p.add(orderLabel, BorderLayout.WEST); + p.add(orderCombo, BorderLayout.CENTER); + p.setBorder(BorderFactory.createEmptyBorder(10, 10, 5, 10)); + cp.add(p); + + useAlpha = new JCheckBox(rb.getString(PatchAnimBundle.USEALPHA)); + p = new JPanel(); + p.setLayout(new BorderLayout(8, 8)); + p.add(useAlpha, BorderLayout.CENTER); + p.setBorder(BorderFactory.createEmptyBorder(10, 10, 5, 10)); + cp.add(p); + + p = new JPanel(); + p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); + p.add(Box.createHorizontalGlue()); + ok = new JButton(rb.getString(PatchAnimBundle.OK)); + p.add(ok); + p.add(Box.createHorizontalStrut(10)); + cancel = new JButton(rb.getString(PatchAnimBundle.CANCEL)); + p.add(cancel); + p.add(Box.createHorizontalGlue()); + p.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + cp.add(p); + + Utils.sizeUniformly(Utils.Sizing.Width, orderCombo, useAlpha); + Utils.sizeUniformly(Utils.Sizing.Width, ok, cancel); + pack(); + } + + private void initListeners() { + ok.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + isOk = true; + dispose(); + } + }); + + cancel.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ae) { + isOk = false; + dispose(); + } + }); + + addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent we) { + isOk = false; + dispose(); + } + }); + } + + public boolean isOk() { + return isOk; + } + + public int getOrder() { + if (isOk) + return ((Integer)orderCombo.getSelectedItem()).intValue(); + return 4; + } + + public boolean useAlpha() { + if (isOk) + return useAlpha.isSelected(); + return false; + } +} Property changes on: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/NewDocumentDialog.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java 2008-02-24 02:25:51 UTC (rev 224) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java 2008-02-24 02:28:36 UTC (rev 225) @@ -47,14 +47,18 @@ return mediator; } public void addDocumentChangedListener(DocumentChangedListener dcl) { - dclisteners.add(dcl); + synchronized(dclisteners) { + dclisteners.add(dcl); + } } public void setDocument(PatchAnimDocument doc) { document = doc; DocumentChangedEvent dce = new DocumentChangedEvent(this, doc); - for (DocumentChangedListener dcl : dclisteners) { - dcl.documentChanged(dce); + synchronized(dclisteners) { + for (DocumentChangedListener dcl : dclisteners) { + dcl.documentChanged(dce); + } } } Added: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/SourcePatchesPanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/SourcePatchesPanel.java (rev 0) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/SourcePatchesPanel.java 2008-02-24 02:28:36 UTC (rev 225) @@ -0,0 +1,90 @@ +/* + * patchanim - A bezier surface patch color blend gif builder + * Copyright (C) 2008 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package com.mebigfatguy.patchanim.gui; + +import java.awt.Container; + +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import com.mebigfatguy.patchanim.PatchColor; +import com.mebigfatguy.patchanim.gui.events.DocumentChangedEvent; +import com.mebigfatguy.patchanim.gui.events.DocumentChangedListener; + +public class SourcePatchesPanel extends JPanel { + + private static final long serialVersionUID = 4186927445084750958L; + + private boolean useAlpha; + JColorControlPatchPanel redPatch; + JColorControlPatchPanel greenPatch; + JColorControlPatchPanel bluePatch; + JColorControlPatchPanel alphaPatch; + + + public SourcePatchesPanel() { + useAlpha = false; + + redPatch = new JColorControlPatchPanel(PatchColor.Red); + greenPatch = new JColorControlPatchPanel(PatchColor.Green); + bluePatch = new JColorControlPatchPanel(PatchColor.Blue); + alphaPatch = new JColorControlPatchPanel(PatchColor.Alpha); + + rebuild(useAlpha); + + PatchPanelMediator mediator = PatchPanelMediator.getMediator(); + mediator.addDocumentChangedListener(new DocumentChangedListener() { + public void documentChanged(DocumentChangedEvent dce) { + rebuild(dce.getDocument().useAlpha()); + } + }); + } + + public void rebuild(final boolean useAlpha) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + Container c = SourcePatchesPanel.this.getParent(); + if (c != null) + c.invalidate(); + removeAll(); + setLayout(new BoxLayout(SourcePatchesPanel.this, BoxLayout.X_AXIS)); + add(Box.createHorizontalGlue()); + add(redPatch); + add(Box.createHorizontalStrut(10)); + add(greenPatch); + add(Box.createHorizontalStrut(10)); + add(bluePatch); + if (useAlpha) { + add(Box.createHorizontalStrut(10)); + add(alphaPatch); + } + add(Box.createHorizontalGlue()); + invalidate(); + revalidate(); + if (c != null) { + c.invalidate(); + c.repaint(); + } + + } + }); + } +} Property changes on: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/SourcePatchesPanel.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsd =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsd 2008-02-24 02:25:51 UTC (rev 224) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsd 2008-02-24 02:28:36 UTC (rev 225) @@ -27,6 +27,7 @@ <xsd:attribute name="version" type="xsd:string" use="required"/> </xsd:complexType> <xsd:complexType name="SettingsClass"> + <xsd:attribute name="alpha" type="xsd:boolean" default="false"/> <xsd:attribute name="animationType" type="AnimationTypeClass" use="required"/> <xsd:attribute name="height" type="xsd:integer" use="required"/> <xsd:attribute name="order" type="xsd:positiveInteger" default="4"/> @@ -50,9 +51,10 @@ </xsd:simpleType> <xsd:simpleType name="ColorClass"> <xsd:restriction base="xsd:string"> + <xsd:enumeration value="Red"/> <xsd:enumeration value="Green"/> <xsd:enumeration value="Blue"/> - <xsd:enumeration value="Red"/> + <xsd:enumeration value="Alpha"/> </xsd:restriction> </xsd:simpleType> <xsd:complexType name="CoordinateClass"> @@ -68,7 +70,7 @@ </xsd:complexType> <xsd:complexType name="CombinedPatchClass"> <xsd:sequence> - <xsd:element maxOccurs="3" minOccurs="3" name="Patch" type="PatchClass"/> + <xsd:element maxOccurs="4" minOccurs="3" name="Patch" type="PatchClass"/> </xsd:sequence> <xsd:attribute name="name" type="NameClass" use="required"/> </xsd:complexType> Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsl =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsl 2008-02-24 02:25:51 UTC (rev 224) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimDoc.xsl 2008-02-24 02:28:36 UTC (rev 225) @@ -40,6 +40,9 @@ <xsl:attribute name="order"> <xsl:value-of select="pae:getOrder($ext)"/> </xsl:attribute> + <xsl:attribute name="alpha"> + <xsl:value-of select="pae:useAlpha($ext)"/> + </xsl:attribute> <xsl:attribute name="width"> <xsl:value-of select="pae:getWidth($ext)"/> </xsl:attribute> @@ -108,6 +111,23 @@ </Coordinate> </xsl:for-each> </Patch> + <xsl:if test="pae:useAlpha($ext)='true'"> + <Patch color="Alpha"> + <xsl:for-each select="pae:getCoordinates($ext)"> + <Coordinate> + <xsl:attribute name="x"> + <xsl:value-of select="pae:getX($ext, 'Alpha', $patchIndex, .)"/> + </xsl:attribute> + <xsl:attribute name="y"> + <xsl:value-of select="pae:getY($ext, 'Alpha', $patchIndex, .)"/> + </xsl:attribute> + <xsl:attribute name="color"> + <xsl:value-of select="pae:getColor($ext, 'Alpha', $patchIndex, .)"/> + </xsl:attribute> + </Coordinate> + </xsl:for-each> + </Patch> + </xsl:if> </CombinedPatch> </xsl:for-each> </Patches> Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimExtension.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimExtension.java 2008-02-24 02:25:51 UTC (rev 224) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimExtension.java 2008-02-24 02:28:36 UTC (rev 225) @@ -83,6 +83,10 @@ return String.valueOf(paDoc.getTweenCount()); } + public String useAlpha(@SuppressWarnings("unused") ExpressionContext context) { + return String.valueOf(paDoc.useAlpha()); + } + public NodeList getPatches(@SuppressWarnings("unused") ExpressionContext context) { return new NodeList() { Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java 2008-02-24 02:25:51 UTC (rev 224) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java 2008-02-24 02:28:36 UTC (rev 225) @@ -112,6 +112,7 @@ static class PatchAnimDocContentHandler extends DefaultHandler { private static final String SETTINGS = "Settings"; private static final String ORDER = "order"; + private static final String ALPHA = "alpha"; private static final String WIDTH = "width"; private static final String HEIGHT = "height"; private static final String ANIMATIONTYPE = "animationType"; @@ -135,7 +136,8 @@ public void startElement(String uri, String localName, String qName, Attributes atts) { if (SETTINGS.equals(localName)) { int order = Integer.parseInt(atts.getValue(ORDER)); - doc = new PatchAnimDocument(order); + boolean alpha = Boolean.parseBoolean(atts.getValue(ALPHA)); + doc = new PatchAnimDocument(order, alpha); doc.getPatches().clear(); doc.setWidth(Integer.parseInt(atts.getValue(WIDTH))); doc.setHeight(Integer.parseInt(atts.getValue(HEIGHT))); Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java 2008-02-24 02:25:51 UTC (rev 224) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java 2008-02-24 02:28:36 UTC (rev 225) @@ -47,7 +47,11 @@ public static final String EXPORTINGFILE = "patchanim.exportfile"; public static final String QUIT = "patchanim.quit"; public static final String CONTROLS = "patchanim.control"; + public static final String NEWDOCUMENT = "patchanim.newdocument"; public static final String SETORDER = "patchanim.setorder"; + public static final String USEALPHA = "patchanim.usealpha"; + public static final String OK = "patchanim.ok"; + public static final String CANCEL = "patchanim.cancel"; public static final String PATCHES = "patchanim.patches"; public static final String WIDTH = "patchanim.width"; public static final String WIDTH_TT = "patchanim.tooltip.width"; Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-02-24 02:25:51 UTC (rev 224) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-02-24 02:28:36 UTC (rev 225) @@ -40,7 +40,11 @@ patchanim.exportfile = Exporting Animation patchanim.quit = Quit patchanim.control = Controls +patchanim.newdocument = New PatchAnim document settings patchanim.setorder = Set the order of the patches to +patchanim.usealpha = Use Alpha channel (transparency) +patchanim.ok = OK +patchanim.cancel = Cancel patchanim.patches = Patches patchanim.width = Width patchanim.tooltip.width = The width of the exported animation Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/surface/CombinedPatch.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/surface/CombinedPatch.java 2008-02-24 02:25:51 UTC (rev 224) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/surface/CombinedPatch.java 2008-02-24 02:28:36 UTC (rev 225) @@ -24,6 +24,7 @@ import java.util.ResourceBundle; import com.mebigfatguy.patchanim.PatchColor; +import com.mebigfatguy.patchanim.gui.PatchPanelMediator; import com.mebigfatguy.patchanim.main.PatchAnimBundle; public class CombinedPatch implements Serializable, Cloneable { @@ -37,19 +38,22 @@ patches.put(PatchColor.Red, PatchCoords.buildRandomPatch(order)); patches.put(PatchColor.Green, PatchCoords.buildRandomPatch(order)); patches.put(PatchColor.Blue, PatchCoords.buildRandomPatch(order)); + patches.put(PatchColor.Alpha, PatchCoords.buildFullColorPatch(order)); } else { patches.put(PatchColor.Red, new PatchCoords(order)); patches.put(PatchColor.Green, new PatchCoords(order)); patches.put(PatchColor.Blue, new PatchCoords(order)); + patches.put(PatchColor.Alpha, new PatchCoords(order)); } ResourceBundle rb = PatchAnimBundle.getBundle(); name = rb.getString(PatchAnimBundle.DEFAULTPATCHNAME); } - public CombinedPatch(PatchCoords redPatch, PatchCoords greenPatch, PatchCoords bluePatch) { + public CombinedPatch(PatchCoords redPatch, PatchCoords greenPatch, PatchCoords bluePatch, PatchCoords alphaPatch) { patches.put(PatchColor.Red, redPatch); patches.put(PatchColor.Green, greenPatch); patches.put(PatchColor.Blue, bluePatch); + patches.put(PatchColor.Alpha, alphaPatch); } @Override @@ -82,6 +86,14 @@ PatchCoords eBlueCoords = endPatch.getPatch(PatchColor.Blue); tweenPatch.setPatch(PatchColor.Blue, PatchCoords.tween(sBlueCoords, eBlueCoords, frac)); } + + PatchPanelMediator mediator = PatchPanelMediator.getMediator(); + if (mediator.getDocument().useAlpha()) + { + PatchCoords sAlphaCoords = startPatch.getPatch(PatchColor.Alpha); + PatchCoords eAlphaCoords = endPatch.getPatch(PatchColor.Alpha); + tweenPatch.setPatch(PatchColor.Alpha, PatchCoords.tween(sAlphaCoords, eAlphaCoords, frac)); + } return tweenPatch; } Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchCoords.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchCoords.java 2008-02-24 02:25:51 UTC (rev 224) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchCoords.java 2008-02-24 02:28:36 UTC (rev 225) @@ -39,6 +39,16 @@ return new PatchCoords(patchOrder, coords); } + public static PatchCoords buildFullColorPatch(int patchOrder) { + Coordinate[][] coords = new Coordinate[patchOrder][patchOrder]; + for (int u = 0; u < patchOrder; u++) { + for (int v = 0; v < patchOrder; v++) { + coords[u][v] = new Coordinate((u * 100.0) / (patchOrder - 1), (v * 100.0) / (patchOrder - 1), 255); + } + } + return new PatchCoords(patchOrder, coords); + } + public PatchCoords(int patchOrder) { order = patchOrder; coords = new Coordinate[patchOrder][patchOrder]; Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchGenerator.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchGenerator.java 2008-02-24 02:25:51 UTC (rev 224) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchGenerator.java 2008-02-24 02:28:36 UTC (rev 225) @@ -97,6 +97,9 @@ int pixel = 0; PatchCoords coords = patch.getPatch(color); + if (coords.getCoordinate(0, 0) == null) + return; + int order = coords.getOrder(); double u; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-02-24 02:49:04
|
Revision: 226 http://patchanim.svn.sourceforge.net/patchanim/?rev=226&view=rev Author: dbrosius Date: 2008-02-23 18:49:10 -0800 (Sat, 23 Feb 2008) Log Message: ----------- transparency seems to be mostly working Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchAnimator.java trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchGenerator.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-02-24 02:28:36 UTC (rev 225) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-02-24 02:49:10 UTC (rev 226) @@ -95,7 +95,7 @@ } private void initComponents() { - image = PatchGenerator.buildImage(rgb, SAMPLE_SIZE, SAMPLE_SIZE); + image = PatchGenerator.buildImage(rgb, false, SAMPLE_SIZE, SAMPLE_SIZE); setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); Dimension d = new Dimension(SAMPLE_SIZE, SAMPLE_SIZE); setMinimumSize(d); @@ -146,6 +146,7 @@ mediator.addDocumentChangedListener(new DocumentChangedListener() { public void documentChanged(DocumentChangedEvent dce) { PatchAnimDocument doc = dce.getDocument(); + image = PatchGenerator.buildImage(rgb, doc.useAlpha(), SAMPLE_SIZE, SAMPLE_SIZE); oob = doc.getOutOfBoundsColor(); PatchPanelMediator mediator = PatchPanelMediator.getMediator(); if ((color != PatchColor.Alpha) || mediator.getDocument().useAlpha()) Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchAnimator.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchAnimator.java 2008-02-24 02:28:36 UTC (rev 225) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchAnimator.java 2008-02-24 02:49:10 UTC (rev 226) @@ -43,7 +43,7 @@ } public void animatePatches() throws InterruptedException { - BufferedImage image = PatchGenerator.buildImage(null, document.getWidth(), document.getHeight()); + BufferedImage image = PatchGenerator.buildImage(null, document.useAlpha(), document.getWidth(), document.getHeight()); List<CombinedPatch> patches = document.getPatches(); int lastPatch = patches.size() - 1; int tweenCount = document.getTweenCount(); Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchGenerator.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchGenerator.java 2008-02-24 02:28:36 UTC (rev 225) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/surface/PatchGenerator.java 2008-02-24 02:49:10 UTC (rev 226) @@ -37,23 +37,27 @@ if (patch == null) return; + int numComponents = image.getColorModel().getNumComponents(); + boolean useAlpha = numComponents == 4; + WritableRaster wr = image.getRaster(); DataBuffer db = wr.getDataBuffer(); int pixel = 0; - PatchCoords[] coords = new PatchCoords[3]; + PatchCoords[] coords = new PatchCoords[4]; coords[0] = patch.getPatch(PatchColor.Red); coords[1] = patch.getPatch(PatchColor.Green); coords[2] = patch.getPatch(PatchColor.Blue); + coords[3] = patch.getPatch(PatchColor.Alpha); int order = coords[0].getOrder(); double u; double v; double[] uCoeffs = new double[order]; double[] vCoeffs = new double[order]; - double[] value = new double[3]; - int[] iValue = new int[3]; + double[] value = new double[4]; + int[] iValue = new int[4]; int sampleSizeX = image.getWidth(); int sampleSizeY = image.getHeight(); @@ -66,21 +70,23 @@ u = (double)iu / (double)sampleSizeX; buildCoefficients(u, uCoeffs); - value[0] = value[1] = value[2] = 0.0; + value[0] = value[1] = value[2] = value[3] = 0.0; for (int j = 0; j < order; j++) { for (int i = 0; i < order; i++) { double coeff = uCoeffs[i] * vCoeffs[j]; - value[0] += coords[0].getCoordinate(i, j).getColor() * coeff; - value[1] += coords[1].getCoordinate(i, j).getColor() * coeff; - value[2] += coords[2].getCoordinate(i, j).getColor() * coeff; + for (int k = 0; k < numComponents; k++) { + value[k] += coords[k].getCoordinate(i, j).getColor() * coeff; + } } } - for (int k = 0; k < 3; k++) { + for (int k = 0; k < numComponents; k++) { iValue[k] = adjustColor(value[k], oob); } + if (useAlpha) + db.setElem(pixel++, iValue[3]); db.setElem(pixel++, iValue[2]); db.setElem(pixel++, iValue[1]); db.setElem(pixel++, iValue[0]); @@ -167,11 +173,11 @@ return value; } - public static BufferedImage buildImage(Color color, int sampleSizeX, int sampleSizeY) { + public static BufferedImage buildImage(Color color, boolean useAlpha, int sampleSizeX, int sampleSizeY) { BufferedImage image = null; if (color == null) { - image = new BufferedImage(sampleSizeX, sampleSizeY, BufferedImage.TYPE_3BYTE_BGR); + image = new BufferedImage(sampleSizeX, sampleSizeY, useAlpha ? BufferedImage.TYPE_4BYTE_ABGR : BufferedImage.TYPE_3BYTE_BGR); } else { byte[] r = new byte[256]; byte[] g = new byte[256]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-02-24 16:07:22
|
Revision: 238 http://patchanim.svn.sourceforge.net/patchanim/?rev=238&view=rev Author: dbrosius Date: 2008-02-24 08:07:24 -0800 (Sun, 24 Feb 2008) Log Message: ----------- put file filter string in resources strings Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchAnimFileFilter.java trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchAnimFileFilter.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchAnimFileFilter.java 2008-02-24 16:05:05 UTC (rev 237) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchAnimFileFilter.java 2008-02-24 16:07:24 UTC (rev 238) @@ -19,9 +19,12 @@ package com.mebigfatguy.patchanim.gui; import java.io.File; +import java.util.ResourceBundle; import javax.swing.filechooser.FileFilter; +import com.mebigfatguy.patchanim.main.PatchAnimBundle; + public class PatchAnimFileFilter extends FileFilter { @Override public boolean accept(File f) { @@ -32,6 +35,7 @@ @Override public String getDescription() { - return "PatchAnim Files (*.paf)"; + ResourceBundle rb = PatchAnimBundle.getBundle(); + return rb.getString(PatchAnimBundle.FILEFILTER); } } Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java 2008-02-24 16:05:05 UTC (rev 237) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java 2008-02-24 16:07:24 UTC (rev 238) @@ -31,6 +31,7 @@ public static final String OPEN = "patchanim.open"; public static final String SAVE = "patchanim.save"; public static final String SAVEAS = "patchanim.saveas"; + public static final String FILEFILTER = "patchanim.patchanimfilter"; public static final String EXPORT = "patchanim.export"; public static final String JPGSERIES = "patchanim.jpgs"; public static final String JPGSERIESFILTER = "patchanim.filter.jpgs"; Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-02-24 16:05:05 UTC (rev 237) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-02-24 16:07:24 UTC (rev 238) @@ -24,6 +24,7 @@ patchanim.open = Open... patchanim.save = Save patchanim.saveas = Save As... +patchanim.patchanimfilter = PatchAnim Files (*.paf) patchanim.export = Export As... patchanim.jpgs = a series of JPGs patchanim.filter.jpgs = Files (*.jpg) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |