From ccb46d8082b9f45cbbde7bf4aeed4ecf55d5ae67 Mon Sep 17 00:00:00 2001 From: Lodici Date: Wed, 4 Dec 2013 08:15:37 +0000 Subject: [PATCH 1/5] - refactor : removing redundant code. --- src/magic/ui/viewer/LogBookViewer.java | 70 +------------------------- 1 file changed, 2 insertions(+), 68 deletions(-) diff --git a/src/magic/ui/viewer/LogBookViewer.java b/src/magic/ui/viewer/LogBookViewer.java index 7d359fdbcb..6e92f32841 100644 --- a/src/magic/ui/viewer/LogBookViewer.java +++ b/src/magic/ui/viewer/LogBookViewer.java @@ -1,7 +1,5 @@ package magic.ui.viewer; -import magic.data.GeneralConfig; -import magic.data.IconImages; import magic.model.MagicLogBook; import magic.model.MagicMessage; import magic.ui.widget.FontsAndBorders; @@ -10,25 +8,15 @@ import magic.ui.widget.TitleBar; import javax.swing.BorderFactory; import javax.swing.BoxLayout; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JLabel; -import javax.swing.JMenuItem; import javax.swing.JPanel; -import javax.swing.JPopupMenu; import javax.swing.JScrollBar; import javax.swing.JScrollPane; import javax.swing.border.CompoundBorder; -import javax.swing.event.MouseInputAdapter; - import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Cursor; import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; -import java.awt.event.MouseEvent; import java.util.ListIterator; public class LogBookViewer extends JPanel { @@ -45,9 +33,8 @@ public class LogBookViewer extends JPanel { private final MagicLogBook logBook; private final JPanel messagePanel; private final JScrollPane scrollPane; - private final GeneralConfig config = GeneralConfig.getInstance(); - private boolean isScrollbarVisible = false; //config.isLogScrollbarVisible(); - private boolean isNewMessageAddedToTop = false; // config.isLogMessageAddedToTop(); + private boolean isScrollbarVisible = false; + private boolean isNewMessageAddedToTop = false; public LogBookViewer(final MagicLogBook logBook) { @@ -57,7 +44,6 @@ public class LogBookViewer extends JPanel { TitleBar tb = new TitleBar("Log"); tb.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.BLACK)); - //tb.add(getOptionsButton(), BorderLayout.EAST); add(tb, BorderLayout.NORTH); final JPanel centerPanel=new JPanel(); @@ -91,7 +77,6 @@ public class LogBookViewer extends JPanel { } - public MagicLogBook getLogBook() { return logBook; } @@ -137,57 +122,6 @@ public class LogBookViewer extends JPanel { return panel; } - private JLabel getOptionsButton() { - JLabel lbl = new JLabel(IconImages.PROGRESS); - lbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - lbl.addMouseListener(new MouseInputAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - doPopup(e); - } - private void doPopup(MouseEvent e){ - JPopupMenu menu = getOptionsPopupMenu(); - menu.show(e.getComponent(), e.getX(), e.getY()); - } - }); - return lbl; - } - - private JPopupMenu getOptionsPopupMenu() { - JPopupMenu menu = new JPopupMenu(); - menu.add(getMenuItem_ScrollbarVisibility()); - menu.add(getMenuItem_TopInsert()); - return menu; - } - - private JMenuItem getMenuItem_TopInsert() { - JCheckBoxMenuItem item = new JCheckBoxMenuItem("Add new message to top", isNewMessageAddedToTop); - item.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - isNewMessageAddedToTop = !isNewMessageAddedToTop; - update(); - config.setLogMessageAddedToTop(isNewMessageAddedToTop); - config.save(); - } - }); - return item; - } - - private JCheckBoxMenuItem getMenuItem_ScrollbarVisibility() { - JCheckBoxMenuItem item = new JCheckBoxMenuItem("Show scroll-bar", isScrollbarVisible); - item.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - isScrollbarVisible = !isScrollbarVisible; - setVerticalScrollbarPolicy(); - config.setLogScrollbarVisible(isScrollbarVisible); - config.save(); - } - }); - return item; - } - private void setVerticalScrollbarPolicy() { scrollPane.setVerticalScrollBarPolicy(getVerticalScrollbarPolicy()); } From 93da0235e92515cfeff4871ffa5a9c44171a3eb3 Mon Sep 17 00:00:00 2001 From: Lodici Date: Wed, 4 Dec 2013 08:26:45 +0000 Subject: [PATCH 2/5] - Make statistics viewer background translucent instead of textured so it is readable regardless of the theme selected. --- src/magic/ui/viewer/DeckStatisticsViewer.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/magic/ui/viewer/DeckStatisticsViewer.java b/src/magic/ui/viewer/DeckStatisticsViewer.java index 82a0e70155..172ff5c6a6 100644 --- a/src/magic/ui/viewer/DeckStatisticsViewer.java +++ b/src/magic/ui/viewer/DeckStatisticsViewer.java @@ -21,7 +21,7 @@ import java.awt.GridLayout; import java.util.ArrayList; import java.util.List; -public class DeckStatisticsViewer extends JPanel implements ChangeListener { +public class DeckStatisticsViewer extends TexturedPanel implements ChangeListener { private static final long serialVersionUID = 1L; @@ -35,19 +35,22 @@ public class DeckStatisticsViewer extends JPanel implements ChangeListener { private final Color textColor; public DeckStatisticsViewer() { + textColor=ThemeFactory.getInstance().getCurrentTheme().getTextColor(); setPreferredSize(PREFERRED_SIZE); setBorder(FontsAndBorders.UP_BORDER); + setBackground(new Color(255, 255, 255, 200)); setLayout(new BorderLayout()); titleBar=new TitleBar("Deck Statistics"); add(titleBar,BorderLayout.NORTH); - final JPanel mainPanel=new TexturedPanel(); + final JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); mainPanel.setBorder(FontsAndBorders.BLACK_BORDER_2); + mainPanel.setOpaque(false); add(mainPanel,BorderLayout.CENTER); topPanel=new JPanel(new FlowLayout(FlowLayout.LEFT,10,5)); From c86fec2cced33d016aedaa6f8cd679b3ff517d1e Mon Sep 17 00:00:00 2001 From: Lodici Date: Wed, 4 Dec 2013 13:12:20 +0000 Subject: [PATCH 3/5] - refactor: replace translucent color magic numbers with symbolic constants in FontsAndBorders. --- src/magic/ui/CardExplorerScreenOptions.java | 9 +++------ src/magic/ui/DeckEditorScreenOptions.java | 11 ++++------- src/magic/ui/DuelDecksScreenOptions.java | 11 ++++------- src/magic/ui/DuelDialog.java | 4 +--- src/magic/ui/DuelPanel.java | 3 +-- src/magic/ui/DuelScreenOptions.java | 11 ++++------- src/magic/ui/ExplorerPanel.java | 3 +-- src/magic/ui/GamePanel.java | 8 ++++---- src/magic/ui/KeywordsScreen.java | 6 ++---- src/magic/ui/ReadmeScreen.java | 5 ++--- src/magic/ui/viewer/DeckStatisticsViewer.java | 2 +- src/magic/ui/viewer/HistoryViewer.java | 6 ++---- src/magic/ui/widget/FontsAndBorders.java | 11 +++++++++++ src/magic/ui/widget/MagActionBar.java | 4 +--- src/magic/ui/widget/MagStatusBar.java | 4 +--- src/magic/ui/widget/MenuPanel.java | 2 +- 16 files changed, 43 insertions(+), 57 deletions(-) diff --git a/src/magic/ui/CardExplorerScreenOptions.java b/src/magic/ui/CardExplorerScreenOptions.java index 0826163ecc..eed05f34df 100644 --- a/src/magic/ui/CardExplorerScreenOptions.java +++ b/src/magic/ui/CardExplorerScreenOptions.java @@ -1,6 +1,5 @@ package magic.ui; -import java.awt.Color; import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; @@ -11,6 +10,7 @@ import javax.swing.JPanel; import javax.swing.KeyStroke; import net.miginfocom.swing.MigLayout; +import magic.ui.widget.FontsAndBorders; import magic.ui.widget.MenuButton; import magic.ui.widget.MenuPanel; import magic.ui.widget.TexturedPanel; @@ -18,16 +18,13 @@ import magic.ui.widget.TexturedPanel; @SuppressWarnings("serial") public class CardExplorerScreenOptions extends TexturedPanel implements IMenuOverlay { - private static Color BACKGROUND_COLOR = new Color(0, 0, 0, 150); - private static Color MENUPANEL_COLOR = new Color(0, 0, 0, 230); - private final MagicFrame frame; public CardExplorerScreenOptions(final MagicFrame frame0) { this.frame = frame0; - setBackground(BACKGROUND_COLOR); + setBackground(FontsAndBorders.IMENUOVERLAY_BACKGROUND_COLOR); setLayout(new MigLayout("insets 0, gap 10, flowx, center, center")); add(getGeneralMenu()); @@ -57,7 +54,7 @@ public class CardExplorerScreenOptions extends TexturedPanel implements IMenuOve } })); menuPanel.refreshLayout(); - menuPanel.setBackground(MENUPANEL_COLOR); + menuPanel.setBackground(FontsAndBorders.IMENUOVERLAY_MENUPANEL_COLOR); return menuPanel; } diff --git a/src/magic/ui/DeckEditorScreenOptions.java b/src/magic/ui/DeckEditorScreenOptions.java index 8e6da5d405..3de2f36ab3 100644 --- a/src/magic/ui/DeckEditorScreenOptions.java +++ b/src/magic/ui/DeckEditorScreenOptions.java @@ -1,6 +1,5 @@ package magic.ui; -import java.awt.Color; import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; @@ -11,15 +10,13 @@ import javax.swing.JPanel; import javax.swing.KeyStroke; import net.miginfocom.swing.MigLayout; +import magic.ui.widget.FontsAndBorders; import magic.ui.widget.MenuPanel; import magic.ui.widget.TexturedPanel; @SuppressWarnings("serial") public class DeckEditorScreenOptions extends TexturedPanel implements IMenuOverlay { - private static Color BACKGROUND_COLOR = new Color(0, 0, 0, 150); - private static Color MENUPANEL_COLOR = new Color(0, 0, 0, 230); - private final MagicFrame frame; private final DeckEditorScreen screen; @@ -28,7 +25,7 @@ public class DeckEditorScreenOptions extends TexturedPanel implements IMenuOverl this.frame = frame0; this.screen = screen0; - setBackground(BACKGROUND_COLOR); + setBackground(FontsAndBorders.IMENUOVERLAY_BACKGROUND_COLOR); setLayout(new MigLayout("insets 0, gap 10, flowx, center, center")); add(getScreenMenu()); add(getGeneralMenu()); @@ -51,7 +48,7 @@ public class DeckEditorScreenOptions extends TexturedPanel implements IMenuOverl private MenuPanel getGeneralMenu() { final MenuPanel menuPanel = new GeneralMenuPanel(frame, this); - menuPanel.setBackground(MENUPANEL_COLOR); + menuPanel.setBackground(FontsAndBorders.IMENUOVERLAY_MENUPANEL_COLOR); return menuPanel; } @@ -97,7 +94,7 @@ public class DeckEditorScreenOptions extends TexturedPanel implements IMenuOverl }); menu.refreshLayout(); - menu.setBackground(MENUPANEL_COLOR); + menu.setBackground(FontsAndBorders.IMENUOVERLAY_MENUPANEL_COLOR); return menu; } diff --git a/src/magic/ui/DuelDecksScreenOptions.java b/src/magic/ui/DuelDecksScreenOptions.java index aef1957d0d..41caacc3a7 100644 --- a/src/magic/ui/DuelDecksScreenOptions.java +++ b/src/magic/ui/DuelDecksScreenOptions.java @@ -1,6 +1,5 @@ package magic.ui; -import java.awt.Color; import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; @@ -11,15 +10,13 @@ import javax.swing.JPanel; import javax.swing.KeyStroke; import net.miginfocom.swing.MigLayout; +import magic.ui.widget.FontsAndBorders; import magic.ui.widget.MenuPanel; import magic.ui.widget.TexturedPanel; @SuppressWarnings("serial") public class DuelDecksScreenOptions extends TexturedPanel implements IMenuOverlay { - private static Color BACKGROUND_COLOR = new Color(0, 0, 0, 150); - private static Color MENUPANEL_COLOR = new Color(0, 0, 0, 230); - private final MagicFrame frame; private final DuelDecksScreen screen; @@ -28,7 +25,7 @@ public class DuelDecksScreenOptions extends TexturedPanel implements IMenuOverla this.frame = frame0; this.screen = screen0; - setBackground(BACKGROUND_COLOR); + setBackground(FontsAndBorders.IMENUOVERLAY_BACKGROUND_COLOR); setLayout(new MigLayout("insets 0, gap 10, flowx, center, center")); add(getScreenMenu()); add(getGeneralMenu()); @@ -51,7 +48,7 @@ public class DuelDecksScreenOptions extends TexturedPanel implements IMenuOverla private MenuPanel getGeneralMenu() { final MenuPanel menuPanel = new GeneralMenuPanel(frame, this); - menuPanel.setBackground(MENUPANEL_COLOR); + menuPanel.setBackground(FontsAndBorders.IMENUOVERLAY_MENUPANEL_COLOR); return menuPanel; } @@ -90,7 +87,7 @@ public class DuelDecksScreenOptions extends TexturedPanel implements IMenuOverla }); menu.refreshLayout(); - menu.setBackground(MENUPANEL_COLOR); + menu.setBackground(FontsAndBorders.IMENUOVERLAY_MENUPANEL_COLOR); return menu; } diff --git a/src/magic/ui/DuelDialog.java b/src/magic/ui/DuelDialog.java index 5714b4bb23..8ae44fc20f 100644 --- a/src/magic/ui/DuelDialog.java +++ b/src/magic/ui/DuelDialog.java @@ -1,14 +1,12 @@ package magic.ui; import magic.data.IconImages; - import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.BorderLayout; -import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.event.ActionEvent; @@ -48,7 +46,7 @@ public class DuelDialog extends JDialog implements ActionListener { buttonPanel.add(cancelButton); duelSetupPanel = new DuelSetupPanel(frame); - duelSetupPanel.setBackground(new Color(255, 255, 255, 0)); + duelSetupPanel.setOpaque(false); getContentPane().setLayout(new BorderLayout()); getContentPane().add(duelSetupPanel,BorderLayout.CENTER); diff --git a/src/magic/ui/DuelPanel.java b/src/magic/ui/DuelPanel.java index 879a04433c..3ef7dbe612 100644 --- a/src/magic/ui/DuelPanel.java +++ b/src/magic/ui/DuelPanel.java @@ -25,7 +25,6 @@ import javax.swing.JTabbedPane; import javax.swing.ScrollPaneConstants; import javax.swing.SpringLayout; -import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.event.ActionEvent; @@ -55,7 +54,7 @@ public class DuelPanel extends TexturedPanel { this.frame=frame; this.duel=duel; - setBackground(new Color(255, 255, 255, 60)); + setBackground(FontsAndBorders.MAGSCREEN_FADE_COLOR); final SpringLayout springLayout = new SpringLayout(); setLayout(springLayout); diff --git a/src/magic/ui/DuelScreenOptions.java b/src/magic/ui/DuelScreenOptions.java index fb01467007..8b26ea1fbe 100644 --- a/src/magic/ui/DuelScreenOptions.java +++ b/src/magic/ui/DuelScreenOptions.java @@ -1,6 +1,5 @@ package magic.ui; -import java.awt.Color; import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; @@ -12,15 +11,13 @@ import javax.swing.KeyStroke; import net.miginfocom.swing.MigLayout; import magic.data.GeneralConfig; +import magic.ui.widget.FontsAndBorders; import magic.ui.widget.MenuPanel; import magic.ui.widget.TexturedPanel; @SuppressWarnings("serial") public class DuelScreenOptions extends TexturedPanel implements IMenuOverlay { - private static Color BACKGROUND_COLOR = new Color(0, 0, 0, 150); - private static Color MENUPANEL_COLOR = new Color(0, 0, 0, 230); - private final MagicFrame frame; private final DuelScreen screen; @@ -29,7 +26,7 @@ public class DuelScreenOptions extends TexturedPanel implements IMenuOverlay { this.frame = frame0; this.screen = screen0; - setBackground(BACKGROUND_COLOR); + setBackground(FontsAndBorders.IMENUOVERLAY_BACKGROUND_COLOR); setLayout(new MigLayout("insets 0, gap 10, flowx, center, center")); add(getScreenMenu()); add(getGeneralMenu()); @@ -52,7 +49,7 @@ public class DuelScreenOptions extends TexturedPanel implements IMenuOverlay { private MenuPanel getGeneralMenu() { final MenuPanel menuPanel = new GeneralMenuPanel(frame, this); - menuPanel.setBackground(MENUPANEL_COLOR); + menuPanel.setBackground(FontsAndBorders.IMENUOVERLAY_MENUPANEL_COLOR); return menuPanel; } @@ -92,7 +89,7 @@ public class DuelScreenOptions extends TexturedPanel implements IMenuOverlay { }); menu.refreshLayout(); - menu.setBackground(MENUPANEL_COLOR); + menu.setBackground(FontsAndBorders.IMENUOVERLAY_MENUPANEL_COLOR); return menu; } diff --git a/src/magic/ui/ExplorerPanel.java b/src/magic/ui/ExplorerPanel.java index 4c32653cc8..cd80c37c31 100644 --- a/src/magic/ui/ExplorerPanel.java +++ b/src/magic/ui/ExplorerPanel.java @@ -23,7 +23,6 @@ import javax.swing.JTable; import javax.swing.ScrollPaneConstants; import javax.swing.SpringLayout; -import java.awt.Color; import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -72,7 +71,7 @@ public class ExplorerPanel extends TexturedPanel implements ActionListener { this.frame=frame; this.player=player; - setBackground(new Color(255, 255, 255, 60)); + setBackground(FontsAndBorders.MAGSCREEN_FADE_COLOR); final SpringLayout springLayout = new SpringLayout(); setLayout(springLayout); diff --git a/src/magic/ui/GamePanel.java b/src/magic/ui/GamePanel.java index 0853450278..2fb1a56e3a 100644 --- a/src/magic/ui/GamePanel.java +++ b/src/magic/ui/GamePanel.java @@ -23,13 +23,14 @@ import magic.ui.viewer.PlayerViewer; import magic.ui.viewer.StackCombatViewer; import magic.ui.viewer.StackViewer; import magic.ui.viewer.ViewerInfo; +import magic.ui.widget.FontsAndBorders; import magic.ui.widget.ZoneBackgroundLabel; import net.miginfocom.swing.MigLayout; import javax.swing.AbstractAction; import javax.swing.JPanel; import javax.swing.KeyStroke; -import java.awt.Color; + import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.InputEvent; @@ -45,7 +46,6 @@ public final class GamePanel extends JPanel { private static final String SWITCH_KEY="switch"; private static final String PASS_KEY="pass"; private static final Theme theme = ThemeFactory.getInstance().getCurrentTheme(); - private static final Color translucentPanelColor = new Color(255, 255, 255, 200); private final MagicFrame frame; private final MagicGame game; @@ -118,7 +118,7 @@ public final class GamePanel extends JPanel { opponentViewer=new PlayerViewer(viewerInfo,controller,true); gameDuelViewer=new GameDuelViewer(game,controller); - gameDuelViewer.setBackground(translucentPanelColor); + gameDuelViewer.setBackground(FontsAndBorders.TRANSLUCENT_WHITE_STRONG); controller.setGameViewer(gameDuelViewer.getGameViewer()); @@ -131,7 +131,7 @@ public final class GamePanel extends JPanel { opponentPermanentViewer=new BattlefieldViewer(viewerInfo,controller,true); imageStackViewer=new StackViewer(viewerInfo,controller,true); logStackViewer = new LogStackViewer(logBookViewer, imageStackViewer); - logStackViewer.setBackground(translucentPanelColor); + logStackViewer.setBackground(FontsAndBorders.TRANSLUCENT_WHITE_STRONG); imageHandGraveyardViewer=new ImageHandGraveyardExileViewer(viewerInfo,controller); imagePlayerPermanentViewer=new ImageBattlefieldViewer(viewerInfo,controller,false); diff --git a/src/magic/ui/KeywordsScreen.java b/src/magic/ui/KeywordsScreen.java index 9aed78498e..b915129667 100644 --- a/src/magic/ui/KeywordsScreen.java +++ b/src/magic/ui/KeywordsScreen.java @@ -39,7 +39,7 @@ public class KeywordsScreen extends MagScreen implements IMagStatusBar, IMagActi private static JPanel getScreenContent(final MagicFrame frame0) { final JPanel content = new TexturedPanel(); - content.setBackground(new Color(255, 255, 255, 220)); + content.setBackground(FontsAndBorders.TRANSLUCENT_WHITE_STRONG); content.setLayout(new MigLayout("insets 0, gap 0")); createScrollablePanel(); addNewScrollPane(content); @@ -106,9 +106,7 @@ public class KeywordsScreen extends MagScreen implements IMagStatusBar, IMagActi keywordPanel.add(nameLabel, "w 100%"); final JTextArea descriptionLabel = new JTextArea(keywordDefinition.description.replace("
", " ")); - descriptionLabel.setOpaque(false); - // Nimbus LAF opaque bug workaround (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6687960). - descriptionLabel.setBackground(new Color(0,0,0,0)); + descriptionLabel.setBackground(FontsAndBorders.TEXTAREA_TRANSPARENT_COLOR_HACK); descriptionLabel.setBorder(null); descriptionLabel.setLineWrap(true); descriptionLabel.setWrapStyleWord(true); diff --git a/src/magic/ui/ReadmeScreen.java b/src/magic/ui/ReadmeScreen.java index da4dc22b28..11f5883341 100644 --- a/src/magic/ui/ReadmeScreen.java +++ b/src/magic/ui/ReadmeScreen.java @@ -12,7 +12,6 @@ import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.SwingUtilities; -import java.awt.Color; import java.awt.event.ActionEvent; import java.util.List; @@ -33,11 +32,11 @@ public class ReadmeScreen extends MagScreen implements IMagStatusBar, IMagAction final JPanel content = new TexturedPanel(); - content.setBackground(new Color(255, 255, 255, 60)); + content.setBackground(FontsAndBorders.TRANSLUCENT_WHITE_STRONG); content.setLayout(new MigLayout("insets 0, gap 0, center")); final JTextArea readMeTextArea = new JTextArea(); - readMeTextArea.setBackground(new Color(255, 255, 255, 220)); + readMeTextArea.setBackground(FontsAndBorders.TEXTAREA_TRANSPARENT_COLOR_HACK); readMeTextArea.setEditable(false); readMeTextArea.setFont(FontsAndBorders.FONT_README); diff --git a/src/magic/ui/viewer/DeckStatisticsViewer.java b/src/magic/ui/viewer/DeckStatisticsViewer.java index 172ff5c6a6..4dd864a7b5 100644 --- a/src/magic/ui/viewer/DeckStatisticsViewer.java +++ b/src/magic/ui/viewer/DeckStatisticsViewer.java @@ -40,7 +40,7 @@ public class DeckStatisticsViewer extends TexturedPanel implements ChangeListene setPreferredSize(PREFERRED_SIZE); setBorder(FontsAndBorders.UP_BORDER); - setBackground(new Color(255, 255, 255, 200)); + setBackground(FontsAndBorders.TRANSLUCENT_WHITE_STRONG); setLayout(new BorderLayout()); diff --git a/src/magic/ui/viewer/HistoryViewer.java b/src/magic/ui/viewer/HistoryViewer.java index 03334bf359..9e94411863 100644 --- a/src/magic/ui/viewer/HistoryViewer.java +++ b/src/magic/ui/viewer/HistoryViewer.java @@ -9,8 +9,8 @@ import magic.ui.widget.TitleBar; import javax.swing.JPanel; import javax.swing.JTextArea; + import java.awt.BorderLayout; -import java.awt.Color; import java.awt.Dimension; public class HistoryViewer extends JPanel{ @@ -62,9 +62,7 @@ public class HistoryViewer extends JPanel{ final JTextArea textArea = new JTextArea(8, 170); textArea.setEditable(false); textArea.setFocusable(false); - // set background to get transparent effect - // must be done this way because of use of TexturedPanel() - textArea.setBackground(new Color(255, 255, 255, 0)); + textArea.setBackground(FontsAndBorders.TEXTAREA_TRANSPARENT_COLOR_HACK); textArea.setForeground(ThemeFactory.getInstance().getCurrentTheme().getTextColor()); textArea.setTabSize(16); textArea.setText("Games played:\t" + gamesPlayed + diff --git a/src/magic/ui/widget/FontsAndBorders.java b/src/magic/ui/widget/FontsAndBorders.java index 87deedbc98..e49d0be12f 100644 --- a/src/magic/ui/widget/FontsAndBorders.java +++ b/src/magic/ui/widget/FontsAndBorders.java @@ -7,6 +7,17 @@ import java.awt.Font; public class FontsAndBorders { + // Calling JTextArea.setOpaque(false) does not work with Nimbus LAF. This is a workaround. + // (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6687960). + public static final Color TEXTAREA_TRANSPARENT_COLOR_HACK = new Color(255, 255, 255, 0); + + public static final Color MAGSCREEN_FADE_COLOR = new Color(255, 255, 255, 60); + public static final Color TRANSLUCENT_WHITE_STRONG = new Color(255, 255, 255, 220); + public static final Color MAGSCREEN_BAR_COLOR = new Color(0, 0, 0, 220); + public static final Color MENUPANEL_COLOR = new Color(0, 0, 0, 200); + public static final Color IMENUOVERLAY_BACKGROUND_COLOR = new Color(0, 0, 0, 150); + public static final Color IMENUOVERLAY_MENUPANEL_COLOR = new Color(0, 0, 0, 230); + public static final Color GRAY1=new Color(200,200,200); public static final Color GRAY2=new Color(210,210,210); public static final Color GRAY3=new Color(220,220,220); diff --git a/src/magic/ui/widget/MagActionBar.java b/src/magic/ui/widget/MagActionBar.java index 8217981c18..74d680f492 100644 --- a/src/magic/ui/widget/MagActionBar.java +++ b/src/magic/ui/widget/MagActionBar.java @@ -14,14 +14,12 @@ import net.miginfocom.swing.MigLayout; @SuppressWarnings("serial") public class MagActionBar extends TexturedPanel { - private final static Color TRANSLUCENT_COLOR = new Color(0, 0, 0, 220); - private IMagActionBar actionProvider; public MagActionBar(final IMagActionBar provider0) { actionProvider = provider0; setMinimumSize(new Dimension(getPreferredSize().width, 50)); - setBackground(TRANSLUCENT_COLOR); + setBackground(FontsAndBorders.MAGSCREEN_BAR_COLOR); setMagActionBarLayout(); } diff --git a/src/magic/ui/widget/MagStatusBar.java b/src/magic/ui/widget/MagStatusBar.java index 8b66eeb735..a02ea06cbd 100644 --- a/src/magic/ui/widget/MagStatusBar.java +++ b/src/magic/ui/widget/MagStatusBar.java @@ -1,6 +1,5 @@ package magic.ui.widget; -import java.awt.Color; import java.awt.Cursor; import java.awt.Dimension; import java.awt.event.ActionEvent; @@ -20,7 +19,6 @@ import magic.ui.MagicFrame; @SuppressWarnings("serial") public class MagStatusBar extends TexturedPanel { - private final static Color TRANSLUCENT_COLOR = new Color(0, 0, 0, 220); private final static ImageIcon optionsIcon = new ImageIcon(IconImages.OPTIONS_ICON); private final MagScreen magScreen; @@ -28,7 +26,7 @@ public class MagStatusBar extends TexturedPanel { public MagStatusBar(final MagScreen screen0, final MagicFrame frame0) { this.magScreen = screen0; setMinimumSize(new Dimension(getPreferredSize().width, 50)); - setBackground(TRANSLUCENT_COLOR); + setBackground(FontsAndBorders.MAGSCREEN_BAR_COLOR); layoutMagStatusBar(); } diff --git a/src/magic/ui/widget/MenuPanel.java b/src/magic/ui/widget/MenuPanel.java index 24657fdfc6..ead5467d49 100644 --- a/src/magic/ui/widget/MenuPanel.java +++ b/src/magic/ui/widget/MenuPanel.java @@ -28,7 +28,7 @@ public class MenuPanel extends TexturedPanel { setMaximumSize(new Dimension(300, 380)); setBorder(FontsAndBorders.BLACK_BORDER); - setBackground(new Color(0, 0, 0, 200)); + setBackground(FontsAndBorders.MENUPANEL_COLOR); setMenuPanelLayout(); From 810a3338fe65b2ec661127b72ae7870489b51d46 Mon Sep 17 00:00:00 2001 From: Lodici Date: Wed, 4 Dec 2013 13:21:56 +0000 Subject: [PATCH 4/5] - refactor: removed obsolete component. --- src/magic/ui/MagicHelpMenuOverlay.java | 52 -------------------------- 1 file changed, 52 deletions(-) delete mode 100644 src/magic/ui/MagicHelpMenuOverlay.java diff --git a/src/magic/ui/MagicHelpMenuOverlay.java b/src/magic/ui/MagicHelpMenuOverlay.java deleted file mode 100644 index 8442d2e7e0..0000000000 --- a/src/magic/ui/MagicHelpMenuOverlay.java +++ /dev/null @@ -1,52 +0,0 @@ -package magic.ui; - -import java.awt.Color; -import java.awt.event.ActionEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseMotionAdapter; - -import javax.swing.AbstractAction; -import javax.swing.JPanel; -import javax.swing.KeyStroke; - -import magic.ui.widget.TexturedPanel; -import net.miginfocom.swing.MigLayout; - -@SuppressWarnings("serial") -public class MagicHelpMenuOverlay extends TexturedPanel implements IMagicHelpOverlay { - - public MagicHelpMenuOverlay(final MagicFrame frame0) { - - setLayout(new MigLayout("insets 0, gap 0, flowy, center, center")); - setBackground(new Color(0,0,0,150)); - - addMouseListener(new MouseAdapter() {}); - addMouseMotionListener(new MouseMotionAdapter() {}); - - getInputMap(JPanel.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "closeMenu"); - getInputMap(JPanel.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("F1"), "closeMenu"); - getActionMap().put("closeMenu", new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - setVisible(false); - } - }); - - final MagicHelpMenu optionsPanel = new MagicHelpMenu(frame0, this, true); - optionsPanel.setBackground(new Color(0, 0, 0, 240)); - add(optionsPanel); - - frame0.setGlassPane(this); - setVisible(true); - - } - - /* (non-Javadoc) - * @see magic.ui.IMagicHelpOverlay#actionPerformed() - */ - @Override - public void actionPerformed() { - setVisible(false); - } - -} From 5506d151dce2bc98b292a5aef12a3b24e1aee4ca Mon Sep 17 00:00:00 2001 From: Lodici Date: Wed, 4 Dec 2013 15:14:28 +0000 Subject: [PATCH 5/5] - Fix[#398] : Sort by toughness actually sorts by power in deck builder. --- src/magic/model/MagicCondensedCardDefinition.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/magic/model/MagicCondensedCardDefinition.java b/src/magic/model/MagicCondensedCardDefinition.java index 1442435f4e..5d2d796d0d 100644 --- a/src/magic/model/MagicCondensedCardDefinition.java +++ b/src/magic/model/MagicCondensedCardDefinition.java @@ -128,7 +128,7 @@ public class MagicCondensedCardDefinition { public static final Comparator TOUGHNESS_COMPARATOR_ASC=new Comparator() { @Override public int compare(final MagicCondensedCardDefinition cardDefinition1,final MagicCondensedCardDefinition cardDefinition2) { - return MagicCardDefinition.POWER_COMPARATOR_ASC.compare(cardDefinition1.getCard(), cardDefinition2.getCard()); + return MagicCardDefinition.TOUGHNESS_COMPARATOR_ASC.compare(cardDefinition1.getCard(), cardDefinition2.getCard()); } }; }