diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index 9eb675b62..2054a88c3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -20,16 +20,22 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.tags.base.CharacterTag; import com.jpexs.decompiler.flash.tags.base.DrawableTag; import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.FlowLayout; import java.awt.Image; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.util.HashMap; import java.util.Stack; import java.util.Timer; import java.util.TimerTask; import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JColorChooser; import javax.swing.JLabel; import javax.swing.JPanel; -public class ImagePanel extends JPanel { +public class ImagePanel extends JPanel implements ActionListener { public JLabel label = new JLabel(); public DrawableTag drawable; @@ -37,13 +43,53 @@ public class ImagePanel extends JPanel { private int percent; private int frame; + @Override + public void setBackground(Color bg) { + if (label != null) { + label.setBackground(bg);//bg); + } + super.setBackground(bg); + } + public ImagePanel() { super(new BorderLayout()); label.setHorizontalAlignment(JLabel.CENTER); + label.setOpaque(true); + setOpaque(true); + setBackground(Color.white); add(label, BorderLayout.CENTER); + + JPanel bottomPanel = new JPanel(new BorderLayout()); + JPanel buttonsPanel = new JPanel(new FlowLayout()); + JButton selectColorButton = new JButton(View.getIcon("color16")); + selectColorButton.addActionListener(this); + selectColorButton.setActionCommand("SELECTCOLOR"); + selectColorButton.setToolTipText(AppStrings.translate("button.selectcolor.hint")); + buttonsPanel.add(selectColorButton); + bottomPanel.add(buttonsPanel, BorderLayout.EAST); + add(bottomPanel, BorderLayout.SOUTH); + } + + @Override + public void actionPerformed(ActionEvent e) { + if ("SELECTCOLOR".equals(e.getActionCommand())) { + View.execInEventDispatch(new Runnable() { + @Override + public void run() { + Color newColor = JColorChooser.showDialog(null, AppStrings.translate("dialog.selectcolor.title"), View.swfBackgroundColor); + if (newColor != null) { + View.swfBackgroundColor = newColor; + setBackground(newColor); + repaint(); + } + } + }); + + } } public void setImage(byte data[]) { + setBackground(View.swfBackgroundColor); if (timer != null) { timer.cancel(); } @@ -87,6 +133,7 @@ public class ImagePanel extends JPanel { } public void setImage(Image image) { + setBackground(View.swfBackgroundColor); if (timer != null) { timer.cancel(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java index efe28047e..5e3c6082b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java @@ -304,7 +304,7 @@ public class Main { } } - public static boolean reloadSWF(){ + public static boolean reloadSWF() { if (Main.inputStream == null) { mainFrame.setVisible(false); Helper.emptyObject(mainFrame); @@ -327,6 +327,7 @@ public class Main { return false; } } + public static void reloadApp() { if (loadingDialog != null) { loadingDialog.setVisible(false); @@ -336,7 +337,7 @@ public class Main { proxyFrame.setVisible(false); proxyFrame = null; } - if(loadFromMemoryFrame != null){ + if (loadFromMemoryFrame != null) { loadFromMemoryFrame.setVisible(false); loadFromMemoryFrame = null; } @@ -700,6 +701,14 @@ public class Main { UIManager.put("FileChooser.fileSizeMegaBytes", AppStrings.translate("FileChooser.fileSizeMegaBytes")); UIManager.put("FileChooser.fileSizeGigaBytes", AppStrings.translate("FileChooser.fileSizeGigaBytes")); UIManager.put("FileChooser.folderNameLabelText", AppStrings.translate("FileChooser.folderNameLabelText")); + + UIManager.put("ColorChooser.okText", AppStrings.translate("ColorChooser.okText")); + UIManager.put("ColorChooser.cancelText", AppStrings.translate("ColorChooser.cancelText")); + UIManager.put("ColorChooser.resetText", AppStrings.translate("ColorChooser.resetText")); + UIManager.put("ColorChooser.previewText", AppStrings.translate("ColorChooser.previewText")); + UIManager.put("ColorChooser.swatchesNameText", AppStrings.translate("ColorChooser.swatchesNameText")); + UIManager.put("ColorChooser.swatchesRecentText", AppStrings.translate("ColorChooser.swatchesRecentText")); + UIManager.put("ColorChooser.sampleText", AppStrings.translate("ColorChooser.sampleText")); } /** diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java index e336436ca..5c5e3cf1d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java @@ -158,6 +158,7 @@ import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JCheckBoxMenuItem; +import javax.swing.JColorChooser; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JFileChooser; @@ -1239,6 +1240,17 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel //paramsLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); pan.add(prevLabel, BorderLayout.NORTH); pan.add(leftComponent, BorderLayout.CENTER); + if (flashPanel != null) { + JPanel bottomPanel = new JPanel(new BorderLayout()); + JPanel buttonsPanel = new JPanel(new FlowLayout()); + JButton selectColorButton = new JButton(View.getIcon("color16")); + selectColorButton.addActionListener(this); + selectColorButton.setActionCommand("SELECTCOLOR"); + selectColorButton.setToolTipText(AppStrings.translate("button.selectcolor.hint")); + buttonsPanel.add(selectColorButton); + bottomPanel.add(buttonsPanel, BorderLayout.EAST); + pan.add(bottomPanel, BorderLayout.SOUTH); + } previewSplitPane.setLeftComponent(pan); parametersPanel = new JPanel(new BorderLayout()); @@ -1278,6 +1290,16 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel shapesCard.add(previewPanel, BorderLayout.CENTER); displayPanel.add(shapesCard, CARDDRAWPREVIEWPANEL); + Color backgroundColor = Color.white; + if (swf != null) { + for (Tag t : swf.tags) { + if (t instanceof SetBackgroundColorTag) { + backgroundColor = ((SetBackgroundColorTag) t).backgroundColor.toColor(); + break; + } + } + } + View.swfBackgroundColor = backgroundColor; swfPreviewPanel = new SWFPreviwPanel(); displayPanel.add(swfPreviewPanel, CARDSWFPREVIEWPANEL); @@ -2197,8 +2219,15 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel @Override public void actionPerformed(ActionEvent e) { switch (e.getActionCommand()) { + case "SELECTCOLOR": + Color newColor = JColorChooser.showDialog(null, AppStrings.translate("dialog.selectcolor.title"), View.swfBackgroundColor); + if (newColor != null) { + View.swfBackgroundColor = newColor; + reload(true); + } + break; case "RELOAD": - if(View.showConfirmDialog(null, translate("message.confirm.reload"), translate("message.warning"),JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE)==JOptionPane.YES_OPTION){ + if (View.showConfirmDialog(null, translate("message.confirm.reload"), translate("message.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { Main.reloadSWF(); } break; @@ -2945,7 +2974,7 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel sos2.writeUI8(0); sos2.writeUI8(swf.frameRate); sos2.writeUI16(100); //framecnt - sos2.writeTag(new SetBackgroundColorTag(null, new RGB(255, 255, 255))); + sos2.writeTag(new SetBackgroundColorTag(null, new RGB(View.swfBackgroundColor))); if (tagObj instanceof FrameNode) { FrameNode fn = (FrameNode) tagObj; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/SWFPreviwPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/SWFPreviwPanel.java index 97194016f..f1742c92d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/SWFPreviwPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/SWFPreviwPanel.java @@ -19,14 +19,21 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.SWF; import static com.jpexs.decompiler.flash.gui.AppStrings.translate; import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; import java.util.Stack; import java.util.Timer; import java.util.TimerTask; +import javax.swing.JButton; +import javax.swing.JColorChooser; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JScrollPane; import javax.swing.SwingConstants; /** @@ -43,15 +50,16 @@ public class SWFPreviwPanel extends JPanel { public SWFPreviwPanel() { pan = new ImagePanel(); + pan.setBackground(View.swfBackgroundColor); setLayout(new BorderLayout()); - add(pan, BorderLayout.CENTER); - add(buffering, BorderLayout.SOUTH); + add(new JScrollPane(pan), BorderLayout.CENTER); buffering.setHorizontalAlignment(JLabel.CENTER); buffering.setVisible(false); JLabel prevLabel = new HeaderLabel(translate("swfpreview.internal")); prevLabel.setHorizontalAlignment(SwingConstants.CENTER); //prevLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); add(prevLabel, BorderLayout.NORTH); + add(buffering, BorderLayout.SOUTH); } private SWF swf; @@ -92,6 +100,7 @@ public class SWFPreviwPanel extends JPanel { if (frameImages.size() >= newframe) { pan.setImage(frameImages.get(newframe - 1)); frame = newframe; + pan.setBackground(View.swfBackgroundColor); } } }, 0, 1000 / swf.frameRate); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/View.java b/trunk/src/com/jpexs/decompiler/flash/gui/View.java index 5a3172168..74307afd6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/View.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/View.java @@ -37,6 +37,7 @@ import javax.swing.KeyStroke; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.plaf.basic.BasicColorChooserUI; import org.pushingpixels.flamingo.api.common.icon.ImageWrapperResizableIcon; import org.pushingpixels.substance.api.SubstanceConstants; import org.pushingpixels.substance.api.SubstanceLookAndFeel; @@ -49,6 +50,8 @@ import org.pushingpixels.substance.api.skin.SubstanceOfficeBlue2007LookAndFeel; */ public class View { + public static Color swfBackgroundColor = Color.white; + /** * Sets windows Look and Feel */ @@ -69,7 +72,9 @@ public class View { UIManager.put(SubstanceLookAndFeel.COLORIZATION_FACTOR, 0.999);//This works for not changing labels color and not changing Dialogs title UIManager.put("Tree.expandedIcon", getIcon("expand16")); UIManager.put("Tree.collapsedIcon", getIcon("collapse16")); - + UIManager.put("ColorChooserUI", BasicColorChooserUI.class.getName()); + UIManager.put("ColorChooser.swatchesRecentSwatchSize", new Dimension(20, 20)); + UIManager.put("ColorChooser.swatchesSwatchSize", new Dimension(20, 20)); UIManager.put("RibbonApplicationMenuPopupPanelUI", MyRibbonApplicationMenuPopupPanelUI.class.getName()); UIManager.put("RibbonApplicationMenuButtonUI", MyRibbonApplicationMenuButtonUI.class.getName()); UIManager.put("ProgressBarUI", MyProgressBarUI.class.getName()); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/graphics/color16.png b/trunk/src/com/jpexs/decompiler/flash/gui/graphics/color16.png new file mode 100644 index 000000000..809fb00e5 Binary files /dev/null and b/trunk/src/com/jpexs/decompiler/flash/gui/graphics/color16.png differ diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG3Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG3Tag.java index bb3320a0d..6b531dae1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG3Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineBitsJPEG3Tag.java @@ -52,7 +52,7 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag { byte ba[] = new byte[image.getWidth() * image.getHeight()]; for (int i = 0; i < ba.length; i++) { ba[i] = (byte) 255; - } + } bitmapAlphaData = ba; } else { bitmapAlphaData = new byte[0];