diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index dad8adb01..2beb769cf 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -75,6 +75,8 @@ import com.jpexs.decompiler.flash.helpers.collections.MyEntry; import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; +import com.jpexs.decompiler.flash.tags.DefineButton2Tag; +import com.jpexs.decompiler.flash.tags.DefineButtonTag; import com.jpexs.decompiler.flash.tags.DefineSpriteTag; import com.jpexs.decompiler.flash.tags.DoInitActionTag; import com.jpexs.decompiler.flash.tags.EndTag; @@ -1030,6 +1032,11 @@ public final class SWF implements SWFContainerItem, Timelined { return uniqueAS3Packs(packs); } + @Override + public RECT getRect() { + return displayRect; + } + @Override public RECT getRect(Set added) { return displayRect; @@ -2304,6 +2311,9 @@ public final class SWF implements SWFContainerItem, Timelined { public void clearImageCache() { frameCache.clear(); + DefineSpriteTag.clearCache(); + DefineButtonTag.clearCache(); + DefineButton2Tag.clearCache(); for (Tag tag : tags) { if (tag instanceof ImageTag) { ((ImageTag) tag).clearCache(); @@ -2355,6 +2365,7 @@ public final class SWF implements SWFContainerItem, Timelined { if (actions == null) { actions = src.getActions(); } + HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true); Action.actionsToSource(src, actions, src.toString()/*FIXME?*/, writer); List hilights = writer.instructionHilights; @@ -2694,7 +2705,7 @@ public final class SWF implements SWFContainerItem, Timelined { String assetName; Tag drawableTag = (Tag) drawable; - RECT boundRect = drawable.getRect(new HashSet()); + RECT boundRect = drawable.getRect(); if (exporter.exportedTags.containsKey(drawableTag)) { assetName = exporter.exportedTags.get(drawableTag); } else { @@ -2858,7 +2869,7 @@ public final class SWF implements SWFContainerItem, Timelined { } } - RECT boundRect = drawable.getRect(new HashSet()); + RECT boundRect = drawable.getRect(); ExportRectangle rect = new ExportRectangle(boundRect); rect = mat.transform(rect); Matrix m = mat.clone(); @@ -3006,7 +3017,7 @@ public final class SWF implements SWFContainerItem, Timelined { BoundedTag b = (BoundedTag) character; g.setPaint(new Color(255, 255, 255, 128)); g.setComposite(BlendComposite.Invert); - RECT r = b.getRect(new HashSet()); + RECT r = b.getRect(); int div = (int) unzoom; g.drawString(character.toString(), r.Xmin / div + 3, r.Ymin / div + 15); g.draw(new Rectangle(r.Xmin / div, r.Ymin / div, r.getWidth() / div, r.getHeight() / div)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java index 3b5552cd9..cd917c937 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -702,7 +702,13 @@ public class ABC { if (methodInfo == -1) { return -1; } - return getBodyIdxFromMethodIdx().get(methodInfo); + + Integer result = getBodyIdxFromMethodIdx().get(methodInfo); + if (result == null) { + return -1; + } + + return result; } public MethodBody findBodyByClassAndName(String className, String methodName) { 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 ee0f5ece6..543d2bc1e 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 @@ -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.exporters; import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; @@ -26,7 +27,6 @@ import com.jpexs.decompiler.flash.exporters.morphshape.CanvasMorphShapeExporter; import com.jpexs.decompiler.flash.exporters.settings.MorphShapeExportSettings; import com.jpexs.decompiler.flash.tags.DefineMorphShapeTag; import com.jpexs.decompiler.flash.tags.Tag; -import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.MorphShapeTag; import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; @@ -79,7 +79,7 @@ public class MorphShapeExporter { switch (settings.mode) { case SVG: try (FileOutputStream fos = new FileOutputStream(file)) { - ExportRectangle rect = new ExportRectangle(mst.getRect(new HashSet())); + ExportRectangle rect = new ExportRectangle(mst.getRect()); rect.xMax *= settings.zoom; rect.yMax *= settings.zoom; rect.xMin *= settings.zoom; 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 0fe34645e..cae9e54e5 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 @@ -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.exporters; import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler; @@ -28,7 +29,6 @@ import com.jpexs.decompiler.flash.exporters.shape.CanvasShapeExporter; import com.jpexs.decompiler.flash.helpers.BMPFile; import com.jpexs.decompiler.flash.helpers.ImageHelper; import com.jpexs.decompiler.flash.tags.Tag; -import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.ShapeTag; import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; @@ -91,7 +91,7 @@ public class ShapeExporter { switch (settings.mode) { case SVG: try (FileOutputStream fos = new FileOutputStream(file)) { - ExportRectangle rect = new ExportRectangle(st.getRect(new HashSet())); + ExportRectangle rect = new ExportRectangle(st.getRect()); rect.xMax *= settings.zoom; rect.yMax *= settings.zoom; rect.xMin *= settings.zoom; @@ -103,7 +103,7 @@ public class ShapeExporter { break; case PNG: case BMP: - RECT rect = st.getRect(new HashSet()); + RECT rect = st.getRect(); int newWidth = (int) (rect.getWidth() * settings.zoom / SWF.unitDivisor); int newHeight = (int) (rect.getHeight() * settings.zoom / SWF.unitDivisor); SerializableImage img = new SerializableImage(newWidth, newHeight, SerializableImage.TYPE_INT_ARGB); 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 b71ba57d8..a79860ffd 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 @@ -25,7 +25,6 @@ import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; import com.jpexs.decompiler.flash.exporters.modes.TextExportMode; import com.jpexs.decompiler.flash.exporters.settings.TextExportSettings; import com.jpexs.decompiler.flash.tags.Tag; -import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.TextTag; import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA; import com.jpexs.helpers.Helper; @@ -35,7 +34,6 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; /** @@ -73,7 +71,7 @@ public class TextExporter { @Override public void run() throws IOException { try (FileOutputStream fos = new FileOutputStream(file)) { - ExportRectangle rect = new ExportRectangle(textTag.getRect(new HashSet())); + 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())); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/ShapeImporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/ShapeImporter.java index 0ccee46c7..2d526a083 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/ShapeImporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/ShapeImporter.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.importers; import com.jpexs.decompiler.flash.SWF; @@ -23,14 +24,12 @@ import com.jpexs.decompiler.flash.tags.DefineShape3Tag; import com.jpexs.decompiler.flash.tags.DefineShape4Tag; import com.jpexs.decompiler.flash.tags.DefineShapeTag; import com.jpexs.decompiler.flash.tags.Tag; -import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.ShapeTag; import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.util.HashSet; /** * @@ -53,7 +52,7 @@ public class ShapeImporter { swf.tags.add(jpeg2Tag); swf.updateCharacters(); st.setModified(true); - SHAPEWITHSTYLE shapes = jpeg2Tag.getShape(st.getRect(new HashSet()), true); + SHAPEWITHSTYLE shapes = jpeg2Tag.getShape(st.getRect(), true); if (st instanceof DefineShapeTag) { DefineShapeTag dst = (DefineShapeTag) st; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java index 310ba8ae1..031ab4230 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java @@ -42,7 +42,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import java.util.Set; @@ -87,6 +86,8 @@ public class DefineButton2Tag extends ButtonTag implements ASMSourceContainer { private boolean isSingleFrame; + private static final Cache rectCache = Cache.getInstance(true, "rect_button2"); + @Override public int getCharacterId() { return buttonId; @@ -198,8 +199,6 @@ public class DefineButton2Tag extends ButtonTag implements ASMSourceContainer { return modified; } - private static final Cache rectCache = Cache.getInstance(true, "rect_button2"); - @Override public RECT getRect(Set added) { if (rectCache.contains(this)) { @@ -213,6 +212,7 @@ public class DefineButton2Tag extends ButtonTag implements ASMSourceContainer { if (!added.contains(bt)) { added.add(bt); RECT r2 = bt.getRect(added); + added.remove(bt); MATRIX mat = r.placeMatrix; if (mat != null) { r2 = mat.apply(r2); @@ -228,6 +228,10 @@ public class DefineButton2Tag extends ButtonTag implements ASMSourceContainer { return rect; } + public static void clearCache() { + rectCache.clear(); + } + @Override public boolean trackAsMenu() { return trackAsMenu; @@ -258,7 +262,7 @@ public class DefineButton2Tag extends ButtonTag implements ASMSourceContainer { if (timeline != null) { return timeline; } - timeline = new Timeline(swf, this, new ArrayList(), buttonId, getRect(new HashSet())); + timeline = new Timeline(swf, this, new ArrayList(), buttonId, getRect()); int maxDepth = 0; Frame frameUp = new Frame(timeline, 0); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java index cab006684..63b90bf86 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java @@ -49,7 +49,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.logging.Level; @@ -93,6 +92,8 @@ public class DefineButtonTag extends ButtonTag implements ASMSource { private boolean isSingleFrame; + private static final Cache rectCache = Cache.getInstance(true, "rect_button"); + @Override public List getRecords() { return characters; @@ -249,8 +250,6 @@ public class DefineButtonTag extends ButtonTag implements ASMSource { return modified; } - private static final Cache rectCache = Cache.getInstance(true, "rect_button"); - @Override public RECT getRect(Set added) { if (rectCache.contains(this)) { @@ -264,6 +263,7 @@ public class DefineButtonTag extends ButtonTag implements ASMSource { if (!added.contains(bt)) { added.add(bt); RECT r2 = bt.getRect(added); + added.remove(bt); MATRIX mat = r.placeMatrix; if (mat != null) { r2 = mat.apply(r2); @@ -280,6 +280,10 @@ public class DefineButtonTag extends ButtonTag implements ASMSource { return rect; } + public static void clearCache() { + rectCache.clear(); + } + List listeners = new ArrayList<>(); @Override @@ -342,7 +346,7 @@ public class DefineButtonTag extends ButtonTag implements ASMSource { if (timeline != null) { return timeline; } - timeline = new Timeline(swf, this, new ArrayList(), buttonId, getRect(new HashSet())); + timeline = new Timeline(swf, this, new ArrayList(), buttonId, getRect()); ColorTransform clrTrans = null; for (Tag t : swf.tags) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java index 9775115b7..9105f8ebb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java @@ -57,7 +57,6 @@ import java.io.OutputStream; import java.io.StringReader; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.Stack; @@ -821,7 +820,7 @@ public class DefineEditTextTag extends TextTag { RGB borderColor = new RGBA(Color.black); RGB fillColor = new RGBA(Color.white); if (!canvas) { - drawBorder(swf, image, borderColor, fillColor, getRect(new HashSet()), getTextMatrix(), transformation, colorTransform); + drawBorder(swf, image, borderColor, fillColor, getRect(), getTextMatrix(), transformation, colorTransform); } else { // TODO: draw border } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java index fe739c543..2084369f6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShape2Tag.java @@ -26,7 +26,6 @@ import com.jpexs.decompiler.flash.exporters.morphshape.SVGMorphShapeExporter; import com.jpexs.decompiler.flash.exporters.shape.BitmapExporter; import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter; import com.jpexs.decompiler.flash.tags.base.BoundedTag; -import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.MorphShapeTag; import com.jpexs.decompiler.flash.timeline.DepthState; import com.jpexs.decompiler.flash.types.BasicType; @@ -62,7 +61,7 @@ import java.util.Set; * * @author JPEXS */ -public class DefineMorphShape2Tag extends CharacterTag implements MorphShapeTag { +public class DefineMorphShape2Tag extends MorphShapeTag { @SWFType(BasicType.UI16) public int characterId; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java index 5158d806c..200abe861 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineMorphShapeTag.java @@ -26,7 +26,6 @@ import com.jpexs.decompiler.flash.exporters.morphshape.SVGMorphShapeExporter; import com.jpexs.decompiler.flash.exporters.shape.BitmapExporter; import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter; import com.jpexs.decompiler.flash.tags.base.BoundedTag; -import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.MorphShapeTag; import com.jpexs.decompiler.flash.timeline.DepthState; import com.jpexs.decompiler.flash.types.BasicType; @@ -61,7 +60,7 @@ import java.util.Set; * * @author JPEXS */ -public class DefineMorphShapeTag extends CharacterTag implements MorphShapeTag { +public class DefineMorphShapeTag extends MorphShapeTag { @SWFType(BasicType.UI16) public int characterId; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java index a325d1dc7..bddd21deb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java @@ -84,10 +84,12 @@ public class DefineSpriteTag extends CharacterTag implements DrawableTag, Timeli private boolean isSingleFrame; + private static final Cache rectCache = Cache.getInstance(true, "rect_sprite"); + @Override public Timeline getTimeline() { if (timeline == null) { - timeline = new Timeline(swf, this, subTags, spriteId, getRect(new HashSet())); + timeline = new Timeline(swf, this, subTags, spriteId, getRect()); } return timeline; } @@ -108,6 +110,7 @@ public class DefineSpriteTag extends CharacterTag implements DrawableTag, Timeli if (!added.contains(bt)) { added.add(bt); r = bt.getRect(added); + added.remove(bt); } } if (r != null) { @@ -124,7 +127,10 @@ public class DefineSpriteTag extends CharacterTag implements DrawableTag, Timeli return ret; } - private static final Cache rectCache = Cache.getInstance(true, "rect_sprite"); + @Override + public RECT getRect() { + return getRect(new HashSet()); + } @Override public RECT getRect(Set added) { @@ -134,9 +140,7 @@ public class DefineSpriteTag extends CharacterTag implements DrawableTag, Timeli RECT ret = new RECT(Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE); HashMap depthMap = new HashMap<>(); boolean foundSomething = false; - int pos = 0; for (Tag t : subTags) { - pos++; MATRIX m = null; int characterId = -1; if (t instanceof PlaceObjectTypeTag) { @@ -145,9 +149,9 @@ public class DefineSpriteTag extends CharacterTag implements DrawableTag, Timeli int charId = pot.getCharacterId(); if (charId > -1) { depthMap.put(pot.getDepth(), charId); - characterId = (charId); + characterId = charId; } else { - Integer chi = (depthMap.get(pot.getDepth())); + Integer chi = depthMap.get(pot.getDepth()); if (chi != null) { characterId = chi; } @@ -262,6 +266,10 @@ public class DefineSpriteTag extends CharacterTag implements DrawableTag, Timeli return subTags; } + public static void clearCache() { + rectCache.clear(); + } + @Override public void getNeededCharacters(Set needed) { for (Tag t : subTags) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java index 2fe285944..6b38b2fa9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java @@ -47,7 +47,6 @@ import java.io.IOException; import java.io.OutputStream; import java.io.StringReader; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.regex.Matcher; @@ -565,7 +564,7 @@ public class DefineText2Tag extends TextTag { @Override public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) { - staticTextToSVG(swf, textRecords, 2, exporter, getRect(new HashSet()), getTextMatrix(), colorTransform, zoom); + staticTextToSVG(swf, textRecords, 2, exporter, getRect(), getTextMatrix(), colorTransform, zoom); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java index 6e1e94adc..72ae78b90 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java @@ -48,7 +48,6 @@ import java.io.IOException; import java.io.OutputStream; import java.io.StringReader; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.regex.Matcher; @@ -584,7 +583,7 @@ public class DefineTextTag extends TextTag { @Override public void toSVG(SVGExporter exporter, int ratio, ColorTransform colorTransform, int level, double zoom) { - staticTextToSVG(swf, textRecords, 1, exporter, getRect(new HashSet()), getTextMatrix(), colorTransform, zoom); + staticTextToSVG(swf, textRecords, 1, exporter, getRect(), getTextMatrix(), colorTransform, zoom); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineVideoStreamTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineVideoStreamTag.java index a5c5df6c5..5b239e772 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineVideoStreamTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineVideoStreamTag.java @@ -131,6 +131,11 @@ public class DefineVideoStreamTag extends CharacterTag implements BoundedTag { codecID = sis.readUI8("codecID"); } + @Override + public RECT getRect() { + return getRect(null); // parameter not used + } + @Override public RECT getRect(Set added) { return new RECT(0, (int) (SWF.unitDivisor * width), 0, (int) (SWF.unitDivisor * height)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/BoundedTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/BoundedTag.java index 336269094..787afc22e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/BoundedTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/BoundedTag.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.tags.base; import com.jpexs.decompiler.flash.types.RECT; @@ -24,5 +25,7 @@ import java.util.Set; */ public interface BoundedTag { + public RECT getRect(); + public RECT getRect(Set added); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ButtonTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ButtonTag.java index d35d0f488..85a579a24 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ButtonTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ButtonTag.java @@ -25,11 +25,13 @@ import com.jpexs.decompiler.flash.timeline.DepthState; import com.jpexs.decompiler.flash.timeline.Timelined; import com.jpexs.decompiler.flash.types.BUTTONRECORD; import com.jpexs.decompiler.flash.types.ColorTransform; +import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.helpers.ByteArrayRange; import com.jpexs.helpers.SerializableImage; import java.awt.Shape; import java.io.IOException; import java.util.Arrays; +import java.util.HashSet; import java.util.List; /** @@ -54,6 +56,11 @@ public abstract class ButtonTag extends CharacterTag implements DrawableTag, Tim public abstract boolean trackAsMenu(); + @Override + public RECT getRect() { + return getRect(new HashSet()); + } + @Override public Shape getOutline(int frame, int time, int ratio, DepthState stateUnderCursor, int mouseButton, Matrix transformation) { return getTimeline().getOutline(frame, time, ratio, stateUnderCursor, mouseButton, transformation); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java index e6b6d7808..76103e7c0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java @@ -44,7 +44,6 @@ import java.awt.font.GlyphMetrics; import java.awt.font.GlyphVector; import java.awt.geom.Area; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -315,10 +314,15 @@ public abstract class FontTag extends CharacterTag implements AloneTag, Drawable @Override public Shape getOutline(int frame, int time, int ratio, DepthState stateUnderCursor, int mouseButton, Matrix transformation) { - RECT r = getRect(new HashSet()); + RECT r = getRect(); return new Area(new Rectangle(r.Xmin, r.Ymin, r.getWidth(), r.getHeight())); } + @Override + public RECT getRect() { + return getRect(null); // parameter not used + } + @Override public RECT getRect(Set added) { return new RECT(0, (int) (PREVIEWSIZE * SWF.unitDivisor), 0, (int) (PREVIEWSIZE * SWF.unitDivisor)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ImageTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ImageTag.java index c2d8cd881..bef4e0429 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ImageTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ImageTag.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.tags.base; import com.jpexs.decompiler.flash.SWF; @@ -40,7 +41,6 @@ import java.awt.Shape; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; -import java.util.HashSet; import java.util.Set; /** @@ -109,7 +109,7 @@ public abstract class ImageTag extends CharacterTag implements DrawableTag { } private SHAPEWITHSTYLE getShape() { - RECT rect = getRect(new HashSet()); + RECT rect = getRect(); return getShape(rect, false); } @@ -124,7 +124,7 @@ public abstract class ImageTag extends CharacterTag implements DrawableTag { MATRIX matrix = new MATRIX(); matrix.hasScale = true; if (fill) { - RECT imageRect = getRect(new HashSet()); + RECT imageRect = getRect(); matrix.scaleX = (int) ((((long) SWF.unitDivisor) << 16) * rect.getWidth() / imageRect.getWidth()); matrix.scaleY = (int) ((((long) SWF.unitDivisor) << 16) * rect.getHeight() / imageRect.getHeight()); } else { @@ -170,6 +170,11 @@ public abstract class ImageTag extends CharacterTag implements DrawableTag { return shape; } + @Override + public RECT getRect() { + return getRect(null); // parameter not used + } + @Override public RECT getRect(Set added) { SerializableImage image = getImage(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/MorphShapeTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/MorphShapeTag.java index 9a2895ddc..a1ca554c5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/MorphShapeTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/MorphShapeTag.java @@ -1,45 +1,58 @@ /* * 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.tags.base; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.types.MORPHFILLSTYLEARRAY; import com.jpexs.decompiler.flash.types.MORPHLINESTYLEARRAY; import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPE; import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE; +import com.jpexs.helpers.ByteArrayRange; +import java.util.HashSet; /** * * @author JPEXS */ -public interface MorphShapeTag extends DrawableTag { +public abstract class MorphShapeTag extends CharacterTag implements DrawableTag { - public RECT getStartBounds(); + public MorphShapeTag(SWF swf, int id, String name, ByteArrayRange data) { + super(swf, id, name, data); + } - public RECT getEndBounds(); + public abstract RECT getStartBounds(); - public MORPHFILLSTYLEARRAY getFillStyles(); + public abstract RECT getEndBounds(); - public MORPHLINESTYLEARRAY getLineStyles(); + public abstract MORPHFILLSTYLEARRAY getFillStyles(); - public SHAPE getStartEdges(); + public abstract MORPHLINESTYLEARRAY getLineStyles(); - public SHAPE getEndEdges(); + public abstract SHAPE getStartEdges(); - public int getShapeNum(); + public abstract SHAPE getEndEdges(); - public SHAPEWITHSTYLE getShapeAtRatio(int ratio); + public abstract int getShapeNum(); + + public abstract SHAPEWITHSTYLE getShapeAtRatio(int ratio); + + @Override + public RECT getRect() { + return getRect(new HashSet()); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java index ce09bdb99..2c93e4a67 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/ShapeTag.java @@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.exporters.shape.SVGShapeExporter; import com.jpexs.decompiler.flash.helpers.LazyObject; import com.jpexs.decompiler.flash.timeline.DepthState; import com.jpexs.decompiler.flash.types.ColorTransform; +import com.jpexs.decompiler.flash.types.RECT; import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE; import com.jpexs.helpers.ByteArrayRange; import com.jpexs.helpers.SerializableImage; @@ -61,6 +62,11 @@ public abstract class ShapeTag extends CharacterTag implements DrawableTag, Lazy public abstract int getShapeNum(); + @Override + public RECT getRect() { + return getRect(null); // parameter not used + } + @Override public Shape getOutline(int frame, int time, int ratio, DepthState stateUnderCursor, int mouseButton, Matrix transformation) { return transformation.toTransform().createTransformedShape(getShapes().getOutline()); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java index a03ad3b0b..b1658ab93 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/TextTag.java @@ -95,6 +95,11 @@ public abstract class TextTag extends CharacterTag implements DrawableTag { public abstract ExportRectangle calculateTextBounds(); + @Override + public RECT getRect() { + return getRect(null); // parameter not used + } + private static void updateRect(RECT ret, int x, int y) { if (x < ret.Xmin) { ret.Xmin = x; 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 8eb880f51..872a06957 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 @@ -55,7 +55,6 @@ import com.jpexs.decompiler.flash.tags.StartSoundTag; import com.jpexs.decompiler.flash.tags.SymbolClassTag; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ASMSource; -import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.ButtonTag; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.FontTag; @@ -116,7 +115,6 @@ import java.io.StringWriter; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Random; @@ -1080,7 +1078,7 @@ public class XFLConverter { ret.append(" symbolType=\"graphic\" loop=\"loop\""); } else if (tag instanceof DefineSpriteTag) { DefineSpriteTag sprite = (DefineSpriteTag) tag; - RECT spriteRect = sprite.getRect(new HashSet()); + RECT spriteRect = sprite.getRect(); double centerPoint3DX = twipToPixel(matrix.translateX + spriteRect.getWidth() / 2); double centerPoint3DY = twipToPixel(matrix.translateY + spriteRect.getHeight() / 2); ret.append(" centerPoint3DX=\"").append(centerPoint3DX).append("\" centerPoint3DY=\"").append(centerPoint3DY).append("\""); diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/resources/jsyntaxpane/Bundle_fr.properties b/libsrc/jsyntaxpane/jsyntaxpane/src/main/resources/jsyntaxpane/Bundle_fr.properties index 1a9da1652..2d46381c5 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/resources/jsyntaxpane/Bundle_fr.properties +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/resources/jsyntaxpane/Bundle_fr.properties @@ -22,7 +22,7 @@ ReplaceDialog.jChkWrap.text=Chercher partout ReplaceDialog.title=Chercher et Remplacer ReplaceDialog.jBtnNext.text=Suivant ReplaceDialog.jLblFind.text=Chercher -ReplaceDialog.jBtnReplace.text=Remplaceer +ReplaceDialog.jBtnReplace.text=Remplacer ShowAbbsDialog.title=Abr\u00e9viations GotoLineDialog.title=Aller \u00e0 la ligne GotoLineDialog.jBtnOk.text=GO diff --git a/src/com/jpexs/decompiler/flash/gui/FolderPreviewPanel.java b/src/com/jpexs/decompiler/flash/gui/FolderPreviewPanel.java index ffd20353e..edc3d0ce0 100644 --- a/src/com/jpexs/decompiler/flash/gui/FolderPreviewPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/FolderPreviewPanel.java @@ -42,7 +42,6 @@ import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.concurrent.Callable; @@ -289,7 +288,7 @@ public class FolderPreviewPanel extends JPanel { height = imgSrc.getHeight(); } else if (treeItem instanceof BoundedTag) { BoundedTag boundedTag = (BoundedTag) treeItem; - RECT rect = boundedTag.getRect(new HashSet()); + RECT rect = boundedTag.getRect(); width = (int) (rect.getWidth() / SWF.unitDivisor) + 1; height = (int) (rect.getHeight() / SWF.unitDivisor) + 1; m.translate(-rect.Xmin, -rect.Ymin); diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index 7560745f9..f07ceee6a 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -57,7 +57,6 @@ import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import java.util.Timer; import java.util.TimerTask; @@ -253,7 +252,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis Timeline tim = ((Timelined) timelined).getTimeline(); BoundedTag bounded = (BoundedTag) timelined; - RECT rect = bounded.getRect(new HashSet()); + RECT rect = bounded.getRect(); int width = rect.getWidth(); double scale = 1.0; /*if (width > swf.displayRect.getWidth()) { @@ -464,7 +463,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis @Override public synchronized double getZoomToFit() { if (timelined instanceof BoundedTag) { - RECT bounds = ((BoundedTag) timelined).getRect(new HashSet()); + RECT bounds = ((BoundedTag) timelined).getRect(); double w1 = bounds.getWidth() / SWF.unitDivisor; double h1 = bounds.getHeight() / SWF.unitDivisor; @@ -577,7 +576,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis double zoomDouble = zoom.fit ? getZoomToFit() : zoom.value; - RECT rect = textTag.getRect(new HashSet()); + RECT rect = textTag.getRect(); int width = (int) (rect.getWidth() * zoomDouble); int height = (int) (rect.getHeight() * zoomDouble); SerializableImage image = new SerializableImage((int) (width / SWF.unitDivisor) + 1, @@ -668,7 +667,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis if (img == null) { if (drawable instanceof BoundedTag) { BoundedTag bounded = (BoundedTag) drawable; - RECT rect = bounded.getRect(new HashSet()); + RECT rect = bounded.getRect(); if (rect == null) { //??? Why? rect = new RECT(0, 0, 1, 1); } diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 073bdf780..3342c8300 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -2502,7 +2502,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec DefineSpriteTag parentSprite = (DefineSpriteTag) fn.timeline.timelined; controlTags = parentSprite.subTags; containerId = parentSprite.spriteId; - rect = parentSprite.getRect(new HashSet()); + rect = parentSprite.getRect(); totalFrameCount = parentSprite.frameCount; timelined = parentSprite; } @@ -2650,7 +2650,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec if (tim != null) { return tim; } - tim = new Timeline(tag.getSwf(), null, new ArrayList(), ((CharacterTag) tag).getCharacterId(), getRect(new HashSet())); + tim = new Timeline(tag.getSwf(), null, new ArrayList(), ((CharacterTag) tag).getCharacterId(), getRect()); if (tag instanceof MorphShapeTag) { tim.frameRate = MORPH_SHAPE_ANIMATION_FRAME_RATE; int framesCnt = tim.frameRate * MORPH_SHAPE_ANIMATION_LENGTH; @@ -2682,10 +2682,15 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec f.layers.put(1, ds); tim.getFrames().add(f); } - tim.displayRect = getRect(new HashSet()); + tim.displayRect = getRect(); return tim; } + @Override + public RECT getRect() { + return getRect(new HashSet()); + } + @Override public RECT getRect(Set added) { BoundedTag bt = (BoundedTag) tag; diff --git a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java index 34f8365ce..b8def2260 100644 --- a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java @@ -631,7 +631,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener { } mat = Helper.deepCopy(mat); if (parent instanceof BoundedTag) { - RECT r = ((BoundedTag) parent).getRect(new HashSet()); + RECT r = ((BoundedTag) parent).getRect(); mat.translateX = mat.translateX + width / 2 - r.getWidth() / 2; mat.translateY = mat.translateY + height / 2 - r.getHeight() / 2; } else { @@ -680,7 +680,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener { mat.translateX = 0; mat.translateY = 0; if (tagObj instanceof BoundedTag) { - RECT r = ((BoundedTag) tagObj).getRect(new HashSet()); + RECT r = ((BoundedTag) tagObj).getRect(); mat.translateX = -r.Xmin; mat.translateY = -r.Ymin; mat.translateX = mat.translateX + width / 2 - r.getWidth() / 2;