From 14b274c8d499ad4212c2e545447838c20b6b09f2 Mon Sep 17 00:00:00 2001 From: Honfika Date: Sun, 18 Aug 2013 19:11:58 +0200 Subject: [PATCH 1/2] Issue #336: Graph window is too small --- .../decompiler/flash/gui/GraphFrame.java | 50 +++++++++++++++---- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java index 748a7f640..b67579031 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java @@ -234,15 +234,30 @@ public class GraphFrame extends AppFrame { return w; } } + GraphPanel gp; - + int scrollBarWidth; + int scrollBarHeight; + int frameWidthDiff; + int frameHeightDiff; + public GraphFrame(Graph graph, String name) { setSize(500, 500); Container cnt = getContentPane(); cnt.setLayout(new BorderLayout()); gp = new GraphPanel(graph); setTitle(translate("graph") + " " + name); - cnt.add(new JScrollPane(gp)); + JScrollPane scrollPane = new JScrollPane(gp); + scrollBarWidth = scrollPane.getVerticalScrollBar().getPreferredSize().width; + scrollBarHeight = scrollPane.getHorizontalScrollBar().getPreferredSize().height; + cnt.add(scrollPane, BorderLayout.CENTER); + pack(); + + Dimension size = getSize(); + Dimension innerSize = getContentPane().getSize(); + + frameWidthDiff = size.width - innerSize.width; + frameHeightDiff = size.height - innerSize.height; View.setWindowIcon(this); @@ -255,24 +270,41 @@ public class GraphFrame extends AppFrame { Dimension screen = getToolkit().getScreenSize(); Dimension dim = new Dimension(0, 0); Dimension panDim = gp.getPreferredSize(); - if (panDim.width < screen.width) { - dim.width = panDim.width + 10; + // add some magic constants + panDim = new Dimension(panDim.width + 3, panDim.height + 2); + + boolean tooHigh = false; + boolean tooWide = false; + + if (panDim.width + frameWidthDiff < screen.width) { + dim.width = panDim.width; } else { dim.width = screen.width; + tooWide = true; } - if (panDim.height < screen.height) { - dim.height = panDim.height + 10; + if (panDim.height + frameHeightDiff < screen.height) { + dim.height = panDim.height; } else { dim.height = screen.height; + tooHigh = true; } + + if (tooWide) { + dim.height += scrollBarHeight; + dim.height = Math.min(dim.height, screen.height); + } + if (tooHigh) { + dim.width += scrollBarWidth; + dim.width = Math.min(dim.width, screen.width); + } + 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)); + + setSize(new Dimension(dim.width + frameWidthDiff, dim.height + frameHeightDiff)); } private void drawArrow(Graphics g, int x1, int y1, int x2, int y2) { From 6c5f974ed6b4cc64714dbed9cf6f6ce2fc773ca4 Mon Sep 17 00:00:00 2001 From: Honfika Date: Sun, 18 Aug 2013 19:28:20 +0200 Subject: [PATCH 2/2] Issue #330: protection against adding the same multiple cyrillic characters doesn't work --- trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java | 1 - trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java index b67579031..dfd4ef8ed 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/GraphFrame.java @@ -303,7 +303,6 @@ public class GraphFrame extends AppFrame { } private void setVisibleSize(Dimension dim) { - setSize(new Dimension(dim.width + frameWidthDiff, dim.height + frameHeightDiff)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java index 00a6d54a4..d6535ae6b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java @@ -2192,6 +2192,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel char c = newchars.charAt(i); if (oldchars.indexOf((int) c) == -1) { f.addCharacter(swf.tags, c, fontSelection.getSelectedItem().toString()); + oldchars += c; } } fontAddCharactersField.setText("");