From 40217c0a3922b91c3f278988a1ab8cdb8c3a4ae6 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Wed, 6 May 2015 10:51:05 +0200 Subject: [PATCH] split panes simplified (base class stores the position) --- libsrc/ffdec_lib/nbproject/project.xml | 6 +- .../jpexs/decompiler/flash/RunnableIOEx.java | 10 +- .../flash/configuration/Configuration.java | 19 +- .../flash/exporters/BinaryDataExporter.java | 10 +- .../flash/exporters/FontExporter.java | 8 +- .../flash/exporters/FrameExporter.java | 289 ++++++++---------- .../flash/exporters/ImageExporter.java | 14 +- .../flash/exporters/MorphShapeExporter.java | 65 ++-- .../flash/exporters/MovieExporter.java | 10 +- .../flash/exporters/ShapeExporter.java | 99 +++--- .../flash/exporters/SoundExporter.java | 10 +- .../flash/exporters/TextExporter.java | 60 ++-- .../decompiler/flash/helpers/FontHelper.java | 5 +- .../decompiler/flash/xfl/XFLConverter.java | 39 +-- .../com/jpexs/helpers/ProgressListener.java | 10 +- .../jpexs/decompiler/flash/gui/MainPanel.java | 72 +---- .../decompiler/flash/gui/PreviewPanel.java | 25 +- .../decompiler/flash/gui/SearchDialog.java | 1 - .../decompiler/flash/gui/abc/ABCPanel.java | 32 +- .../flash/gui/abc/DecompiledEditorPane.java | 7 - .../flash/gui/abc/DeobfuscationDialog.java | 1 - .../decompiler/flash/gui/abc/DetailPanel.java | 53 ++-- .../flash/gui/action/ActionPanel.java | 26 +- .../gui/controls/JPersistentSplitPane.java | 57 ++++ .../gui/generictageditors/ChangeListener.java | 7 +- .../helpers/CollectionChangedListener.java | 1 + .../gui/timeline/FrameSelectionListener.java | 7 +- .../flash/gui/timeline/TimelineViewPanel.java | 4 +- 28 files changed, 420 insertions(+), 527 deletions(-) create mode 100644 src/com/jpexs/decompiler/flash/gui/controls/JPersistentSplitPane.java diff --git a/libsrc/ffdec_lib/nbproject/project.xml b/libsrc/ffdec_lib/nbproject/project.xml index 2e574c954..cb4de07c9 100644 --- a/libsrc/ffdec_lib/nbproject/project.xml +++ b/libsrc/ffdec_lib/nbproject/project.xml @@ -89,18 +89,18 @@ auxiliary.show.customizer.message= - + src ../../lib/LZMA.jar;../../lib/avi.jar;../../lib/gif.jar;../../lib/gnujpdf.jar;../../lib/jl1.0.1.jar;../../lib/jpacker.jar;../../lib/nellymoser.jar;../../lib/sfntly.jar;../../lib/ttf.jar;../../src build - 1.7 + 1.8 test ../../lib/LZMA.jar;../../lib/avi.jar;../../lib/gif.jar;../../lib/gnujpdf.jar;../../lib/jl1.0.1.jar;../../lib/jpacker.jar;../../lib/nellymoser.jar;../../lib/sfntly.jar;../../lib/ttf.jar;testlib/emma.jar;testlib/emma_ant.jar;testlib/testng-6.8.jar;src - 1.7 + 1.8 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/RunnableIOEx.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/RunnableIOEx.java index 1d197e620..bcb22ffbf 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/RunnableIOEx.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/RunnableIOEx.java @@ -1,18 +1,19 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * 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 3.0 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. */ + * License along with this library. + */ package com.jpexs.decompiler.flash; import java.io.IOException; @@ -21,6 +22,7 @@ import java.io.IOException; * * @author JPEXS */ +@FunctionalInterface public interface RunnableIOEx { public void run() throws IOException; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java index f2259a026..a77bb1c42 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -251,21 +251,30 @@ public class Configuration { @ConfigurationName("gui.window.maximized.vertical") public static final ConfigurationItem guiWindowMaximizedVertical = null; + @ConfigurationDefaultInt(50) @ConfigurationName("gui.avm2.splitPane.dividerLocationPercent") public static final ConfigurationItem guiAvm2SplitPaneDividerLocationPercent = null; - @ConfigurationName("guiActionSplitPaneDividerLocationPercent") + @ConfigurationDefaultInt(50) + @ConfigurationName("gui.actionSplitPane.dividerLocationPercent") public static final ConfigurationItem guiActionSplitPaneDividerLocationPercent = null; - @ConfigurationName("guiPreviewSplitPaneDividerLocationPercent") + @ConfigurationDefaultInt(50) + @ConfigurationName("gui.previewSplitPane.dividerLocationPercent") public static final ConfigurationItem guiPreviewSplitPaneDividerLocationPercent = null; + @ConfigurationDefaultInt(33) @ConfigurationName("gui.splitPane1.dividerLocationPercent") public static final ConfigurationItem guiSplitPane1DividerLocationPercent = null; + @ConfigurationDefaultInt(60) @ConfigurationName("gui.splitPane2.dividerLocationPercent") public static final ConfigurationItem guiSplitPane2DividerLocationPercent = null; + @ConfigurationDefaultInt(50) + @ConfigurationName("gui.timeLineSplitPane.dividerLocationPercent") + public static final ConfigurationItem guiTimeLineSplitPaneDividerLocationPercent = null; + @ConfigurationDefaultString("com.jpexs.decompiler.flash.gui.OceanicSkin") @ConfigurationName("gui.skin") @ConfigurationCategory("ui") @@ -595,16 +604,16 @@ public class Configuration { } private static HashMap loadFromFile(String file) { - HashMap config = new HashMap<>(); try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file))) { @SuppressWarnings("unchecked") HashMap cfg = (HashMap) ois.readObject(); - config = cfg; + //return cfg; } catch (ClassNotFoundException | IOException ex) { // ignore } - return config; + + return new HashMap<>(); } private static void saveToFile(String file) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/BinaryDataExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/BinaryDataExporter.java index 8b71b47b9..486331ccd 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/BinaryDataExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/BinaryDataExporter.java @@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.exporters; import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; import com.jpexs.decompiler.flash.EventListener; import com.jpexs.decompiler.flash.RetryTask; -import com.jpexs.decompiler.flash.RunnableIOEx; import com.jpexs.decompiler.flash.exporters.settings.BinaryDataExportSettings; import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; import com.jpexs.decompiler.flash.tags.Tag; @@ -68,12 +67,9 @@ public class BinaryDataExporter { int characterID = ((DefineBinaryDataTag) t).getCharacterId(); final File file = new File(outdir + File.separator + characterID + ".bin"); - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { - fos.write(((DefineBinaryDataTag) t).binaryData.getRangeData()); - } + new RetryTask(() -> { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { + fos.write(((DefineBinaryDataTag) t).binaryData.getRangeData()); } }, handler).run(); ret.add(file); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FontExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FontExporter.java index 747e1b5ae..3d4389b4b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FontExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FontExporter.java @@ -24,7 +24,6 @@ import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; import com.jpexs.decompiler.flash.ApplicationInfo; import com.jpexs.decompiler.flash.EventListener; import com.jpexs.decompiler.flash.RetryTask; -import com.jpexs.decompiler.flash.RunnableIOEx; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.exporters.modes.FontExportMode; @@ -90,11 +89,8 @@ public class FontExporter { ext = ".woff"; } final File file = new File(outdir + File.separator + Helper.makeFileName(st.getCharacterExportFileName() + ext)); - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - exportFont(st, settings.mode, file); - } + new RetryTask(() -> { + exportFont(st, settings.mode, file); }, handler).run(); ret.add(file); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FrameExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FrameExporter.java index 0d61f104a..b37ffd3cc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FrameExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/FrameExporter.java @@ -20,7 +20,6 @@ import com.jpacker.JPacker; import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; import com.jpexs.decompiler.flash.EventListener; import com.jpexs.decompiler.flash.RetryTask; -import com.jpexs.decompiler.flash.RunnableIOEx; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle; @@ -157,26 +156,23 @@ public class FrameExporter { final int fi = i; final Color fbackgroundColor = backgroundColor; - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - int frame = fframes.get(fi); - File f = new File(foutdir + File.separator + frame + ".svg"); - try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(f))) { - ExportRectangle rect = new ExportRectangle(tim.displayRect); - rect.xMax *= settings.zoom; - rect.yMax *= settings.zoom; - rect.xMin *= settings.zoom; - rect.yMin *= settings.zoom; - SVGExporter exporter = new SVGExporter(rect); - if (fbackgroundColor != null) { - exporter.setBackGroundColor(fbackgroundColor); - } - SWF.frameToSvg(tim, frame, 0, null, 0, exporter, new ColorTransform(), 0, settings.zoom); - fos.write(Utf8Helper.getBytes(exporter.getSVG())); + new RetryTask(() -> { + int frame = fframes.get(fi); + File f = new File(foutdir + File.separator + frame + ".svg"); + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(f))) { + ExportRectangle rect = new ExportRectangle(tim.displayRect); + rect.xMax *= settings.zoom; + rect.yMax *= settings.zoom; + rect.xMin *= settings.zoom; + rect.yMin *= settings.zoom; + SVGExporter exporter = new SVGExporter(rect); + if (fbackgroundColor != null) { + exporter.setBackGroundColor(fbackgroundColor); } - ret.add(f); + SWF.frameToSvg(tim, frame, 0, null, 0, exporter, new ColorTransform(), 0, settings.zoom); + fos.write(Utf8Helper.getBytes(exporter.getSVG())); } + ret.add(f); }, handler).run(); if (evl != null) { @@ -195,105 +191,103 @@ public class FrameExporter { final Timeline ftim = tim; final Color fbackgroundColor = backgroundColor; final SWF fswf = swf; - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - File fcanvas = new File(foutdir + File.separator + "canvas.js"); - Helper.saveStream(SWF.class.getClassLoader().getResourceAsStream("com/jpexs/helpers/resource/canvas.js"), fcanvas); - ret.add(fcanvas); + new RetryTask(() -> { + File fcanvas = new File(foutdir + File.separator + "canvas.js"); + Helper.saveStream(SWF.class.getClassLoader().getResourceAsStream("com/jpexs/helpers/resource/canvas.js"), fcanvas); + ret.add(fcanvas); - File f = new File(foutdir + File.separator + "frames.js"); - File fmin = new File(foutdir + File.separator + "frames.min.js"); - int width = (int) (ftim.displayRect.getWidth() * settings.zoom / SWF.unitDivisor); - int height = (int) (ftim.displayRect.getHeight() * settings.zoom / SWF.unitDivisor); - try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(f))) { - fos.write(Utf8Helper.getBytes("\r\n")); - Set library = new HashSet<>(); - ftim.getNeededCharacters(fframes, library); + File f = new File(foutdir + File.separator + "frames.js"); + File fmin = new File(foutdir + File.separator + "frames.min.js"); + int width = (int) (ftim.displayRect.getWidth() * settings.zoom / SWF.unitDivisor); + int height = (int) (ftim.displayRect.getHeight() * settings.zoom / SWF.unitDivisor); + try (final OutputStream fos = new BufferedOutputStream(new FileOutputStream(f))) { + fos.write(Utf8Helper.getBytes("\r\n")); + Set library = new HashSet<>(); + ftim.getNeededCharacters(fframes, library); - SWF.writeLibrary(fswf, library, fos); + SWF.writeLibrary(fswf, library, fos); - String currentName = ftim.id == 0 ? "main" : SWF.getTypePrefix(fswf.getCharacter(ftim.id)) + ftim.id; + String currentName = ftim.id == 0 ? "main" : SWF.getTypePrefix(fswf.getCharacter(ftim.id)) + ftim.id; - fos.write(Utf8Helper.getBytes("function " + currentName + "(ctx,ctrans,frame,ratio,time){\r\n")); - fos.write(Utf8Helper.getBytes("\tctx.save();\r\n")); - fos.write(Utf8Helper.getBytes("\tctx.transform(1,0,0,1," + (-ftim.displayRect.Xmin * settings.zoom / SWF.unitDivisor) + "," + (-ftim.displayRect.Ymin * settings.zoom / SWF.unitDivisor) + ");\r\n")); - fos.write(Utf8Helper.getBytes(framesToHtmlCanvas(SWF.unitDivisor / settings.zoom, ftim, fframes, 0, null, 0, ftim.displayRect, new ColorTransform(), fbackgroundColor))); - fos.write(Utf8Helper.getBytes("\tctx.restore();\r\n")); - fos.write(Utf8Helper.getBytes("}\r\n\r\n")); + fos.write(Utf8Helper.getBytes("function " + currentName + "(ctx,ctrans,frame,ratio,time){\r\n")); + fos.write(Utf8Helper.getBytes("\tctx.save();\r\n")); + fos.write(Utf8Helper.getBytes("\tctx.transform(1,0,0,1," + (-ftim.displayRect.Xmin * settings.zoom / SWF.unitDivisor) + "," + (-ftim.displayRect.Ymin * settings.zoom / SWF.unitDivisor) + ");\r\n")); + fos.write(Utf8Helper.getBytes(framesToHtmlCanvas(SWF.unitDivisor / settings.zoom, ftim, fframes, 0, null, 0, ftim.displayRect, new ColorTransform(), fbackgroundColor))); + fos.write(Utf8Helper.getBytes("\tctx.restore();\r\n")); + fos.write(Utf8Helper.getBytes("}\r\n\r\n")); - fos.write(Utf8Helper.getBytes("var frame = -1;\r\n")); - fos.write(Utf8Helper.getBytes("var time = 0;\r\n")); - fos.write(Utf8Helper.getBytes("var frames = [];\r\n")); - for (int i : fframes) { - fos.write(Utf8Helper.getBytes("frames.push(" + i + ");\r\n")); + fos.write(Utf8Helper.getBytes("var frame = -1;\r\n")); + fos.write(Utf8Helper.getBytes("var time = 0;\r\n")); + fos.write(Utf8Helper.getBytes("var frames = [];\r\n")); + for (int i : fframes) { + fos.write(Utf8Helper.getBytes("frames.push(" + i + ");\r\n")); + } + fos.write(Utf8Helper.getBytes("\r\n")); + RGB backgroundColor1 = new RGB(255, 255, 255); + for (Tag t : fswf.tags) { + if (t instanceof SetBackgroundColorTag) { + SetBackgroundColorTag sb = (SetBackgroundColorTag) t; + backgroundColor1 = sb.backgroundColor; } - fos.write(Utf8Helper.getBytes("\r\n")); - RGB backgroundColor = new RGB(255, 255, 255); - for (Tag t : fswf.tags) { - if (t instanceof SetBackgroundColorTag) { - SetBackgroundColorTag sb = (SetBackgroundColorTag) t; - backgroundColor = sb.backgroundColor; - } - } - - fos.write(Utf8Helper.getBytes("var backgroundColor = \"" + backgroundColor.toHexRGB() + "\";\r\n")); - fos.write(Utf8Helper.getBytes("var originalWidth = " + width + ";\r\n")); - fos.write(Utf8Helper.getBytes("var originalHeight= " + height + ";\r\n")); - fos.write(Utf8Helper.getBytes("function nextFrame(ctx,ctrans){\r\n")); - fos.write(Utf8Helper.getBytes("\tvar oldframe = frame;\r\n")); - fos.write(Utf8Helper.getBytes("\tframe = (frame+1)%frames.length;\r\n")); - fos.write(Utf8Helper.getBytes("\tif(frame==oldframe){time++;}else{time=0;};\r\n")); - fos.write(Utf8Helper.getBytes("\tdrawFrame();\r\n")); - fos.write(Utf8Helper.getBytes("}\r\n\r\n")); - - fos.write(Utf8Helper.getBytes("function drawFrame(){\r\n")); - fos.write(Utf8Helper.getBytes("\tctx.fillStyle = backgroundColor;\r\n")); - fos.write(Utf8Helper.getBytes("\tctx.fillRect(0,0,canvas.width,canvas.height);\r\n")); - fos.write(Utf8Helper.getBytes("\tctx.save();\r\n")); - fos.write(Utf8Helper.getBytes("\tctx.transform(canvas.width/originalWidth,0,0,canvas.height/originalHeight,0,0);\r\n")); - fos.write(Utf8Helper.getBytes("\t" + currentName + "(ctx,ctrans,frames[frame],0,time);\r\n")); - fos.write(Utf8Helper.getBytes("\tctx.restore();\r\n")); - fos.write(Utf8Helper.getBytes("}\r\n\r\n")); - if (ftim.swf.frameRate > 0) { - fos.write(Utf8Helper.getBytes("window.setInterval(function(){nextFrame(ctx,ctrans);}," + (int) (1000.0 / ftim.swf.frameRate) + ");\r\n")); - } - fos.write(Utf8Helper.getBytes("nextFrame(ctx,ctrans);\r\n")); } - boolean packed = false; - if (Configuration.packJavaScripts.get()) { - try { - JPacker.main(new String[]{"-q", "-b", "62", "-o", fmin.getAbsolutePath(), f.getAbsolutePath()}); - f.delete(); - packed = true; - } catch (Exception | Error e) { // Something wrong in the packer - logger.log(Level.WARNING, "JPacker: Cannot minimize script"); - f.renameTo(fmin); - } - } else { + fos.write(Utf8Helper.getBytes("var backgroundColor = \"" + backgroundColor1.toHexRGB() + "\";\r\n")); + fos.write(Utf8Helper.getBytes("var originalWidth = " + width + ";\r\n")); + fos.write(Utf8Helper.getBytes("var originalHeight= " + height + ";\r\n")); + fos.write(Utf8Helper.getBytes("function nextFrame(ctx,ctrans){\r\n")); + fos.write(Utf8Helper.getBytes("\tvar oldframe = frame;\r\n")); + fos.write(Utf8Helper.getBytes("\tframe = (frame+1)%frames.length;\r\n")); + fos.write(Utf8Helper.getBytes("\tif(frame==oldframe){time++;}else{time=0;};\r\n")); + fos.write(Utf8Helper.getBytes("\tdrawFrame();\r\n")); + fos.write(Utf8Helper.getBytes("}\r\n\r\n")); + + fos.write(Utf8Helper.getBytes("function drawFrame(){\r\n")); + fos.write(Utf8Helper.getBytes("\tctx.fillStyle = backgroundColor;\r\n")); + fos.write(Utf8Helper.getBytes("\tctx.fillRect(0,0,canvas.width,canvas.height);\r\n")); + fos.write(Utf8Helper.getBytes("\tctx.save();\r\n")); + fos.write(Utf8Helper.getBytes("\tctx.transform(canvas.width/originalWidth,0,0,canvas.height/originalHeight,0,0);\r\n")); + fos.write(Utf8Helper.getBytes("\t" + currentName + "(ctx,ctrans,frames[frame],0,time);\r\n")); + fos.write(Utf8Helper.getBytes("\tctx.restore();\r\n")); + fos.write(Utf8Helper.getBytes("}\r\n\r\n")); + if (ftim.swf.frameRate > 0) { + fos.write(Utf8Helper.getBytes("window.setInterval(function(){nextFrame(ctx,ctrans);}," + (int) (1000.0 / ftim.swf.frameRate) + ");\r\n")); + } + fos.write(Utf8Helper.getBytes("nextFrame(ctx,ctrans);\r\n")); + } + + boolean packed = false; + if (Configuration.packJavaScripts.get()) { + try { + JPacker.main(new String[]{"-q", "-b", "62", "-o", fmin.getAbsolutePath(), f.getAbsolutePath()}); + f.delete(); + packed = true; + } catch (Exception | Error e) { // Something wrong in the packer + logger.log(Level.WARNING, "JPacker: Cannot minimize script"); f.renameTo(fmin); } - - File fh = new File(foutdir + File.separator + "frames.html"); - try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(fh)); FileInputStream fis = new FileInputStream(fmin)) { - fos.write(Utf8Helper.getBytes(CanvasShapeExporter.getHtmlPrefix(width, height))); - fos.write(Utf8Helper.getBytes(CanvasShapeExporter.getJsPrefix())); - byte[] buf = new byte[1000]; - int cnt; - while ((cnt = fis.read(buf)) > 0) { - fos.write(buf, 0, cnt); - } - if (packed) { - fos.write(Utf8Helper.getBytes(";")); - } - fos.write(Utf8Helper.getBytes(CanvasShapeExporter.getJsSuffix())); - fos.write(Utf8Helper.getBytes(CanvasShapeExporter.getHtmlSuffix())); - } - fmin.delete(); - - ret.add(f); + } else { + f.renameTo(fmin); } + + File fh = new File(foutdir + File.separator + "frames.html"); + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(fh)); FileInputStream fis = new FileInputStream(fmin)) { + fos.write(Utf8Helper.getBytes(CanvasShapeExporter.getHtmlPrefix(width, height))); + fos.write(Utf8Helper.getBytes(CanvasShapeExporter.getJsPrefix())); + byte[] buf = new byte[1000]; + int cnt; + while ((cnt = fis.read(buf)) > 0) { + fos.write(buf, 0, cnt); + } + if (packed) { + fos.write(Utf8Helper.getBytes(";")); + } + fos.write(Utf8Helper.getBytes(CanvasShapeExporter.getJsSuffix())); + fos.write(Utf8Helper.getBytes(CanvasShapeExporter.getHtmlSuffix())); + } + + fmin.delete(); + + ret.add(f); }, handler).run(); if (evl != null) { @@ -340,76 +334,61 @@ public class FrameExporter { switch (settings.mode) { case GIF: - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - File f = new File(foutdir + File.separator + "frames.gif"); - makeGIF(frameImages, swf.frameRate, f, evl); - ret.add(f); - } + new RetryTask(() -> { + File f = new File(foutdir + File.separator + "frames.gif"); + makeGIF(frameImages, swf.frameRate, f, evl); + ret.add(f); }, handler).run(); break; case BMP: for (int i = 0; frameImages.hasNext(); i++) { final int fi = i; - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - File f = new File(foutdir + File.separator + (fframes.get(fi) + 1) + ".bmp"); - BMPFile.saveBitmap(frameImages.next(), f); - ret.add(f); - } + new RetryTask(() -> { + File f = new File(foutdir + File.separator + (fframes.get(fi) + 1) + ".bmp"); + BMPFile.saveBitmap(frameImages.next(), f); + ret.add(f); }, handler).run(); } break; case PNG: for (int i = 0; frameImages.hasNext(); i++) { final int fi = i; - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - File file = new File(foutdir + File.separator + (fframes.get(fi) + 1) + ".png"); - ImageHelper.write(frameImages.next(), "PNG", file); - ret.add(file); - } + new RetryTask(() -> { + File file = new File(foutdir + File.separator + (fframes.get(fi) + 1) + ".png"); + ImageHelper.write(frameImages.next(), "PNG", file); + ret.add(file); }, handler).run(); } //ShapeExporterBase.clearCache(); break; case PDF: - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - File f = new File(foutdir + File.separator + "frames.pdf"); - PDFJob job = new PDFJob(new BufferedOutputStream(new FileOutputStream(f))); - PageFormat pf = new PageFormat(); - pf.setOrientation(PageFormat.PORTRAIT); - Paper p = new Paper(); - BufferedImage img0 = frameImages.next(); - p.setSize(img0.getWidth() + 10, img0.getHeight() + 10); - pf.setPaper(p); + new RetryTask(() -> { + File f = new File(foutdir + File.separator + "frames.pdf"); + PDFJob job = new PDFJob(new BufferedOutputStream(new FileOutputStream(f))); + PageFormat pf = new PageFormat(); + pf.setOrientation(PageFormat.PORTRAIT); + Paper p = new Paper(); + BufferedImage img0 = frameImages.next(); + p.setSize(img0.getWidth() + 10, img0.getHeight() + 10); + pf.setPaper(p); - for (int i = 0; frameImages.hasNext(); i++) { - BufferedImage img = frameImages.next(); - Graphics g = job.getGraphics(pf); - g.drawImage(img, 5, 5, img.getWidth(), img.getHeight(), null); - g.dispose(); - } - - job.end(); - ret.add(f); + for (int i = 0; frameImages.hasNext(); i++) { + BufferedImage img = frameImages.next(); + Graphics g = job.getGraphics(pf); + g.drawImage(img, 5, 5, img.getWidth(), img.getHeight(), null); + g.dispose(); } + + job.end(); + ret.add(f); }, handler).run(); break; case AVI: - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - File f = new File(foutdir + File.separator + "frames.avi"); - makeAVI(frameImages, swf.frameRate, f, evl); - ret.add(f); - } + new RetryTask(() -> { + File f = new File(foutdir + File.separator + "frames.avi"); + makeAVI(frameImages, swf.frameRate, f, evl); + ret.add(f); }, handler).run(); break; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ImageExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ImageExporter.java index cac82662f..44da54611 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ImageExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ImageExporter.java @@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.exporters; import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; import com.jpexs.decompiler.flash.EventListener; import com.jpexs.decompiler.flash.RetryTask; -import com.jpexs.decompiler.flash.RunnableIOEx; import com.jpexs.decompiler.flash.exporters.modes.ImageExportMode; import com.jpexs.decompiler.flash.exporters.settings.ImageExportSettings; import com.jpexs.decompiler.flash.helpers.BMPFile; @@ -85,14 +84,11 @@ public class ImageExporter { final File file = new File(outdir + File.separator + Helper.makeFileName(imageTag.getCharacterExportFileName() + "." + fileFormat)); final String ffileFormat = fileFormat; - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - if (ffileFormat.equals("bmp")) { - BMPFile.saveBitmap(imageTag.getImage().getBufferedImage(), file); - } else { - ImageHelper.write(imageTag.getImage().getBufferedImage(), ffileFormat.toUpperCase(Locale.ENGLISH), file); - } + new RetryTask(() -> { + if (ffileFormat.equals("bmp")) { + BMPFile.saveBitmap(imageTag.getImage().getBufferedImage(), file); + } else { + ImageHelper.write(imageTag.getImage().getBufferedImage(), ffileFormat.toUpperCase(Locale.ENGLISH), file); } }, handler).run(); ret.add(file); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java index e8833db5d..acdd19787 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MorphShapeExporter.java @@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.exporters; import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; import com.jpexs.decompiler.flash.EventListener; import com.jpexs.decompiler.flash.RetryTask; -import com.jpexs.decompiler.flash.RunnableIOEx; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle; import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; @@ -86,40 +85,36 @@ public class MorphShapeExporter { String ext = settings.mode == MorphShapeExportMode.CANVAS ? "html" : "svg"; final File file = new File(outdir + File.separator + characterID + "." + ext); - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - MorphShapeTag mst = (MorphShapeTag) t; - switch (settings.mode) { - case SVG: - try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { - ExportRectangle rect = new ExportRectangle(mst.getRect()); - rect.xMax *= settings.zoom; - rect.yMax *= settings.zoom; - rect.xMin *= settings.zoom; - rect.yMin *= settings.zoom; - SVGExporter exporter = new SVGExporter(rect); - mst.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0, settings.zoom); - fos.write(Utf8Helper.getBytes(exporter.getSVG())); - } - break; - case CANVAS: - try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { - int deltaX = -Math.min(mst.getStartBounds().Xmin, mst.getEndBounds().Xmin); - int deltaY = -Math.min(mst.getStartBounds().Ymin, mst.getEndBounds().Ymin); - CanvasMorphShapeExporter cse = new CanvasMorphShapeExporter(((Tag) mst).getSwf(), mst.getShapeAtRatio(0), mst.getShapeAtRatio(DefineMorphShapeTag.MAX_RATIO), new CXFORMWITHALPHA(), SWF.unitDivisor, deltaX, deltaY); - cse.export(); - Set needed = new HashSet<>(); - CharacterTag ct = ((CharacterTag) mst); - needed.add(ct.getCharacterId()); - ct.getNeededCharactersDeep(needed); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWF.writeLibrary(ct.getSwf(), needed, baos); - fos.write(Utf8Helper.getBytes(cse.getHtml(new String(baos.toByteArray(), "UTF-8")))); - } - break; - } - + new RetryTask(() -> { + MorphShapeTag mst = (MorphShapeTag) t; + switch (settings.mode) { + case SVG: + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { + ExportRectangle rect = new ExportRectangle(mst.getRect()); + rect.xMax *= settings.zoom; + rect.yMax *= settings.zoom; + rect.xMin *= settings.zoom; + rect.yMin *= settings.zoom; + SVGExporter exporter = new SVGExporter(rect); + mst.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0, settings.zoom); + fos.write(Utf8Helper.getBytes(exporter.getSVG())); + } + break; + case CANVAS: + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { + int deltaX = -Math.min(mst.getStartBounds().Xmin, mst.getEndBounds().Xmin); + int deltaY = -Math.min(mst.getStartBounds().Ymin, mst.getEndBounds().Ymin); + CanvasMorphShapeExporter cse = new CanvasMorphShapeExporter(((Tag) mst).getSwf(), mst.getShapeAtRatio(0), mst.getShapeAtRatio(DefineMorphShapeTag.MAX_RATIO), new CXFORMWITHALPHA(), SWF.unitDivisor, deltaX, deltaY); + cse.export(); + Set needed = new HashSet<>(); + CharacterTag ct = ((CharacterTag) mst); + needed.add(ct.getCharacterId()); + ct.getNeededCharactersDeep(needed); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWF.writeLibrary(ct.getSwf(), needed, baos); + fos.write(Utf8Helper.getBytes(cse.getHtml(new String(baos.toByteArray(), "UTF-8")))); + } + break; } }, handler).run(); ret.add(file); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MovieExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MovieExporter.java index 3a6476f39..dd2bab57e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MovieExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/MovieExporter.java @@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.exporters; import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; import com.jpexs.decompiler.flash.EventListener; import com.jpexs.decompiler.flash.RetryTask; -import com.jpexs.decompiler.flash.RunnableIOEx; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; @@ -78,12 +77,9 @@ public class MovieExporter { final DefineVideoStreamTag videoStream = (DefineVideoStreamTag) t; final File file = new File(outdir + File.separator + Helper.makeFileName(videoStream.getCharacterExportFileName() + ".flv")); - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { - fos.write(exportMovie(videoStream, settings.mode)); - } + new RetryTask(() -> { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { + fos.write(exportMovie(videoStream, settings.mode)); } }, handler).run(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java index db48fa930..c12f0defe 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/ShapeExporter.java @@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.exporters; import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; import com.jpexs.decompiler.flash.EventListener; import com.jpexs.decompiler.flash.RetryTask; -import com.jpexs.decompiler.flash.RunnableIOEx; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle; import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; @@ -100,57 +99,53 @@ public class ShapeExporter { } final File file = new File(outdir + File.separator + characterID + "." + ext); - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - ShapeTag st = (ShapeTag) t; - switch (settings.mode) { - case SVG: - try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { - ExportRectangle rect = new ExportRectangle(st.getRect()); - rect.xMax *= settings.zoom; - rect.yMax *= settings.zoom; - rect.xMin *= settings.zoom; - rect.yMin *= settings.zoom; - SVGExporter exporter = new SVGExporter(rect); - st.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0, settings.zoom); - fos.write(Utf8Helper.getBytes(exporter.getSVG())); - } - break; - case PNG: - case BMP: - RECT rect = st.getRect(); - int newWidth = (int) (rect.getWidth() * settings.zoom / SWF.unitDivisor) + 1; - int newHeight = (int) (rect.getHeight() * settings.zoom / SWF.unitDivisor) + 1; - SerializableImage img = new SerializableImage(newWidth, newHeight, SerializableImage.TYPE_INT_ARGB); - img.fillTransparent(); - Matrix m = new Matrix(); - m.translate(-rect.Xmin, -rect.Ymin); - m.scale(settings.zoom); - st.toImage(0, 0, 0, new RenderContext(), img, m, new CXFORMWITHALPHA()); - if (settings.mode == ShapeExportMode.PNG) { - ImageHelper.write(img.getBufferedImage(), "PNG", file); - } else { - BMPFile.saveBitmap(img.getBufferedImage(), file); - } - break; - case CANVAS: - try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { - SHAPE shp = st.getShapes(); - int deltaX = -shp.getBounds().Xmin; - int deltaY = -shp.getBounds().Ymin; - CanvasShapeExporter cse = new CanvasShapeExporter(null, SWF.unitDivisor / settings.zoom, ((Tag) st).getSwf(), shp, new CXFORMWITHALPHA(), deltaX, deltaY); - cse.export(); - Set needed = new HashSet<>(); - needed.add(st.getCharacterId()); - st.getNeededCharactersDeep(needed); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWF.writeLibrary(st.getSwf(), needed, baos); - fos.write(Utf8Helper.getBytes(cse.getHtml(new String(baos.toByteArray(), "UTF-8")))); - } - break; - } - + new RetryTask(() -> { + ShapeTag st = (ShapeTag) t; + switch (settings.mode) { + case SVG: + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { + ExportRectangle rect = new ExportRectangle(st.getRect()); + rect.xMax *= settings.zoom; + rect.yMax *= settings.zoom; + rect.xMin *= settings.zoom; + rect.yMin *= settings.zoom; + SVGExporter exporter = new SVGExporter(rect); + st.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0, settings.zoom); + fos.write(Utf8Helper.getBytes(exporter.getSVG())); + } + break; + case PNG: + case BMP: + RECT rect = st.getRect(); + int newWidth = (int) (rect.getWidth() * settings.zoom / SWF.unitDivisor) + 1; + int newHeight = (int) (rect.getHeight() * settings.zoom / SWF.unitDivisor) + 1; + SerializableImage img = new SerializableImage(newWidth, newHeight, SerializableImage.TYPE_INT_ARGB); + img.fillTransparent(); + Matrix m = new Matrix(); + m.translate(-rect.Xmin, -rect.Ymin); + m.scale(settings.zoom); + st.toImage(0, 0, 0, new RenderContext(), img, m, new CXFORMWITHALPHA()); + if (settings.mode == ShapeExportMode.PNG) { + ImageHelper.write(img.getBufferedImage(), "PNG", file); + } else { + BMPFile.saveBitmap(img.getBufferedImage(), file); + } + break; + case CANVAS: + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { + SHAPE shp = st.getShapes(); + int deltaX = -shp.getBounds().Xmin; + int deltaY = -shp.getBounds().Ymin; + CanvasShapeExporter cse = new CanvasShapeExporter(null, SWF.unitDivisor / settings.zoom, ((Tag) st).getSwf(), shp, new CXFORMWITHALPHA(), deltaX, deltaY); + cse.export(); + Set needed = new HashSet<>(); + needed.add(st.getCharacterId()); + st.getNeededCharactersDeep(needed); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWF.writeLibrary(st.getSwf(), needed, baos); + fos.write(Utf8Helper.getBytes(cse.getHtml(new String(baos.toByteArray(), "UTF-8")))); + } + break; } }, handler).run(); ret.add(file); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/SoundExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/SoundExporter.java index c631ca6d6..9abe06d7a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/SoundExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/SoundExporter.java @@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.exporters; import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; import com.jpexs.decompiler.flash.EventListener; import com.jpexs.decompiler.flash.RetryTask; -import com.jpexs.decompiler.flash.RunnableIOEx; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode; @@ -99,12 +98,9 @@ public class SoundExporter { } final File file = new File(outdir + File.separator + Helper.makeFileName(st.getCharacterExportFileName()) + "." + ext); - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) { - exportSound(os, st, settings.mode); - } + new RetryTask(() -> { + try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) { + exportSound(os, st, settings.mode); } }, handler).run(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/TextExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/TextExporter.java index 87b64de62..e248371fc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/TextExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/TextExporter.java @@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.exporters; import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; import com.jpexs.decompiler.flash.EventListener; import com.jpexs.decompiler.flash.RetryTask; -import com.jpexs.decompiler.flash.RunnableIOEx; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle; import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; @@ -79,15 +78,12 @@ public class TextExporter { final TextTag textTag = (TextTag) t; final File file = new File(outdir + File.separator + Helper.makeFileName(textTag.getCharacterExportFileName() + ".svg")); - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { - ExportRectangle rect = new ExportRectangle(textTag.getRect()); - SVGExporter exporter = new SVGExporter(rect); - textTag.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0, settings.zoom); - fos.write(Utf8Helper.getBytes(exporter.getSVG())); - } + new RetryTask(() -> { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { + ExportRectangle rect = new ExportRectangle(textTag.getRect()); + SVGExporter exporter = new SVGExporter(rect); + textTag.toSVG(exporter, -2, new CXFORMWITHALPHA(), 0, settings.zoom); + fos.write(Utf8Helper.getBytes(exporter.getSVG())); } }, handler).run(); ret.add(file); @@ -115,20 +111,17 @@ public class TextExporter { for (final Tag t : tags) { if (t instanceof TextTag) { final TextTag textTag = (TextTag) t; - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - fos.write(Utf8Helper.getBytes("ID: " + textTag.getCharacterId() + Helper.newLine)); - if (settings.mode == TextExportMode.FORMATTED) { - fos.write(Utf8Helper.getBytes(textTag.getFormattedText().text)); - } else { - String separator = Configuration.textExportSingleFileRecordSeparator.get(); - separator = Helper.newLine + separator + Helper.newLine; - List texts = textTag.getTexts(); - fos.write(Utf8Helper.getBytes(String.join(separator, texts))); - } - fos.write(Utf8Helper.getBytes(Helper.newLine + Configuration.textExportSingleFileSeparator.get() + Helper.newLine)); + new RetryTask(() -> { + fos.write(Utf8Helper.getBytes("ID: " + textTag.getCharacterId() + Helper.newLine)); + if (settings.mode == TextExportMode.FORMATTED) { + fos.write(Utf8Helper.getBytes(textTag.getFormattedText().text)); + } else { + String separator = Configuration.textExportSingleFileRecordSeparator.get(); + separator = Helper.newLine + separator + Helper.newLine; + List texts = textTag.getTexts(); + fos.write(Utf8Helper.getBytes(String.join(separator, texts))); } + fos.write(Utf8Helper.getBytes(Helper.newLine + Configuration.textExportSingleFileSeparator.get() + Helper.newLine)); }, handler).run(); } } @@ -143,18 +136,15 @@ public class TextExporter { final TextTag textTag = (TextTag) t; final File file = new File(outdir + File.separator + Helper.makeFileName(textTag.getCharacterExportFileName() + ".txt")); - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { - if (settings.mode == TextExportMode.FORMATTED) { - fos.write(Utf8Helper.getBytes(textTag.getFormattedText().text)); - } else { - String separator = Configuration.textExportSingleFileRecordSeparator.get(); - separator = Helper.newLine + separator + Helper.newLine; - List texts = textTag.getTexts(); - fos.write(Utf8Helper.getBytes(String.join(separator, texts))); - } + new RetryTask(() -> { + try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(file))) { + if (settings.mode == TextExportMode.FORMATTED) { + fos.write(Utf8Helper.getBytes(textTag.getFormattedText().text)); + } else { + String separator = Configuration.textExportSingleFileRecordSeparator.get(); + separator = Helper.newLine + separator + Helper.newLine; + List texts = textTag.getTexts(); + fos.write(Utf8Helper.getBytes(String.join(separator, texts))); } } }, handler).run(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FontHelper.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FontHelper.java index 5244b0e2e..b8b1d732b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FontHelper.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FontHelper.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.helpers; +import java.awt.Canvas; import java.awt.Font; import java.awt.FontFormatException; import java.awt.GraphicsEnvironment; @@ -36,7 +37,6 @@ import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; -import javax.swing.JPanel; /** * @@ -175,7 +175,8 @@ public class FontHelper { } private static FontRenderContext getFontRenderContext(Font font) { - return (new JPanel()).getFontMetrics(font).getFontRenderContext(); + // Canvas works in headless mode + return (new Canvas()).getFontMetrics(font).getFontRenderContext(); } private static List getFontKerningPairsOneChar(List availableChars, Font font, char firstChar) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index e154be654..ee32de5b5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -18,7 +18,6 @@ package com.jpexs.decompiler.flash.xfl; import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; import com.jpexs.decompiler.flash.RetryTask; -import com.jpexs.decompiler.flash.RunnableIOEx; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFCompression; import com.jpexs.decompiler.flash.SWFInputStream; @@ -2294,12 +2293,9 @@ public class XFLConverter { } private static void writeFile(AbortRetryIgnoreHandler handler, final byte[] data, final String file) throws IOException { - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - try (FileOutputStream fos = new FileOutputStream(file)) { - fos.write(data); - } + new RetryTask(() -> { + try (FileOutputStream fos = new FileOutputStream(file)) { + fos.write(data); } }, handler).run(); } @@ -2988,22 +2984,19 @@ public class XFLConverter { final String domDocumentF = domDocumentStr; final String publishSettingsF = publishSettingsStr; final String outfileF = outfile; - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - try (ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outfileF))) { - out.putNextEntry(new ZipEntry("DOMDocument.xml")); - out.write(Utf8Helper.getBytes(domDocumentF)); - out.putNextEntry(new ZipEntry("PublishSettings.xml")); - out.write(Utf8Helper.getBytes(publishSettingsF)); - for (String fileName : files.keySet()) { - out.putNextEntry(new ZipEntry("LIBRARY/" + fileName)); - out.write(files.get(fileName)); - } - for (String fileName : datfiles.keySet()) { - out.putNextEntry(new ZipEntry("bin/" + fileName)); - out.write(datfiles.get(fileName)); - } + new RetryTask(() -> { + try (ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outfileF))) { + out.putNextEntry(new ZipEntry("DOMDocument.xml")); + out.write(Utf8Helper.getBytes(domDocumentF)); + out.putNextEntry(new ZipEntry("PublishSettings.xml")); + out.write(Utf8Helper.getBytes(publishSettingsF)); + for (String fileName : files.keySet()) { + out.putNextEntry(new ZipEntry("LIBRARY/" + fileName)); + out.write(files.get(fileName)); + } + for (String fileName : datfiles.keySet()) { + out.putNextEntry(new ZipEntry("bin/" + fileName)); + out.write(datfiles.get(fileName)); } } }, handler).run(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/ProgressListener.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/ProgressListener.java index 954298236..4a4da4d1a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/ProgressListener.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/ProgressListener.java @@ -1,24 +1,26 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * 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 3.0 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. */ + * License along with this library. + */ package com.jpexs.helpers; /** * * @author JPEXS */ +@FunctionalInterface public interface ProgressListener { public void progress(int p); diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index d3aec21d9..7b7a97f58 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -69,6 +69,7 @@ import com.jpexs.decompiler.flash.gui.abc.ABCPanel; import com.jpexs.decompiler.flash.gui.abc.ClassesListTreeModel; import com.jpexs.decompiler.flash.gui.abc.DeobfuscationDialog; import com.jpexs.decompiler.flash.gui.action.ActionPanel; +import com.jpexs.decompiler.flash.gui.controls.JPersistentSplitPane; import com.jpexs.decompiler.flash.gui.dumpview.DumpTree; import com.jpexs.decompiler.flash.gui.dumpview.DumpTreeModel; import com.jpexs.decompiler.flash.gui.dumpview.DumpViewPanel; @@ -155,7 +156,6 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; @@ -264,11 +264,9 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se private static final String TIMELINE_PANEL = "TIMELINEPANEL"; - private final JSplitPane splitPane1; + private final JPersistentSplitPane splitPane1; - private final JSplitPane splitPane2; - - private boolean splitsInited = false; + private final JPersistentSplitPane splitPane2; private JPanel detailPanel; @@ -557,32 +555,12 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se }); //displayPanel.setBorder(BorderFactory.createLineBorder(Color.black)); - splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, treePanel, detailPanel); - splitPane1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, splitPane2, displayPanel); + splitPane2 = new JPersistentSplitPane(JSplitPane.VERTICAL_SPLIT, treePanel, detailPanel, Configuration.guiSplitPane2DividerLocationPercent); + splitPane1 = new JPersistentSplitPane(JSplitPane.HORIZONTAL_SPLIT, splitPane2, displayPanel, Configuration.guiSplitPane1DividerLocationPercent); welcomePanel = createWelcomePanel(); add(welcomePanel, BorderLayout.CENTER); - splitPane1.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, (PropertyChangeEvent pce) -> { - if (splitsInited) { - int width = ((JSplitPane) pce.getSource()).getWidth(); - if (width != 0) { - int p = Math.round((100.0f * (Integer) pce.getNewValue() / width)); - Configuration.guiSplitPane1DividerLocationPercent.set(p); - } - } - }); - - splitPane2.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, (PropertyChangeEvent pce) -> { - if (detailPanel.isVisible()) { - int width = ((JSplitPane) pce.getSource()).getWidth(); - if (width != 0) { - int p = Math.round((100.0f * (Integer) pce.getNewValue() / width)); - Configuration.guiSplitPane2DividerLocationPercent.set(p); - } - } - }); - timelineViewPanel = new TimelineViewPanel(); CardLayout cl3 = new CardLayout(); @@ -658,7 +636,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se if (abcPanel != null) { abcPanel.reload(); } - + updateClassesList(); } catch (InterruptedException ex) { logger.log(Level.SEVERE, null, ex); @@ -680,9 +658,8 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se abcPanel = new ABCPanel(this); displayPanel.add(abcPanel, CARDACTIONSCRIPT3PANEL); detailPanel.add(abcPanel.tabbedPane, DETAILCARDAS3NAVIGATOR); - abcPanel.initSplits(); } - + return abcPanel; } @@ -690,7 +667,6 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se if (actionPanel == null) { actionPanel = new ActionPanel(MainPanel.this); displayPanel.add(actionPanel, CARDACTIONSCRIPTPANEL); - actionPanel.initSplits(); } return actionPanel; @@ -857,25 +833,6 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se } } - @Override - public void setVisible(boolean b) { - super.setVisible(b); - if (b) { - int split = Configuration.guiSplitPane1DividerLocationPercent.get(33); - splitPane1.setDividerLocation(split / 100.0); - - int confDivLoc = Configuration.guiSplitPane2DividerLocationPercent.get(60); - splitPane2.setDividerLocation(confDivLoc / 100.0); - - split = Configuration.guiPreviewSplitPaneDividerLocationPercent.get(50); - previewPanel.setDividerLocation(split / 100.0); - - splitPos = splitPane2.getDividerLocation(); - splitsInited = true; - previewPanel.setSplitsInited(); - } - } - public void renameIdentifier(SWF swf, String identifier) throws InterruptedException { String oldName = identifier; String newName = View.showInputDialog(translate("rename.enternew"), oldName); @@ -1367,7 +1324,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se View.execInEventDispatch(() -> { getActionPanel(); }); - + if (getActionPanel().search(txt, searchDialog.ignoreCaseCheckBox.isSelected(), searchDialog.regexpCheckBox.isSelected())) { found = true; View.execInEventDispatch(() -> { @@ -1450,6 +1407,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se swf.clearImageCache(); repaintTree(); } + return null; } }.execute(); @@ -2129,9 +2087,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se return false; } - //View.execInEventDispatch(() -> { - font.addCharacter(character, f); - //}); + font.addCharacter(character, f); return true; } @@ -2375,20 +2331,16 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se return null; } - private int splitPos = 0; - public void showDetail(String card) { CardLayout cl = (CardLayout) (detailPanel.getLayout()); cl.show(detailPanel, card); if (card.equals(DETAILCARDEMPTYPANEL)) { if (detailPanel.isVisible()) { - splitPos = splitPane2.getDividerLocation(); detailPanel.setVisible(false); } } else { if (!detailPanel.isVisible()) { detailPanel.setVisible(true); - splitPane2.setDividerLocation(splitPos); } } @@ -2641,9 +2593,9 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se @Override protected void done() { - Main.stopWork(); - View.execInEventDispatch(() -> { + Main.stopWork(); + setSourceWorker = null; try { get(); diff --git a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java index c1e3571c0..0d547a829 100644 --- a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java @@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane; +import com.jpexs.decompiler.flash.gui.controls.JPersistentSplitPane; import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel; import com.jpexs.decompiler.flash.gui.player.MediaDisplay; import com.jpexs.decompiler.flash.gui.player.PlayerControls; @@ -75,7 +76,6 @@ import java.awt.Component; import java.awt.Font; import java.awt.Insets; import java.awt.event.ActionEvent; -import java.beans.PropertyChangeEvent; import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -114,7 +114,7 @@ import jsyntaxpane.DefaultSyntaxKit; * * @author JPEXS */ -public class PreviewPanel extends JSplitPane { +public class PreviewPanel extends JPersistentSplitPane { private static final String FLASH_VIEWER_CARD = "FLASHVIEWER"; @@ -184,12 +184,10 @@ public class PreviewPanel extends JSplitPane { private TextPanel textPanel; - private boolean splitsInited; - private MetadataTag metadataTag; public PreviewPanel(MainPanel mainPanel, FlashPlayerPanel flashPanel) { - super(JSplitPane.HORIZONTAL_SPLIT); + super(JSplitPane.HORIZONTAL_SPLIT, Configuration.guiPreviewSplitPaneDividerLocationPercent); this.mainPanel = mainPanel; this.flashPanel = flashPanel; @@ -201,23 +199,12 @@ public class PreviewPanel extends JSplitPane { try { tempFile.delete(); } catch (Exception ex) { - } } } }); - addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, (PropertyChangeEvent pce) -> { - if (splitsInited && getRightComponent().isVisible()) { - int width = ((JSplitPane) pce.getSource()).getWidth(); - if (width != 0) { - int p = Math.round((100.0f * (Integer) pce.getNewValue() / width)); - Configuration.guiPreviewSplitPaneDividerLocationPercent.set(p); - } - } - }); - viewerCards = new JPanel(); viewerCards.setLayout(new CardLayout()); @@ -459,10 +446,6 @@ public class PreviewPanel extends JSplitPane { cl.show(displayWithPreview, card); } - public void setSplitsInited() { - splitsInited = true; - } - public TextPanel getTextPanel() { return textPanel; } @@ -505,7 +488,6 @@ public class PreviewPanel extends JSplitPane { showCardRight(CARDFONTPANEL); parametersPanel.setVisible(true); - setDividerLocation(Configuration.guiPreviewSplitPaneDividerLocationPercent.get(50) / 100.0); fontPanel.showFontTag(fontTag); int pageCount = getFontPageCount(fontTag); @@ -536,7 +518,6 @@ public class PreviewPanel extends JSplitPane { showCardRight(CARDTEXTPANEL); parametersPanel.setVisible(true); - setDividerLocation(Configuration.guiPreviewSplitPaneDividerLocationPercent.get(50) / 100.0); textPanel.setText(textTag); } diff --git a/src/com/jpexs/decompiler/flash/gui/SearchDialog.java b/src/com/jpexs/decompiler/flash/gui/SearchDialog.java index 4ecc95582..4d11fea52 100644 --- a/src/com/jpexs/decompiler/flash/gui/SearchDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/SearchDialog.java @@ -112,7 +112,6 @@ public class SearchDialog extends AppDialog { cnt.add(panButtons); getRootPane().setDefaultButton(okButton); View.centerScreen(this); - //View.setWindowIcon(this); setIconImage(View.loadImage(replace ? "replace16" : "search16")); setTitle(replace ? translate("dialog.title.replace") : translate("dialog.title")); setModalityType(ModalityType.APPLICATION_MODAL); diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index 3b84b75de..2d7ecb2e8 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -57,6 +57,7 @@ import com.jpexs.decompiler.flash.gui.abc.tablemodels.NamespaceSetTableModel; import com.jpexs.decompiler.flash.gui.abc.tablemodels.NamespaceTableModel; import com.jpexs.decompiler.flash.gui.abc.tablemodels.StringTableModel; import com.jpexs.decompiler.flash.gui.abc.tablemodels.UIntTableModel; +import com.jpexs.decompiler.flash.gui.controls.JPersistentSplitPane; import com.jpexs.decompiler.flash.gui.tagtree.TagTreeModel; import com.jpexs.decompiler.flash.helpers.Freed; import com.jpexs.decompiler.flash.tags.ABCContainerTag; @@ -79,7 +80,6 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; -import java.beans.PropertyChangeEvent; import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -124,7 +124,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener { - if (!directEditing) { - int width = ((JSplitPane) pce.getSource()).getWidth(); - if (width != 0) { - int p = Math.round((100.0f * (Integer) pce.getNewValue() / width)); - Configuration.guiAvm2SplitPaneDividerLocationPercent.set(p); - } - } - }); - decompiledTextArea.setContentType("text/actionscript"); decompiledTextArea.setFont(new Font("Monospaced", Font.PLAIN, decompiledTextArea.getFont().getSize())); @@ -697,10 +681,6 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener { - caretUpdate(e); - }); - return; - } - ABC abc = getABC(); if (abc == null) { return; diff --git a/src/com/jpexs/decompiler/flash/gui/abc/DeobfuscationDialog.java b/src/com/jpexs/decompiler/flash/gui/abc/DeobfuscationDialog.java index bc72c4f66..e66a1d4b2 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/DeobfuscationDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/DeobfuscationDialog.java @@ -99,7 +99,6 @@ public class DeobfuscationDialog extends AppDialog { setModal(true); View.centerScreen(this); - //View.setWindowIcon(this); setIconImage(View.loadImage("deobfuscate16")); } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java index d0c9bc1de..78f0ba2a4 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java @@ -149,39 +149,36 @@ public class DetailPanel extends JPanel { } public void showCard(final String name, final Trait trait) { - View.execInEventDispatch(() -> { - CardLayout layout = (CardLayout) innerPanel.getLayout(); - layout.show(innerPanel, name); - boolean b = cardMap.get(name) instanceof TraitDetail; - buttonsPanel.setVisible(b); + CardLayout layout = (CardLayout) innerPanel.getLayout(); + layout.show(innerPanel, name); + boolean b = cardMap.get(name) instanceof TraitDetail; + buttonsPanel.setVisible(b); - TraitDetail newDetail = null; - if (b) { - newDetail = (TraitDetail) cardMap.get(name); - } - for (JComponent v : cardMap.values()) { - if (v instanceof TraitDetail) { - if (v != newDetail) { - TraitDetail oldDetail = (TraitDetail) v; - oldDetail.setActive(false); - } + TraitDetail newDetail = null; + if (b) { + newDetail = (TraitDetail) cardMap.get(name); + } + for (JComponent v : cardMap.values()) { + if (v instanceof TraitDetail) { + if (v != newDetail) { + TraitDetail oldDetail = (TraitDetail) v; + oldDetail.setActive(false); } } - if (newDetail != null) { - newDetail.setActive(true); - } + } + if (newDetail != null) { + newDetail.setActive(true); + } - selectedCard = name; - selectedLabel.setText(selectedCard); - if (trait == null) { - traitNameLabel.setText("-"); - } else { - if (abcPanel != null) { - traitNameLabel.setText(trait.getName(abcPanel.abc).getName(abcPanel.abc.constants, new ArrayList<>(), false)); - } + selectedCard = name; + selectedLabel.setText(selectedCard); + if (trait == null) { + traitNameLabel.setText("-"); + } else { + if (abcPanel != null) { + traitNameLabel.setText(trait.getName(abcPanel.abc).getName(abcPanel.abc.constants, new ArrayList<>(), false)); } - }); - + } } private void editButtonActionPerformed(ActionEvent evt) { diff --git a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index a27a4b0da..419f5edae 100644 --- a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -42,6 +42,7 @@ import com.jpexs.decompiler.flash.gui.SearchPanel; import com.jpexs.decompiler.flash.gui.SearchResultsDialog; import com.jpexs.decompiler.flash.gui.View; import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane; +import com.jpexs.decompiler.flash.gui.controls.JPersistentSplitPane; import com.jpexs.decompiler.flash.gui.tagtree.TagTreeModel; import com.jpexs.decompiler.flash.helpers.HighlightedText; import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; @@ -56,7 +57,6 @@ import java.awt.FlowLayout; import java.awt.Font; import java.awt.Insets; import java.awt.event.ActionEvent; -import java.beans.PropertyChangeEvent; import java.io.IOException; import java.io.StringReader; import java.util.ArrayList; @@ -95,7 +95,7 @@ public class ActionPanel extends JPanel implements SearchListener { + setSourceWorker = null; + Main.stopWork(); + try { get(); } catch (CancellationException ex) { @@ -554,15 +555,7 @@ public class ActionPanel extends JPanel implements SearchListener { - int width = ((JSplitPane) pce.getSource()).getWidth(); - if (width != 0) { - int p = Math.round((100.0f * (Integer) pce.getNewValue() / width)); - Configuration.guiActionSplitPaneDividerLocationPercent.set(p); - } - }); + add(splitPane = new JPersistentSplitPane(JSplitPane.HORIZONTAL_SPLIT, panA, panB, Configuration.guiActionSplitPaneDividerLocationPercent), BorderLayout.CENTER); editor.setFont(new Font("Monospaced", Font.PLAIN, editor.getFont().getSize())); decompiledEditor.setFont(new Font("Monospaced", Font.PLAIN, decompiledEditor.getFont().getSize())); @@ -627,11 +620,6 @@ public class ActionPanel extends JPanel implements SearchListener. + */ +package com.jpexs.decompiler.flash.gui.controls; + +import com.jpexs.decompiler.flash.configuration.ConfigurationItem; +import java.awt.Component; +import java.beans.PropertyChangeEvent; +import javax.swing.JSplitPane; + +/** + * + * @author JPEXS + */ +public class JPersistentSplitPane extends JSplitPane { + + public JPersistentSplitPane(int newOrientation, ConfigurationItem config) { + super(newOrientation); + initialize(config); + } + + public JPersistentSplitPane(int newOrientation, + Component newLeftComponent, + Component newRightComponent, + ConfigurationItem config) { + super(newOrientation, newLeftComponent, newRightComponent); + initialize(config); + } + + private void initialize(ConfigurationItem config) { + setResizeWeight(0.5); + + addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, (PropertyChangeEvent pce) -> { + if (getLeftComponent().isVisible() && getRightComponent().isVisible()) { + int width = ((JSplitPane) pce.getSource()).getWidth(); + if (width != 0) { + int p = Math.round((100.0f * (Integer) pce.getNewValue() / width)); + System.out.println(config.getName() + ": " + p); + config.set(p); + } + } + }); + } +} diff --git a/src/com/jpexs/decompiler/flash/gui/generictageditors/ChangeListener.java b/src/com/jpexs/decompiler/flash/gui/generictageditors/ChangeListener.java index 9ddc556a0..86d2ce0bb 100644 --- a/src/com/jpexs/decompiler/flash/gui/generictageditors/ChangeListener.java +++ b/src/com/jpexs/decompiler/flash/gui/generictageditors/ChangeListener.java @@ -1,16 +1,16 @@ /* * Copyright (C) 2010-2015 JPEXS - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program 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 General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -20,6 +20,7 @@ package com.jpexs.decompiler.flash.gui.generictageditors; * * @author JPEXS */ +@FunctionalInterface public interface ChangeListener { public void change(GenericTagEditor editor); diff --git a/src/com/jpexs/decompiler/flash/gui/helpers/CollectionChangedListener.java b/src/com/jpexs/decompiler/flash/gui/helpers/CollectionChangedListener.java index 33b8451aa..feb0ff54e 100644 --- a/src/com/jpexs/decompiler/flash/gui/helpers/CollectionChangedListener.java +++ b/src/com/jpexs/decompiler/flash/gui/helpers/CollectionChangedListener.java @@ -22,6 +22,7 @@ import java.util.EventListener; * * @author JPEXS */ +@FunctionalInterface public interface CollectionChangedListener extends EventListener { public void collectionChanged(CollectionChangedEvent e); diff --git a/src/com/jpexs/decompiler/flash/gui/timeline/FrameSelectionListener.java b/src/com/jpexs/decompiler/flash/gui/timeline/FrameSelectionListener.java index e44053451..0c5a0a1f9 100644 --- a/src/com/jpexs/decompiler/flash/gui/timeline/FrameSelectionListener.java +++ b/src/com/jpexs/decompiler/flash/gui/timeline/FrameSelectionListener.java @@ -1,16 +1,16 @@ /* * Copyright (C) 2010-2015 JPEXS - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program 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 General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -20,6 +20,7 @@ package com.jpexs.decompiler.flash.gui.timeline; * * @author JPEXS */ +@FunctionalInterface public interface FrameSelectionListener { public void frameSelected(int frame, int depth); diff --git a/src/com/jpexs/decompiler/flash/gui/timeline/TimelineViewPanel.java b/src/com/jpexs/decompiler/flash/gui/timeline/TimelineViewPanel.java index d00958583..0fc4509a5 100644 --- a/src/com/jpexs/decompiler/flash/gui/timeline/TimelineViewPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/timeline/TimelineViewPanel.java @@ -16,7 +16,9 @@ */ package com.jpexs.decompiler.flash.gui.timeline; +import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.gui.ImagePanel; +import com.jpexs.decompiler.flash.gui.controls.JPersistentSplitPane; import com.jpexs.decompiler.flash.timeline.Timelined; import java.awt.BorderLayout; import javax.swing.JPanel; @@ -45,7 +47,7 @@ public class TimelineViewPanel extends JPanel { setLayout(new BorderLayout()); timeline = new TimelinePanel(); timeline.setTimelined(timelined); - add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, timeline, previewPanel = new ImagePanel())); + add(new JPersistentSplitPane(JSplitPane.HORIZONTAL_SPLIT, timeline, previewPanel = new ImagePanel(), Configuration.guiTimeLineSplitPaneDividerLocationPercent)); previewPanel.setTimelined(timelined, timelined.getTimeline().swf, 0); //previewPanel.setPreferredSize(new Dimension(400,300));