[Patchanim-commit] SF.net SVN: patchanim: [51] trunk/patchanim/src/com/mebigfatguy/patchanim
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2008-01-28 07:48:25
|
Revision: 51
http://patchanim.svn.sourceforge.net/patchanim/?rev=51&view=rev
Author: dbrosius
Date: 2008-01-27 23:48:31 -0800 (Sun, 27 Jan 2008)
Log Message:
-----------
add context menu to patches to bulk set all ctrl points to either black, fullcolor or custom value
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-01-28 02:45:47 UTC (rev 50)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-01-28 07:48:31 UTC (rev 51)
@@ -23,18 +23,28 @@
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
+import java.util.ResourceBundle;
import javax.swing.BorderFactory;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import com.mebigfatguy.patchanim.OutOfBoundsColor;
import com.mebigfatguy.patchanim.PatchAnimDocument;
import com.mebigfatguy.patchanim.PatchColor;
+import com.mebigfatguy.patchanim.main.PatchAnimBundle;
import com.mebigfatguy.patchanim.surface.CombinedPatch;
+import com.mebigfatguy.patchanim.surface.Coordinate;
+import com.mebigfatguy.patchanim.surface.PatchCoords;
import com.mebigfatguy.patchanim.surface.PatchGenerator;
public class JPatchSamplePanel extends JPanel {
@@ -81,10 +91,21 @@
addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent me) {
- if (decorator != null) {
+ if (decorator != null)
decorator.click(me.getPoint(), JPatchSamplePanel.this.getBounds());
- }
}
+
+ @Override
+ public void mousePressed(MouseEvent me) {
+ if ((color != PatchColor.Combined) && me.isPopupTrigger())
+ showPatchContentMenu(me);
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent me) {
+ if ((color != PatchColor.Combined) && me.isPopupTrigger())
+ showPatchContentMenu(me);
+ }
});
PatchPanelMediator mediator = PatchPanelMediator.getMediator();
@@ -142,6 +163,54 @@
}
}
+ private void showPatchContentMenu(MouseEvent me) {
+ final ResourceBundle rb = PatchAnimBundle.getBundle();
+ JPopupMenu menu = new JPopupMenu();
+ JMenu setAllItem = new JMenu(rb.getString(PatchAnimBundle.SETALLPOINTS));
+ menu.add(setAllItem);
+ JMenuItem blackItem = new JMenuItem(rb.getString(PatchAnimBundle.BLACK));
+ blackItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ setAllPts(0.0);
+ }
+ });
+ setAllItem.add(blackItem);
+ JMenuItem fullColorItem = new JMenuItem(rb.getString(PatchAnimBundle.FULLCOLOR));
+ fullColorItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ setAllPts(255.0);
+ }
+ });
+
+ setAllItem.add(fullColorItem);
+ JMenuItem valueItem = new JMenuItem(rb.getString(PatchAnimBundle.VALUE));
+ valueItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ String value = JOptionPane.showInputDialog(JPatchSamplePanel.this, rb.getString(PatchAnimBundle.VALUE), "128");
+ try {
+ setAllPts(Double.parseDouble(value));
+ } catch (NumberFormatException nfe) {
+ }
+ }
+ });
+ setAllItem.add(valueItem);
+ menu.show(JPatchSamplePanel.this, me.getX(), me.getY());
+ }
+
+ private void setAllPts(double d) {
+ PatchPanelMediator mediator = PatchPanelMediator.getMediator();
+ CombinedPatch patch = mediator.getActivePatch();
+ PatchCoords coords = patch.getPatch(color);
+ for (int i = 0; i < PatchCoords.ORDER; i++) {
+ for (int j = 0; j < PatchCoords.ORDER; j++) {
+ Coordinate c = coords.getCoordinate(i, j);
+ c.setColor(d);
+ coords.setCoordinate(i, j, c);
+ }
+ }
+ mediator.setNewActivePatch(patch);
+ }
+
@Override
public void paintComponent(Graphics g) {
Rectangle bounds = getBounds();
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java 2008-01-28 02:45:47 UTC (rev 50)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java 2008-01-28 07:48:31 UTC (rev 51)
@@ -46,6 +46,10 @@
public static final String ADD = "patchanim.add";
public static final String REMOVE = "patchanim.remove";
public static final String COLOR = "patchanim.color";
+ public static final String SETALLPOINTS = "patchanim.setallpoints";
+ public static final String BLACK = "patchanim.black";
+ public static final String FULLCOLOR="patchanim.fullcolor";
+ public static final String VALUE="patchanim.value";
public static final String ASKSAVE = "patchanim.asksave";
public static final String LOADFAILED = "patchanim.err.loadfailed";
public static final String SAVEFAILED = "patchanim.err.savefailed";
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-01-28 02:45:47 UTC (rev 50)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-01-28 07:48:31 UTC (rev 51)
@@ -39,6 +39,10 @@
patchanim.add = Add
patchanim.remove = Remove
patchanim.color = Color
+patchanim.setallpoints = Set all control points to...
+patchanim.black = Black
+patchanim.fullcolor = Full Color
+patchanim.value = Value...
patchanim.asksave = Do you want to save your changes?
patchanim.err.savefailed = Failed saving Patch Animation File
patchanim.err.loadfailed = Failed loading Patch Animation File
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|