Thread: [Patchanim-commit] SF.net SVN: patchanim: [18] trunk/patchanim/src/com/mebigfatguy/patchanim/ gui
Brought to you by:
dbrosius
From: <dbr...@us...> - 2008-01-26 06:34:52
|
Revision: 18 http://patchanim.svn.sourceforge.net/patchanim/?rev=18&view=rev Author: dbrosius Date: 2008-01-25 22:34:57 -0800 (Fri, 25 Jan 2008) Log Message: ----------- draw ctrls in yellow so they stand out, and get the edit ctrl working Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/IntegerDocument.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/IntegerDocument.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/IntegerDocument.java 2008-01-26 06:02:34 UTC (rev 17) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/IntegerDocument.java 2008-01-26 06:34:57 UTC (rev 18) @@ -30,7 +30,7 @@ { private static final long serialVersionUID = -1526356835854424028L; - private static final Pattern INTEGERPATTERN = Pattern.compile("-?(:?[1-9][0-9]*)?"); + private static final Pattern INTEGERPATTERN = Pattern.compile("-?(:?[0-9]*)?"); @Override public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { @@ -38,13 +38,9 @@ String end = getText(offs, this.getLength() - offs); String newIntegerString = (start + str + end).trim(); - if (newIntegerString.length() == 0) - super.insertString(offs, str, a); - else { - Matcher m = INTEGERPATTERN.matcher(newIntegerString); - if (m.matches()) { - super.insertString(offs, str, a); - } + Matcher m = INTEGERPATTERN.matcher(newIntegerString); + if (m.matches()) { + super.insertString(offs, str, a); } } } \ No newline at end of file Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java 2008-01-26 06:02:34 UTC (rev 17) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java 2008-01-26 06:34:57 UTC (rev 18) @@ -23,7 +23,6 @@ import java.awt.Graphics2D; import java.awt.Point; import java.awt.Rectangle; -import java.awt.image.BufferedImage; import java.util.ResourceBundle; import javax.swing.Box; @@ -32,6 +31,8 @@ import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; import com.mebigfatguy.patchanim.PatchColor; import com.mebigfatguy.patchanim.main.PatchAnimBundle; @@ -46,13 +47,14 @@ private JPatchSamplePanel sample; private JLabel colorLabel; private JTextField colorField; - private int selectedU; - private int selectedV; + private ValueDocumentListener docListener = new ValueDocumentListener(); + private int selectedXPt; + private int selectedYPt; public JColorControlPatchPanel(PatchColor c) { color = c; - selectedU = 0; - selectedV = 0; + selectedXPt = 0; + selectedYPt = 0; initComponents(); initListeners(); } @@ -64,7 +66,7 @@ sample.setDecorator(this); colorLabel = new JLabel(rb.getString(PatchAnimBundle.COLOR)); - colorField = new JTextField(4); + colorField = new JTextField(new IntegerDocument(), "", 4); add(Box.createVerticalGlue()); JPanel p = new JPanel(); @@ -94,19 +96,24 @@ CombinedPatch currentPatch = apce.getActivePatch(); coords = currentPatch.getPatch(color); if (coords != null) { - setColorField(); + setColorField(false); sample.recalcImage(color, currentPatch); } } - }); + }); + colorField.getDocument().addDocumentListener(docListener); } - private void setColorField() { + private void setColorField(final boolean fireEvents) { SwingUtilities.invokeLater(new Runnable() { public void run() { - Coordinate coord = coords.getCoordinate(selectedU, selectedV); + Coordinate coord = coords.getCoordinate(selectedXPt, selectedYPt); + if (!fireEvents) + colorField.getDocument().removeDocumentListener(docListener); colorField.setText(String.valueOf(coord.getColor())); + if (!fireEvents) + colorField.getDocument().addDocumentListener(docListener); } }); } @@ -115,11 +122,11 @@ if (coords == null) return; - g.setColor(Color.black); + g.setColor(Color.yellow); for (int u = 0; u < 4; u++) { for (int v = 0; v < 4; v++) { Coordinate c = coords.getCoordinate(u, v); - if ((selectedU == u) && (selectedV == v)) { + if ((selectedXPt == u) && (selectedYPt == v)) { g.fillOval(((c.getX() * (bounds.width - 5)) / 100) + bounds.x, ((c.getY() * (bounds.height - 5)) / 100) + bounds.y, 5, 5); } else { g.drawOval(((c.getX() * (bounds.width - 5)) / 100) + bounds.x, ((c.getY() * (bounds.height - 5)) / 100) + bounds.y, 5, 5); @@ -129,13 +136,45 @@ } public void click(Point p, Rectangle bounds) { - int newSelectedU = ((((p.x - bounds.x) * 100) / bounds.width) + 16) / 33; - int newSelectedV = ((((p.y - bounds.y) * 100) / bounds.height) + 16) / 33; - if ((newSelectedU != selectedU) || (newSelectedV != selectedV)) { - selectedU = newSelectedU; - selectedV = newSelectedV; - sample.repaint(); - setColorField(); + int newSelectedXPt = ((((p.x - bounds.x) * 100) / bounds.width) + 16) / 33; + int newSelectedYPt = ((((p.y - bounds.y) * 100) / bounds.height) + 16) / 33; + if ((newSelectedXPt != selectedXPt) || (newSelectedYPt != selectedYPt)) { + selectedXPt = newSelectedXPt; + selectedYPt = newSelectedYPt; + setColorField(false); + invalidate(); + revalidate(); + repaint(); } } + + class ValueDocumentListener implements DocumentListener + { + public void changedUpdate(DocumentEvent de) { + processChange(); + } + + public void insertUpdate(DocumentEvent de) { + processChange(); + } + + public void removeUpdate(DocumentEvent de) { + processChange(); + } + + private void processChange() { + int value; + String color = colorField.getText(); + if (color.length() == 0) + value = 0; + else + value = Integer.parseInt(colorField.getText()); + + Coordinate coord = coords.getCoordinate(selectedXPt, selectedYPt); + coord.setColor(value); + coords.setCoordinate(selectedXPt, selectedYPt, coord); + PatchPanelMediator mediator = PatchPanelMediator.getMediator(); + mediator.setNewActivePatch(mediator.getActivePatch()); + } + } } Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java 2008-01-26 06:02:34 UTC (rev 17) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java 2008-01-26 06:34:57 UTC (rev 18) @@ -28,6 +28,7 @@ private static final PatchPanelMediator mediator = new PatchPanelMediator(); private PatchAnimDocument document; + private CombinedPatch activePatch; private Set<DocumentChangedListener> dclisteners = new HashSet<DocumentChangedListener>(); private Set<ActivePatchChangedListener> apclisteners = new HashSet<ActivePatchChangedListener>(); @@ -53,7 +54,12 @@ apclisteners.add(apcl); } + public CombinedPatch getActivePatch() { + return activePatch; + } + public void setNewActivePatch(CombinedPatch patch) { + activePatch = patch; ActivePatchChangedEvent apce = new ActivePatchChangedEvent(this, patch); for (ActivePatchChangedListener apcl : apclisteners) { apcl.activePatchChanged(apce); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-01-26 06:42:04
|
Revision: 19 http://patchanim.svn.sourceforge.net/patchanim/?rev=19&view=rev Author: dbrosius Date: 2008-01-25 22:42:09 -0800 (Fri, 25 Jan 2008) Log Message: ----------- allow for typing - signs Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/IntegerDocument.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/IntegerDocument.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/IntegerDocument.java 2008-01-26 06:34:57 UTC (rev 18) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/IntegerDocument.java 2008-01-26 06:42:09 UTC (rev 19) @@ -30,7 +30,7 @@ { private static final long serialVersionUID = -1526356835854424028L; - private static final Pattern INTEGERPATTERN = Pattern.compile("-?(:?[0-9]*)?"); + private static final Pattern INTEGERPATTERN = Pattern.compile("-?(:?-?[0-9]*)?"); @Override public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java 2008-01-26 06:34:57 UTC (rev 18) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java 2008-01-26 06:42:09 UTC (rev 19) @@ -164,9 +164,9 @@ private void processChange() { int value; - String color = colorField.getText(); - if (color.length() == 0) - value = 0; + String color = colorField.getText().trim(); + if ((color.length() == 0) || ("-".equals(color))) + return; else value = Integer.parseInt(colorField.getText()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-01-30 01:44:49
|
Revision: 59 http://patchanim.svn.sourceforge.net/patchanim/?rev=59&view=rev Author: dbrosius Date: 2008-01-29 17:44:54 -0800 (Tue, 29 Jan 2008) Log Message: ----------- Move listeners/event objects to separate package Added Paths: ----------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/ActivePatchChangedEvent.java Removed Paths: ------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/ActivePatchChangedEvent.java Deleted: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/ActivePatchChangedEvent.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/ActivePatchChangedEvent.java 2008-01-30 01:37:31 UTC (rev 58) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/ActivePatchChangedEvent.java 2008-01-30 01:44:54 UTC (rev 59) @@ -1,38 +0,0 @@ -/* - * 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.util.EventObject; - -import com.mebigfatguy.patchanim.surface.CombinedPatch; - -public class ActivePatchChangedEvent extends EventObject { - private static final long serialVersionUID = -6329025951907079541L; - - private CombinedPatch patch; - - public ActivePatchChangedEvent(Object src, CombinedPatch activePatch) { - super(src); - patch = activePatch; - } - - public CombinedPatch getActivePatch() { - return patch; - } -} Copied: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/ActivePatchChangedEvent.java (from rev 58, trunk/patchanim/src/com/mebigfatguy/patchanim/gui/ActivePatchChangedEvent.java) =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/ActivePatchChangedEvent.java (rev 0) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/ActivePatchChangedEvent.java 2008-01-30 01:44:54 UTC (rev 59) @@ -0,0 +1,38 @@ +/* + * 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.util.EventObject; + +import com.mebigfatguy.patchanim.surface.CombinedPatch; + +public class ActivePatchChangedEvent extends EventObject { + private static final long serialVersionUID = -6329025951907079541L; + + private CombinedPatch patch; + + public ActivePatchChangedEvent(Object src, CombinedPatch activePatch) { + super(src); + patch = activePatch; + } + + public CombinedPatch getActivePatch() { + return patch; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-01-30 01:45:07
|
Revision: 60 http://patchanim.svn.sourceforge.net/patchanim/?rev=60&view=rev Author: dbrosius Date: 2008-01-29 17:45:12 -0800 (Tue, 29 Jan 2008) Log Message: ----------- Move listeners/event objects to separate package Added Paths: ----------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/ActivePatchChangedListener.java Removed Paths: ------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/ActivePatchChangedListener.java Deleted: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/ActivePatchChangedListener.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/ActivePatchChangedListener.java 2008-01-30 01:44:54 UTC (rev 59) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/ActivePatchChangedListener.java 2008-01-30 01:45:12 UTC (rev 60) @@ -1,23 +0,0 @@ -/* - * 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; - -public interface ActivePatchChangedListener { - void activePatchChanged(ActivePatchChangedEvent apce); -} Copied: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/ActivePatchChangedListener.java (from rev 59, trunk/patchanim/src/com/mebigfatguy/patchanim/gui/ActivePatchChangedListener.java) =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/ActivePatchChangedListener.java (rev 0) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/ActivePatchChangedListener.java 2008-01-30 01:45:12 UTC (rev 60) @@ -0,0 +1,23 @@ +/* + * 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; + +public interface ActivePatchChangedListener { + void activePatchChanged(ActivePatchChangedEvent apce); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-01-30 01:45:30
|
Revision: 61 http://patchanim.svn.sourceforge.net/patchanim/?rev=61&view=rev Author: dbrosius Date: 2008-01-29 17:45:33 -0800 (Tue, 29 Jan 2008) Log Message: ----------- Move listeners/event objects to separate package Added Paths: ----------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/DocumentChangedEvent.java Removed Paths: ------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/DocumentChangedEvent.java Deleted: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/DocumentChangedEvent.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/DocumentChangedEvent.java 2008-01-30 01:45:12 UTC (rev 60) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/DocumentChangedEvent.java 2008-01-30 01:45:33 UTC (rev 61) @@ -1,38 +0,0 @@ -/* - * 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.util.EventObject; - -import com.mebigfatguy.patchanim.PatchAnimDocument; - -public class DocumentChangedEvent extends EventObject { - private static final long serialVersionUID = 7694516648407911200L; - - private PatchAnimDocument document; - - public DocumentChangedEvent(Object src, PatchAnimDocument d) { - super(src); - document = d; - } - - public PatchAnimDocument getDocument() { - return document; - } -} Copied: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/DocumentChangedEvent.java (from rev 60, trunk/patchanim/src/com/mebigfatguy/patchanim/gui/DocumentChangedEvent.java) =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/DocumentChangedEvent.java (rev 0) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/DocumentChangedEvent.java 2008-01-30 01:45:33 UTC (rev 61) @@ -0,0 +1,38 @@ +/* + * 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.util.EventObject; + +import com.mebigfatguy.patchanim.PatchAnimDocument; + +public class DocumentChangedEvent extends EventObject { + private static final long serialVersionUID = 7694516648407911200L; + + private PatchAnimDocument document; + + public DocumentChangedEvent(Object src, PatchAnimDocument d) { + super(src); + document = d; + } + + public PatchAnimDocument getDocument() { + return document; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-01-30 01:45:53
|
Revision: 62 http://patchanim.svn.sourceforge.net/patchanim/?rev=62&view=rev Author: dbrosius Date: 2008-01-29 17:45:51 -0800 (Tue, 29 Jan 2008) Log Message: ----------- Move listeners/event objects to separate package Added Paths: ----------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/DocumentChangedListener.java Removed Paths: ------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/DocumentChangedListener.java Deleted: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/DocumentChangedListener.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/DocumentChangedListener.java 2008-01-30 01:45:33 UTC (rev 61) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/DocumentChangedListener.java 2008-01-30 01:45:51 UTC (rev 62) @@ -1,23 +0,0 @@ -/* - * 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; - -public interface DocumentChangedListener { - void documentChanged(DocumentChangedEvent dce); -} Copied: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/DocumentChangedListener.java (from rev 61, trunk/patchanim/src/com/mebigfatguy/patchanim/gui/DocumentChangedListener.java) =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/DocumentChangedListener.java (rev 0) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/DocumentChangedListener.java 2008-01-30 01:45:51 UTC (rev 62) @@ -0,0 +1,23 @@ +/* + * 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; + +public interface DocumentChangedListener { + void documentChanged(DocumentChangedEvent dce); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-01-30 01:46:04
|
Revision: 63 http://patchanim.svn.sourceforge.net/patchanim/?rev=63&view=rev Author: dbrosius Date: 2008-01-29 17:46:08 -0800 (Tue, 29 Jan 2008) Log Message: ----------- Move listeners/event objects to separate package Added Paths: ----------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/SettingsChangedEvent.java Removed Paths: ------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/SettingsChangedEvent.java Deleted: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/SettingsChangedEvent.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/SettingsChangedEvent.java 2008-01-30 01:45:51 UTC (rev 62) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/SettingsChangedEvent.java 2008-01-30 01:46:08 UTC (rev 63) @@ -1,38 +0,0 @@ -/* - * 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.util.EventObject; - -import com.mebigfatguy.patchanim.PatchAnimDocument; - -public class SettingsChangedEvent extends EventObject { - private static final long serialVersionUID = 2005167344637800832L; - - private PatchAnimDocument doc; - - public SettingsChangedEvent(Object src, PatchAnimDocument document) { - super(src); - doc = document; - } - - public PatchAnimDocument getDocument() { - return doc; - } -} Copied: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/SettingsChangedEvent.java (from rev 62, trunk/patchanim/src/com/mebigfatguy/patchanim/gui/SettingsChangedEvent.java) =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/SettingsChangedEvent.java (rev 0) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/SettingsChangedEvent.java 2008-01-30 01:46:08 UTC (rev 63) @@ -0,0 +1,38 @@ +/* + * 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.util.EventObject; + +import com.mebigfatguy.patchanim.PatchAnimDocument; + +public class SettingsChangedEvent extends EventObject { + private static final long serialVersionUID = 2005167344637800832L; + + private PatchAnimDocument doc; + + public SettingsChangedEvent(Object src, PatchAnimDocument document) { + super(src); + doc = document; + } + + public PatchAnimDocument getDocument() { + return doc; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-02-12 19:22:11
|
Revision: 175 http://patchanim.svn.sourceforge.net/patchanim/?rev=175&view=rev Author: dbrosius Date: 2008-02-12 11:22:13 -0800 (Tue, 12 Feb 2008) Log Message: ----------- fix handle redrawing when window focus is lost/gained Modified Paths: -------------- 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/JPatchSamplePanel.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java 2008-02-12 05:03:39 UTC (rev 174) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java 2008-02-12 19:22:13 UTC (rev 175) @@ -56,6 +56,7 @@ private ValueDocumentListener docListener = new ValueDocumentListener(); private int selectedXPt; private int selectedYPt; + private boolean drawHandles = false; public JColorControlPatchPanel(PatchColor c) { color = c; @@ -133,11 +134,15 @@ } }); } - + public void drawDecoration(Graphics2D g, Rectangle bounds) { if (coords == null) return; + PatchPanelMediator mediator = PatchPanelMediator.getMediator(); + if (!mediator.isFocused()) + return; + g.setColor(Color.yellow); for (int u = 0; u < 4; u++) { for (int v = 0; v < 4; v++) { Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java 2008-02-12 05:03:39 UTC (rev 174) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java 2008-02-12 19:22:13 UTC (rev 175) @@ -22,8 +22,10 @@ import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.awt.event.WindowFocusListener; import java.io.File; import java.io.IOException; import java.util.ResourceBundle; @@ -151,6 +153,19 @@ } }); + addWindowFocusListener(new WindowFocusListener() { + + public void windowGainedFocus(WindowEvent e) { + PatchPanelMediator mediator = PatchPanelMediator.getMediator(); + mediator.setFocused(true); + } + + public void windowLostFocus(WindowEvent e) { + PatchPanelMediator mediator = PatchPanelMediator.getMediator(); + mediator.setFocused(false); + } + }); + newItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { try { Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-02-12 05:03:39 UTC (rev 174) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-02-12 19:22:13 UTC (rev 175) @@ -23,6 +23,7 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; +import java.awt.Shape; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; @@ -327,9 +328,16 @@ @Override public void paintComponent(Graphics g) { - Rectangle bounds = getBounds(); - g.drawImage(image, 0, 0, (int)bounds.getWidth(), (int)bounds.getHeight(), 0, 0, SAMPLE_SIZE, SAMPLE_SIZE, null); - if (decorator != null) - decorator.drawDecoration(((Graphics2D) g), g.getClipBounds()); + Shape clip = g.getClip(); + try { + Rectangle bounds = getBounds(); + g.setClip(0, 0, (int)bounds.getWidth(), (int)bounds.getHeight()); + + g.drawImage(image, 0, 0, (int)bounds.getWidth(), (int)bounds.getHeight(), 0, 0, SAMPLE_SIZE, SAMPLE_SIZE, null); + if (decorator != null) + decorator.drawDecoration(((Graphics2D) g), g.getClipBounds()); + } finally { + g.setClip(clip); + } } } Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java 2008-02-12 05:03:39 UTC (rev 174) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java 2008-02-12 19:22:13 UTC (rev 175) @@ -38,6 +38,7 @@ private Set<DocumentChangedListener> dclisteners = new HashSet<DocumentChangedListener>(); private Set<ActivePatchChangedListener> apclisteners = new HashSet<ActivePatchChangedListener>(); private Set<SettingsChangedListener> sclisteners = new HashSet<SettingsChangedListener>(); + private boolean windowFocused = true; private PatchPanelMediator() { } @@ -96,6 +97,20 @@ } } + public void setFocused(boolean focused) { + windowFocused = focused; + synchronized(apclisteners) { + ActivePatchChangedEvent apce = new ActivePatchChangedEvent(this, activePatch); + for (ActivePatchChangedListener apcl : apclisteners) { + apcl.activePatchChanged(apce); + } + } + } + public boolean isFocused() { + return windowFocused; + } + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-02-15 06:30:51
|
Revision: 191 http://patchanim.svn.sourceforge.net/patchanim/?rev=191&view=rev Author: dbrosius Date: 2008-02-14 22:30:52 -0800 (Thu, 14 Feb 2008) Log Message: ----------- use varargs for sizeUniformly Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimPanel.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchControlPanel.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchListPanel.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/Utils.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimPanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimPanel.java 2008-02-15 06:22:04 UTC (rev 190) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimPanel.java 2008-02-15 06:30:52 UTC (rev 191) @@ -58,7 +58,7 @@ JPanel listPanel = new JPatchListPanel(); p.add(listPanel, BorderLayout.WEST); - Utils.sizeUniformly(new JComponent[] { ctrl, listPanel }, Utils.Sizing.Width); + Utils.sizeUniformly(Utils.Sizing.Width, ctrl, listPanel ); q = new JPanel(); { Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchControlPanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchControlPanel.java 2008-02-15 06:22:04 UTC (rev 190) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchControlPanel.java 2008-02-15 06:30:52 UTC (rev 191) @@ -136,8 +136,8 @@ testButton.setToolTipText(rb.getString(PatchAnimBundle.TEST_TT)); add(testButton); - Utils.sizeUniformly(new JComponent[] { widthLabel, heightLabel, animationLabel, outOfBoundsLabel, tweenFramesLabel }, Utils.Sizing.Both); - Utils.sizeUniformly(new JComponent[] { widthField, heightField, animationCB, outOfBoundsColorCB, tweenFramesField }, Utils.Sizing.Width); + Utils.sizeUniformly(Utils.Sizing.Both, widthLabel, heightLabel, animationLabel, outOfBoundsLabel, tweenFramesLabel); + Utils.sizeUniformly(Utils.Sizing.Width, new JComponent[] { widthField, heightField, animationCB, outOfBoundsColorCB, tweenFramesField }); add(Box.createVerticalGlue()); Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchListPanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchListPanel.java 2008-02-15 06:22:04 UTC (rev 190) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchListPanel.java 2008-02-15 06:30:52 UTC (rev 191) @@ -82,7 +82,7 @@ addButton = new JButton(rb.getString(PatchAnimBundle.ADD)); removeButton = new JButton(rb.getString(PatchAnimBundle.REMOVE)); removeButton.setEnabled(false); - Utils.sizeUniformly(new JComponent[] {addButton, removeButton}, Utils.Sizing.Both); + Utils.sizeUniformly(Utils.Sizing.Both, addButton, removeButton); modCtrls.add(addButton); modCtrls.add(Box.createHorizontalStrut(10)); modCtrls.add(removeButton); @@ -94,7 +94,7 @@ downButton = new JButton(new ImageIcon(getClass().getResource(DOWNBUTTON))); upButton.setEnabled(false); downButton.setEnabled(false); - Utils.sizeUniformly(new JComponent[] {upButton, downButton}, Utils.Sizing.Both); + Utils.sizeUniformly(Utils.Sizing.Both, new JComponent[] {upButton, downButton}); moveCtrls.setLayout(new BoxLayout(moveCtrls, BoxLayout.Y_AXIS)); moveCtrls.add(Box.createVerticalGlue()); moveCtrls.add(upButton); Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/Utils.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/Utils.java 2008-02-15 06:22:04 UTC (rev 190) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/Utils.java 2008-02-15 06:30:52 UTC (rev 191) @@ -47,7 +47,7 @@ p.setMaximumSize(ms); } - public static void sizeUniformly(JComponent[] components, Sizing sizing) { + public static void sizeUniformly(Sizing sizing, JComponent... components) { int width = 0; int height = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-01-30 01:46:20
|
Revision: 64 http://patchanim.svn.sourceforge.net/patchanim/?rev=64&view=rev Author: dbrosius Date: 2008-01-29 17:46:25 -0800 (Tue, 29 Jan 2008) Log Message: ----------- Move listeners/event objects to separate package Added Paths: ----------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/SettingsChangedListener.java Removed Paths: ------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/SettingsChangedListener.java Deleted: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/SettingsChangedListener.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/SettingsChangedListener.java 2008-01-30 01:46:08 UTC (rev 63) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/SettingsChangedListener.java 2008-01-30 01:46:25 UTC (rev 64) @@ -1,23 +0,0 @@ -/* - * 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; - -public interface SettingsChangedListener { - void settingsChanged(SettingsChangedEvent sce); -} Copied: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/SettingsChangedListener.java (from rev 63, trunk/patchanim/src/com/mebigfatguy/patchanim/gui/SettingsChangedListener.java) =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/SettingsChangedListener.java (rev 0) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/SettingsChangedListener.java 2008-01-30 01:46:25 UTC (rev 64) @@ -0,0 +1,23 @@ +/* + * 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; + +public interface SettingsChangedListener { + void settingsChanged(SettingsChangedEvent sce); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-02-03 02:35:50
|
Revision: 96 http://patchanim.svn.sourceforge.net/patchanim/?rev=96&view=rev Author: dbrosius Date: 2008-02-02 18:35:56 -0800 (Sat, 02 Feb 2008) Log Message: ----------- better control point clicking, and add drag ability but commented out till i can figure how to effect the blend with it. Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchDecorator.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java 2008-02-03 01:47:06 UTC (rev 95) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java 2008-02-03 02:35:56 UTC (rev 96) @@ -45,6 +45,8 @@ public class JColorControlPatchPanel extends JPanel implements PatchDecorator { private static final long serialVersionUID = -2524694507912574529L; + private static final double MINCLICKDISTANCESQ = 12.0; + private static final double MINDRAGDISTANCESQ = 3.0; private PatchCoords coords; private PatchColor color; @@ -151,19 +153,79 @@ } } - public void click(Point p, Rectangle bounds) { - int newSelectedXPt = ((((p.x - bounds.x) * 100) / bounds.width) + 16) / 33; - int newSelectedYPt = ((((p.y - bounds.y) * 100) / bounds.height) + 16) / 33; - if ((newSelectedXPt != selectedXPt) || (newSelectedYPt != selectedYPt)) { - selectedXPt = newSelectedXPt; - selectedYPt = newSelectedYPt; + public boolean press(Point p, Rectangle bounds) { + + if (setSelectedControlPt(p, bounds)) { setColorField(false); - invalidate(); - revalidate(); - repaint(); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + invalidate(); + revalidate(); + repaint(); + } + }); + return true; } + return false; } + public boolean drag(Point p, Rectangle bounds) { + return false; +/* + double inputX = ((p.x - bounds.x) * 100.0) / bounds.width; + double inputY = ((p.y - bounds.y) * 100.0) / bounds.height; + Coordinate c= coords.getCoordinate(selectedXPt, selectedYPt); + double oldX = c.getX(); + double oldY = c.getY(); + + double xDeltaSq = inputX - oldX; + xDeltaSq *= xDeltaSq; + double yDeltaSq = inputY - oldY; + yDeltaSq *= yDeltaSq; + + if ((xDeltaSq + yDeltaSq) > MINDRAGDISTANCESQ) { + c.setX(inputX); + c.sety(inputY); + return true; + } + + return false; +*/ + } + + private boolean setSelectedControlPt(Point p, Rectangle bounds) { + double minDistanceSq = Double.MAX_VALUE; + double inputX = ((p.x - bounds.x) * 100.0) / bounds.width; + double inputY = ((p.y - bounds.y) * 100.0) / bounds.height; + int minU = 0; + int minV = 0; + + for (int u = 0; u < 4; u++) { + for (int v = 0; v < 4; v++) { + Coordinate c = coords.getCoordinate(u, v); + double xSq = c.getX() - inputX; + xSq *= xSq; + double ySq = c.getY() - inputY; + ySq *= ySq; + + double distSq = xSq + ySq; + if (distSq < minDistanceSq) { + minDistanceSq = distSq; + minU = u; + minV = v; + } + } + } + + if (minDistanceSq < MINCLICKDISTANCESQ) { + selectedXPt = minU; + selectedYPt = minV; + return true; + } + + return false; + } + class ValueDocumentListener implements DocumentListener { public void changedUpdate(DocumentEvent de) { Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-02-03 01:47:06 UTC (rev 95) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-02-03 02:35:56 UTC (rev 96) @@ -27,6 +27,7 @@ import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; import java.awt.image.BufferedImage; import java.util.ResourceBundle; @@ -65,6 +66,7 @@ private Thread redrawThread = null; private Object redrawLock = new Object(); private boolean redrawing = false; + private boolean dragging = false; public JPatchSamplePanel(PatchColor c) { color = c; @@ -99,24 +101,34 @@ private void initListeners() { addMouseListener(new MouseAdapter() { @Override - public void mouseClicked(MouseEvent me) { - if (decorator != null) - decorator.click(me.getPoint(), JPatchSamplePanel.this.getBounds()); - } - - @Override public void mousePressed(MouseEvent me) { if ((color != PatchColor.Combined) && me.isPopupTrigger()) showPatchContentMenu(me); + else if (decorator != null) { + dragging = decorator.press(me.getPoint(), JPatchSamplePanel.this.getBounds()); + } } @Override public void mouseReleased(MouseEvent me) { if ((color != PatchColor.Combined) && me.isPopupTrigger()) showPatchContentMenu(me); + dragging = false; } }); + addMouseMotionListener(new MouseMotionAdapter() { + @Override + public void mouseDragged(MouseEvent me) { + if ((decorator != null) && dragging) + if (decorator.drag(me.getPoint(), JPatchSamplePanel.this.getBounds())) { + PatchPanelMediator mediator = PatchPanelMediator.getMediator(); + CombinedPatch currentPatch = mediator.getActivePatch(); + recalcImage(color, currentPatch); + } + } + }); + PatchPanelMediator mediator = PatchPanelMediator.getMediator(); mediator.addActivePatchChangedListener(new ActivePatchChangedListener() { public void activePatchChanged(ActivePatchChangedEvent apce) { Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchDecorator.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchDecorator.java 2008-02-03 01:47:06 UTC (rev 95) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchDecorator.java 2008-02-03 02:35:56 UTC (rev 96) @@ -25,5 +25,7 @@ public interface PatchDecorator { void drawDecoration(Graphics2D g, Rectangle bounds); - void click(Point p, Rectangle bounds); + boolean press(Point p, Rectangle bounds); + + boolean drag(Point p, Rectangle bounds); } Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java 2008-02-03 01:47:06 UTC (rev 95) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java 2008-02-03 02:35:56 UTC (rev 96) @@ -62,17 +62,23 @@ } public void addActivePatchChangedListener(ActivePatchChangedListener apcl) { - apclisteners.add(apcl); + synchronized(apclisteners) { + apclisteners.add(apcl); + } } public void addSettingsChangedListener(SettingsChangedListener scl) { - sclisteners.add(scl); + synchronized(sclisteners) { + sclisteners.add(scl); + } } public void fireSettingsChanged() { - SettingsChangedEvent sce = new SettingsChangedEvent(this, document); - for (SettingsChangedListener scl : sclisteners) { - scl.settingsChanged(sce); + synchronized(sclisteners) { + SettingsChangedEvent sce = new SettingsChangedEvent(this, document); + for (SettingsChangedListener scl : sclisteners) { + scl.settingsChanged(sce); + } } } @@ -83,8 +89,10 @@ public void setNewActivePatch(CombinedPatch patch) { activePatch = patch; ActivePatchChangedEvent apce = new ActivePatchChangedEvent(this, patch); - for (ActivePatchChangedListener apcl : apclisteners) { - apcl.activePatchChanged(apce); + synchronized(apclisteners) { + for (ActivePatchChangedListener apcl : apclisteners) { + apcl.activePatchChanged(apce); + } } } 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:05:01
|
Revision: 237 http://patchanim.svn.sourceforge.net/patchanim/?rev=237&view=rev Author: dbrosius Date: 2008-02-24 08:05:05 -0800 (Sun, 24 Feb 2008) Log Message: ----------- split out file filter to separate class, and use in save dialog as well. Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java Added Paths: ----------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchAnimFileFilter.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java 2008-02-24 16:01:04 UTC (rev 236) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java 2008-02-24 16:05:05 UTC (rev 237) @@ -343,20 +343,7 @@ try { JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - chooser.setFileFilter(new FileFilter() { - - @Override - public boolean accept(File f) { - if (f.isDirectory()) - return true; - return (f.getPath().endsWith("paf")); - } - - @Override - public String getDescription() { - return "PatchAnim Files (*.paf)"; - } - }); + chooser.setFileFilter(new PatchAnimFileFilter()); chooser.setCurrentDirectory(new File(System.getProperty("user.dir"))); int option = chooser.showOpenDialog(JPatchAnimFrame.this); if (option == JFileChooser.APPROVE_OPTION) { @@ -385,6 +372,7 @@ defLocation = documentLocation.getParentFile(); chooser.setCurrentDirectory(defLocation); + chooser.setFileFilter(new PatchAnimFileFilter()); int option = chooser.showSaveDialog(JPatchAnimFrame.this); if (option == JFileChooser.APPROVE_OPTION) { String path = chooser.getSelectedFile().getPath(); Added: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchAnimFileFilter.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchAnimFileFilter.java (rev 0) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchAnimFileFilter.java 2008-02-24 16:05:05 UTC (rev 237) @@ -0,0 +1,37 @@ +/* + * 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.io.File; + +import javax.swing.filechooser.FileFilter; + +public class PatchAnimFileFilter extends FileFilter { + @Override + public boolean accept(File f) { + if (f.isDirectory()) + return true; + return (f.getPath().endsWith("paf")); + } + + @Override + public String getDescription() { + return "PatchAnim Files (*.paf)"; + } +} Property changes on: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchAnimFileFilter.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-06-07 22:53:22
|
Revision: 247 http://patchanim.svn.sourceforge.net/patchanim/?rev=247&view=rev Author: dbrosius Date: 2008-06-07 15:53:31 -0700 (Sat, 07 Jun 2008) Log Message: ----------- Se fixes Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JTestFrame.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java 2008-06-07 22:51:14 UTC (rev 246) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java 2008-06-07 22:53:31 UTC (rev 247) @@ -53,7 +53,7 @@ private JPatchSamplePanel sample; private JLabel colorLabel; private JTextField colorField; - private ValueDocumentListener docListener = new ValueDocumentListener(); + private transient ValueDocumentListener docListener = new ValueDocumentListener(); private int selectedXPt; private int selectedYPt; Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-06-07 22:51:14 UTC (rev 246) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchSamplePanel.java 2008-06-07 22:53:31 UTC (rev 247) @@ -64,9 +64,9 @@ private PatchColor color; private Color rgb; private OutOfBoundsColor oob; - private BufferedImage image; + private transient BufferedImage image; private PatchDecorator decorator; - private Thread redrawThread = null; + private transient Thread redrawThread = null; private Object redrawLock = new Object(); private boolean redrawing = false; private boolean dragging = false; Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JTestFrame.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JTestFrame.java 2008-06-07 22:51:14 UTC (rev 246) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JTestFrame.java 2008-06-07 22:53:31 UTC (rev 247) @@ -42,7 +42,7 @@ private static final long serialVersionUID = -7975149184522257748L; - private Thread animThread = null; + private transient Thread animThread = null; private TestPanel testPanel = null; private PatchAnimDocument document; private long lastRedraw; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |