From 75994632121e9e7e03f8ff0ef220eb19cbceec83 Mon Sep 17 00:00:00 2001 From: Honfika Date: Wed, 5 Mar 2014 17:31:20 +0100 Subject: [PATCH] small fixes --- .../decompiler/flash/ApplicationInfo.java | 2 +- trunk/src/com/jpexs/decompiler/flash/SWF.java | 45 +++++++++---------- .../jpexs/decompiler/flash/action/Action.java | 6 +-- .../flash/action/ActionDeobfuscation.java | 3 -- .../parser/script/ActionScriptLexer.java | 10 +++-- .../parser/script/ActionScriptParser.java | 2 +- .../flash/exporters/BitmapExporter.java | 34 +++++++++++--- .../flash/exporters/ExportRectangle.java | 8 ++++ .../decompiler/flash/exporters/Matrix.java | 12 +++++ .../decompiler/flash/gui/ImagePanel.java | 21 +++++---- .../jpexs/decompiler/flash/gui/MainPanel.java | 10 ++--- .../decompiler/flash/gui/SWFPreviewPanel.java | 2 +- .../flash/tags/DefineButton2Tag.java | 2 - .../flash/tags/DefineButtonTag.java | 2 - .../flash/tags/DefineEditTextTag.java | 16 +++---- .../decompiler/flash/tags/base/TextTag.java | 2 +- .../tags/dynamictext/CharacterWithStyle.java | 2 +- .../tags/dynamictext/DynamicTextModel.java | 16 +++---- .../tags/dynamictext/GlyphCharacter.java | 6 +-- .../flash/tags/dynamictext/Paragraph.java | 8 ++-- .../tags/dynamictext/SameStyleTextRecord.java | 4 +- .../flash/tags/dynamictext/TextStyle.java | 4 +- .../flash/tags/dynamictext/Word.java | 12 ++--- .../decompiler/flash/timeline/DepthState.java | 2 +- .../decompiler/flash/timeline/Frame.java | 2 +- .../decompiler/flash/timeline/Timeline.java | 22 ++++----- .../decompiler/flash/timeline/Timelined.java | 2 +- .../flash/types/CLIPACTIONRECORD.java | 4 +- .../flash/types/filters/BEVELFILTER.java | 2 +- .../flash/types/filters/BLURFILTER.java | 2 +- .../types/filters/COLORMATRIXFILTER.java | 2 +- .../types/filters/CONVOLUTIONFILTER.java | 2 +- .../flash/types/filters/DROPSHADOWFILTER.java | 2 +- .../flash/types/filters/FILTER.java | 2 +- .../flash/types/filters/Filtering.java | 4 +- .../flash/types/filters/GLOWFILTER.java | 2 +- .../types/filters/GRADIENTBEVELFILTER.java | 2 +- .../types/filters/GRADIENTGLOWFILTER.java | 2 +- 38 files changed, 159 insertions(+), 124 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/ApplicationInfo.java b/trunk/src/com/jpexs/decompiler/flash/ApplicationInfo.java index 47eff68fb..248defe42 100644 --- a/trunk/src/com/jpexs/decompiler/flash/ApplicationInfo.java +++ b/trunk/src/com/jpexs/decompiler/flash/ApplicationInfo.java @@ -40,7 +40,7 @@ public class ApplicationInfo { static { loadProperties(); } - + private static void loadProperties() { Properties prop = new Properties(); try { diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index 1af376a19..5b41fd180 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -71,7 +71,6 @@ import com.jpexs.decompiler.flash.tags.DoInitActionTag; import com.jpexs.decompiler.flash.tags.ExportAssetsTag; import com.jpexs.decompiler.flash.tags.FileAttributesTag; import com.jpexs.decompiler.flash.tags.JPEGTablesTag; -import com.jpexs.decompiler.flash.tags.SetBackgroundColorTag; import com.jpexs.decompiler.flash.tags.ShowFrameTag; import com.jpexs.decompiler.flash.tags.SoundStreamBlockTag; import com.jpexs.decompiler.flash.tags.SymbolClassTag; @@ -170,7 +169,7 @@ import com.jpexs.decompiler.flash.timeline.Timelined; * * @author JPEXS */ -public final class SWF implements TreeItem,Timelined { +public final class SWF implements TreeItem, Timelined { /** * Default version of SWF file format @@ -234,15 +233,15 @@ public final class SWF implements TreeItem,Timelined { public static final double unitDivisor = 20; private Timeline timeline; - + @Override - public Timeline getTimeline(){ - if(timeline == null){ + public Timeline getTimeline() { + if (timeline == null) { timeline = new Timeline(this); } return timeline; } - + /** * Gets all tags with specified id * @@ -2220,14 +2219,13 @@ public final class SWF implements TreeItem,Timelined { return ret; } - public static SerializableImage frameToImageGet(Timeline timeline,int frame, RECT displayRect, Stack visited, Matrix transformation, ColorTransform colorTransform) { + public static SerializableImage frameToImageGet(Timeline timeline, int frame, RECT displayRect, Stack visited, Matrix transformation, ColorTransform colorTransform) { String key = "frame_" + frame + "_" + timeline.id + "_" + timeline.swf.hashCode(); SerializableImage image = getFromCache(key); if (image != null) { return image; } - if (timeline.frames.isEmpty()) { return new SerializableImage(1, 1, SerializableImage.TYPE_INT_ARGB); } @@ -2247,14 +2245,12 @@ public final class SWF implements TreeItem,Timelined { return image; } - - - public static void framesToImage(Timeline timeline, List ret, int startFrame, int stopFrame, RECT displayRect, int totalFrameCount, Stack visited, Matrix transformation, ColorTransform colorTransform) { + public static void framesToImage(Timeline timeline, List ret, int startFrame, int stopFrame, RECT displayRect, int totalFrameCount, Stack visited, Matrix transformation, ColorTransform colorTransform) { RECT rect = displayRect; - for (int f=0;f visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform) { + public static void frameToImage(Timeline timeline, int frame, RECT displayRect, Stack visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform) { float unzoom = (float) SWF.unitDivisor; Frame frameObj = timeline.frames.get(frame); Graphics2D g = (Graphics2D) image.getGraphics(); @@ -2287,9 +2283,8 @@ public final class SWF implements TreeItem,Timelined { g.setTransform(transformation.toTransform()); List clips = new ArrayList<>(); List prevClips = new ArrayList<>(); - - for (int i = 1; i <= timeline.getMaxDepth(); i++) { + for (int i = 1; i <= timeline.getMaxDepth(); i++) { for (int c = 0; c < clips.size(); c++) { if (clips.get(c).clipDepth == i) { g.setClip(prevClips.get(c)); @@ -2348,15 +2343,15 @@ public final class SWF implements TreeItem,Timelined { rect.yMax += deltaYMax * SWF.unitDivisor; } - rect.xMin = Math.max(0, rect.xMin); - rect.yMin = Math.max(0, rect.yMin); - + rect.xMin = Math.max(0, rect.xMin - 1); + rect.yMin = Math.max(0, rect.yMin - 1); + int newWidth = (int) (rect.getWidth() / SWF.unitDivisor); int newHeight = (int) (rect.getHeight() / SWF.unitDivisor); int deltaX = (int) (rect.xMin / SWF.unitDivisor); int deltaY = (int) (rect.yMin / SWF.unitDivisor); - newWidth = Math.min(image.getWidth() - deltaX, newWidth); - newHeight = Math.min(image.getHeight() - deltaY, newHeight); + newWidth = Math.min(image.getWidth() - deltaX, newWidth) + 2; + newHeight = Math.min(image.getHeight() - deltaY, newHeight) + 2; if (newWidth <= 0 || newHeight <= 0) { continue; @@ -2365,7 +2360,7 @@ public final class SWF implements TreeItem,Timelined { img = new SerializableImage(newWidth, newHeight, SerializableImage.TYPE_INT_ARGB); m.translate(-rect.xMin, -rect.yMin); drawMatrix.translate(rect.xMin, rect.yMin); - + //Make all pixels transparent Graphics2D gr = (Graphics2D) img.getGraphics(); gr.setComposite(AlphaComposite.Src); @@ -2374,7 +2369,7 @@ public final class SWF implements TreeItem,Timelined { drawable.toImage(dframe, layer.ratio, timeline.swf.tags, timeline.characters, visited, img, m, clrTrans); } else if (drawable instanceof FontTag) { // only DefineFont tags - FontTag fontTag = (FontTag) drawable; + FontTag fontTag = (FontTag) drawable; img = fontTag.toImage(dframe, layer.ratio, timeline.swf.tags, timeline.characters, visited, transformation, clrTrans); } else { throw new Error("Unsupported drawable."); @@ -2393,7 +2388,7 @@ public final class SWF implements TreeItem,Timelined { drawMatrix.translateX /= unzoom; drawMatrix.translateY /= unzoom; AffineTransform trans = drawMatrix.toTransform(); - + switch (layer.blendMode) { case 0: case 1: @@ -2459,7 +2454,7 @@ public final class SWF implements TreeItem,Timelined { prevClips.add(g.getClip()); g.setTransform(AffineTransform.getTranslateInstance(0, 0)); g.setClip(clip.shape); - } else { + } else { g.setTransform(trans); g.drawImage(img.getBufferedImage(), 0, 0, null); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/Action.java b/trunk/src/com/jpexs/decompiler/flash/action/Action.java index dfc749966..ffcf160bc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/Action.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/Action.java @@ -109,7 +109,7 @@ public class Action implements GraphSourceItem { public int actionLength; public long containerSWFOffset; private long address; - + public static final String[] reservedWords = { "as", "break", "case", "catch", "class", "const", "continue", "default", "delete", "do", "each", "else", "extends", "false", "finally", "for", "function", "get", "if", "implements", "import", "in", "instanceof", @@ -118,7 +118,7 @@ public class Action implements GraphSourceItem { "with", "dynamic", "default", "final", "in"}; public static boolean isReservedWord(String s) { - if(s == null){ + if (s == null) { return false; } for (String rw : reservedWords) { @@ -128,7 +128,7 @@ public class Action implements GraphSourceItem { } return false; } - + public long getFileAddress() { return containerSWFOffset + getAddress(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/ActionDeobfuscation.java b/trunk/src/com/jpexs/decompiler/flash/action/ActionDeobfuscation.java index 5f0e790b0..0772814f5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/ActionDeobfuscation.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/ActionDeobfuscation.java @@ -39,14 +39,11 @@ public class ActionDeobfuscation { public HashSet allVariableNamesStr = new HashSet<>(); private final HashMap typeCounts = new HashMap<>(); - public static final String VALID_FIRST_CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"; public static final String VALID_NEXT_CHARACTERS = VALID_FIRST_CHARACTERS + "0123456789"; public static final String FOO_CHARACTERS = "bcdfghjklmnpqrstvwz"; public static final String FOO_JOIN_CHARACTERS = "aeiouy"; - - private String fooString(HashMap deobfuscated, String orig, boolean firstUppercase, int rndSize) { boolean exists; String ret; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptLexer.java b/trunk/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptLexer.java index 719d87334..b909c3bdf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptLexer.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptLexer.java @@ -1333,6 +1333,7 @@ public final class ActionScriptLexer { /** * Closes the input stream. + * * @throws java.io.IOException */ public final void yyclose() throws java.io.IOException { @@ -1374,7 +1375,8 @@ public final class ActionScriptLexer { /** * Returns the current lexical state. - * @return + * + * @return */ public final int yystate() { return zzLexicalState; @@ -1391,7 +1393,8 @@ public final class ActionScriptLexer { /** * Returns the text matched by the current regular expression. - * @return + * + * @return */ public final String yytext() { return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead); @@ -1413,7 +1416,8 @@ public final class ActionScriptLexer { /** * Returns the length of the matched text region. - * @return + * + * @return */ public final int yylength() { return zzMarkedPos - zzStartRead; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptParser.java b/trunk/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptParser.java index 1b4fef0d4..f9e921f79 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptParser.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptParser.java @@ -1553,7 +1553,7 @@ public class ActionScriptParser { case FUNCTION: s = lexer.lex(); String fname = ""; - if (s.isType(SymbolType.IDENTIFIER,SymbolGroup.GLOBALFUNC)) { + if (s.isType(SymbolType.IDENTIFIER, SymbolGroup.GLOBALFUNC)) { fname = s.value.toString(); } else { lexer.pushback(s); diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java b/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java index 89de22f26..168aeb387 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/BitmapExporter.java @@ -43,6 +43,7 @@ import java.awt.Stroke; import java.awt.TexturePaint; import java.awt.geom.AffineTransform; import java.awt.geom.GeneralPath; +import java.awt.geom.NoninvertibleTransformException; import java.util.ArrayList; import java.util.List; @@ -373,7 +374,6 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter } protected void finalizePath() { - final int maxRepeat = 10; // TODO: better handle gradient repeating if (path != null) { if (fillPaint != null) { if (fillPaint instanceof MultipleGradientPaint) { @@ -383,21 +383,45 @@ public class BitmapExporter extends ShapeExporterBase implements IShapeExporter } graphics.fill(path); graphics.setClip(path); + Matrix inverse = null; + try { + inverse = new Matrix(new AffineTransform(fillTransform).createInverse()); + } catch (NoninvertibleTransformException ex) { + } + fillTransform.preConcatenate(oldAf); graphics.setTransform(fillTransform); - graphics.setPaint(fillPaint); - graphics.fill(new java.awt.Rectangle(-16384 * maxRepeat, -16384 * maxRepeat, 16384 * 2 * maxRepeat, 16384 * 2 * maxRepeat)); + + if (inverse != null) { + ExportRectangle rect = inverse.transform(new ExportRectangle(path.getBounds2D())); + double minX = rect.xMin; + double minY = rect.yMin; + graphics.fill(new java.awt.Rectangle((int) minX, (int) minY, (int) (rect.xMax - minX), (int) (rect.yMax - minY))); + } + graphics.setTransform(oldAf); graphics.setClip(null); } else if (fillPaint instanceof TexturePaint) { AffineTransform oldAf = graphics.getTransform(); graphics.setClip(path); + Matrix inverse = null; + try { + inverse = new Matrix(new AffineTransform(fillTransform).createInverse()); + } catch (NoninvertibleTransformException ex) { + } + fillTransform.preConcatenate(oldAf); graphics.setTransform(fillTransform); - graphics.setPaint(fillPaint); - graphics.fill(new java.awt.Rectangle(-16384 * maxRepeat, -16384 * maxRepeat, 16384 * 2 * maxRepeat, 16384 * 2 * maxRepeat)); + + if (inverse != null) { + ExportRectangle rect = inverse.transform(new ExportRectangle(path.getBounds2D())); + double minX = rect.xMin; + double minY = rect.yMin; + graphics.fill(new java.awt.Rectangle((int) minX, (int) minY, (int) (rect.xMax - minX), (int) (rect.yMax - minY))); + } + graphics.setTransform(oldAf); graphics.setClip(null); } else { diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/ExportRectangle.java b/trunk/src/com/jpexs/decompiler/flash/exporters/ExportRectangle.java index 6c1a979d3..a268a53e0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/ExportRectangle.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/ExportRectangle.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.exporters; import com.jpexs.decompiler.flash.types.RECT; +import java.awt.geom.Rectangle2D; /** * @@ -43,6 +44,13 @@ public class ExportRectangle { this.yMax = rect.Ymax; } + public ExportRectangle(Rectangle2D rect) { + this.xMin = rect.getMinX(); + this.yMin = rect.getMinY(); + this.xMax = rect.getMaxX(); + this.yMax = rect.getMaxY(); + } + public double getWidth() { return xMax - xMin; } diff --git a/trunk/src/com/jpexs/decompiler/flash/exporters/Matrix.java b/trunk/src/com/jpexs/decompiler/flash/exporters/Matrix.java index 7ec7e8c05..0f59c203a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/exporters/Matrix.java +++ b/trunk/src/com/jpexs/decompiler/flash/exporters/Matrix.java @@ -68,6 +68,18 @@ public class Matrix { } } + public Matrix(AffineTransform transform) { + this(); + if (transform != null) { + scaleX = transform.getScaleX(); + rotateSkew1 = transform.getShearX(); + translateX = transform.getTranslateX(); + rotateSkew0 = transform.getShearY(); + scaleY = transform.getScaleY(); + translateY = transform.getTranslateY(); + } + } + @Override public Matrix clone() { Matrix mat = new Matrix(); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index 34bd20a74..966d82b5e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -40,7 +40,6 @@ import java.util.Map; import java.util.Stack; import java.util.Timer; import java.util.TimerTask; -import java.util.concurrent.ExecutorService; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JColorChooser; @@ -63,11 +62,11 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis private SWF swf; private HashMap characters; private boolean loaded; - + @Override public void setBackground(Color bg) { if (label != null) { - label.setBackground(bg); + label.setBackground(bg); } super.setBackground(bg); } @@ -164,7 +163,7 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis setImage(img); } return; - } + } play(); } @@ -213,16 +212,16 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis drawFrame(); } } - - private static SerializableImage getFrame(SWF swf,int frame,DrawableTag drawable,Map characters){ + + private static SerializableImage getFrame(SWF swf, int frame, DrawableTag drawable, Map characters) { String key = "drawable_" + frame + "_" + drawable.hashCode(); SerializableImage img = SWF.getFromCache(key); if (img == null) { if (drawable instanceof BoundedTag) { BoundedTag bounded = (BoundedTag) drawable; RECT rect = bounded.getRect(characters, new Stack()); - if(rect == null){ //??? Why? - rect = new RECT(0,0,1,1); + if (rect == null) { //??? Why? + rect = new RECT(0, 0, 1, 1); } SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1, (int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB); @@ -244,15 +243,15 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis } return img; } - + private void drawFrame() { if (drawable == null) { return; } Matrix mat = new Matrix(); mat.translateX = swf.displayRect.Xmin; - mat.translateY = swf.displayRect.Ymin; - ImageIcon icon = new ImageIcon(getFrame(swf,frame,drawable,characters).getBufferedImage()); + mat.translateY = swf.displayRect.Ymin; + ImageIcon icon = new ImageIcon(getFrame(swf, frame, drawable, characters).getBufferedImage()); label.setIcon(icon); } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 80fe94e03..5d1f2ec27 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -892,10 +892,10 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec } public void load(SWFList newSwfs, boolean first) { - + swfPreviewPanel.stop(); imagePanel.stop(); - + swfs.add(newSwfs); for (SWF swf : newSwfs) { @@ -2467,13 +2467,13 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec int containerId = 0; RECT rect = swf.displayRect; int totalFrameCount = swf.frameCount; - Timeline timeline=swf.getTimeline(); + Timeline timeline = swf.getTimeline(); if (fn.getParent() instanceof DefineSpriteTag) { controlTags = ((DefineSpriteTag) fn.getParent()).subTags; containerId = ((DefineSpriteTag) fn.getParent()).spriteId; rect = ((DefineSpriteTag) fn.getParent()).getRect(swf.characters, new Stack()); totalFrameCount = ((DefineSpriteTag) fn.getParent()).frameCount; - timeline = ((DefineSpriteTag)fn.getParent()).getTimeline(); + timeline = ((DefineSpriteTag) fn.getParent()).getTimeline(); } previewImagePanel.setImage(SWF.frameToImageGet(timeline, fn.getFrame() - 1, rect, new Stack(), Matrix.getScaleInstance(1 / SWF.unitDivisor), new ColorTransform())); } else if (((tagObj instanceof FrameNodeItem) && ((FrameNodeItem) tagObj).isDisplayed()) || ((tagObj instanceof CharacterTag) || (tagObj instanceof FontTag)) && (tagObj instanceof Tag)) { @@ -2907,7 +2907,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec textValue.setText(textTag.getFormattedText()); textValue.setCaretPosition(0); } - + public void expandSwfNodes() { TreeModel model = tagTree.getModel(); Object node = model.getRoot(); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/SWFPreviewPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/SWFPreviewPanel.java index 31112d45f..e0efee73a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/SWFPreviewPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/SWFPreviewPanel.java @@ -113,7 +113,7 @@ public class SWFPreviewPanel extends JPanel implements FlashDisplay { } } } - + private void drawFrame() { pan.setImage(frameImages.get(frame)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java index c95c9985b..51e6ba0c0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java @@ -42,13 +42,11 @@ import com.jpexs.decompiler.flash.types.annotations.Reserved; import com.jpexs.decompiler.flash.types.annotations.SWFType; import com.jpexs.helpers.Cache; import com.jpexs.helpers.SerializableImage; -import java.awt.Color; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java index 66d3b1317..3437e4679 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java @@ -47,13 +47,11 @@ import com.jpexs.helpers.Cache; import com.jpexs.helpers.Helper; import com.jpexs.helpers.MemoryInputStream; import com.jpexs.helpers.SerializableImage; -import java.awt.Color; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java index 1e7088a7b..850c00ee1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java @@ -760,7 +760,7 @@ public class DefineEditTextTag extends TextTag { @Override public void toImage(int frame, int ratio, List tags, Map characters, Stack visited, SerializableImage image, Matrix transformation, ColorTransform colorTransform) { if (border) { - // todo: how to get the border and fill colors? + // border is always black, fill color is always white? RGB borderColor = new RGBA(Color.black); RGB fillColor = new RGBA(Color.white); drawBorder(swf, image, borderColor, fillColor, getRect(characters, visited), getTextMatrix(), transformation, colorTransform); @@ -853,7 +853,7 @@ public class DefineEditTextTag extends TextTag { lines.add(line); } } - + // remove spaces after last word for (List line : lines) { boolean removed = true; @@ -865,17 +865,17 @@ public class DefineEditTextTag extends TextTag { } if (line.size() > 0) { SameStyleTextRecord lastRecord = line.get(line.size() - 1); - while (lastRecord.glyphEntries.size() > 0 && - Character.isWhitespace(lastRecord.glyphEntries.get(lastRecord.glyphEntries.size() - 1).character)) { - lastRecord.glyphEntries.remove(lastRecord.glyphEntries.size() -1); + while (lastRecord.glyphEntries.size() > 0 + && Character.isWhitespace(lastRecord.glyphEntries.get(lastRecord.glyphEntries.size() - 1).character)) { + lastRecord.glyphEntries.remove(lastRecord.glyphEntries.size() - 1); removed = true; } } } } - + textModel.calculateTexWidths(); - + List allTextRecords = new ArrayList<>(); int yOffset = 0; for (List line : lines) { @@ -946,7 +946,7 @@ public class DefineEditTextTag extends TextTag { } return font; } - + @Override public Point getImagePos(int frame, Map characters, Stack visited) { return new Point(bounds.Xmin / SWF.unitDivisor, bounds.Ymin / SWF.unitDivisor); diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/TextTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/TextTag.java index 8a3cbb030..39b5179dc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/TextTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/TextTag.java @@ -251,7 +251,7 @@ public abstract class TextTag extends CharacterTag implements BoundedTag, Drawab shape.shapeRecords.add(new EndShapeRecord()); BitmapExporter.exportTo(swf, shape, null, image, mat, colorTransform); } - + public static void staticTextToImage(SWF swf, Map characters, List textRecords, int numText, SerializableImage image, MATRIX textMatrix, Matrix transformation, ColorTransform colorTransform) { Color textColor = new Color(0, 0, 0); FontTag font = null; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/CharacterWithStyle.java b/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/CharacterWithStyle.java index 5903962a7..1bca1b1e6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/CharacterWithStyle.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/CharacterWithStyle.java @@ -22,7 +22,7 @@ package com.jpexs.decompiler.flash.tags.dynamictext; * @author JPEXS */ public class CharacterWithStyle { - + public char character; public TextStyle style; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/DynamicTextModel.java b/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/DynamicTextModel.java index f74866881..9d6685197 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/DynamicTextModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/DynamicTextModel.java @@ -28,7 +28,7 @@ import java.util.List; public class DynamicTextModel { public List paragraphs = new ArrayList<>(); - + private Paragraph paragraph; public TextStyle style; public int width; @@ -36,18 +36,18 @@ public class DynamicTextModel { public DynamicTextModel() { } - + public void addGlyph(char character, GLYPHENTRY glyphEntry) { - + if (paragraph == null) { paragraph = new Paragraph(this); paragraphs.add(paragraph); } paragraph.addGlyph(character, glyphEntry); } - + public void newParagraph() { - + paragraph = null; } @@ -59,14 +59,14 @@ public class DynamicTextModel { } public void newRecord() { - + if (paragraph != null) { paragraph.newRecord(); } } - + public int calculateTexWidths() { - + int width = 0; for (Paragraph p : paragraphs) { width += p.calculateTexWidths(); diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/GlyphCharacter.java b/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/GlyphCharacter.java index 6eaa25ac5..89f7f32bb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/GlyphCharacter.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/GlyphCharacter.java @@ -26,11 +26,11 @@ import com.jpexs.decompiler.flash.types.GLYPHENTRY; public class GlyphCharacter { public GLYPHENTRY glyphEntry; - + public char character; - + public GlyphCharacter(char character, GLYPHENTRY glyphEntry) { - + this.character = character; this.glyphEntry = glyphEntry; } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/Paragraph.java b/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/Paragraph.java index 49615a774..b685084ca 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/Paragraph.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/Paragraph.java @@ -26,7 +26,7 @@ import java.util.List; * @author JPEXS */ public class Paragraph { - + public List words = new ArrayList<>(); private Word word; @@ -39,7 +39,7 @@ public class Paragraph { } public void addGlyph(char character, GLYPHENTRY glyphEntry) { - + if (word == null) { word = new Word(model); words.add(word); @@ -53,14 +53,14 @@ public class Paragraph { } public void newRecord() { - + if (word != null) { word.newRecord(); } } public int calculateTexWidths() { - + int width = 0; for (Word w : words) { width += w.calculateTexWidths(); diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/SameStyleTextRecord.java b/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/SameStyleTextRecord.java index 5a03e15ad..4cb21caae 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/SameStyleTextRecord.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/SameStyleTextRecord.java @@ -25,7 +25,7 @@ import java.util.List; * @author JPEXS */ public class SameStyleTextRecord { - + public TextStyle style; public int xOffset; @@ -35,7 +35,7 @@ public class SameStyleTextRecord { public List glyphEntries = new ArrayList<>(); public int calculateTexWidths() { - + int width = 0; for (GlyphCharacter gc : glyphEntries) { width += gc.glyphEntry.glyphAdvance; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/TextStyle.java b/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/TextStyle.java index 888161a3a..4af976492 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/TextStyle.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/TextStyle.java @@ -25,9 +25,9 @@ import com.jpexs.decompiler.flash.types.RGBA; * @author JPEXS */ public class TextStyle { - + public FontTag font; - + public int fontHeight; public int fontLeading; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/Word.java b/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/Word.java index a21ddbf2e..fb14ca240 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/Word.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/dynamictext/Word.java @@ -26,9 +26,9 @@ import java.util.List; * @author JPEXS */ public class Word { - + public List records = new ArrayList<>(); - + private SameStyleTextRecord record; private final DynamicTextModel model; public int width; @@ -36,9 +36,9 @@ public class Word { public Word(DynamicTextModel model) { this.model = model; } - + public void addGlyph(char character, GLYPHENTRY glyphEntry) { - + if (record == null) { record = new SameStyleTextRecord(); record.style = model.style; @@ -48,12 +48,12 @@ public class Word { } public void newRecord() { - + record = null; } public int calculateTexWidths() { - + int width = 0; for (SameStyleTextRecord r : records) { width += r.calculateTexWidths(); diff --git a/trunk/src/com/jpexs/decompiler/flash/timeline/DepthState.java b/trunk/src/com/jpexs/decompiler/flash/timeline/DepthState.java index 0a58adadb..f3d8a03f0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/timeline/DepthState.java +++ b/trunk/src/com/jpexs/decompiler/flash/timeline/DepthState.java @@ -62,6 +62,6 @@ public class DepthState { clipActions = obj.clipActions; ratio = obj.ratio; clipDepth = obj.clipDepth; - time = obj.time+1; + time = obj.time + 1; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/timeline/Frame.java b/trunk/src/com/jpexs/decompiler/flash/timeline/Frame.java index 286a8b897..3c97ffa43 100644 --- a/trunk/src/com/jpexs/decompiler/flash/timeline/Frame.java +++ b/trunk/src/com/jpexs/decompiler/flash/timeline/Frame.java @@ -30,7 +30,7 @@ public class Frame { public Map layers = new HashMap<>(); public DoActionTag action; - public RGB backgroundColor = new RGBA(0,0,0,0); + public RGB backgroundColor = new RGBA(0, 0, 0, 0); public Frame() { diff --git a/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline.java b/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline.java index 03821b4ce..4b79c2af7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline.java +++ b/trunk/src/com/jpexs/decompiler/flash/timeline/Timeline.java @@ -41,7 +41,7 @@ public class Timeline { public List frames = new ArrayList<>(); public int id; - public Map characters = new HashMap<>(); + public Map characters = new HashMap<>(); public SWF swf; public Timeline() { @@ -63,23 +63,23 @@ public class Timeline { return frames.size(); } - public Timeline(SWF swf){ - this(swf,swf.tags,0); + public Timeline(SWF swf) { + this(swf, swf.tags, 0); } - - public Timeline(SWF swf,List tags,int id) { - this.id =id; + + public Timeline(SWF swf, List tags, int id) { + this.id = id; this.swf = swf; Frame frame = new Frame(); for (Tag t : swf.tags) { - if(t instanceof CharacterTag){ - CharacterTag c=(CharacterTag)t; + if (t instanceof CharacterTag) { + CharacterTag c = (CharacterTag) t; characters.put(c.getCharacterId(), c); } } for (Tag t : tags) { - if(t instanceof SetBackgroundColorTag){ - frame.backgroundColor = ((SetBackgroundColorTag)t).backgroundColor; + if (t instanceof SetBackgroundColorTag) { + frame.backgroundColor = ((SetBackgroundColorTag) t).backgroundColor; } if (t instanceof PlaceObjectTypeTag) { PlaceObjectTypeTag po = (PlaceObjectTypeTag) t; @@ -126,7 +126,7 @@ public class Timeline { fl.ratio = ratio2; } int clipDepth2 = po.getClipDepth(); - if(clipDepth2>-1){ + if (clipDepth2 > -1) { fl.clipDepth = clipDepth2; } } else { diff --git a/trunk/src/com/jpexs/decompiler/flash/timeline/Timelined.java b/trunk/src/com/jpexs/decompiler/flash/timeline/Timelined.java index c37772d4d..be3e4e3d4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/timeline/Timelined.java +++ b/trunk/src/com/jpexs/decompiler/flash/timeline/Timelined.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.decompiler.flash.timeline; /** @@ -22,5 +21,6 @@ package com.jpexs.decompiler.flash.timeline; * @author JPEXS */ public interface Timelined { + public Timeline getTimeline(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java b/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java index d78846e27..bf60d89bf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java @@ -96,13 +96,13 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem, S private long hdrPos; //Constructor for Generic tag editor. TODO:Handle this somehow better - public CLIPACTIONRECORD(){ + public CLIPACTIONRECORD() { swf = null; eventFlags = new CLIPEVENTFLAGS(); actionBytes = new byte[0]; hdrPos = 0; } - + public CLIPACTIONRECORD(SWF swf, InputStream is, long pos) throws IOException { this.swf = swf; SWFInputStream sis = new SWFInputStream(is, swf.version); diff --git a/trunk/src/com/jpexs/decompiler/flash/types/filters/BEVELFILTER.java b/trunk/src/com/jpexs/decompiler/flash/types/filters/BEVELFILTER.java index 6b884dbc7..9481a2c43 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/filters/BEVELFILTER.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/filters/BEVELFILTER.java @@ -106,7 +106,7 @@ public class BEVELFILTER extends FILTER { public double getDeltaX() { return blurX; } - + @Override public double getDeltaY() { return blurY; diff --git a/trunk/src/com/jpexs/decompiler/flash/types/filters/BLURFILTER.java b/trunk/src/com/jpexs/decompiler/flash/types/filters/BLURFILTER.java index 835c1c7cc..f70940553 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/filters/BLURFILTER.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/filters/BLURFILTER.java @@ -60,7 +60,7 @@ public class BLURFILTER extends FILTER { public double getDeltaX() { return blurX; } - + @Override public double getDeltaY() { return blurY; diff --git a/trunk/src/com/jpexs/decompiler/flash/types/filters/COLORMATRIXFILTER.java b/trunk/src/com/jpexs/decompiler/flash/types/filters/COLORMATRIXFILTER.java index aa7dbc667..e36321c20 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/filters/COLORMATRIXFILTER.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/filters/COLORMATRIXFILTER.java @@ -56,7 +56,7 @@ public class COLORMATRIXFILTER extends FILTER { public double getDeltaX() { return 0; } - + @Override public double getDeltaY() { return 0; diff --git a/trunk/src/com/jpexs/decompiler/flash/types/filters/CONVOLUTIONFILTER.java b/trunk/src/com/jpexs/decompiler/flash/types/filters/CONVOLUTIONFILTER.java index 1dbe797b8..ab6a3e994 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/filters/CONVOLUTIONFILTER.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/filters/CONVOLUTIONFILTER.java @@ -94,7 +94,7 @@ public class CONVOLUTIONFILTER extends FILTER { public double getDeltaX() { return 0; } - + @Override public double getDeltaY() { return 0; diff --git a/trunk/src/com/jpexs/decompiler/flash/types/filters/DROPSHADOWFILTER.java b/trunk/src/com/jpexs/decompiler/flash/types/filters/DROPSHADOWFILTER.java index 629963692..8bc404588 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/filters/DROPSHADOWFILTER.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/filters/DROPSHADOWFILTER.java @@ -91,7 +91,7 @@ public class DROPSHADOWFILTER extends FILTER { public double getDeltaX() { return blurX; } - + @Override public double getDeltaY() { return blurY; diff --git a/trunk/src/com/jpexs/decompiler/flash/types/filters/FILTER.java b/trunk/src/com/jpexs/decompiler/flash/types/filters/FILTER.java index c8903089b..0ffc0ff7c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/filters/FILTER.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/filters/FILTER.java @@ -44,7 +44,7 @@ public abstract class FILTER implements Serializable { } public abstract SerializableImage apply(SerializableImage src); - + public abstract double getDeltaX(); public abstract double getDeltaY(); diff --git a/trunk/src/com/jpexs/decompiler/flash/types/filters/Filtering.java b/trunk/src/com/jpexs/decompiler/flash/types/filters/Filtering.java index da8547230..2df9830ee 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/filters/Filtering.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/filters/Filtering.java @@ -250,7 +250,7 @@ public class Filtering { public static SerializableImage gradientBevel(SerializableImage src, Color[] colors, float[] ratios, int blurX, int blurY, float strength, int type, float angle, float distance, boolean knockout, int iterations) { return new SerializableImage(gradientBevel(src.getBufferedImage(), colors, ratios, blurX, blurY, strength, type, angle, distance, knockout, iterations)); } - + private static BufferedImage gradientBevel(BufferedImage src, Color[] colors, float[] ratios, int blurX, int blurY, float strength, int type, float angle, float distance, boolean knockout, int iterations) { int width = src.getWidth(); int height = src.getHeight(); @@ -332,7 +332,7 @@ public class Filtering { public static SerializableImage gradientGlow(SerializableImage src, int blurX, int blurY, float angle, double distance, Color[] colors, float[] ratios, int type, int iterations, float strength, boolean knockout) { return new SerializableImage(gradientGlow(src.getBufferedImage(), blurX, blurY, angle, distance, colors, ratios, type, iterations, strength, knockout)); } - + private static BufferedImage gradientGlow(BufferedImage src, int blurX, int blurY, float angle, double distance, Color[] colors, float[] ratios, int type, int iterations, float strength, boolean knockout) { int width = src.getWidth(); int height = src.getHeight(); diff --git a/trunk/src/com/jpexs/decompiler/flash/types/filters/GLOWFILTER.java b/trunk/src/com/jpexs/decompiler/flash/types/filters/GLOWFILTER.java index 76e718e60..a624bffed 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/filters/GLOWFILTER.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/filters/GLOWFILTER.java @@ -81,7 +81,7 @@ public class GLOWFILTER extends FILTER { public double getDeltaX() { return blurX; } - + @Override public double getDeltaY() { return blurY; diff --git a/trunk/src/com/jpexs/decompiler/flash/types/filters/GRADIENTBEVELFILTER.java b/trunk/src/com/jpexs/decompiler/flash/types/filters/GRADIENTBEVELFILTER.java index 80705b128..603f4d6f4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/filters/GRADIENTBEVELFILTER.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/filters/GRADIENTBEVELFILTER.java @@ -122,7 +122,7 @@ public class GRADIENTBEVELFILTER extends FILTER { public double getDeltaX() { return blurX; } - + @Override public double getDeltaY() { return blurY; diff --git a/trunk/src/com/jpexs/decompiler/flash/types/filters/GRADIENTGLOWFILTER.java b/trunk/src/com/jpexs/decompiler/flash/types/filters/GRADIENTGLOWFILTER.java index 3b82e4465..97120f71c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/filters/GRADIENTGLOWFILTER.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/filters/GRADIENTGLOWFILTER.java @@ -124,7 +124,7 @@ public class GRADIENTGLOWFILTER extends FILTER { public double getDeltaX() { return blurX; } - + @Override public double getDeltaY() { return blurY;