Thread: [Patchanim-commit] SF.net SVN: patchanim: [79] trunk/patchanim/src/com/mebigfatguy/patchanim/ io/Pa
Brought to you by:
dbrosius
From: <dbr...@us...> - 2008-01-31 06:07:18
|
Revision: 79 http://patchanim.svn.sourceforge.net/patchanim/?rev=79&view=rev Author: dbrosius Date: 2008-01-30 22:07:22 -0800 (Wed, 30 Jan 2008) Log Message: ----------- fix fencepost export problem when there's only one image Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java 2008-01-31 06:00:42 UTC (rev 78) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java 2008-01-31 06:07:22 UTC (rev 79) @@ -86,29 +86,34 @@ agEncoder.setRepeat((atype != AnimationType.None) ? 0 : -1); } - for(int p = 0; p < lastPatch; p++) { - CombinedPatch startPatch = patches.get(p); - CombinedPatch endPatch = patches.get(p+1); - for (int t = 0; t < tweenCount; t++) { - CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)tweenCount); - PatchGenerator.recalcCombinedImage(tweenPatch, image, oob); - writeSingleFile(image, imageIndex++, loc, baseName, type); - } - } - - if (atype == AnimationType.None) - return; - - if (atype == AnimationType.Wave) { - for (int p = lastPatch; p > 0; p--) { - CombinedPatch startPatch = patches.get(p-1); - CombinedPatch endPatch = patches.get(p); - for (int t = tweenCount - 1; t >= 0; t--) { + if (lastPatch == 0) { + PatchGenerator.recalcCombinedImage(patches.get(0), image, oob); + writeSingleFile(image, imageIndex++, loc, baseName, type); + } else { + for(int p = 0; p < lastPatch; p++) { + CombinedPatch startPatch = patches.get(p); + CombinedPatch endPatch = patches.get(p+1); + for (int t = 0; t < tweenCount; t++) { CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)tweenCount); PatchGenerator.recalcCombinedImage(tweenPatch, image, oob); writeSingleFile(image, imageIndex++, loc, baseName, type); } } + + if (atype == AnimationType.None) + return; + + if (atype == AnimationType.Wave) { + for (int p = lastPatch; p > 0; p--) { + CombinedPatch startPatch = patches.get(p-1); + CombinedPatch endPatch = patches.get(p); + for (int t = tweenCount - 1; t >= 0; t--) { + CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)tweenCount); + PatchGenerator.recalcCombinedImage(tweenPatch, image, oob); + writeSingleFile(image, imageIndex++, loc, baseName, type); + } + } + } } } finally { if (type == ExportType.AnimatedGif) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-02-10 05:32:05
|
Revision: 132 http://patchanim.svn.sourceforge.net/patchanim/?rev=132&view=rev Author: dbrosius Date: 2008-02-09 21:32:10 -0800 (Sat, 09 Feb 2008) Log Message: ----------- fix multi file names Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java 2008-02-10 05:29:53 UTC (rev 131) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java 2008-02-10 05:32:10 UTC (rev 132) @@ -140,7 +140,8 @@ private void writeSingleFile(BufferedImage image, int index, File dir, String baseName, ExportType type) throws IOException { NumberFormat nf = NumberFormat.getIntegerInstance(); - nf.setMinimumIntegerDigits(6); + nf.setMinimumIntegerDigits(5); + nf.setGroupingUsed(false); String name = baseName + "_" + nf.format(index) + "." + type.getExtension(); File imageFile = new File(dir, name); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-02-18 03:16:14
|
Revision: 198 http://patchanim.svn.sourceforge.net/patchanim/?rev=198&view=rev Author: dbrosius Date: 2008-02-17 19:16:18 -0800 (Sun, 17 Feb 2008) Log Message: ----------- rework exported to use the new PatchAnimator as well. Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java 2008-02-18 03:04:31 UTC (rev 197) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java 2008-02-18 03:16:18 UTC (rev 198) @@ -23,30 +23,34 @@ import java.io.IOException; import java.text.NumberFormat; import java.util.HashSet; -import java.util.List; +import java.util.ResourceBundle; import java.util.Set; import javax.imageio.ImageIO; +import javax.swing.JOptionPane; import com.fmsware.gif.AnimatedGifEncoder; -import com.mebigfatguy.patchanim.encoders.APngEncoder; -import com.mebigfatguy.patchanim.encoders.MngEncoder; import com.mebigfatguy.patchanim.AnimationType; import com.mebigfatguy.patchanim.ExportType; -import com.mebigfatguy.patchanim.OutOfBoundsColor; import com.mebigfatguy.patchanim.PatchAnimDocument; +import com.mebigfatguy.patchanim.encoders.APngEncoder; +import com.mebigfatguy.patchanim.encoders.MngEncoder; import com.mebigfatguy.patchanim.gui.events.ExportEvent; import com.mebigfatguy.patchanim.gui.events.ExportListener; -import com.mebigfatguy.patchanim.surface.CombinedPatch; -import com.mebigfatguy.patchanim.surface.PatchGenerator; +import com.mebigfatguy.patchanim.gui.events.PatchCompletionEvent; +import com.mebigfatguy.patchanim.gui.events.PatchCompletionListener; +import com.mebigfatguy.patchanim.main.PatchAnimBundle; +import com.mebigfatguy.patchanim.surface.PatchAnimator; -public class PatchExporter { +public class PatchExporter implements PatchCompletionListener { private ExportType type; private File loc; private AnimatedGifEncoder agEncoder; private APngEncoder apngEncoder; private MngEncoder mngEncoder; private int totalImages; + private int imageIndex; + private String baseName; private Set<ExportListener> elisteners = new HashSet<ExportListener>(); public PatchExporter(ExportType exportType, File location) { @@ -66,7 +70,7 @@ public void export(PatchAnimDocument document) throws IOException { try { - String baseName = loc.getName(); + baseName = loc.getName(); if (type.isMultipleFiles()) { loc.mkdir(); } else { @@ -83,74 +87,33 @@ } totalImages = calcImageCount(document); + imageIndex = 1; - BufferedImage image = PatchGenerator.buildImage(null, document.getWidth(), document.getHeight()); - List<CombinedPatch> patches = document.getPatches(); - int lastPatch = patches.size() - 1; - int tweenCount = document.getTweenCount(); - OutOfBoundsColor oob = document.getOutOfBoundsColor(); - int imageIndex = 1; AnimationType atype = document.getAnimationType(); - - if (type == ExportType.AnimatedGif) { - agEncoder.setRepeat((atype != AnimationType.None) ? 0 : -1); - } else if (type == ExportType.AnimatedPng) { - apngEncoder.setRepeat(atype != AnimationType.None); - apngEncoder.setNumFrames(totalImages); - } else if (type == ExportType.AnimatedMng) { - mngEncoder.setRepeat(atype != AnimationType.None); - mngEncoder.setNumFrames(totalImages); - mngEncoder.setDelay(100); + switch (type) { + case AnimatedGif: + agEncoder.setRepeat((atype != AnimationType.None) ? 0 : -1); + break; + + case AnimatedPng: + apngEncoder.setRepeat(atype != AnimationType.None); + apngEncoder.setNumFrames(totalImages); + break; + + case AnimatedMng: + mngEncoder.setRepeat(atype != AnimationType.None); + mngEncoder.setNumFrames(totalImages); + mngEncoder.setDelay(100); } + - if (lastPatch == 0) { - PatchGenerator.recalcCombinedImage(patches.get(0), image, oob); - writeSingleFile(image, imageIndex++, loc, baseName, type); - } else { - for(int p = 0; p < lastPatch; p++) { - CombinedPatch startPatch = patches.get(p); - CombinedPatch endPatch = patches.get(p+1); - for (int t = 0; t < tweenCount + 1; t++) { - CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)(tweenCount + 1)); - PatchGenerator.recalcCombinedImage(tweenPatch, image, oob); - writeSingleFile(image, imageIndex++, loc, baseName, type); - } - } - - switch (atype) { - case None: { - CombinedPatch patch = patches.get(lastPatch); - PatchGenerator.recalcCombinedImage(patch, image, oob); - writeSingleFile(image, imageIndex++, loc, baseName, type); - if (atype == AnimationType.None) - return; - } - break; - - case Cycle: { - CombinedPatch startPatch = patches.get(lastPatch); - CombinedPatch endPatch = patches.get(0); - for (int t = 0; t < tweenCount + 1; t++) { - CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)(tweenCount + 1)); - PatchGenerator.recalcCombinedImage(tweenPatch, image, oob); - writeSingleFile(image, imageIndex++, loc, baseName, type); - } - } - break; - - case Wave: { - for (int p = lastPatch; p > 0; p--) { - CombinedPatch startPatch = patches.get(p-1); - CombinedPatch endPatch = patches.get(p); - for (int t = tweenCount + 1; t > 0; t--) { - CombinedPatch tweenPatch = CombinedPatch.tween(startPatch, endPatch, (double)t / (double)(tweenCount + 1)); - PatchGenerator.recalcCombinedImage(tweenPatch, image, oob); - writeSingleFile(image, imageIndex++, loc, baseName, type); - } - } - } - break; - } + PatchAnimator animator = new PatchAnimator(document); + animator.addPatchCompletionListener(this); + try { + animator.animatePatches(); + } catch (InterruptedException ie) { + ResourceBundle rb = PatchAnimBundle.getBundle(); + JOptionPane.showMessageDialog(null, rb.getString(PatchAnimBundle.EXPORTFAILED)); } } finally { if (type == ExportType.AnimatedGif) { @@ -163,6 +126,16 @@ } } + public void patchCompleted(PatchCompletionEvent pce) throws InterruptedException { + try { + writeSingleFile(pce.getImage(), imageIndex++, loc, baseName, type); + } catch (IOException ioe) { + InterruptedException ie = new InterruptedException("Failed saving animation"); + ie.initCause(ioe); + throw ie; + } + } + private void writeSingleFile(BufferedImage image, int index, File dir, String baseName, ExportType type) throws IOException { NumberFormat nf = NumberFormat.getIntegerInstance(); nf.setMinimumIntegerDigits(5); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2008-02-24 15:38:47
|
Revision: 235 http://patchanim.svn.sourceforge.net/patchanim/?rev=235&view=rev Author: dbrosius Date: 2008-02-24 07:38:47 -0800 (Sun, 24 Feb 2008) Log Message: ----------- throw exception if you can't create export directory Modified Paths: -------------- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java Modified: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java =================================================================== --- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java 2008-02-24 15:32:21 UTC (rev 234) +++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchExporter.java 2008-02-24 15:38:47 UTC (rev 235) @@ -72,7 +72,8 @@ try { baseName = loc.getName(); if (type.isMultipleFiles()) { - loc.mkdir(); + if (!loc.mkdir()) + throw new IOException("Failed to create directory " + loc.getName()); } else { loc = loc.getParentFile(); String dotExt = "." + type.getExtension(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |