[Patchanim-commit] SF.net SVN: patchanim: [192] trunk/patchanim/src/com/mebigfatguy/patchanim
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.
|