small fixes, cleanup

This commit is contained in:
2014-09-01 21:06:01 +02:00
parent ed53ba9d0f
commit 278b9256d2
19 changed files with 954 additions and 940 deletions
File diff suppressed because it is too large Load Diff
+102 -103
View File
@@ -1,103 +1,102 @@
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.gui;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.LayoutManager;
/**
*
* @author JPEXS
*/
public class ListLayout implements LayoutManager {
private int border;
public ListLayout() {
this(5);
}
public ListLayout(int border) {
this.border = border;
}
@Override
public void addLayoutComponent(String name, Component comp) {
}
@Override
public void removeLayoutComponent(Component comp) {
}
@Override
public Dimension preferredLayoutSize(Container parent) {
int h = 0;
int maxw = 0;
Insets ins = parent.getInsets();
boolean first = true;
for (Component c : parent.getComponents()) {
if (!c.isVisible()) {
continue;
}
if (true) { //!first) {
h += border;
}
Dimension pref = c.getPreferredSize();
if (pref.width > maxw) {
maxw = pref.width;
}
h += pref.height;
first = false;
}
h += border;
maxw = (parent.getSize().width == 0 ? maxw : parent.getSize().width) - ins.left - ins.right;
return new Dimension(maxw, h);
}
@Override
public Dimension minimumLayoutSize(Container parent) {
return preferredLayoutSize(parent);
}
@Override
public void layoutContainer(Container parent) {
Dimension dim = preferredLayoutSize(parent);
int top = 0;
Insets ins = parent.getInsets();
top = ins.top;
boolean first = true;
for (Component c : parent.getComponents()) {
if (!c.isVisible()) {
continue;
}
if (!first) {
top += border;
}
Dimension pref = c.getPreferredSize();
c.setPreferredSize(new Dimension(dim.width, pref.height));
c.setMinimumSize(new Dimension(dim.width, pref.height));
c.setBounds(0, top, dim.width, pref.height);
top += pref.height;
first = false;
}
}
}
/*
* Copyright (C) 2010-2014 JPEXS
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.gui;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.LayoutManager;
/**
*
* @author JPEXS
*/
public class ListLayout implements LayoutManager {
private int border;
public ListLayout() {
this(5);
}
public ListLayout(int border) {
this.border = border;
}
@Override
public void addLayoutComponent(String name, Component comp) {
}
@Override
public void removeLayoutComponent(Component comp) {
}
@Override
public Dimension preferredLayoutSize(Container parent) {
int h = 0;
int maxw = 0;
Insets ins = parent.getInsets();
boolean first = true;
for (Component c : parent.getComponents()) {
if (!c.isVisible()) {
continue;
}
if (true) { //!first) {
h += border;
}
Dimension pref = c.getPreferredSize();
if (pref.width > maxw) {
maxw = pref.width;
}
h += pref.height;
first = false;
}
h += border;
maxw = (parent.getSize().width == 0 ? maxw : parent.getSize().width) - ins.left - ins.right;
return new Dimension(maxw, h);
}
@Override
public Dimension minimumLayoutSize(Container parent) {
return preferredLayoutSize(parent);
}
@Override
public void layoutContainer(Container parent) {
Dimension dim = preferredLayoutSize(parent);
Insets ins = parent.getInsets();
int top = ins.top;
boolean first = true;
for (Component c : parent.getComponents()) {
if (!c.isVisible()) {
continue;
}
if (!first) {
top += border;
}
Dimension pref = c.getPreferredSize();
c.setPreferredSize(new Dimension(dim.width, pref.height));
c.setMinimumSize(new Dimension(dim.width, pref.height));
c.setBounds(0, top, dim.width, pref.height);
top += pref.height;
first = false;
}
}
}
@@ -93,8 +93,7 @@ public class LoadingPanel extends JPanel {
lastSize = size;
drawTimer = new Timer();
int timeSpin = 1000;
double delay = 0;
delay = timeSpin / o;
double delay = timeSpin / o;
while (delay < 10) {
o--;
delay = timeSpin / o;
+1 -1
View File
@@ -329,7 +329,7 @@ public class Main {
if (mode == SaveFileMode.EXE) {
InputStream exeStream = View.class.getClassLoader().getResourceAsStream("com/jpexs/helpers/resource/Swf2Exe.bin");
byte[] buffer = new byte[4096];
int bytesRead = 0;
int bytesRead;
while ((bytesRead = exeStream.read(buffer)) != -1) {
fos.write(buffer, 0, bytesRead);
}
@@ -1255,7 +1255,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
SearchPanel<TextTag> textSearchPanel = previewPanel.getTextPanel().getSearchPanel();
textSearchPanel.setOptions(ignoreCase, regexp);
List<TextTag> found = new ArrayList<>();
Pattern pat = null;
Pattern pat;
if (regexp) {
pat = Pattern.compile(txt, ignoreCase ? Pattern.CASE_INSENSITIVE : 0);
} else {
@@ -1379,7 +1379,6 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
List<FileFilter> flaFilters = new ArrayList<>();
List<FileFilter> xflFilters = new ArrayList<>();
List<FLAVersion> versions = new ArrayList<>();
FileFilter defaultFilter = null;
for (int i = FLAVersion.values().length - 1; i >= 0; i--) {
final FLAVersion v = FLAVersion.values()[i];
if (!swf.isAS3 && v.minASVersion() > 2) {
@@ -1398,7 +1397,6 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
}
};
if (v == FLAVersion.CS6) {
defaultFilter = f;
fc.setFileFilter(f);
} else {
fc.addChoosableFileFilter(f);
@@ -1419,9 +1417,6 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
xflFilters.add(f);
}
}
if (defaultFilter == null) {
defaultFilter = flaFilters.get(0);
}
fc.setAcceptAllFileFilterUsed(false);
JFrame f = new JFrame();
@@ -2302,7 +2297,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
final Tag tag = (Tag) tagObj;
showCard(CARDPREVIEWPANEL);
DrawableTag d = (DrawableTag) tag;
Timelined timelined = null;
Timelined timelined;
if (tagObj instanceof Timelined && !(tagObj instanceof ButtonTag)) {
timelined = (Timelined) tag;
} else {
@@ -169,7 +169,6 @@ public class PreviewImage extends JPanel {
private Image renderImage(SWF swf, TreeItem treeItem) {
double scale = 1;
int width = 0;
int height = 0;
SerializableImage imgSrc = null;
@@ -206,7 +205,7 @@ public class PreviewImage extends JPanel {
w = w2;
}
scale = (double) w / (double) w1;
double scale = (double) w / (double) w1;
if (w1 <= w2 && h1 <= h2) {
scale = 1;
}
@@ -131,7 +131,7 @@ public class SoundTagPlayer implements MediaDisplay {
public void run() {
boolean playAgain = true;
while (playAgain) {
int startPos = 0;
int startPos;
synchronized (playLock) {
startPos = actualPos * FRAME_DIVISOR;
}
@@ -759,7 +759,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
View.navigateUrl(adobePage);
int ret = 0;
int ret;
do {
ret = View.showConfirmDialog(this, AppStrings.translate("message.action.playerglobal.place").replace("%libpath%", Configuration.getFlashLibPath().getAbsolutePath()), AppStrings.translate("message.action.playerglobal.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE);
swc = Configuration.getPlayerSWC();
@@ -459,7 +459,6 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
public void cacheScriptPack(ScriptPack scriptLeaf, List<ABCContainerTag> abcList) throws InterruptedException {
int maxCacheSize = 50;
int scriptIndex = scriptLeaf.scriptIndex;
HilightedText hilightedCode = null;
ScriptInfo script = null;
ABC abc = scriptLeaf.abc;
if (scriptIndex > -1) {
@@ -469,7 +468,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
boolean parallel = Configuration.parallelSpeedUp.get();
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true);
scriptLeaf.toSource(writer, abcList, script.traits.traits, ScriptExportMode.AS, parallel);
hilightedCode = new HilightedText(writer);
HilightedText hilightedCode = new HilightedText(writer);
cache.put(scriptLeaf, new CachedDecompilation(hilightedCode));
}
}
@@ -200,33 +200,13 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene
}
}
private void getASMs(String path, List<TreeNode> nodes, Map<String, ASMSource> result) {
for (TreeNode n : nodes) {
String subPath = path + "/" + n.toString();
if (n.getItem() instanceof ASMSource) {
//cacheScript((ASMSource) n.tag);
String npath = subPath;
int ppos = 1;
while (result.containsKey(npath)) {
ppos++;
npath = subPath + "[" + ppos + "]";
}
result.put(npath, (ASMSource) n.getItem());
}
getASMs(subPath, n.subNodes, result);
}
}
public boolean search(final String txt, boolean ignoreCase, boolean regexp) {
if ((txt != null) && (!txt.isEmpty())) {
searchPanel.setOptions(ignoreCase, regexp);
SWF swf = mainPanel.getCurrentSwf();
List<TreeNode> list = SWF.createASTagList(swf.tags, swf);
Map<String, ASMSource> asms = new HashMap<>();
getASMs("", list, asms);
Map<String, ASMSource> asms = swf.getASMs();
final List<ActionSearchResult> found = new ArrayList<>();
Pattern pat = null;
Pattern pat;
if (regexp) {
pat = Pattern.compile(txt, ignoreCase ? Pattern.CASE_INSENSITIVE : 0);
} else {