From edc9ed88b6a8e8d5117acc79b95ed80c6f1a2fb7 Mon Sep 17 00:00:00 2001 From: Honfika Date: Thu, 6 Mar 2014 22:06:22 +0100 Subject: [PATCH] folder preview panel hack + small fixes --- .../decompiler/flash/configuration/Configuration.java | 4 ++-- .../com/jpexs/decompiler/flash/gui/PreviewImage.java | 10 +++++++++- trunk/src/com/jpexs/helpers/Helper.java | 8 ++++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java index 1866f2362..d97cbcee5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -168,7 +168,7 @@ public class Configuration { public static final ConfigurationItem locale = null; @ConfigurationDefaultString("_loc%d_") public static final ConfigurationItem registerNameFormat = null; - @ConfigurationDefaultInt(8) + @ConfigurationDefaultInt(10) public static final ConfigurationItem maxRecentFileCount = null; public static final ConfigurationItem recentFiles = null; public static final ConfigurationItem fontPairing = null; @@ -338,7 +338,7 @@ public class Configuration { recentFilesArray.remove(idx); } recentFilesArray.add(path); - while (recentFilesArray.size() >= maxRecentFileCount.get()) { + while (recentFilesArray.size() > maxRecentFileCount.get()) { recentFilesArray.remove(0); } recentFiles.set(Helper.joinStrings(recentFilesArray, "::")); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/PreviewImage.java b/trunk/src/com/jpexs/decompiler/flash/gui/PreviewImage.java index a8bac8d43..311bb054f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/PreviewImage.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/PreviewImage.java @@ -80,9 +80,17 @@ public class PreviewImage extends JPanel { @Override public void run() { + // todo: + // call repaint on MainPanel.folderPreviewPanel + // this is a hack, but otherwise the preview panel looks crazy sometimes + // how to handle it in a better way? + // normally repaint() on this panel should be enough Component parent = getParent(); if (parent != null) { - parent.repaint(); + parent = parent.getParent(); + if (parent != null) { + parent.repaint(); + } } } }); diff --git a/trunk/src/com/jpexs/helpers/Helper.java b/trunk/src/com/jpexs/helpers/Helper.java index f05f41983..f0a675a9e 100644 --- a/trunk/src/com/jpexs/helpers/Helper.java +++ b/trunk/src/com/jpexs/helpers/Helper.java @@ -796,18 +796,18 @@ public class Helper { Rectangle rectangle = new Rectangle(); int y1, y2; for (int x = 0; x < image.getWidth(); x++) { - y1 = 99; + y1 = Integer.MAX_VALUE; y2 = -1; for (int y = 0; y < image.getHeight(); y++) { int rgb = image.getRGB(x, y); rgb = rgb >>> 24; if (rgb > 0) { - if (y1 == 99) { + if (y1 == Integer.MAX_VALUE) { y1 = y; y2 = y; } if (y > (y2 + 1)) { - rectangle.setBounds(x, y1, 1, y2 - y1); + rectangle.setBounds(x, y1, 1, y2 - y1 + 1); area.add(new Area(rectangle)); y1 = y; } @@ -815,7 +815,7 @@ public class Helper { } } if ((y2 - y1) >= 0) { - rectangle.setBounds(x, y1, 1, y2 - y1); + rectangle.setBounds(x, y1, 1, y2 - y1 + 1); area.add(new Area(rectangle)); } }