[Patchanim-commit] SF.net SVN: patchanim: [67] trunk/patchanim/src/com/mebigfatguy/patchanim
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2008-01-30 02:35:20
|
Revision: 67
http://patchanim.svn.sourceforge.net/patchanim/?rev=67&view=rev
Author: dbrosius
Date: 2008-01-29 18:35:25 -0800 (Tue, 29 Jan 2008)
Log Message:
-----------
add a progress bar on export
Modified Paths:
--------------
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java
trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java
trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties
Added Paths:
-----------
trunk/patchanim/src/com/mebigfatguy/patchanim/gui/ExportFrame.java
Added: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/ExportFrame.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/gui/ExportFrame.java (rev 0)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/ExportFrame.java 2008-01-30 02:35:25 UTC (rev 67)
@@ -0,0 +1,46 @@
+package com.mebigfatguy.patchanim.gui;
+
+import java.awt.BorderLayout;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.util.ResourceBundle;
+
+import javax.swing.BorderFactory;
+import javax.swing.JDialog;
+import javax.swing.JProgressBar;
+import javax.swing.SwingUtilities;
+
+import com.mebigfatguy.patchanim.gui.events.ExportEvent;
+import com.mebigfatguy.patchanim.gui.events.ExportListener;
+import com.mebigfatguy.patchanim.main.PatchAnimBundle;
+
+public class ExportFrame extends JDialog implements ExportListener {
+ private static final long serialVersionUID = 3111097499092146056L;
+ private JProgressBar bar;
+
+ public ExportFrame() {
+ initComponents();
+ }
+
+ private void initComponents() {
+ ResourceBundle rb = PatchAnimBundle.getBundle();
+ Container cp = getContentPane();
+ cp.setLayout(new BorderLayout(4, 4));
+ bar = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);
+ bar.setBorder(BorderFactory.createEmptyBorder(10, 50, 10, 50));
+ cp.add(bar, BorderLayout.CENTER);
+ pack();
+ setTitle(rb.getString(PatchAnimBundle.EXPORTINGFILE));
+ Dimension d = getPreferredSize();
+ }
+
+ public void imageExported(final ExportEvent ee) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ bar.setMaximum(ee.getTotalImages());
+ bar.setValue(ee.getCurrentImage());
+ }
+ });
+ }
+
+}
Property changes on: trunk/patchanim/src/com/mebigfatguy/patchanim/gui/ExportFrame.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 02:04:43 UTC (rev 66)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/gui/JPatchAnimFrame.java 2008-01-30 02:35:25 UTC (rev 67)
@@ -34,6 +34,7 @@
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
import javax.swing.filechooser.FileFilter;
import com.mebigfatguy.patchanim.ExportType;
@@ -206,57 +207,25 @@
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);
- }
+ export(ExportType.JPegs);
}
});
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);
- }
+ export(ExportType.Pngs);
}
});
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);
- }
+ export(ExportType.Gifs);
}
});
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);
- }
+ export(ExportType.AnimatedGif);
}
});
@@ -396,5 +365,31 @@
return chooser.getSelectedFile();
}
+
+ private void export(ExportType type) {
+ File f = getExportLocation(type);
+ if (f != null) {
+ final PatchExporter exporter = new PatchExporter(type, f);
+ final ExportFrame ed = new ExportFrame();
+ ed.setLocationRelativeTo(JPatchAnimFrame.this);
+ ed.setVisible(true);
+ Thread t = new Thread(new Runnable() {
+ public void run() {
+ try {
+ exporter.addExportListener(ed);
+ exporter.export(document);
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ ed.dispose();
+ }
+ });
+ } catch (IOException ioe) {
+ JOptionPane.showMessageDialog(JPatchAnimFrame.this, PatchAnimBundle.EXPORTFAILED);
+ }
+ }
+ });
+ t.start();
+ }
+ }
}
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java 2008-01-30 02:04:43 UTC (rev 66)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/main/PatchAnimBundle.java 2008-01-30 02:35:25 UTC (rev 67)
@@ -40,6 +40,7 @@
public static final String ANIMATEDGIFFILTER = "patchanim.filter.animatedgif";
public static final String MPEG = "patchanim.mpeg";
public static final String MPEGFILTER = "patchanim.filter.mpeg";
+ public static final String EXPORTINGFILE = "patchanim.exportfile";
public static final String QUIT = "patchanim.quit";
public static final String CONTROLS = "patchanim.control";
public static final String WIDTH = "patchanim.width";
Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-01-30 02:04:43 UTC (rev 66)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/resources.properties 2008-01-30 02:35:25 UTC (rev 67)
@@ -26,13 +26,14 @@
patchanim.jpgs = a series of JPGs
patchanim.filter.jpgs = Files (*.jpg)
patchanim.pngs = a series of PNGs
-patchanim.filter.pnga = Png Files (*.png)
+patchanim.filter.pngs = Png Files (*.png)
patchanim.gifs = a series of GIFs
patchanim.filter.gifs = Gif Files (*.gif)
patchanim.animatedgif = an Animated Gif
patchanim.filter.animatedgif = Gif Files (*.gif)
patchanim.mpeg = an MPEG
patchanim.filter.mpeg = MPEG Files (*.mpg)
+patchanim.exportfile = Exporting Animation
patchanim.quit = Quit
patchanim.control = Controls
patchanim.width = Width
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|