mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 18:30:43 +00:00
split panes simplified (base class stores the position)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -251,21 +251,30 @@ public class Configuration {
|
||||
@ConfigurationName("gui.window.maximized.vertical")
|
||||
public static final ConfigurationItem<Boolean> guiWindowMaximizedVertical = null;
|
||||
|
||||
@ConfigurationDefaultInt(50)
|
||||
@ConfigurationName("gui.avm2.splitPane.dividerLocationPercent")
|
||||
public static final ConfigurationItem<Integer> guiAvm2SplitPaneDividerLocationPercent = null;
|
||||
|
||||
@ConfigurationName("guiActionSplitPaneDividerLocationPercent")
|
||||
@ConfigurationDefaultInt(50)
|
||||
@ConfigurationName("gui.actionSplitPane.dividerLocationPercent")
|
||||
public static final ConfigurationItem<Integer> guiActionSplitPaneDividerLocationPercent = null;
|
||||
|
||||
@ConfigurationName("guiPreviewSplitPaneDividerLocationPercent")
|
||||
@ConfigurationDefaultInt(50)
|
||||
@ConfigurationName("gui.previewSplitPane.dividerLocationPercent")
|
||||
public static final ConfigurationItem<Integer> guiPreviewSplitPaneDividerLocationPercent = null;
|
||||
|
||||
@ConfigurationDefaultInt(33)
|
||||
@ConfigurationName("gui.splitPane1.dividerLocationPercent")
|
||||
public static final ConfigurationItem<Integer> guiSplitPane1DividerLocationPercent = null;
|
||||
|
||||
@ConfigurationDefaultInt(60)
|
||||
@ConfigurationName("gui.splitPane2.dividerLocationPercent")
|
||||
public static final ConfigurationItem<Integer> guiSplitPane2DividerLocationPercent = null;
|
||||
|
||||
@ConfigurationDefaultInt(50)
|
||||
@ConfigurationName("gui.timeLineSplitPane.dividerLocationPercent")
|
||||
public static final ConfigurationItem<Integer> guiTimeLineSplitPaneDividerLocationPercent = null;
|
||||
|
||||
@ConfigurationDefaultString("com.jpexs.decompiler.flash.gui.OceanicSkin")
|
||||
@ConfigurationName("gui.skin")
|
||||
@ConfigurationCategory("ui")
|
||||
@@ -595,16 +604,16 @@ public class Configuration {
|
||||
}
|
||||
|
||||
private static HashMap<String, Object> loadFromFile(String file) {
|
||||
HashMap<String, Object> config = new HashMap<>();
|
||||
try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file))) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
HashMap<String, Object> cfg = (HashMap<String, Object>) ois.readObject();
|
||||
config = cfg;
|
||||
//return cfg;
|
||||
} catch (ClassNotFoundException | IOException ex) {
|
||||
// ignore
|
||||
}
|
||||
return config;
|
||||
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
private static void saveToFile(String file) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<Integer> 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<Integer> 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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<Integer> 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<Integer> 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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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<Integer> 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<Integer> 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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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<String> 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<String> 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<String> 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<String> texts = textTag.getTexts();
|
||||
fos.write(Utf8Helper.getBytes(String.join(separator, texts)));
|
||||
}
|
||||
}
|
||||
}, handler).run();
|
||||
|
||||
@@ -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<KerningPair> getFontKerningPairsOneChar(List<Character> availableChars, Font font, char firstChar) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user