From d28965490a310da60f66fb0538b78c04d6526666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Sun, 3 Mar 2013 12:42:53 +0100 Subject: [PATCH] better graph display --- .../src/com/jpexs/decompiler/flash/Main.java | 2 + .../flash/abc/gui/ASMSourceEditorPane.java | 14 +- .../flash/abc/gui/DecompiledEditorPane.java | 33 +- .../decompiler/flash/abc/gui/GraphFrame.java | 132 -------- .../flash/abc/gui/MethodCodePanel.java | 9 +- .../flash/action/gui/ActionPanel.java | 2 +- .../decompiler/flash/gui/GraphFrame.java | 298 ++++++++++++++++++ .../flash/{abc => }/gui/GraphTreeFrame.java | 2 +- .../jpexs/decompiler/flash/gui/MainFrame.java | 4 +- 9 files changed, 350 insertions(+), 146 deletions(-) delete mode 100644 trunk/src/com/jpexs/decompiler/flash/abc/gui/GraphFrame.java create mode 100644 trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java rename trunk/src/com/jpexs/decompiler/flash/{abc => }/gui/GraphTreeFrame.java (94%) diff --git a/trunk/src/com/jpexs/decompiler/flash/Main.java b/trunk/src/com/jpexs/decompiler/flash/Main.java index abaeca90c..706e0d053 100644 --- a/trunk/src/com/jpexs/decompiler/flash/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/Main.java @@ -80,6 +80,8 @@ public class Main { public static boolean isCommandLineMode() { return commandLineMode; } + + public static final boolean DISPLAY_FILENAME=true; public static boolean DEBUG_COPY = false; /** * Debug mode = throwing an error when comparing original file and recompiled diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ASMSourceEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ASMSourceEditorPane.java index a33fdc303..5aa57ff1d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ASMSourceEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ASMSourceEditorPane.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.abc.gui; +import com.jpexs.decompiler.flash.gui.GraphFrame; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; @@ -41,7 +42,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi private List disassembledHilights = new ArrayList(); private DecompiledEditorPane decompiledEditor; private boolean ignoreCarret = false; - + private String name; public void setIgnoreCarret(boolean ignoreCarret) { this.ignoreCarret = ignoreCarret; } @@ -66,15 +67,22 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi } } - public void setBodyIndex(int bodyIndex, ABC abc) { + @Override + public String getName() { + return super.getName(); + } + + + public void setBodyIndex(int bodyIndex, ABC abc,String name) { this.bodyIndex = bodyIndex; this.abc = abc; + this.name=name; setText(abc.bodies[bodyIndex].code.toASMSource(abc.constants, abc.bodies[bodyIndex])); } public void graph() { AVM2Graph gr = new AVM2Graph(abc.bodies[bodyIndex].code, abc, abc.bodies[bodyIndex], false, 0, new HashMap(), new Stack(), new HashMap(), new ArrayList()); - (new GraphFrame(gr, "")).setVisible(true); + (new GraphFrame(gr, name)).setVisible(true); } public void exec() { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java index 2bd81adc7..234f36970 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java @@ -72,7 +72,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL this.classIndex = classIndex; } - private boolean displayMethod(int pos, int methodIndex) { + private boolean displayMethod(int pos, int methodIndex, String name) { if (abc == null) { return false; } @@ -82,7 +82,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL } abcPanel.detailPanel.showCard(DetailPanel.METHOD_TRAIT_CARD); if (reset || (abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getBodyIndex() != bi)) { - abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setBodyIndex(bi, abc); + abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setBodyIndex(bi, abc, name); abcPanel.detailPanel.methodTraitPanel.methodBodyParamsPanel.loadFromBody(abc.bodies[bi]); abcPanel.detailPanel.methodTraitPanel.methodInfoPanel.load(abc.bodies[bi].method_info, abc); abcPanel.detailPanel.setEditMode(false); @@ -134,14 +134,26 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL for (Highlighting tm : methodHighlights) { if ((pos >= tm.startPos) && (pos < tm.startPos + tm.len)) { - displayMethod(pos, (int) tm.offset); - currentMethodHighlight = tm; - + String name = ""; + if (abc != null) { + name = abc.instance_info[classIndex].getName(abc.constants).getNameWithNamespace(abc.constants); + } for (Highlighting th : traitHighlights) { if ((pos >= th.startPos) && (pos < th.startPos + th.len)) { lastTraitIndex = (int) th.offset; + if (abc != null) { + Trait t = abc.findTraitByTraitId(classIndex, lastTraitIndex); + if (t != null) { + name += ":"+t.getName(abc).getName(abc.constants, new ArrayList()); + } + } } } + + displayMethod(pos, (int) tm.offset, name); + currentMethodHighlight = tm; + + return; } } @@ -163,7 +175,16 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL } } currentMethodHighlight = th; - displayMethod(pos, abc.findMethodIdByTraitId(classIndex, (int) th.offset)); + String name = ""; + if (abc != null) { + name = abc.instance_info[classIndex].getName(abc.constants).getNameWithNamespace(abc.constants); + Trait t = abc.findTraitByTraitId(classIndex, lastTraitIndex); + if (t != null) { + name+=":"+t.getName(abc).getName(abc.constants, new ArrayList()); + } + } + + displayMethod(pos, abc.findMethodIdByTraitId(classIndex, (int) th.offset), name); return; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/GraphFrame.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/GraphFrame.java deleted file mode 100644 index a8b18a050..000000000 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/GraphFrame.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (C) 2010-2013 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 . - */ -package com.jpexs.decompiler.flash.abc.gui; - -import com.jpexs.decompiler.flash.graph.Graph; -import com.jpexs.decompiler.flash.graph.GraphPart; -import com.jpexs.decompiler.flash.gui.View; -import java.awt.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.JScrollPane; - -/** - * - * @author JPEXS - */ -public class GraphFrame extends JFrame { - - private class GraphPanel extends JPanel { - - private static final int SPACE_VERTICAL = 10; - private static final int SPACE_HORIZONTAL = 10; - private static final int BLOCK_WIDTH = 200; - private static final int BLOCK_HEIGHT = 20; - private Graph graph; - - public GraphPanel(Graph graph) { - this.graph = graph; - setPreferredSize(new Dimension((BLOCK_WIDTH + SPACE_HORIZONTAL) * getPartWidth(graph.heads.get(0), new HashSet()), (BLOCK_HEIGHT + SPACE_VERTICAL) * getPartHeight(graph.heads.get(0), new ArrayList()))); - } - - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - g.setColor(Color.black); - paintPart(g, graph.heads.get(0), 0, getPartWidth(graph.heads.get(0), new HashSet()) * (BLOCK_WIDTH + SPACE_HORIZONTAL) / 2, new HashMap()); - } - - private void paintPart(Graphics g, GraphPart part, int y, int x, HashMap used) { - HashMap l = new HashMap(); - l.putAll(used); - HashSet hs = new HashSet(); - hs.addAll(l.keySet()); - int totalWidthParts = getPartWidth(part, hs); - int totalWidth = totalWidthParts * (BLOCK_WIDTH + SPACE_HORIZONTAL); - - if (used.containsKey(part)) { - g.setColor(Color.black); - Point p = used.get(part); - g.drawLine(x, y, p.x, p.y); - return; - } - g.drawRect(x - BLOCK_WIDTH / 2 - SPACE_HORIZONTAL / 2, y, BLOCK_WIDTH, BLOCK_HEIGHT); - g.drawString(part.toString(), x - BLOCK_WIDTH / 2, y + BLOCK_HEIGHT); - - used.put(part, new Point(x, y)); - if (part.nextParts.size() > 0) { - int cx = x - totalWidth / 2; - for (int p = 0; p < part.nextParts.size(); p++) { - HashSet k = new HashSet(); - k.addAll(used.keySet()); - int cellWidth = getPartWidth(part.nextParts.get(p), k) * (BLOCK_WIDTH + SPACE_HORIZONTAL); - g.setColor(Color.black); - g.drawLine(x, y + BLOCK_HEIGHT, cx + cellWidth / 2, y + BLOCK_HEIGHT + SPACE_VERTICAL); - paintPart(g, part.nextParts.get(p), y + BLOCK_HEIGHT + SPACE_VERTICAL, cx + cellWidth / 2, used); - cx += cellWidth; - - } - } - - } - - private int getPartHeight(GraphPart part, List used) { - if (used.contains(part)) { - return 1; - } - used.add(part); - int maxH = 0; - for (int p = 0; p < part.nextParts.size(); p++) { - int h = getPartHeight(part.nextParts.get(p), used); - if (h > maxH) { - maxH = h; - } - } - return 1 + maxH; - } - - private int getPartWidth(GraphPart part, HashSet used) { - - if (used.contains(part)) { - return 1; - } - used.add(part); - if (part.nextParts.isEmpty()) { - return 1; - } - int w = 0; - for (GraphPart subpart : part.nextParts) { - w += getPartWidth(subpart, used); - } - return w; - } - } - - public GraphFrame(Graph graph, String name) { - setSize(500, 500); - Container cnt = getContentPane(); - cnt.setLayout(new BorderLayout()); - cnt.add(new JScrollPane(new GraphPanel(graph))); - setTitle("Graph " + name); - View.setWindowIcon(this); - View.centerScreen(this); - } -} diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodCodePanel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodCodePanel.java index 5a2ee1bea..91d85d6c4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodCodePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodCodePanel.java @@ -40,6 +40,10 @@ public class MethodCodePanel extends JPanel implements ActionListener { public void focusEditor() { sourceTextArea.requestFocusInWindow(); } + + public String getTraitName(){ + return sourceTextArea.getName(); + } public void setIgnoreCarret(boolean ignoreCarret) { sourceTextArea.setIgnoreCarret(ignoreCarret); @@ -50,7 +54,10 @@ public class MethodCodePanel extends JPanel implements ActionListener { } public void setBodyIndex(int bodyIndex, ABC abc) { - sourceTextArea.setBodyIndex(bodyIndex, abc); + sourceTextArea.setBodyIndex(bodyIndex, abc,sourceTextArea.getName()); + } + public void setBodyIndex(int bodyIndex, ABC abc,String name) { + sourceTextArea.setBodyIndex(bodyIndex, abc,name); } public int getBodyIndex() { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java b/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java index e8327f929..9a9f7926f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.action.gui; import com.jpexs.decompiler.flash.Main; import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.abc.gui.GraphFrame; +import com.jpexs.decompiler.flash.gui.GraphFrame; import com.jpexs.decompiler.flash.abc.gui.LineMarkedEditorPane; import com.jpexs.decompiler.flash.action.ActionGraph; import com.jpexs.decompiler.flash.action.parser.ASMParser; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java new file mode 100644 index 000000000..92ae83e43 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java @@ -0,0 +1,298 @@ +/* + * Copyright (C) 2010-2013 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 . + */ +package com.jpexs.decompiler.flash.gui; + +import com.jpexs.decompiler.flash.graph.Graph; +import com.jpexs.decompiler.flash.graph.GraphPart; +import java.awt.*; +import java.awt.geom.AffineTransform; +import java.awt.geom.Line2D; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; + +/** + * + * @author JPEXS + */ +public class GraphFrame extends JFrame { + + private class GraphPanel extends JPanel { + + private static final int SPACE_VERTICAL = 16; + private static final int SPACE_HORIZONTAL = 10; + private static final int SPACE_BACKLINKS = 5; + private static final int BLOCK_WIDTH = 200; + private static final int BLOCK_HEIGHT = 20; + private HashMap partPos = new HashMap(); + private Point size; + private int backLinksLeft = 0; + private int backLinksRight = 0; + private GraphPart head; + + public GraphPanel(Graph graph) { + size = getPartPositions(head = graph.heads.get(0), SPACE_VERTICAL + SPACE_VERTICAL + BLOCK_HEIGHT / 2, getPartWidth(graph.heads.get(0), new HashSet()) * (BLOCK_WIDTH + SPACE_HORIZONTAL) / 2 - SPACE_HORIZONTAL, partPos, true); + backLinksLeft = 1; + backLinksRight = 1; + for (GraphPart part : partPos.keySet()) { + Point p = partPos.get(part); + for (GraphPart n : part.nextParts) { + Point npos = partPos.get(n); + if (npos.y < p.y) { + if (p.x > size.x / 2) { + backLinksRight++; + } else { + backLinksLeft++; + } + } + } + } + size.x += 2 * SPACE_BACKLINKS + backLinksLeft * SPACE_BACKLINKS + backLinksRight * SPACE_BACKLINKS; + setPreferredSize(new Dimension(size.x, size.y)); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + + Graphics2D g2 = (Graphics2D) g; + /*g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON);*/ + g2.setColor(Color.black); + int startX = SPACE_BACKLINKS + backLinksLeft * SPACE_BACKLINKS; + int blLeft = 0; + int blRight = 0; + for (GraphPart part : partPos.keySet()) { + Point p = partPos.get(part); + g2.setColor(Color.white); + g2.fillRect(startX + p.x - BLOCK_WIDTH / 2, p.y - BLOCK_HEIGHT / 2, BLOCK_WIDTH, BLOCK_HEIGHT); + g2.setColor(Color.black); + g2.drawRect(startX + p.x - BLOCK_WIDTH / 2, p.y - BLOCK_HEIGHT / 2, BLOCK_WIDTH, BLOCK_HEIGHT); + g2.drawString(part.toString(), startX + p.x - g2.getFontMetrics().stringWidth(part.toString()) / 2, p.y + g2.getFontMetrics().getHeight() / 2); + } + + Point hp = partPos.get(head); + drawArrow(g2, startX + hp.x, hp.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL, startX + hp.x, hp.y - BLOCK_HEIGHT / 2); + + for (GraphPart part : partPos.keySet()) { + Point p = partPos.get(part); + + for (int n = 0; n < part.nextParts.size(); n++) { + boolean isIf = part.nextParts.size() == 2; + if (isIf) { + if (n == 0) { + g2.setColor(new Color(0, 0x80, 0)); + } else { + g2.setColor(Color.red); + } + } else { + g2.setColor(Color.black); + } + Point npos = partPos.get(part.nextParts.get(n)); + if (npos.y < p.y) { + int sidex = startX; + if (p.x > size.x / 2) { + blRight++; + sidex = size.x - backLinksRight * SPACE_BACKLINKS; + sidex += SPACE_BACKLINKS + SPACE_BACKLINKS * blRight; + } else { + blLeft++; + sidex -= SPACE_BACKLINKS + SPACE_BACKLINKS * blLeft; + } + g2.drawLine(startX + p.x, p.y + BLOCK_HEIGHT / 2, startX + p.x, p.y + BLOCK_HEIGHT / 2 + SPACE_VERTICAL / 2); + g2.drawLine(startX + p.x, p.y + BLOCK_HEIGHT / 2 + SPACE_VERTICAL / 2, sidex, p.y + BLOCK_HEIGHT / 2 + SPACE_VERTICAL / 2); + g2.drawLine(sidex, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2, sidex, p.y + BLOCK_HEIGHT / 2 + SPACE_VERTICAL / 2); + drawArrow(g2, sidex, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2, startX + npos.x, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2); + g2.drawLine(startX + npos.x, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2, startX + npos.x, npos.y - BLOCK_HEIGHT / 2); + } else { + drawArrow(g2, startX + p.x, p.y + BLOCK_HEIGHT / 2, startX + npos.x, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2); + g2.drawLine(startX + npos.x, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2, startX + npos.x, npos.y - BLOCK_HEIGHT / 2); + } + } + } + } + + private Point getPartSubPositions(Point ret, int totalWidth, GraphPart part, int y, int x, HashMap used) { + if (used.containsKey(part)) { + Point p = used.get(part); + return new Point(x, y); + } + used.put(part, new Point(x, y)); + if (part.nextParts.size() > 0) { + int cx = x - totalWidth / 2; + for (int p = 0; p < part.nextParts.size(); p++) { + HashSet k = new HashSet(); + k.addAll(used.keySet()); + int partWidth = getPartWidth(part.nextParts.get(p), k); + int cellWidth = partWidth * (BLOCK_WIDTH + SPACE_HORIZONTAL); + Point pt = getPartPositions(part.nextParts.get(p), y + BLOCK_HEIGHT + SPACE_VERTICAL, cx + cellWidth / 2, used, false); + if (pt.x > ret.x) { + ret.x = pt.x; + } + if (pt.y > ret.y) { + ret.y = pt.y; + } + cx += cellWidth; + + } + cx = x - totalWidth / 2; + for (int p = 0; p < part.nextParts.size(); p++) { + HashSet k = new HashSet(); + k.addAll(used.keySet()); + int cellWidth = getPartWidth(part.nextParts.get(p), k) * (BLOCK_WIDTH + SPACE_HORIZONTAL); + + HashSet hs = new HashSet(); + hs.addAll(used.keySet()); + int totalWidthParts2 = getPartWidth(part.nextParts.get(p), hs); + int totalWidth2 = totalWidthParts2 * (BLOCK_WIDTH + SPACE_HORIZONTAL); + + Point pt = getPartSubPositions(ret, totalWidth2, part.nextParts.get(p), y + BLOCK_HEIGHT + SPACE_VERTICAL, cx + cellWidth / 2, used); + if (pt.x > ret.x) { + ret.x = pt.x; + } + if (pt.y > ret.y) { + ret.y = pt.y; + } + cx += cellWidth; + } + + } + return ret; + } + + private Point getPartPositions(GraphPart part, int y, int x, HashMap used, boolean goSub) { + HashMap l = new HashMap(); + l.putAll(used); + HashSet hs = new HashSet(); + hs.addAll(l.keySet()); + int totalWidthParts = getPartWidth(part, hs); + int totalWidth = totalWidthParts * (BLOCK_WIDTH + SPACE_HORIZONTAL); + + if (used.containsKey(part)) { + Point p = used.get(part); + return new Point(x, y); + } + Point ret = new Point(x - BLOCK_WIDTH / 2 - SPACE_HORIZONTAL / 2 + BLOCK_WIDTH, y + BLOCK_HEIGHT); + if (goSub) { + Point p2 = getPartSubPositions(ret, totalWidth, part, y, x, used); + if (p2.x > ret.x) { + ret.x = p2.x; + } + if (p2.y > ret.y) { + ret.y = p2.y; + } + } + return ret; + } + + private int getPartHeight(GraphPart part, List used) { + if (used.contains(part)) { + return 1; + } + used.add(part); + int maxH = 0; + for (int p = 0; p < part.nextParts.size(); p++) { + int h = getPartHeight(part.nextParts.get(p), used); + if (h > maxH) { + maxH = h; + } + } + return 1 + maxH; + } + + private int getPartWidth(GraphPart part, HashSet used) { + + if (used.contains(part)) { + return 1; + } + used.add(part); + if (part.nextParts.isEmpty()) { + return 1; + } + int w = 0; + for (GraphPart subpart : part.nextParts) { + w += getPartWidth(subpart, used); + } + return w; + } + } + GraphPanel gp; + + public GraphFrame(Graph graph, String name) { + setSize(500, 500); + Container cnt = getContentPane(); + cnt.setLayout(new BorderLayout()); + gp = new GraphPanel(graph); + setTitle("Graph " + name); + cnt.add(new JScrollPane(gp)); + + View.setWindowIcon(this); + + } + + @Override + public void setVisible(boolean b) { + + super.setVisible(b); + Dimension screen = getToolkit().getScreenSize(); + Dimension dim = new Dimension(0, 0); + Dimension panDim = gp.getPreferredSize(); + if (panDim.width < screen.width) { + dim.width = panDim.width+10; + } else { + dim.width = screen.width; + } + if (panDim.height < screen.height) { + dim.height = panDim.height+10; + } else { + dim.height = screen.height; + } + setVisibleSize(dim); + View.centerScreen(this); + } + + + + private void setVisibleSize(Dimension dim) { + Insets insets = this.getInsets(); + setSize(new Dimension(insets.left + insets.right + dim.width, + insets.top + insets.bottom + dim.height)); + } + + private void drawArrow(Graphics g, int x1, int y1, int x2, int y2) { + Polygon arrowHead = new Polygon(); + arrowHead.addPoint(0, 0); + arrowHead.addPoint(-3, -8); + arrowHead.addPoint(3, -8); + Line2D.Double line = new Line2D.Double(x1, y1, x2, y2); + AffineTransform tx = new AffineTransform(); + tx.setToIdentity(); + double angle = Math.atan2(line.y2 - line.y1, line.x2 - line.x1); + tx.translate(line.x2, line.y2); + tx.rotate((angle - Math.PI / 2d)); + + Graphics2D g2d = (Graphics2D) g; + g2d.draw(line); + Graphics2D g2 = (Graphics2D) g2d.create(); + g2.setTransform(tx); + g2.fill(arrowHead); + g2.dispose(); + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/GraphTreeFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/GraphTreeFrame.java similarity index 94% rename from trunk/src/com/jpexs/decompiler/flash/abc/gui/GraphTreeFrame.java rename to trunk/src/com/jpexs/decompiler/flash/gui/GraphTreeFrame.java index 48ffea40e..b531b6638 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/GraphTreeFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/GraphTreeFrame.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.jpexs.decompiler.flash.abc.gui; +package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.abc.avm2.graph.AVM2Graph; import com.jpexs.decompiler.flash.graph.GraphPart; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java index 668d4fb8c..0e616e4bb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java @@ -217,7 +217,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi Main.exit(); } }); - setTitle(Main.applicationName + " - " + Main.getFileTitle()); + setTitle(Main.applicationName +(Main.DISPLAY_FILENAME?" - " + Main.getFileTitle():"")); JMenuBar menuBar = new JMenuBar(); JMenu menuFile = new JMenu("File"); @@ -1024,7 +1024,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi } if (e.getActionCommand().equals("SAVEAS")) { if (Main.saveFileDialog()) { - setTitle(Main.applicationName + " - " + Main.getFileTitle()); + setTitle(Main.applicationName + (Main.DISPLAY_FILENAME?" - " + Main.getFileTitle():"")); } } if (e.getActionCommand().equals("OPEN")) {