[Patchanim-commit] SF.net SVN: patchanim: [65] trunk/patchanim/src/com
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2008-01-30 01:49:40
|
Revision: 65
http://patchanim.svn.sourceforge.net/patchanim/?rev=65&view=rev
Author: dbrosius
Date: 2008-01-29 17:49:46 -0800 (Tue, 29 Jan 2008)
Log Message:
-----------
rework packages to move events/listeners to a new package
Modified Paths:
--------------
trunk/patchanim/src/com/fmsware/gif/NeuQuant.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/JPatchControlPanel.java
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchListPanel.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/PatchListModel.java
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/Utils.java
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/ActivePatchChangedEvent.java
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/ActivePatchChangedListener.java
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/DocumentChangedEvent.java
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/DocumentChangedListener.java
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/SettingsChangedEvent.java
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/events/SettingsChangedListener.java
trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java
Property Changed:
----------------
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/JPatchControlPanel.java
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchListPanel.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/PatchListModel.java
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/PatchPanelMediator.java
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/Utils.java
Modified: trunk/patchanim/src/com/fmsware/gif/NeuQuant.java
===================================================================
--- trunk/patchanim/src/com/fmsware/gif/NeuQuant.java 2008-01-30 01:46:25 UTC (rev 64)
+++ trunk/patchanim/src/com/fmsware/gif/NeuQuant.java 2008-01-30 01:49:46 UTC (rev 65)
@@ -345,7 +345,7 @@
----------------------------------------------------------------------------------- */
public void unbiasnet() {
- int i, j;
+ int i;
for (i = 0; i < netsize; i++) {
network[i][0] >>= netbiasshift;
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java 2008-01-30 01:46:25 UTC (rev 64)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java 2008-01-30 01:49:46 UTC (rev 65)
@@ -1,194 +1,196 @@
-/*
- * 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.Color;
-import java.awt.Graphics2D;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.util.ResourceBundle;
-
-import javax.swing.Box;
-import javax.swing.BoxLayout;
-import javax.swing.JLabel;
-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;
-import com.mebigfatguy.patchanim.surface.CombinedPatch;
-import com.mebigfatguy.patchanim.surface.Coordinate;
-import com.mebigfatguy.patchanim.surface.PatchCoords;
-
-public class JColorControlPatchPanel extends JPanel implements PatchDecorator {
-
- private static final long serialVersionUID = -2524694507912574529L;
-
- private PatchCoords coords;
- private PatchColor color;
- private JPatchSamplePanel sample;
- private JLabel colorLabel;
- private JTextField colorField;
- private ValueDocumentListener docListener = new ValueDocumentListener();
- private int selectedXPt;
- private int selectedYPt;
-
- public JColorControlPatchPanel(PatchColor c) {
- color = c;
- selectedXPt = 0;
- selectedYPt = 0;
- initComponents();
- initListeners();
- }
-
- private void initComponents() {
- ResourceBundle rb = PatchAnimBundle.getBundle();
- setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
- sample = new JPatchSamplePanel(color);
- sample.setDecorator(this);
-
- colorLabel = new JLabel(rb.getString(PatchAnimBundle.COLOR));
- colorField = new JTextField(new DoubleDocument(), "", 4);
- colorLabel.setLabelFor(colorField);
-
- add(Box.createVerticalGlue());
- JPanel p = new JPanel();
- {
- p.setLayout(new BorderLayout(4, 4));
- p.add(sample, BorderLayout.CENTER);
-
- JPanel south = new JPanel();
- south.setLayout(new BoxLayout(south, BoxLayout.X_AXIS));
- south.add(Box.createHorizontalGlue());
- south.add(colorLabel);
- south.add(Box.createHorizontalStrut(5));
- south.add(colorField);
- south.add(Box.createHorizontalGlue());
- p.add(south, BorderLayout.SOUTH);
- }
- add(p);
- add(Box.createVerticalGlue());
-
- setMaximumSize(getPreferredSize());
- }
-
- private void initListeners() {
- 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);
- }
- }
- });
- colorField.getDocument().addDocumentListener(docListener);
- }
-
- private void setColorField(final boolean fireEvents) {
-
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- Coordinate coord = coords.getCoordinate(selectedXPt, selectedYPt);
- double newColor = coord.getColor();
- double oldColor;
- try {
- oldColor = Double.parseDouble(colorField.getText());
- } catch (NumberFormatException nfe) {
- oldColor = 0.0;
- }
- if (newColor != oldColor) {
- if (!fireEvents)
- colorField.getDocument().removeDocumentListener(docListener);
- colorField.setText(String.valueOf(coord.getColor()));
- if (!fireEvents)
- colorField.getDocument().addDocumentListener(docListener);
- }
- }
- });
- }
-
- public void drawDecoration(Graphics2D g, Rectangle bounds) {
- if (coords == null)
- return;
-
- 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 ((selectedXPt == u) && (selectedYPt == v)) {
- g.fillOval((int)(((c.getX() * (bounds.width - 5)) / 100.0) + bounds.x),
- (int)(((c.getY() * (bounds.height - 5)) / 100.0) + bounds.y), 5, 5);
- } else {
- g.drawOval((int)(((c.getX() * (bounds.width - 5)) / 100.0) + bounds.x),
- (int)(((c.getY() * (bounds.height - 5)) / 100.0) + bounds.y), 5, 5);
- }
- }
- }
- }
-
- 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;
- 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() {
- double value;
-
- try {
- value = Double.parseDouble(colorField.getText());
- } catch (NumberFormatException nfe) {
- value = 0.0;
- }
- Coordinate coord = coords.getCoordinate(selectedXPt, selectedYPt);
- coord.setColor(value);
- coords.setCoordinate(selectedXPt, selectedYPt, coord);
- PatchPanelMediator mediator = PatchPanelMediator.getMediator();
- mediator.setNewActivePatch(mediator.getActivePatch());
- }
- }
-}
+/*
+ * 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.Color;
+import java.awt.Graphics2D;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.util.ResourceBundle;
+
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JLabel;
+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.gui.events.ActivePatchChangedEvent;
+import com.mebigfatguy.patchanim.gui.events.ActivePatchChangedListener;
+import com.mebigfatguy.patchanim.main.PatchAnimBundle;
+import com.mebigfatguy.patchanim.surface.CombinedPatch;
+import com.mebigfatguy.patchanim.surface.Coordinate;
+import com.mebigfatguy.patchanim.surface.PatchCoords;
+
+public class JColorControlPatchPanel extends JPanel implements PatchDecorator {
+
+ private static final long serialVersionUID = -2524694507912574529L;
+
+ private PatchCoords coords;
+ private PatchColor color;
+ private JPatchSamplePanel sample;
+ private JLabel colorLabel;
+ private JTextField colorField;
+ private ValueDocumentListener docListener = new ValueDocumentListener();
+ private int selectedXPt;
+ private int selectedYPt;
+
+ public JColorControlPatchPanel(PatchColor c) {
+ color = c;
+ selectedXPt = 0;
+ selectedYPt = 0;
+ initComponents();
+ initListeners();
+ }
+
+ private void initComponents() {
+ ResourceBundle rb = PatchAnimBundle.getBundle();
+ setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+ sample = new JPatchSamplePanel(color);
+ sample.setDecorator(this);
+
+ colorLabel = new JLabel(rb.getString(PatchAnimBundle.COLOR));
+ colorField = new JTextField(new DoubleDocument(), "", 4);
+ colorLabel.setLabelFor(colorField);
+
+ add(Box.createVerticalGlue());
+ JPanel p = new JPanel();
+ {
+ p.setLayout(new BorderLayout(4, 4));
+ p.add(sample, BorderLayout.CENTER);
+
+ JPanel south = new JPanel();
+ south.setLayout(new BoxLayout(south, BoxLayout.X_AXIS));
+ south.add(Box.createHorizontalGlue());
+ south.add(colorLabel);
+ south.add(Box.createHorizontalStrut(5));
+ south.add(colorField);
+ south.add(Box.createHorizontalGlue());
+ p.add(south, BorderLayout.SOUTH);
+ }
+ add(p);
+ add(Box.createVerticalGlue());
+
+ setMaximumSize(getPreferredSize());
+ }
+
+ private void initListeners() {
+ 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);
+ }
+ }
+ });
+ colorField.getDocument().addDocumentListener(docListener);
+ }
+
+ private void setColorField(final boolean fireEvents) {
+
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ Coordinate coord = coords.getCoordinate(selectedXPt, selectedYPt);
+ double newColor = coord.getColor();
+ double oldColor;
+ try {
+ oldColor = Double.parseDouble(colorField.getText());
+ } catch (NumberFormatException nfe) {
+ oldColor = 0.0;
+ }
+ if (newColor != oldColor) {
+ if (!fireEvents)
+ colorField.getDocument().removeDocumentListener(docListener);
+ colorField.setText(String.valueOf(coord.getColor()));
+ if (!fireEvents)
+ colorField.getDocument().addDocumentListener(docListener);
+ }
+ }
+ });
+ }
+
+ public void drawDecoration(Graphics2D g, Rectangle bounds) {
+ if (coords == null)
+ return;
+
+ 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 ((selectedXPt == u) && (selectedYPt == v)) {
+ g.fillOval((int)(((c.getX() * (bounds.width - 5)) / 100.0) + bounds.x),
+ (int)(((c.getY() * (bounds.height - 5)) / 100.0) + bounds.y), 5, 5);
+ } else {
+ g.drawOval((int)(((c.getX() * (bounds.width - 5)) / 100.0) + bounds.x),
+ (int)(((c.getY() * (bounds.height - 5)) / 100.0) + bounds.y), 5, 5);
+ }
+ }
+ }
+ }
+
+ 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;
+ 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() {
+ double value;
+
+ try {
+ value = Double.parseDouble(colorField.getText());
+ } catch (NumberFormatException nfe) {
+ value = 0.0;
+ }
+ Coordinate coord = coords.getCoordinate(selectedXPt, selectedYPt);
+ coord.setColor(value);
+ coords.setCoordinate(selectedXPt, selectedYPt, coord);
+ PatchPanelMediator mediator = PatchPanelMediator.getMediator();
+ mediator.setNewActivePatch(mediator.getActivePatch());
+ }
+ }
+}
Property changes on: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JColorControlPatchPanel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java 2008-01-30 01:46:25 UTC (rev 64)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java 2008-01-30 01:49:46 UTC (rev 65)
@@ -1,405 +1,400 @@
-/*
- * 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.awt.image.BufferedImage;
-import java.io.File;
-import java.io.IOException;
-import java.text.NumberFormat;
-import java.util.List;
-import java.util.ResourceBundle;
-
-import javax.imageio.ImageIO;
-import javax.swing.JFileChooser;
-import javax.swing.JFrame;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-import javax.swing.filechooser.FileFilter;
-
-import com.fmsware.gif.AnimatedGifEncoder;
-import com.mebigfatguy.patchanim.AnimationType;
-import com.mebigfatguy.patchanim.ExportType;
-import com.mebigfatguy.patchanim.OutOfBoundsColor;
-import com.mebigfatguy.patchanim.PatchAnimDocument;
-import com.mebigfatguy.patchanim.io.PatchAnimIO;
-import com.mebigfatguy.patchanim.io.PatchExporter;
-import com.mebigfatguy.patchanim.main.PatchAnimBundle;
-import com.mebigfatguy.patchanim.surface.CombinedPatch;
-import com.mebigfatguy.patchanim.surface.PatchGenerator;
-
-public class JPatchAnimFrame extends JFrame {
-
- private static final long serialVersionUID = -4610407923936772733L;
-
- private JMenuItem newItem;
- private JMenuItem openItem;
- private JMenuItem saveItem;
- private JMenuItem saveAsItem;
- private JMenu exportMenu;
- private JMenuItem exportJpgsItem;
- private JMenuItem exportPngsItem;
- private JMenuItem exportGifsItem;
- private JMenuItem exportAnimatedGifItem;
- private JMenuItem quitItem;
- private PatchAnimDocument document;
- private File documentLocation;
-
- public JPatchAnimFrame() {
- initComponents();
- initMenus();
- initListeners();
- }
-
- private void initComponents() {
- ResourceBundle rb = PatchAnimBundle.getBundle();
- Container cp = getContentPane();
- cp.setLayout(new BorderLayout(4, 4));
-
- JPatchAnimPanel patchPanel = new JPatchAnimPanel();
- document = new PatchAnimDocument();
- documentLocation = null;
- PatchPanelMediator mediator = PatchPanelMediator.getMediator();
- mediator.setDocument(document);
-
- cp.add(patchPanel, BorderLayout.CENTER);
- setTitle(rb.getString(PatchAnimBundle.TITLE));
- pack();
- }
-
- private void initMenus() {
- ResourceBundle rb = PatchAnimBundle.getBundle();
- JMenuBar mb = new JMenuBar();
- JMenu fileMenu = new JMenu(rb.getString(PatchAnimBundle.FILE));
- newItem = new JMenuItem(rb.getString(PatchAnimBundle.NEW));
- fileMenu.add(newItem);
- openItem = new JMenuItem(rb.getString(PatchAnimBundle.OPEN));
- fileMenu.add(openItem);
- fileMenu.addSeparator();
- saveItem = new JMenuItem(rb.getString(PatchAnimBundle.SAVE));
- saveItem.setEnabled(false);
- fileMenu.add(saveItem);
- saveAsItem = new JMenuItem(rb.getString(PatchAnimBundle.SAVEAS));
- fileMenu.add(saveAsItem);
- fileMenu.addSeparator();
- exportMenu = new JMenu(rb.getString(PatchAnimBundle.EXPORT));
- exportJpgsItem = new JMenuItem(rb.getString(PatchAnimBundle.JPGSERIES));
- exportPngsItem = new JMenuItem(rb.getString(PatchAnimBundle.PNGSERIES));
- exportGifsItem = new JMenuItem(rb.getString(PatchAnimBundle.GIFSERIES));
- exportAnimatedGifItem = new JMenuItem(rb.getString(PatchAnimBundle.ANIMATEDGIF));
- exportMenu.add(exportJpgsItem);
- exportMenu.add(exportPngsItem);
- exportMenu.add(exportGifsItem);
- exportMenu.addSeparator();
- exportMenu.add(exportAnimatedGifItem);
- fileMenu.add(exportMenu);
- fileMenu.addSeparator();
- quitItem = new JMenuItem(rb.getString(PatchAnimBundle.QUIT));
- fileMenu.add(quitItem);
-
- mb.add(fileMenu);
-
- setJMenuBar(mb);
- }
-
- private void initListeners() {
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent we) {
- try {
- if (document.isDirty()) {
- int choice = askSave();
- if (choice == JOptionPane.CANCEL_OPTION)
- return;
- if (choice == JOptionPane.YES_OPTION) {
- save();
- }
- }
- dispose();
- System.exit(0);
- } catch (IOException ioe) {
- JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.SAVEFAILED);
- }
- }
- });
-
- newItem.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent ae) {
- try {
- if (document.isDirty()) {
- int choice = askSave();
- if (choice == JOptionPane.CANCEL_OPTION)
- return;
- if (choice == JOptionPane.YES_OPTION) {
- save();
- }
- }
-
- document = new PatchAnimDocument();
- documentLocation = null;
- saveItem.setEnabled(false);
- } catch (IOException ioe) {
- JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.SAVEFAILED);
- }
- }
- });
-
- openItem.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent ae) {
- try {
- if (document.isDirty()) {
- int choice = askSave();
- if (choice == JOptionPane.CANCEL_OPTION)
- return;
- if (choice == JOptionPane.YES_OPTION) {
- save();
- }
- }
- load();
- } catch (IOException ioe) {
- JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.LOADFAILED);
- }
- }
- });
-
- saveItem.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent ae) {
- try {
- if (documentLocation == null) {
- saveAs();
- } else {
- save();
- }
- } catch (IOException ioe) {
- JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.SAVEFAILED);
- }
- }
- });
-
- saveAsItem.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent ae) {
- try {
- saveAs();
- } catch (IOException ioe) {
- JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.SAVEFAILED);
- }
- }
- });
-
- exportJpgsItem.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent ae) {
- try {
- File f = getExportLocation(ExportType.JPegs);
- if (f != null) {
- PatchExporter exporter = new PatchExporter(ExportType.JPegs, f);
- exporter.export(document);
- }
- } catch (IOException ioe) {
- JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.EXPORTFAILED);
- }
- }
- });
-
- exportPngsItem.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent ae) {
- try {
- File f = getExportLocation(ExportType.Pngs);
- if (f != null) {
- PatchExporter exporter = new PatchExporter(ExportType.Pngs, f);
- exporter.export(document);
- }
- } catch (IOException ioe) {
- JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.EXPORTFAILED);
- }
- }
- });
-
- exportGifsItem.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent ae) {
- try {
- File f = getExportLocation(ExportType.Gifs);
- if (f != null) {
- PatchExporter exporter = new PatchExporter(ExportType.Gifs, f);
- exporter.export(document);
- }
- } catch (IOException ioe) {
- JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.EXPORTFAILED);
- }
- }
- });
-
- exportAnimatedGifItem.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent ae) {
- try {
- File f = getExportLocation(ExportType.AnimatedGif);
- if (f != null) {
- PatchExporter exporter = new PatchExporter(ExportType.AnimatedGif, f);
- exporter.export(document);
- }
- } catch (IOException ioe) {
- JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.EXPORTFAILED);
- }
- }
- });
-
- quitItem.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent ae) {
- try {
- if (document.isDirty()) {
- int choice = askSave();
- if (choice == JOptionPane.CANCEL_OPTION)
- return;
- if (choice == JOptionPane.YES_OPTION) {
- save();
- }
- }
- dispose();
- System.exit(0);
- } catch (IOException ioe) {
- JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.SAVEFAILED);
- }
- }
- });
-
- PatchPanelMediator mediator = PatchPanelMediator.getMediator();
- mediator.addActivePatchChangedListener(new ActivePatchChangedListener () {
- public void activePatchChanged(ActivePatchChangedEvent apce) {
- document.setDirty(true);
- saveItem.setEnabled(true);
- }
- });
-
- mediator.addSettingsChangedListener(new SettingsChangedListener() {
- public void settingsChanged(SettingsChangedEvent sce) {
- document.setDirty(true);
- saveItem.setEnabled(true);
- }
- });
- }
-
- private void load() {
- 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.setCurrentDirectory(new File(System.getProperty("user.dir")));
- int option = chooser.showOpenDialog(JPatchAnimFrame.this);
- if (option == JFileChooser.APPROVE_OPTION) {
- documentLocation = chooser.getSelectedFile();
- document = PatchAnimIO.loadFile(documentLocation);
- }
- } catch (Exception e) {
- JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.SAVEFAILED);
- documentLocation = null;
- document = new PatchAnimDocument();
- } finally {
- PatchPanelMediator mediator = PatchPanelMediator.getMediator();
- mediator.setDocument(document);
- saveItem.setEnabled(false);
- }
- }
-
- private void saveAs() throws IOException {
- JFileChooser chooser = new JFileChooser();
- chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
- File defLocation;
- if (documentLocation == null)
- defLocation = new File(System.getProperty("user.dir"));
- else
- defLocation = documentLocation.getParentFile();
-
- chooser.setCurrentDirectory(defLocation);
- int option = chooser.showSaveDialog(JPatchAnimFrame.this);
- if (option == JFileChooser.APPROVE_OPTION) {
- String path = chooser.getSelectedFile().getPath();
- if (!path.toLowerCase().endsWith(".paf"))
- path += ".paf";
- documentLocation = new File(path);
- PatchAnimIO.saveFile(documentLocation, document);
- documentLocation = chooser.getSelectedFile();
- document.setDirty(false);
- saveItem.setEnabled(false);
- }
- }
-
- private void save() throws IOException {
- PatchAnimIO.saveFile(documentLocation, document);
- document.setDirty(false);
- saveItem.setEnabled(false);
- }
-
- private int askSave() {
- ResourceBundle rb = PatchAnimBundle.getBundle();
- return JOptionPane.showConfirmDialog(JPatchAnimFrame.this, rb.getString(PatchAnimBundle.ASKSAVE), rb.getString(PatchAnimBundle.TITLE), JOptionPane.YES_NO_CANCEL_OPTION);
- }
-
- private File getExportLocation(final ExportType type) {
- final ResourceBundle rb = PatchAnimBundle.getBundle();
- JFileChooser chooser = new JFileChooser();
- chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
- File defLocation;
- if (documentLocation == null)
- defLocation = new File(System.getProperty("user.dir"));
- else
- defLocation = documentLocation.getParentFile();
- chooser.setCurrentDirectory(defLocation);
-
- if (!type.isMultipleFiles()) {
- chooser.setFileFilter(new FileFilter() {
-
- @Override
- public boolean accept(File f) {
- return (f.isDirectory() || f.getPath().toLowerCase().endsWith("." + type.getExtension()));
- }
-
- @Override
- public String getDescription() {
- return rb.getString(type.getDescriptionKey());
- }
- });
- }
-
- int option = chooser.showSaveDialog(JPatchAnimFrame.this);
- if (option != JFileChooser.APPROVE_OPTION)
- return null;
-
- return chooser.getSelectedFile();
- }
-}
-
+/*
+ * 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.io.File;
+import java.io.IOException;
+import java.util.ResourceBundle;
+
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.filechooser.FileFilter;
+
+import com.mebigfatguy.patchanim.ExportType;
+import com.mebigfatguy.patchanim.PatchAnimDocument;
+import com.mebigfatguy.patchanim.gui.events.ActivePatchChangedEvent;
+import com.mebigfatguy.patchanim.gui.events.ActivePatchChangedListener;
+import com.mebigfatguy.patchanim.gui.events.SettingsChangedEvent;
+import com.mebigfatguy.patchanim.gui.events.SettingsChangedListener;
+import com.mebigfatguy.patchanim.io.PatchAnimIO;
+import com.mebigfatguy.patchanim.io.PatchExporter;
+import com.mebigfatguy.patchanim.main.PatchAnimBundle;
+
+public class JPatchAnimFrame extends JFrame {
+
+ private static final long serialVersionUID = -4610407923936772733L;
+
+ private JMenuItem newItem;
+ private JMenuItem openItem;
+ private JMenuItem saveItem;
+ private JMenuItem saveAsItem;
+ private JMenu exportMenu;
+ private JMenuItem exportJpgsItem;
+ private JMenuItem exportPngsItem;
+ private JMenuItem exportGifsItem;
+ private JMenuItem exportAnimatedGifItem;
+ private JMenuItem quitItem;
+ private PatchAnimDocument document;
+ private File documentLocation;
+
+ public JPatchAnimFrame() {
+ initComponents();
+ initMenus();
+ initListeners();
+ }
+
+ private void initComponents() {
+ ResourceBundle rb = PatchAnimBundle.getBundle();
+ Container cp = getContentPane();
+ cp.setLayout(new BorderLayout(4, 4));
+
+ JPatchAnimPanel patchPanel = new JPatchAnimPanel();
+ document = new PatchAnimDocument();
+ documentLocation = null;
+ PatchPanelMediator mediator = PatchPanelMediator.getMediator();
+ mediator.setDocument(document);
+
+ cp.add(patchPanel, BorderLayout.CENTER);
+ setTitle(rb.getString(PatchAnimBundle.TITLE));
+ pack();
+ }
+
+ private void initMenus() {
+ ResourceBundle rb = PatchAnimBundle.getBundle();
+ JMenuBar mb = new JMenuBar();
+ JMenu fileMenu = new JMenu(rb.getString(PatchAnimBundle.FILE));
+ newItem = new JMenuItem(rb.getString(PatchAnimBundle.NEW));
+ fileMenu.add(newItem);
+ openItem = new JMenuItem(rb.getString(PatchAnimBundle.OPEN));
+ fileMenu.add(openItem);
+ fileMenu.addSeparator();
+ saveItem = new JMenuItem(rb.getString(PatchAnimBundle.SAVE));
+ saveItem.setEnabled(false);
+ fileMenu.add(saveItem);
+ saveAsItem = new JMenuItem(rb.getString(PatchAnimBundle.SAVEAS));
+ fileMenu.add(saveAsItem);
+ fileMenu.addSeparator();
+ exportMenu = new JMenu(rb.getString(PatchAnimBundle.EXPORT));
+ exportJpgsItem = new JMenuItem(rb.getString(PatchAnimBundle.JPGSERIES));
+ exportPngsItem = new JMenuItem(rb.getString(PatchAnimBundle.PNGSERIES));
+ exportGifsItem = new JMenuItem(rb.getString(PatchAnimBundle.GIFSERIES));
+ exportAnimatedGifItem = new JMenuItem(rb.getString(PatchAnimBundle.ANIMATEDGIF));
+ exportMenu.add(exportJpgsItem);
+ exportMenu.add(exportPngsItem);
+ exportMenu.add(exportGifsItem);
+ exportMenu.addSeparator();
+ exportMenu.add(exportAnimatedGifItem);
+ fileMenu.add(exportMenu);
+ fileMenu.addSeparator();
+ quitItem = new JMenuItem(rb.getString(PatchAnimBundle.QUIT));
+ fileMenu.add(quitItem);
+
+ mb.add(fileMenu);
+
+ setJMenuBar(mb);
+ }
+
+ private void initListeners() {
+ addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent we) {
+ try {
+ if (document.isDirty()) {
+ int choice = askSave();
+ if (choice == JOptionPane.CANCEL_OPTION)
+ return;
+ if (choice == JOptionPane.YES_OPTION) {
+ save();
+ }
+ }
+ dispose();
+ System.exit(0);
+ } catch (IOException ioe) {
+ JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.SAVEFAILED);
+ }
+ }
+ });
+
+ newItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ try {
+ if (document.isDirty()) {
+ int choice = askSave();
+ if (choice == JOptionPane.CANCEL_OPTION)
+ return;
+ if (choice == JOptionPane.YES_OPTION) {
+ save();
+ }
+ }
+
+ document = new PatchAnimDocument();
+ documentLocation = null;
+ saveItem.setEnabled(false);
+ } catch (IOException ioe) {
+ JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.SAVEFAILED);
+ }
+ }
+ });
+
+ openItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ try {
+ if (document.isDirty()) {
+ int choice = askSave();
+ if (choice == JOptionPane.CANCEL_OPTION)
+ return;
+ if (choice == JOptionPane.YES_OPTION) {
+ save();
+ }
+ }
+ load();
+ } catch (IOException ioe) {
+ JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.LOADFAILED);
+ }
+ }
+ });
+
+ saveItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ try {
+ if (documentLocation == null) {
+ saveAs();
+ } else {
+ save();
+ }
+ } catch (IOException ioe) {
+ JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.SAVEFAILED);
+ }
+ }
+ });
+
+ saveAsItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ try {
+ saveAs();
+ } catch (IOException ioe) {
+ JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.SAVEFAILED);
+ }
+ }
+ });
+
+ exportJpgsItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ try {
+ File f = getExportLocation(ExportType.JPegs);
+ if (f != null) {
+ PatchExporter exporter = new PatchExporter(ExportType.JPegs, f);
+ exporter.export(document);
+ }
+ } catch (IOException ioe) {
+ JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.EXPORTFAILED);
+ }
+ }
+ });
+
+ exportPngsItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ try {
+ File f = getExportLocation(ExportType.Pngs);
+ if (f != null) {
+ PatchExporter exporter = new PatchExporter(ExportType.Pngs, f);
+ exporter.export(document);
+ }
+ } catch (IOException ioe) {
+ JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.EXPORTFAILED);
+ }
+ }
+ });
+
+ exportGifsItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ try {
+ File f = getExportLocation(ExportType.Gifs);
+ if (f != null) {
+ PatchExporter exporter = new PatchExporter(ExportType.Gifs, f);
+ exporter.export(document);
+ }
+ } catch (IOException ioe) {
+ JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.EXPORTFAILED);
+ }
+ }
+ });
+
+ exportAnimatedGifItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ try {
+ File f = getExportLocation(ExportType.AnimatedGif);
+ if (f != null) {
+ PatchExporter exporter = new PatchExporter(ExportType.AnimatedGif, f);
+ exporter.export(document);
+ }
+ } catch (IOException ioe) {
+ JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.EXPORTFAILED);
+ }
+ }
+ });
+
+ quitItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent ae) {
+ try {
+ if (document.isDirty()) {
+ int choice = askSave();
+ if (choice == JOptionPane.CANCEL_OPTION)
+ return;
+ if (choice == JOptionPane.YES_OPTION) {
+ save();
+ }
+ }
+ dispose();
+ System.exit(0);
+ } catch (IOException ioe) {
+ JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.SAVEFAILED);
+ }
+ }
+ });
+
+ PatchPanelMediator mediator = PatchPanelMediator.getMediator();
+ mediator.addActivePatchChangedListener(new ActivePatchChangedListener () {
+ public void activePatchChanged(ActivePatchChangedEvent apce) {
+ document.setDirty(true);
+ saveItem.setEnabled(true);
+ }
+ });
+
+ mediator.addSettingsChangedListener(new SettingsChangedListener() {
+ public void settingsChanged(SettingsChangedEvent sce) {
+ document.setDirty(true);
+ saveItem.setEnabled(true);
+ }
+ });
+ }
+
+ private void load() {
+ 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.setCurrentDirectory(new File(System.getProperty("user.dir")));
+ int option = chooser.showOpenDialog(JPatchAnimFrame.this);
+ if (option == JFileChooser.APPROVE_OPTION) {
+ documentLocation = chooser.getSelectedFile();
+ document = PatchAnimIO.loadFile(documentLocation);
+ }
+ } catch (Exception e) {
+ JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.SAVEFAILED);
+ documentLocation = null;
+ document = new PatchAnimDocument();
+ } finally {
+ PatchPanelMediator mediator = PatchPanelMediator.getMediator();
+ mediator.setDocument(document);
+ saveItem.setEnabled(false);
+ }
+ }
+
+ private void saveAs() throws IOException {
+ JFileChooser chooser = new JFileChooser();
+ chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ File defLocation;
+ if (documentLocation == null)
+ defLocation = new File(System.getProperty("user.dir"));
+ else
+ defLocation = documentLocation.getParentFile();
+
+ chooser.setCurrentDirectory(defLocation);
+ int option = chooser.showSaveDialog(JPatchAnimFrame.this);
+ if (option == JFileChooser.APPROVE_OPTION) {
+ String path = chooser.getSelectedFile().getPath();
+ if (!path.toLowerCase().endsWith(".paf"))
+ path += ".paf";
+ documentLocation = new File(path);
+ PatchAnimIO.saveFile(documentLocation, document);
+ documentLocation = chooser.getSelectedFile();
+ document.setDirty(false);
+ saveItem.setEnabled(false);
+ }
+ }
+
+ private void save() throws IOException {
+ PatchAnimIO.saveFile(documentLocation, document);
+ document.setDirty(false);
+ saveItem.setEnabled(false);
+ }
+
+ private int askSave() {
+ ResourceBundle rb = PatchAnimBundle.getBundle();
+ return JOptionPane.showConfirmDialog(JPatchAnimFrame.this, rb.getString(PatchAnimBundle.ASKSAVE), rb.getString(PatchAnimBundle.TITLE), JOptionPane.YES_NO_CANCEL_OPTION);
+ }
+
+ private File getExportLocation(final ExportType type) {
+ final ResourceBundle rb = PatchAnimBundle.getBundle();
+ JFileChooser chooser = new JFileChooser();
+ chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ File defLocation;
+ if (documentLocation == null)
+ defLocation = new File(System.getProperty("user.dir"));
+ else
+ defLocation = documentLocation.getParentFile();
+ chooser.setCurrentDirectory(defLocation);
+
+ if (!type.isMultipleFiles()) {
+ chooser.setFileFilter(new FileFilter() {
+
+ @Override
+ public boolean accept(File f) {
+ return (f.isDirectory() || f.getPath().toLowerCase().endsWith("." + type.getExtension()));
+ }
+
+ @Override
+ public String getDescription() {
+ return rb.getString(type.getDescriptionKey());
+ }
+ });
+ }
+
+ int option = chooser.showSaveDialog(JPatchAnimFrame.this);
+ if (option != JFileChooser.APPROVE_OPTION)
+ return null;
+
+ return chooser.getSelectedFile();
+ }
+}
+
Property changes on: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimPanel.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimPanel.java 2008-01-30 01:46:25 UTC (rev 64)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimPanel.java 2008-01-30 01:49:46 UTC (rev 65)
@@ -1,84 +1,84 @@
-/*
- * 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 javax.swing.BorderFactory;
-import javax.swing.Box;
-import javax.swing.BoxLayout;
-import javax.swing.JPanel;
-
-import com.mebigfatguy.patchanim.PatchColor;
-
-public class JPatchAnimPanel extends JPanel {
-
- private static final long serialVersionUID = 7719900566976553103L;
- private JPatchControlPanel ctrl;
- private JPatchSamplePanel sample;
-
- public JPatchAnimPanel() {
- initComponents();
- }
-
- private void initComponents() {
- setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
- JPanel p = new JPanel();
- p.setLayout(new BorderLayout(4, 4));
- ctrl = new JPatchControlPanel();
- p.add(ctrl, BorderLayout.WEST);
- sample = new JPatchSamplePanel(PatchColor.Combined);
- JPanel q = new JPanel();
- q.setLayout(new BoxLayout(q, BoxLayout.X_AXIS));
- q.add(Box.createHorizontalGlue());
- q.add(sample);
- q.add(Box.createHorizontalGlue());
- q.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
- p.add(q, BorderLayout.CENTER);
- add(p);
-
-
- p = new JPanel();
- p.setLayout(new BorderLayout(4, 4));
- p.add(new JPatchListPanel(), BorderLayout.WEST);
-
- 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());
- }
-
- p.add(q, BorderLayout.CENTER);
-
- p.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
-
- add(p);
- setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
- }
-}
+/*
+ * 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 javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JPanel;
+
+import com.mebigfatguy.patchanim.PatchColor;
+
+public class JPatchAnimPanel extends JPanel {
+
+ private static final long serialVersionUID = 7719900566976553103L;
+ private JPatchControlPanel ctrl;
+ private JPatchSamplePanel sample;
+
+ public JPatchAnimPanel() {
+ initComponents();
+ }
+
+ private void initComponents() {
+ setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+ JPanel p = new JPanel();
+ p.setLayout(new BorderLayout(4, 4));
+ ctrl = new JPatchControlPanel();
+ p.add(ctrl, BorderLayout.WEST);
+ sample = new JPatchSamplePanel(PatchColor.Combined);
+ JPanel q = new JPanel();
+ q.setLayout(new BoxLayout(q, BoxLayout.X_AXIS));
+ q.add(Box.createHorizontalGlue());
+ q.add(sample);
+ q.add(Box.createHorizontalGlue());
+ q.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
+ p.add(q, BorderLayout.CENTER);
+ add(p);
+
+
+ p = new JPanel();
+ p.setLayout(new BorderLayout(4, 4));
+ p.add(new JPatchListPanel(), BorderLayout.WEST);
+
+ 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());
+ }
+
+ p.add(q, BorderLayout.CENTER);
+
+ p.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
+
+ add(p);
+ setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
+ }
+}
Property changes on: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimPanel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchControlPanel.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchControlPanel.java 2008-01-30 01:46:25 UTC (rev 64)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchControlPanel.java 2008-01-30 01:49:46 UTC (rev 65)
@@ -1,231 +1,233 @@
-/*
- * 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.Dimension;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.FocusAdapter;
-import java.awt.event.FocusEvent;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.util.ResourceBundle;
-
-import javax.swing.BorderFactory;
-import javax.swing.Box;
-import javax.swing.BoxLayout;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-import javax.swing.SwingUtilities;
-
-import com.mebigfatguy.patchanim.AnimationType;
-import com.mebigfatguy.patchanim.OutOfBoundsColor;
-import com.mebigfatguy.patchanim.PatchAnimDocument;
-import com.mebigfatguy.patchanim.main.PatchAnimBundle;
-
-public class JPatchControlPanel extends JPanel {
-
- private static final long serialVersionUID = -5968231995166721151L;
-
- private PatchAnimDocument document;
- private JTextField widthField;
- private JTextField heightField;
- private JComboBox animationCB;
- private JComboBox outOfBoundsColorCB;
- private JTextField tweenFramesField;
- private JButton testButton;
-
- public JPatchControlPanel() {
- initComponents();
- initListeners();
- }
-
- private void initComponents() {
- ResourceBundle rb = PatchAnimBundle.getBundle();
- setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
- setBorder(BorderFactory.createTitledBorder(rb.getString(PatchAnimBundle.CONTROLS)));
-
- JLabel widthLabel;
- JLabel heightLabel;
- JLabel animationLabel;
- JLabel outOfBoundsLabel;
- JLabel tweenFramesLabel;
-
- {
- widthLabel = new JLabel(rb.getString(PatchAnimBundle.WIDTH));
- widthField = new JTextField(new IntegerDocument(), "", 8);
- widthLabel.setLabelFor(widthField);
- JPanel p = Utils.createFormPanel(widthLabel, widthField);
-
- Utils.limitPanelHeight(p, widthField);
- add(p);
- }
- add(Box.createVerticalStrut(5));
- {
- heightLabel = new JLabel(rb.getString(PatchAnimBundle.HEIGHT));
- heightField = new JTextField(new IntegerDocument(), "", 8);
- heightLabel.setLabelFor(heightField);
- JPanel p = Utils.createFormPanel(heightLabel, heightField);
-
- Utils.limitPanelHeight(p, heightField);
- add(p);
- }
- add(Box.createVerticalStrut(5));
- {
- animationLabel = new JLabel(rb.getString(PatchAnimBundle.ANIMATION));
- animationCB = new JComboBox(new Object[] { AnimationType.None,
- AnimationType.Cycle,
- AnimationType.Wave });
- animationLabel.setLabelFor(animationCB);
- JPanel p = Utils.createFormPanel(animationLabel, animationCB);
-
- Utils.limitPanelHeight(p, animationCB);
- add(p);
- }
- add(Box.createVerticalStrut(5));
- {
- outOfBoundsLabel = new JLabel(rb.getString(PatchAnimBundle.OUTOFBOUNDSCOLOR));
- outOfBoundsColorCB = new JComboBox(new Object[] { OutOfBoundsColor.Clip,
- OutOfBoundsColor.Roll });
- outOfBoundsLabel.setLabelFor(outOfBoundsColorCB);
- JPanel p = Utils.createFormPanel(outOfBoundsLabel, outOfBoundsColorCB);
- Utils.limitPanelHeight(p, outOfBoundsColorCB);
- add(p);
- }
- add(Box.createVerticalStrut(5));
- {
- tweenFramesLabel = new JLabel(rb.getString(PatchAnimBundle.TWEENFRAMES));
- tweenFramesField = new JTextField(new IntegerDocument(), "", 8);
- tweenFramesLabel.setLabelFor(tweenFramesField);
- JPanel p = Utils.createFormPanel(tweenFramesLabel, tweenFramesField);
- Utils.limitPanelHeight(p, tweenFramesField);
- add(p);
- }
- add(Box.createVerticalStrut(5));
-
- testButton = new JButton(rb.getString(PatchAnimBundle.TEST));
- 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);
-
- add(Box.createVerticalGlue());
-
- Dimension d = getPreferredSize();
- if (d.width < 200)
- d.width = 200;
- setPreferredSize(d);
- }
-
- private void initListeners() {
- PatchPanelMediator mediator = PatchPanelMediator.getMediator();
- mediator.addDocumentChangedListener(new DocumentChangedListener() {
- public void documentChanged(DocumentChangedEvent dce) {
- document = dce.getDocument();
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- widthField.setText(String.valueOf(document.getWidth()));
- heightField.setText(String.valueOf(document.getHeight()));
- animationCB.setSelectedIndex(document.getAnimationType().ordinal());
- outOfBoundsColorCB.setSelectedIndex(document.getOutOfBoundsColor().ordinal());
- tweenFramesField.setText(String.valueOf(document.getTweenCount()));
- }
- });
- }
- });
-
- widthField.addFocusListener(new FocusAdapter() {
-
- @Override
- public void focusLost(FocusEvent arg0) {
- try {
- document.setWidth(Integer.parseInt(widthField.getText()));
- } catch (NumberFormatException nfe) {
- document.setWidth(0);
- }
- PatchPanelMediator mediator = PatchPanelMediator.getMediator();
- mediator.fireSettingsChanged();
- }
- });
-
-
- heightField.addFocusListener(new FocusAdapter() {
-
- @Override
- public void focusLost(FocusEvent arg0) {
- try {
- document.setHeight(Integer.parseInt(heightField.getText()));
- } catch (NumberFormatException nfe) {
- document.setHeight(0);
- }
- PatchPanelMediator mediator = PatchPanelMediator.getMediator();
- mediator.fireSettingsChanged();
- }
- });
-
- tweenFramesField.addFocusListener(new FocusAdapter() {
-
- @Override
- public void focusLost(FocusEvent arg0) {
- try {
- document.setTweenCount(Integer.parseInt(tweenFramesField.getText()));
- } catch (NumberFormatException nfe) {
- document.setTweenCount(0);
- }
- PatchPanelMediator mediator = PatchPanelMediator.getMediator();
- mediator.fireSettingsChanged();
- }
- });
-
- animationCB.addItemListener(new ItemListener() {
-
- public void itemStateChanged(ItemEvent ie) {
- if (ie.getStateChange() == ItemEvent.SELECTED) {
- document.setAnimationType((AnimationType)ie.getItem());
- PatchPanelMediator mediator = PatchPanelMediator.getMediator();
- mediator.fireSettingsChanged();
- }
- }
- });
-
- outOfBoundsColorCB.addItemListener(new ItemListener() {
-
- public void itemStateChanged(ItemEvent ie) {
- if (ie.getStateChange() == ItemEvent.SELECTED) {
- document.setOutOfBoundsColor((OutOfBoundsColor)ie.getItem());
- PatchPanelMediator mediator = PatchPanelMediator.getMediator();
- mediator.fireSettingsChanged();
- }
- }
- });
-
- testButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent ae) {
- JTestFrame tf = new JTestFrame();
- tf.setLocationRelativeTo(null);
- tf.setVisible(true);
- tf.beginAnimation();
- }
- });
- }
-}
+/*
+ * 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.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.ResourceBundle;
+
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+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.DocumentChangedEvent;
+import com.mebigfatguy.patchanim.gui.events.DocumentChangedListener;
+import com.mebigfatguy.patchanim.main.PatchAnimBundle;
+
+public class JPatchControlPanel extends JPanel {
+
+ private static final long serialVersionUID = -5968231995166721151L;
+
+ private PatchAnimDocument document;
+ private JTextField widthField;
+ private JTextField heightField;
+ private JComboBox animationCB;
+ private JComboBox outOfBoundsColorCB;
+ private JTextField tweenFramesField;
+ private JButton testButton;
+
+ public JPatchControlPanel() {
+ initComponents();
+ initListeners();
+ }
+
+ private void initComponents() {
+ ResourceBundle rb = PatchAnimBundle.getBundle();
+ setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+ setBorder(BorderFactory.createTitledBorder(rb.getString(PatchAnimBundle.CONTROLS)));
+
+ JLabel widthLabel;
+ JLabel heightLabel;
+ JLabel animationLabel;
+ JLabel outOfBoundsLabel;
+ JLabel tweenFramesLabel;
+
+ {
+ widthLabel = new JLabel(rb.getString(PatchAnimBundle.WIDTH));
+ widthField = new JTextField(new IntegerDocument(), "", 8);
+ widthLabel.setLabelFor(widthField);
+ JPanel p = Utils.createFormPanel(widthLabel, widthField);
+
+ Utils.limitPanelHeight(p, widthField);
+ add(p);
+ }
+ add(Box.createVerticalStrut(5));
+ {
+ heightLabel = new JLabel(rb.getString(PatchAnimBundle.HEIGHT));
+ heightField = new JTextField(new IntegerDocument(), "", 8);
+ heightLabel.setLabelFor(heightField);
+ JPanel p = Utils.createFormPanel(heightLabel, heightField);
+
+ Utils.limitPanelHeight(p, heightField);
+ add(p);
+ }
+ add(Box.createVerticalStrut(5));
+ {
+ an...
[truncated message content] |