Some more changes to GUI to better support high screen resolutions.

This commit is contained in:
LevelX2 2016-02-10 08:31:21 +01:00
parent 2e574ab19e
commit a0ff08b0b9
13 changed files with 388 additions and 273 deletions

View file

@ -234,18 +234,17 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
TConfig config = TConfig.current(); TConfig config = TConfig.current();
config.setArchiveDetector(new TArchiveDetector("zip")); config.setArchiveDetector(new TArchiveDetector("zip"));
config.setAccessPreference(FsAccessOption.STORE, true); config.setAccessPreference(FsAccessOption.STORE, true);
try { try {
UIManager.put("desktop", new Color(0, 0, 0, 0)); UIManager.put("desktop", new Color(0, 0, 0, 0));
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
// Change default font and row size for JTables // Change default font and row size for JTables
Font font = FontSizeHelper.getTableFont(); Font font = FontSizeHelper.getTableFont();
UIManager.put("Table.font", font); UIManager.put("Table.font", font);
UIManager.put("Table.rowHeight", FontSizeHelper.getTableRowHeight()); UIManager.put("Table.rowHeight", FontSizeHelper.tableRowHeight);
} catch (Exception ex) { } catch (Exception ex) {
LOGGER.fatal(null, ex); LOGGER.fatal(null, ex);
} }
FontSizeHelper.setGUISize();
ManaSymbols.loadImages(); ManaSymbols.loadImages();
Plugins.getInstance().loadPlugins(); Plugins.getInstance().loadPlugins();
@ -531,6 +530,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
MagePane window = (MagePane) windows[i]; MagePane window = (MagePane) windows[i];
if (window.isVisible()) { if (window.isVisible()) {
menuItem = new MagePaneMenuItem(window); menuItem = new MagePaneMenuItem(window);
menuItem.setFont(FontSizeHelper.getToolbarFont());
menuItem.setState(i == 0); menuItem.setState(i == 0);
menuItem.addActionListener(new ActionListener() { menuItem.addActionListener(new ActionListener() {
@Override @Override
@ -1068,12 +1068,10 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
if (setActive) { if (setActive) {
setActive(tablesPane); setActive(tablesPane);
} else // if other panel was already shown, mamke sure it's topmost again } else // if other panel was already shown, mamke sure it's topmost again
{
if (topPanebefore != null) { if (topPanebefore != null) {
setActive(topPanebefore); setActive(topPanebefore);
} }
} }
}
public void hideGames() { public void hideGames() {
JInternalFrame[] windows = desktopPane.getAllFramesInLayer(JLayeredPane.DEFAULT_LAYER); JInternalFrame[] windows = desktopPane.getAllFramesInLayer(JLayeredPane.DEFAULT_LAYER);
@ -1270,6 +1268,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
public void setStatusText(String status) { public void setStatusText(String status) {
this.lblStatus.setText(status); this.lblStatus.setText(status);
changeGUISize(); // Needed to layout the tooltbar after text length chnage
} }
public static MageUI getUI() { public static MageUI getUI() {
@ -1403,14 +1402,29 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
} }
public void changeGUISize() { public void changeGUISize() {
// Tables
if (tablesPane != null) {
tablesPane.changeGUISize(); tablesPane.changeGUISize();
}
// Deck editor
JInternalFrame[] windows = desktopPane.getAllFramesInLayer(JLayeredPane.DEFAULT_LAYER);
for (JInternalFrame window : windows) {
if (window instanceof DeckEditorPane) {
((DeckEditorPane) window).getPanel().changeGUISize();
}
}
// Tournament panels
for (Component component : desktopPane.getComponents()) {
if (component instanceof TournamentPane) {
((TournamentPane) component).changeGUISize();
}
}
setGUISize(); setGUISize();
this.revalidate(); this.revalidate();
this.repaint(); this.repaint();
} }
private void setGUISize() { private void setGUISize() {
Font font = FontSizeHelper.getToolbarFont(); Font font = FontSizeHelper.getToolbarFont();
mageToolbar.setFont(font); mageToolbar.setFont(font);
int newHeight = font.getSize() + 6; int newHeight = font.getSize() + 6;

View file

@ -36,6 +36,7 @@ package mage.client.cards;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -72,6 +73,7 @@ import mage.client.util.CardViewNameComparator;
import mage.client.util.CardViewRarityComparator; import mage.client.util.CardViewRarityComparator;
import mage.client.util.Config; import mage.client.util.Config;
import mage.client.util.Event; import mage.client.util.Event;
import mage.client.util.FontSizeHelper;
import mage.client.util.Listener; import mage.client.util.Listener;
import mage.client.util.gui.TableSpinnerEditor; import mage.client.util.gui.TableSpinnerEditor;
import mage.constants.CardType; import mage.constants.CardType;
@ -105,6 +107,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
initComponents(); initComponents();
makeTransparent(); makeTransparent();
initListViewComponents(); initListViewComponents();
setGUISize();
} }
public void cleanUp() { public void cleanUp() {
@ -140,6 +143,16 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
} }
public void changeGUISize() {
setGUISize();
}
private void setGUISize() {
Font font = FontSizeHelper.getTableFont();
mainTable.getTableHeader().setFont(font);
mainTable.getTableHeader().setPreferredSize(new Dimension(FontSizeHelper.tableHeaderHeight, FontSizeHelper.tableHeaderHeight));
}
private void makeTransparent() { private void makeTransparent() {
panelCardArea.setOpaque(false); panelCardArea.setOpaque(false);
cardArea.setOpaque(false); cardArea.setOpaque(false);

View file

@ -31,11 +31,12 @@
* *
* Created on Feb 18, 2010, 2:49:03 PM * Created on Feb 18, 2010, 2:49:03 PM
*/ */
package mage.client.deckeditor; package mage.client.deckeditor;
import java.awt.Color; import java.awt.Color;
import java.awt.Cursor; import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent; import java.awt.event.ComponentEvent;
@ -64,6 +65,7 @@ import mage.client.cards.CardGrid;
import mage.client.cards.ICardGrid; import mage.client.cards.ICardGrid;
import mage.client.constants.Constants.SortBy; import mage.client.constants.Constants.SortBy;
import mage.client.deckeditor.table.TableModel; import mage.client.deckeditor.table.TableModel;
import mage.client.util.FontSizeHelper;
import mage.client.util.sets.ConstructedFormats; import mage.client.util.sets.ConstructedFormats;
import mage.constants.CardType; import mage.constants.CardType;
import mage.filter.FilterCard; import mage.filter.FilterCard;
@ -76,7 +78,6 @@ import mage.filter.predicate.other.CardTextPredicate;
import mage.filter.predicate.other.ExpansionSetPredicate; import mage.filter.predicate.other.ExpansionSetPredicate;
import mage.view.CardsView; import mage.view.CardsView;
/** /**
* *
* @author BetaSteward_at_googlemail.com, nantuko * @author BetaSteward_at_googlemail.com, nantuko
@ -95,13 +96,16 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
} }
}; };
/** Creates new form CardSelector */ /**
* Creates new form CardSelector
*/
public CardSelector() { public CardSelector() {
sortSetting = SortSettingBase.getInstance(); sortSetting = SortSettingBase.getInstance();
initComponents(); initComponents();
cardGrid = new CardGrid(); cardGrid = new CardGrid();
makeTransparent(); makeTransparent();
initListViewComponents(); initListViewComponents();
setGUISize();
currentView = mainModel; // by default we use List View currentView = mainModel; // by default we use List View
} }
@ -178,6 +182,16 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
this.mainModel.clear(); this.mainModel.clear();
} }
public void changeGUISize() {
setGUISize();
}
private void setGUISize() {
Font font = FontSizeHelper.getTableFont();
mainTable.getTableHeader().setFont(font);
mainTable.getTableHeader().setPreferredSize(new Dimension(FontSizeHelper.tableHeaderHeight, FontSizeHelper.tableHeaderHeight));
}
public void switchToGrid() { public void switchToGrid() {
jToggleListView.setSelected(false); jToggleListView.setSelected(false);
jToggleCardView.setSelected(true); jToggleCardView.setSelected(true);
@ -268,7 +282,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
} }
filter.add(Predicates.or(predicates)); filter.add(Predicates.or(predicates));
if (this.cbExpansionSet.isVisible()) { if (this.cbExpansionSet.isVisible()) {
String expansionSelection = this.cbExpansionSet.getSelectedItem().toString(); String expansionSelection = this.cbExpansionSet.getSelectedItem().toString();
if (!expansionSelection.equals("- All Sets")) { if (!expansionSelection.equals("- All Sets")) {
@ -317,8 +330,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
// criteria.types(CardType.TRIBAL); // criteria.types(CardType.TRIBAL);
// criteria.types(CardType.CONSPIRACY); // criteria.types(CardType.CONSPIRACY);
if (this.cbExpansionSet.isVisible()) { if (this.cbExpansionSet.isVisible()) {
String expansionSelection = this.cbExpansionSet.getSelectedItem().toString(); String expansionSelection = this.cbExpansionSet.getSelectedItem().toString();
if (!expansionSelection.equals("- All Sets")) { if (!expansionSelection.equals("- All Sets")) {
@ -378,8 +389,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
filteredCards.add(card); filteredCards.add(card);
} }
} }
} } else {
else {
List<CardInfo> foundCards = CardRepository.instance.findCards(buildCriteria()); List<CardInfo> foundCards = CardRepository.instance.findCards(buildCriteria());
for (CardInfo cardInfo : foundCards) { for (CardInfo cardInfo : foundCards) {
Card card = cardInfo.getMockCard(); Card card = cardInfo.getMockCard();
@ -393,8 +403,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
} }
this.currentView.loadCards(new CardsView(filteredCards), sortSetting, bigCard, null, false); this.currentView.loadCards(new CardsView(filteredCards), sortSetting, bigCard, null, false);
this.cardCount.setText(String.valueOf(filteredCards.size())); this.cardCount.setText(String.valueOf(filteredCards.size()));
} } finally {
finally {
setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
} }
} }
@ -421,10 +430,10 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
} }
} }
/** This method is called from within the constructor to /**
* initialize the form. * This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * WARNING: Do NOT modify this code. The content of this method is always
* always regenerated by the Form Editor. * regenerated by the Form Editor.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
@ -1032,7 +1041,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
mainModel.removeFromSideEvent(0); mainModel.removeFromSideEvent(0);
}//GEN-LAST:event_jButtonRemoveFromSideboardActionPerformed }//GEN-LAST:event_jButtonRemoveFromSideboardActionPerformed
private void jButtonSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSearchActionPerformed private void jButtonSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSearchActionPerformed
filterCards(); filterCards();
}//GEN-LAST:event_jButtonSearchActionPerformed }//GEN-LAST:event_jButtonSearchActionPerformed

View file

@ -25,14 +25,11 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
/* /*
* DeckArea.java * DeckArea.java
* *
* Created on Feb 18, 2010, 3:10:39 PM * Created on Feb 18, 2010, 3:10:39 PM
*/ */
package mage.client.deckeditor; package mage.client.deckeditor;
import mage.cards.decks.Deck; import mage.cards.decks.Deck;
@ -49,7 +46,9 @@ import mage.view.CardsView;
*/ */
public class DeckArea extends javax.swing.JPanel { public class DeckArea extends javax.swing.JPanel {
/** Creates new form DeckArea */ /**
* Creates new form DeckArea
*/
public DeckArea() { public DeckArea() {
initComponents(); initComponents();
deckAreaSplitPane.setOpaque(false); deckAreaSplitPane.setOpaque(false);
@ -66,6 +65,15 @@ public class DeckArea extends javax.swing.JPanel {
sideboardList.cleanUp(); sideboardList.cleanUp();
} }
public void changeGUISize() {
setGUISize();
deckList.changeGUISize();
sideboardList.changeGUISize();
}
private void setGUISize() {
}
public void showSideboard(boolean show) { public void showSideboard(boolean show) {
this.sideboardList.setVisible(show); this.sideboardList.setVisible(show);
} }
@ -98,10 +106,10 @@ public class DeckArea extends javax.swing.JPanel {
sideboardList.clearCardEventListeners(); sideboardList.clearCardEventListeners();
} }
/** This method is called from within the constructor to /**
* initialize the form. * This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * WARNING: Do NOT modify this code. The content of this method is always
* always regenerated by the Form Editor. * regenerated by the Form Editor.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents

View file

@ -31,7 +31,6 @@
* *
* Created on Dec 17, 2009, 9:21:42 AM * Created on Dec 17, 2009, 9:21:42 AM
*/ */
package mage.client.deckeditor; package mage.client.deckeditor;
import java.awt.Component; import java.awt.Component;
@ -44,14 +43,15 @@ import mage.client.MagePane;
import mage.client.constants.Constants.DeckEditorMode; import mage.client.constants.Constants.DeckEditorMode;
import mage.client.plugins.impl.Plugins; import mage.client.plugins.impl.Plugins;
/** /**
* *
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class DeckEditorPane extends MagePane { public class DeckEditorPane extends MagePane {
/** Creates new form TablesPane */ /**
* Creates new form TablesPane
*/
public DeckEditorPane() { public DeckEditorPane() {
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
boolean initialized = false; boolean initialized = false;
@ -75,15 +75,11 @@ public class DeckEditorPane extends MagePane {
public void show(DeckEditorMode mode, Deck deck, String name, UUID tableId, int time) { public void show(DeckEditorMode mode, Deck deck, String name, UUID tableId, int time) {
if (mode == DeckEditorMode.SIDEBOARDING || mode == DeckEditorMode.LIMITED_BUILDING) { if (mode == DeckEditorMode.SIDEBOARDING || mode == DeckEditorMode.LIMITED_BUILDING) {
this.setTitle("Deck Editor - " + tableId.toString()); this.setTitle("Deck Editor - " + tableId.toString());
} } else if (deck != null) {
else {
if (deck != null) {
this.setTitle("Deck Editor - " + deck.getName()); this.setTitle("Deck Editor - " + deck.getName());
} } else {
else {
this.setTitle("Deck Editor"); this.setTitle("Deck Editor");
} }
}
this.deckEditorPanel1.showDeckEditor(mode, deck, tableId, time); this.deckEditorPanel1.showDeckEditor(mode, deck, tableId, time);
this.repaint(); this.repaint();
} }
@ -92,10 +88,10 @@ public class DeckEditorPane extends MagePane {
return this.deckEditorPanel1.getDeckEditorMode(); return this.deckEditorPanel1.getDeckEditorMode();
} }
/** This method is called from within the constructor to /**
* initialize the form. * This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * WARNING: Do NOT modify this code. The content of this method is always
* always regenerated by the Form Editor. * regenerated by the Form Editor.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
@ -133,6 +129,10 @@ public class DeckEditorPane extends MagePane {
pack(); pack();
} }
public DeckEditorPanel getPanel() {
return deckEditorPanel1;
}
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private mage.client.deckeditor.DeckEditorPanel deckEditorPanel1; private mage.client.deckeditor.DeckEditorPanel deckEditorPanel1;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables

View file

@ -81,7 +81,7 @@ import org.apache.log4j.Logger;
*/ */
public class DeckEditorPanel extends javax.swing.JPanel { public class DeckEditorPanel extends javax.swing.JPanel {
private static final Logger logger = Logger.getLogger(DeckEditorPanel.class); private static final Logger LOGGER = Logger.getLogger(DeckEditorPanel.class);
private final JFileChooser fcSelectDeck; private final JFileChooser fcSelectDeck;
private final JFileChooser fcImportDeck; private final JFileChooser fcImportDeck;
private Deck deck = new Deck(); private Deck deck = new Deck();
@ -147,6 +147,11 @@ public class DeckEditorPanel extends javax.swing.JPanel {
this.bigCard = null; this.bigCard = null;
} }
public void changeGUISize() {
this.cardSelector.changeGUISize();
this.deckArea.changeGUISize();
}
public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId, int time) { public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId, int time) {
if (deck != null) { if (deck != null) {
this.deck = deck; this.deck = deck;
@ -685,7 +690,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
} catch (GameException ex) { } catch (GameException ex) {
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error loading deck", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error loading deck", JOptionPane.ERROR_MESSAGE);
} catch (Exception ex) { } catch (Exception ex) {
logger.fatal(ex); LOGGER.fatal(ex);
} finally { } finally {
setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
} }
@ -717,7 +722,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
setCursor(new Cursor(Cursor.WAIT_CURSOR)); setCursor(new Cursor(Cursor.WAIT_CURSOR));
Sets.saveDeck(fileName, deck.getDeckCardLists()); Sets.saveDeck(fileName, deck.getDeckCardLists());
} catch (Exception ex) { } catch (Exception ex) {
logger.fatal(ex); LOGGER.fatal(ex);
} finally { } finally {
setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
} }
@ -766,7 +771,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Unknown deck format", "Error importing deck", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Unknown deck format", "Error importing deck", JOptionPane.ERROR_MESSAGE);
} }
} catch (Exception ex) { } catch (Exception ex) {
logger.fatal(ex); LOGGER.fatal(ex);
} finally { } finally {
setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
} }
@ -872,7 +877,7 @@ class ImportFilter extends FileFilter {
class UpdateDeckTask extends SwingWorker<Void, Void> { class UpdateDeckTask extends SwingWorker<Void, Void> {
private static final Logger logger = Logger.getLogger(UpdateDeckTask.class); private static final Logger LOGGER = Logger.getLogger(UpdateDeckTask.class);
private final Session session; private final Session session;
private final UUID tableId; private final UUID tableId;
private final Deck deck; private final Deck deck;
@ -897,7 +902,7 @@ class UpdateDeckTask extends SwingWorker<Void, Void> {
try { try {
get(); get();
} catch (InterruptedException | ExecutionException ex) { } catch (InterruptedException | ExecutionException ex) {
logger.fatal("Update Matches Task error", ex); LOGGER.fatal("Update Matches Task error", ex);
} catch (CancellationException ex) { } catch (CancellationException ex) {
} }
} }

View file

@ -124,8 +124,7 @@ public class PlayersChatPanel extends javax.swing.JPanel {
private void setGUISize() { private void setGUISize() {
Font font = FontSizeHelper.getTableFont(); Font font = FontSizeHelper.getTableFont();
jTablePlayers.getTableHeader().setFont(font); jTablePlayers.getTableHeader().setFont(font);
int rowHeight = FontSizeHelper.getTableRowHeight(); jTablePlayers.getTableHeader().setPreferredSize(new Dimension(FontSizeHelper.tableHeaderHeight, FontSizeHelper.tableHeaderHeight));
jTablePlayers.getTableHeader().setPreferredSize(new Dimension(rowHeight, rowHeight));
font = FontSizeHelper.getTabFont(); font = FontSizeHelper.getTabFont();
jTabbedPaneText.setFont(font); jTabbedPaneText.setFont(font);
this.revalidate(); this.revalidate();

View file

@ -288,10 +288,9 @@ public class TablesPanel extends javax.swing.JPanel {
private void setGUISize() { private void setGUISize() {
Font font = FontSizeHelper.getTableFont(); Font font = FontSizeHelper.getTableFont();
tableTables.getTableHeader().setFont(font); tableTables.getTableHeader().setFont(font);
int rowHeight = FontSizeHelper.getTableRowHeight(); tableTables.getTableHeader().setPreferredSize(new Dimension(FontSizeHelper.tableHeaderHeight, FontSizeHelper.tableHeaderHeight));
tableTables.getTableHeader().setPreferredSize(new Dimension(rowHeight, rowHeight));
tableCompleted.getTableHeader().setFont(font); tableCompleted.getTableHeader().setFont(font);
tableCompleted.getTableHeader().setPreferredSize(new Dimension(rowHeight, rowHeight)); tableCompleted.getTableHeader().setPreferredSize(new Dimension(FontSizeHelper.tableHeaderHeight, FontSizeHelper.tableHeaderHeight));
} }
private void saveDividerLocations() { private void saveDividerLocations() {

View file

@ -31,7 +31,6 @@
* *
* Created on 22-Jan-2011, 11:41:47 PM * Created on 22-Jan-2011, 11:41:47 PM
*/ */
package mage.client.tournament; package mage.client.tournament;
import java.util.UUID; import java.util.UUID;
@ -43,7 +42,9 @@ import mage.client.MagePane;
*/ */
public class TournamentPane extends MagePane { public class TournamentPane extends MagePane {
/** Creates new form TournamentPane */ /**
* Creates new form TournamentPane
*/
public TournamentPane() { public TournamentPane() {
initComponents(); initComponents();
} }
@ -59,6 +60,10 @@ public class TournamentPane extends MagePane {
removeFrame(); removeFrame();
} }
public void changeGUISize() {
tournamentPanel.changeGUISize();
}
public UUID getTournamentId() { public UUID getTournamentId() {
if (this.tournamentPanel == null) { if (this.tournamentPanel == null) {
return null; return null;
@ -66,10 +71,10 @@ public class TournamentPane extends MagePane {
return tournamentPanel.getTournamentId(); return tournamentPanel.getTournamentId();
} }
/** This method is called from within the constructor to /**
* initialize the form. * This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * WARNING: Do NOT modify this code. The content of this method is always
* always regenerated by the Form Editor. * regenerated by the Form Editor.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
@ -91,7 +96,6 @@ public class TournamentPane extends MagePane {
pack(); pack();
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private mage.client.tournament.TournamentPanel tournamentPanel; private mage.client.tournament.TournamentPanel tournamentPanel;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables

View file

@ -34,6 +34,8 @@
package mage.client.tournament; package mage.client.tournament;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.text.DateFormat; import java.text.DateFormat;
@ -56,6 +58,7 @@ import static mage.client.dialog.PreferencesDialog.KEY_TOURNAMENT_MATCH_COLUMNS_
import static mage.client.dialog.PreferencesDialog.KEY_TOURNAMENT_PLAYER_COLUMNS_ORDER; import static mage.client.dialog.PreferencesDialog.KEY_TOURNAMENT_PLAYER_COLUMNS_ORDER;
import static mage.client.dialog.PreferencesDialog.KEY_TOURNAMENT_PLAYER_COLUMNS_WIDTH; import static mage.client.dialog.PreferencesDialog.KEY_TOURNAMENT_PLAYER_COLUMNS_WIDTH;
import mage.client.util.ButtonColumn; import mage.client.util.ButtonColumn;
import mage.client.util.FontSizeHelper;
import mage.client.util.Format; import mage.client.util.Format;
import mage.client.util.gui.TableUtil; import mage.client.util.gui.TableUtil;
import mage.client.util.gui.countryBox.CountryCellRenderer; import mage.client.util.gui.countryBox.CountryCellRenderer;
@ -105,6 +108,8 @@ public class TournamentPanel extends javax.swing.JPanel {
tableMatches.createDefaultColumnsFromModel(); tableMatches.createDefaultColumnsFromModel();
TableUtil.setColumnWidthAndOrder(tableMatches, DEFAULT_COLUMNS_WIDTH_MATCHES, KEY_TOURNAMENT_MATCH_COLUMNS_WIDTH, KEY_TOURNAMENT_MATCH_COLUMNS_ORDER); TableUtil.setColumnWidthAndOrder(tableMatches, DEFAULT_COLUMNS_WIDTH_MATCHES, KEY_TOURNAMENT_MATCH_COLUMNS_WIDTH, KEY_TOURNAMENT_MATCH_COLUMNS_ORDER);
setGUISize();
chatPanel1.useExtendedView(ChatPanelBasic.VIEW_MODE.NONE); chatPanel1.useExtendedView(ChatPanelBasic.VIEW_MODE.NONE);
chatPanel1.setChatType(ChatPanelBasic.ChatType.TOURNAMENT); chatPanel1.setChatType(ChatPanelBasic.ChatType.TOURNAMENT);
@ -142,6 +147,18 @@ public class TournamentPanel extends javax.swing.JPanel {
} }
public void changeGUISize() {
setGUISize();
}
private void setGUISize() {
Font font = FontSizeHelper.getTableFont();
tablePlayers.getTableHeader().setFont(font);
tablePlayers.getTableHeader().setPreferredSize(new Dimension(FontSizeHelper.tableHeaderHeight, FontSizeHelper.tableHeaderHeight));
tableMatches.getTableHeader().setFont(font);
tableMatches.getTableHeader().setPreferredSize(new Dimension(FontSizeHelper.tableHeaderHeight, FontSizeHelper.tableHeaderHeight));
}
private void saveDividerLocations() { private void saveDividerLocations() {
// save panel sizes and divider locations. // save panel sizes and divider locations.
Rectangle rec = MageFrame.getDesktop().getBounds(); Rectangle rec = MageFrame.getDesktop().getBounds();

View file

@ -16,6 +16,13 @@ import mage.client.dialog.PreferencesDialog;
*/ */
public class FontSizeHelper { public class FontSizeHelper {
public static String basicSymbolSize = "small";
public static int symbolCardSize = 15;
public static int symbolTooltipSize = 15;
public static int symbolPaySize = 15;
public static int tableHeaderHeight = 24;
public static int tableRowHeight = 20;
public static Font getChatFont() { public static Font getChatFont() {
int fontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_FONT_SIZE, 14); int fontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_FONT_SIZE, 14);
return new java.awt.Font("Arial", 0, fontSize); return new java.awt.Font("Arial", 0, fontSize);
@ -42,9 +49,34 @@ public class FontSizeHelper {
} }
public static void changeGUISize() { public static void changeGUISize() {
setGUISize();
for (ChatPanelBasic chatPanel : MageFrame.getChatPanels().values()) { for (ChatPanelBasic chatPanel : MageFrame.getChatPanels().values()) {
chatPanel.changeGUISize(getChatFont()); chatPanel.changeGUISize(getChatFont());
} }
MageFrame.getInstance().changeGUISize(); MageFrame.getInstance().changeGUISize();
} }
public static void setGUISize() {
// Set basic symbol size
int fontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_FONT_SIZE, 14);
if (fontSize < 25) {
basicSymbolSize = "small";
} else if (fontSize < 45) {
basicSymbolSize = "medium";
} else {
basicSymbolSize = "large";
}
if (fontSize > 15) {
symbolTooltipSize = fontSize - 5;
symbolPaySize = fontSize - 5;
symbolCardSize = fontSize - 5;
} else {
symbolTooltipSize = fontSize;
symbolPaySize = fontSize;
symbolCardSize = fontSize;
}
tableRowHeight = fontSize + 4;
tableHeaderHeight = fontSize + 10;
}
} }

View file

@ -1,14 +1,14 @@
package mage.client.util.stats; package mage.client.util.stats;
import org.apache.log4j.Logger;
import javax.swing.*;
import java.util.List; import java.util.List;
import java.util.concurrent.CancellationException; import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import javax.swing.*;
import org.apache.log4j.Logger;
/** /**
* This updates the mem usage info in the Mage client every MEM_USAGE_UPDATE_TIME ms. * This updates the mem usage info in the Mage client every
* MEM_USAGE_UPDATE_TIME ms.
* *
* @author noxx * @author noxx
*/ */
@ -16,9 +16,9 @@ public class UpdateMemUsageTask extends SwingWorker<Void, Float> {
private static final int MEM_USAGE_UPDATE_TIME = 2000; private static final int MEM_USAGE_UPDATE_TIME = 2000;
private JLabel jLabelToDisplayInfo; private final JLabel jLabelToDisplayInfo;
private static final Logger logger = Logger.getLogger(UpdateMemUsageTask.class); private static final Logger LOGGER = Logger.getLogger(UpdateMemUsageTask.class);
public UpdateMemUsageTask(JLabel jLabelToDisplayInfo) { public UpdateMemUsageTask(JLabel jLabelToDisplayInfo) {
this.jLabelToDisplayInfo = jLabelToDisplayInfo; this.jLabelToDisplayInfo = jLabelToDisplayInfo;
@ -28,7 +28,7 @@ public class UpdateMemUsageTask extends SwingWorker<Void, Float> {
protected Void doInBackground() throws Exception { protected Void doInBackground() throws Exception {
while (!isCancelled()) { while (!isCancelled()) {
float memUsage = MemoryUsageStatUtil.getMemoryFreeStatPercentage(); float memUsage = MemoryUsageStatUtil.getMemoryFreeStatPercentage();
this.publish(memUsage >= 0 ? Float.valueOf(memUsage) : null); this.publish(memUsage >= 0 ? memUsage : null);
Thread.sleep(MEM_USAGE_UPDATE_TIME); Thread.sleep(MEM_USAGE_UPDATE_TIME);
} }
return null; return null;
@ -51,8 +51,9 @@ public class UpdateMemUsageTask extends SwingWorker<Void, Float> {
try { try {
get(); get();
} catch (InterruptedException | ExecutionException ex) { } catch (InterruptedException | ExecutionException ex) {
logger.fatal("Update Memory Usage error", ex); LOGGER.fatal("Update Memory Usage error", ex);
} catch (CancellationException ex) {} } catch (CancellationException ex) {
}
} }
} }

View file

@ -14,6 +14,7 @@ import java.util.regex.Pattern;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import mage.cards.repository.ExpansionRepository; import mage.cards.repository.ExpansionRepository;
import mage.client.dialog.PreferencesDialog; import mage.client.dialog.PreferencesDialog;
import mage.client.util.FontSizeHelper;
import mage.client.util.ImageHelper; import mage.client.util.ImageHelper;
import mage.client.util.gui.BufferedImageBuilder; import mage.client.util.gui.BufferedImageBuilder;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -21,12 +22,12 @@ import org.mage.plugins.card.constants.Constants;
public class ManaSymbols { public class ManaSymbols {
private static final Logger log = Logger.getLogger(ManaSymbols.class); private static final Logger LOGGER = Logger.getLogger(ManaSymbols.class);
private static final Map<String, BufferedImage> manaImages = new HashMap<>(); private static final Map<String, BufferedImage> MANA_IMAGES = new HashMap<>();
private static final Map<String, Image> manaImagesOriginal = new HashMap<>(); private static final Map<String, Image> MANA_IMAGES_ORIGINAL = new HashMap<>();
private static final Map<String, Image> setImages = new HashMap<>(); private static final Map<String, Image> SET_IMAGES = new HashMap<>();
private static final Map<String, Dimension> setImagesExist = new HashMap<>(); private static final Map<String, Dimension> SET_IMAGES_EXIST = new HashMap<>();
private static final Pattern replaceSymbolsPattern = Pattern.compile("\\{([^}/]*)/?([^}]*)\\}"); private static final Pattern REPLACE_SYMBOLS_PATTERN = Pattern.compile("\\{([^}/]*)/?([^}]*)\\}");
private static String cachedPath; private static String cachedPath;
public static void loadImages() { public static void loadImages() {
@ -40,21 +41,21 @@ public class ManaSymbols {
try { try {
Image image = UI.getImageIcon(file.getAbsolutePath()).getImage(); Image image = UI.getImageIcon(file.getAbsolutePath()).getImage();
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r); BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
manaImages.put(symbol, resized); MANA_IMAGES.put(symbol, resized);
} catch (Exception e) { } catch (Exception e) {
log.error("Error for symbol:" + symbol); LOGGER.error("Error for symbol:" + symbol);
} }
file = new File(getSymbolsPath() + Constants.RESOURCE_PATH_MANA_MEDIUM + "/" + symbol + ".jpg"); file = new File(getSymbolsPath() + Constants.RESOURCE_PATH_MANA_MEDIUM + "/" + symbol + ".jpg");
try { try {
Image image = UI.getImageIcon(file.getAbsolutePath()).getImage(); Image image = UI.getImageIcon(file.getAbsolutePath()).getImage();
manaImagesOriginal.put(symbol, image); MANA_IMAGES_ORIGINAL.put(symbol, image);
} catch (Exception e) { } catch (Exception e) {
} }
} }
List<String> setCodes = ExpansionRepository.instance.getSetCodes(); List<String> setCodes = ExpansionRepository.instance.getSetCodes();
if (setCodes == null) { if (setCodes == null) {
// the cards db file is probaly not included in the client. It will be created after the first connect to a server. // the cards db file is probaly not included in the client. It will be created after the first connect to a server.
log.warn("No db information for sets found. Connect to a server to create database file on client side. Then try to restart the client."); LOGGER.warn("No db information for sets found. Connect to a server to create database file on client side. Then try to restart the client.");
return; return;
} }
for (String set : setCodes) { for (String set : setCodes) {
@ -67,10 +68,10 @@ public class ManaSymbols {
if (h > 0) { if (h > 0) {
Rectangle r = new Rectangle(21, (int) (h * 21.0f / width)); Rectangle r = new Rectangle(21, (int) (h * 21.0f / width));
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r); BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
setImages.put(set, resized); SET_IMAGES.put(set, resized);
} }
} else { } else {
setImages.put(set, image); SET_IMAGES.put(set, image);
} }
} catch (Exception e) { } catch (Exception e) {
} }
@ -123,7 +124,7 @@ public class ManaSymbols {
Image image = UI.getImageIcon(file.getAbsolutePath()).getImage(); Image image = UI.getImageIcon(file.getAbsolutePath()).getImage();
int width = image.getWidth(null); int width = image.getWidth(null);
int height = image.getHeight(null); int height = image.getHeight(null);
setImagesExist.put(set, new Dimension(width, height)); SET_IMAGES_EXIST.put(set, new Dimension(width, height));
} catch (Exception e) { } catch (Exception e) {
} }
} }
@ -158,7 +159,7 @@ public class ManaSymbols {
} }
public static Image getManaSymbolImage(String symbol) { public static Image getManaSymbolImage(String symbol) {
return manaImagesOriginal.get(symbol); return MANA_IMAGES_ORIGINAL.get(symbol);
} }
public static void draw(Graphics g, String manaCost, int x, int y) { public static void draw(Graphics g, String manaCost, int x, int y) {
@ -170,7 +171,7 @@ public class ManaSymbols {
StringTokenizer tok = new StringTokenizer(manaCost, " "); StringTokenizer tok = new StringTokenizer(manaCost, " ");
while (tok.hasMoreTokens()) { while (tok.hasMoreTokens()) {
String symbol = tok.nextToken().substring(0); String symbol = tok.nextToken().substring(0);
Image image = manaImages.get(symbol); Image image = MANA_IMAGES.get(symbol);
if (image == null) { if (image == null) {
//log.error("Symbol not recognized \"" + symbol + "\" in mana cost: " + manaCost); //log.error("Symbol not recognized \"" + symbol + "\" in mana cost: " + manaCost);
continue; continue;
@ -210,15 +211,29 @@ public class ManaSymbols {
value = value.replace("{source}", "|source|"); value = value.replace("{source}", "|source|");
value = value.replace("{this}", "|this|"); value = value.replace("{this}", "|this|");
String replaced = value; String replaced = value;
if (!manaImages.isEmpty()) {
if (type.equals(Type.TOOLTIP)) { if (!MANA_IMAGES.isEmpty()) {
replaced = replaceSymbolsPattern.matcher(value).replaceAll("<img src='file:" + getSymbolsPath(true) + "/symbols/small/$1$2.jpg' alt='$1$2' width=11 height=11>"); switch (type) {
} else if (type.equals(Type.CARD)) { case TOOLTIP:
replaced = REPLACE_SYMBOLS_PATTERN.matcher(value).replaceAll("<img src='file:" + getSymbolsPath(true) + "/symbols/small/$1$2.jpg' alt='$1$2' width=11 height=11>");
// replaced = REPLACE_SYMBOLS_PATTERN.matcher(value).replaceAll("<img src='file:" + getSymbolsPath(true)
// + "/symbols/" + FontSizeHelper.basicSymbolSize + "/$1$2.jpg' alt='$1$2' width="
// + FontSizeHelper.symbolTooltipSize + " height=" + FontSizeHelper.symbolTooltipSize + ">");
break;
case CARD:
value = value.replace("{slash}", "<img src='file:" + getSymbolsPath() + "/symbols/medium/slash.jpg' alt='slash' width=10 height=13>"); value = value.replace("{slash}", "<img src='file:" + getSymbolsPath() + "/symbols/medium/slash.jpg' alt='slash' width=10 height=13>");
replaced = replaceSymbolsPattern.matcher(value).replaceAll("<img src='file:" + getSymbolsPath(true) + "/symbols/medium/$1$2.jpg' alt='$1$2' width=12 height=12>"); replaced = REPLACE_SYMBOLS_PATTERN.matcher(value).replaceAll("<img src='file:" + getSymbolsPath(true)
} else if (type.equals(Type.PAY)) { + "/symbols/" + FontSizeHelper.basicSymbolSize + "/$1$2.jpg' alt='$1$2' width="
+ FontSizeHelper.symbolCardSize + " height=" + FontSizeHelper.symbolCardSize + ">");
break;
case PAY:
value = value.replace("{slash}", "<img src='file:" + getSymbolsPath() + "/symbols/medium/slash.jpg' alt='slash' width=10 height=13>"); value = value.replace("{slash}", "<img src='file:" + getSymbolsPath() + "/symbols/medium/slash.jpg' alt='slash' width=10 height=13>");
replaced = replaceSymbolsPattern.matcher(value).replaceAll("<img src='file:" + getSymbolsPath(true) + "/symbols/medium/$1$2.jpg' alt='$1$2' width=15 height=15>"); replaced = REPLACE_SYMBOLS_PATTERN.matcher(value).replaceAll("<img src='file:" + getSymbolsPath(true)
+ "/symbols/" + FontSizeHelper.basicSymbolSize + "/$1$2.jpg' alt='$1$2' "
+ "width=" + FontSizeHelper.symbolPaySize + " height=" + FontSizeHelper.symbolPaySize + ">");
break;
default:
break;
} }
} }
replaced = replaced.replace("|source|", "{source}"); replaced = replaced.replace("|source|", "{source}");
@ -228,9 +243,9 @@ public class ManaSymbols {
public static String replaceSetCodeWithHTML(String set, String rarity) { public static String replaceSetCodeWithHTML(String set, String rarity) {
String _set = set; String _set = set;
if (setImagesExist.containsKey(_set)) { if (SET_IMAGES_EXIST.containsKey(_set)) {
Integer width = setImagesExist.get(_set).width; Integer width = SET_IMAGES_EXIST.get(_set).width;
Integer height = setImagesExist.get(_set).height; Integer height = SET_IMAGES_EXIST.get(_set).height;
return "<img src='file:" + getSymbolsPath() + "/sets/small/" + _set + "-" + rarity + ".png' alt='" + rarity + " ' width=" + width + " height=" + height + ">"; return "<img src='file:" + getSymbolsPath() + "/sets/small/" + _set + "-" + rarity + ".png' alt='" + rarity + " ' width=" + width + " height=" + height + ">";
} else { } else {
return set; return set;
@ -238,10 +253,10 @@ public class ManaSymbols {
} }
public static Image getSetSymbolImage(String set) { public static Image getSetSymbolImage(String set) {
return setImages.get(set); return SET_IMAGES.get(set);
} }
public static BufferedImage getManaSymbolImageSmall(String symbol) { public static BufferedImage getManaSymbolImageSmall(String symbol) {
return manaImages.get(symbol); return MANA_IMAGES.get(symbol);
} }
} }