format code: blank lines

This commit is contained in:
2015-01-18 21:32:37 +01:00
parent 6ffcca82e7
commit ade56d45a2
640 changed files with 12702 additions and 3882 deletions
@@ -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.helpers;
import java.awt.Component;
@@ -30,30 +31,51 @@ public class BMPFile extends Component {
//--- Private constants
private final static int BITMAPFILEHEADER_SIZE = 14;
private final static int BITMAPINFOHEADER_SIZE = 40;
//--- Private variable declaration
//--- Bitmap file header
private final byte bitmapFileHeader[] = new byte[14];
private final byte bfType[] = {'B', 'M'};
private int bfSize = 0;
private final int bfReserved1 = 0;
private final int bfReserved2 = 0;
private final int bfOffBits = BITMAPFILEHEADER_SIZE + BITMAPINFOHEADER_SIZE;
//--- Bitmap info header
private final byte bitmapInfoHeader[] = new byte[40];
private final int biSize = BITMAPINFOHEADER_SIZE;
private int biWidth = 0;
private int biHeight = 0;
private final int biPlanes = 1;
private final int biBitCount = 24;
private final int biCompression = 0;
private int biSizeImage = 0x030000;
private final int biXPelsPerMeter = 0x0;
private final int biYPelsPerMeter = 0x0;
private final int biClrUsed = 0;
private final int biClrImportant = 0;
//--- Bitmap raw data
private int bitmap[];
//--- File section
private FileOutputStream fo;
@@ -78,7 +100,7 @@ public class BMPFile extends Component {
* The saveMethod is the main method of the process. This method
* will call the convertImage method to convert the memory image to
* a byte array; method writeBitmapFileHeader creates and writes
* the bitmap file header; writeBitmapInfoHeader creates the
* the bitmap file header; writeBitmapInfoHeader creates the
* information header; and writeBitmap writes the image.
*
*/
@@ -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.helpers;
/**
@@ -22,31 +23,51 @@ package com.jpexs.decompiler.flash.helpers;
public class CodeFormatting {
public String newLineChars = "\r\n";
public String indentString = " ";
public boolean beginBlockOnNewLine = true;
// spaces
// before parentheses
public boolean spaceBeforeParenthesesMethodCallParentheses = false;
public boolean spaceBeforeParenthesesMethodCallEmptyParentheses = false;
public boolean spaceBeforeArrayAccessBrackets = false;
public boolean spaceBeforeParenthesesMethodDeclarationParentheses = false;
public boolean spaceBeforeParenthesesMethodDeclarationEmptyParentheses = false;
public boolean spaceBeforeParenthesesIfParentheses = false;
public boolean spaceBeforeParenthesesWithParentheses = false;
public boolean spaceBeforeParenthesesWhileParentheses = false;
public boolean spaceBeforeParenthesesCatchParentheses = false;
public boolean spaceBeforeParenthesesSwitchParentheses = false;
public boolean spaceBeforeParenthesesForParentheses = false;
public boolean spaceBeforeParenthesesForEachParentheses = false;
// around operators
public boolean spaceAroundOperatorsAssignmentOperators = false; // =, +=,...
public boolean spaceAroundOperatorsLogicalOperators = false; // &&, ||
public boolean spaceAroundOperatorsEqualityOperators = false; // ==, !=
public boolean spaceAroundOperatorsRelationalOperator = false; // <, >, <=, >=
public boolean spaceAroundOperatorsBitwiseOperator = false; // &, |, ^
public boolean spaceAroundOperatorsAdditiveOperator = false; // +, -
public boolean spaceAroundOperatorsMultiplicativeOperator = false; // *, /, %
public boolean spaceAroundOperatorsShiftOperator = false; // <<, >>
}
@@ -1,16 +1,16 @@
/*
* 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.
*/
@@ -34,8 +34,11 @@ import java.util.logging.Logger;
public class FileTextWriter extends GraphTextWriter implements AutoCloseable {
private final Writer writer;
private boolean newLine = true;
private int indent;
private int writtenBytes;
public FileTextWriter(CodeFormatting formatting, FileOutputStream fos) {
@@ -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.helpers;
import java.awt.Font;
@@ -82,14 +83,14 @@ public class FontHelper {
fonts = (Font[]) clFm.getDeclaredMethod("getAllInstalledFonts").invoke(fm);
} catch (Throwable ex) {
// ignore
// ignore
}
if (fonts == null) {
fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
}
List<String> javaFonts = Arrays.asList("Dialog", "DialogInput", "Monospaced", "Serif", "SansSerif");
List<String> javaFonts = Arrays.asList("Dialog", "DialogInput", "Monospaced", "Serif", "SansSerif");
for (Font f : fonts) {
String fam = f.getFamily(Locale.ENGLISH);
//Do not want Java logical fonts
@@ -102,7 +103,7 @@ public class FontHelper {
ret.get(fam).put(f.getFontName(Locale.ENGLISH), f);
}
return ret;
}
@@ -216,7 +217,9 @@ public class FontHelper {
public static class KerningPair {
public char char1;
public char char2;
public int kerning;
public KerningPair(char char1, char char2, int kerning) {
@@ -259,7 +262,6 @@ public class FontHelper {
public String toString() {
return "'" + char1 + "','" + char2 + "' => " + kerning;
}
}
private static Object getFont2d(Font f) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
@@ -295,11 +297,17 @@ public class FontHelper {
private static class KerningLoader {
private int size = -1;
private float scale;
private long bytePosition;
private long headOffset = -1;
private long kernOffset = -1;
private Font font;
private Map<Integer, Character> charmap;
public List<KerningPair> loadFromTTF(File file, int size) throws IOException, FontFormatException {
@@ -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.helpers;
import com.jpexs.decompiler.flash.helpers.hilight.HighlightData;
@@ -26,7 +27,8 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
public class GraphSourceItemPosition {
public GraphSourceItem graphSourceItem;
public int position;
public HighlightData data;
public int position;
public HighlightData data;
}
@@ -1,16 +1,16 @@
/*
* 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.
*/
@@ -28,7 +28,9 @@ import com.jpexs.decompiler.graph.GraphSourceItem;
public abstract class GraphTextWriter {
protected long startTime;
protected long suspendTime;
protected CodeFormatting formatting;
public CodeFormatting getFormatting() {
@@ -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.helpers;
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
@@ -28,10 +29,15 @@ import java.util.List;
public class HighlightedText implements Serializable {
public String text;
public List<Highlighting> traitHilights;
public List<Highlighting> classHilights;
public List<Highlighting> methodHilights;
public List<Highlighting> instructionHilights;
public List<Highlighting> specialHilights;
public List<Highlighting> getTraitHighlights() {
@@ -1,16 +1,16 @@
/*
* 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.
*/
@@ -35,18 +35,29 @@ import java.util.Stack;
public class HighlightedTextWriter extends GraphTextWriter {
private final StringBuilder sb = new StringBuilder();
private final boolean hilight;
private boolean newLine = true;
private int indent = 0;
private final Stack<GraphSourceItemPosition> offsets = new Stack<>();
private boolean toStringCalled = false;
private int newLineCount = 0;
private final Stack<Highlighting> hilightStack = new Stack<>();
public List<Highlighting> traitHilights = new ArrayList<>();
public List<Highlighting> classHilights = new ArrayList<>();
public List<Highlighting> methodHilights = new ArrayList<>();
public List<Highlighting> instructionHilights = new ArrayList<>();
public List<Highlighting> specialHilights = new ArrayList<>();
public HighlightedTextWriter(CodeFormatting formatting, boolean hilight) {
@@ -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.helpers;
import java.awt.image.BufferedImage;
@@ -42,7 +43,7 @@ public class ImageHelper {
newImage.getRaster().setDataElements(0, 0, width, height, imgData);
return newImage;
}
return 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.helpers;
/**
@@ -23,10 +24,12 @@ package com.jpexs.decompiler.flash.helpers;
public class LoopWithType {
public static int LOOP_TYPE_LOOP = 0;
public static int LOOP_TYPE_SWITCH = 1;
public long loopId;
public int type;
public boolean used;
public int type;
public boolean used;
}
@@ -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.helpers;
import com.jpexs.decompiler.flash.helpers.hilight.HighlightData;
@@ -27,7 +28,9 @@ import java.util.Stack;
public class NulWriter extends GraphTextWriter {
private final Stack<LoopWithType> loopStack = new Stack<>();
private final Stack<Boolean> stringAddedStack = new Stack<>();
private boolean stringAdded = false;
public NulWriter() {
@@ -1,18 +1,19 @@
/*
* Copyright (C) 2010-2015 JPEXS, Miron Sadziak, 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.helpers;
import com.jpexs.decompiler.flash.SWF;
@@ -38,6 +39,7 @@ import javax.tools.ToolProvider;
public class SWFDecompilerPlugin {
private static final Logger logger = Logger.getLogger(SWFDecompilerPlugin.class.getName());
private static final List<SWFDecompilerListener> listeners = new ArrayList<>();
public static void loadPlugin(String path) {
@@ -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.helpers.collections;
import java.util.Map.Entry;
@@ -27,6 +28,7 @@ import java.util.Objects;
public class MyEntry<K, V> implements Entry<K, V> {
private final K key;
private V value;
public MyEntry(K key, V value) {
@@ -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.helpers.hilight;
/**
@@ -22,5 +23,4 @@ package com.jpexs.decompiler.flash.helpers.hilight;
public enum HighlightType {
TRAIT, CLASS, METHOD, OFFSET, SPECIAL
}
@@ -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.helpers.hilight;
import com.jpexs.decompiler.flash.configuration.Configuration;
@@ -28,15 +29,19 @@ import java.util.List;
public class Highlighting implements Serializable {
public HighlightType type;
public String HighlightedText;
/**
* Starting position
*/
public int startPos;
/**
* Length of highlighted text
*/
public int len;
private final HighlightData properties;
public HighlightData getProperties() {