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

View file

@ -26,7 +26,7 @@
* or implied, of BetaSteward_at_googlemail.com.
*/
/*
/*
* CardsList.java
*
* Created on Dec 18, 2009, 10:40:12 AM
@ -36,6 +36,7 @@ package mage.client.cards;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@ -72,6 +73,7 @@ import mage.client.util.CardViewNameComparator;
import mage.client.util.CardViewRarityComparator;
import mage.client.util.Config;
import mage.client.util.Event;
import mage.client.util.FontSizeHelper;
import mage.client.util.Listener;
import mage.client.util.gui.TableSpinnerEditor;
import mage.constants.CardType;
@ -105,6 +107,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
initComponents();
makeTransparent();
initListViewComponents();
setGUISize();
}
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() {
panelCardArea.setOpaque(false);
cardArea.setOpaque(false);

View file

@ -24,18 +24,19 @@
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
*/
/*
/*
* CardSelector.java
*
* Created on Feb 18, 2010, 2:49:03 PM
*/
package mage.client.deckeditor;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
@ -64,6 +65,7 @@ import mage.client.cards.CardGrid;
import mage.client.cards.ICardGrid;
import mage.client.constants.Constants.SortBy;
import mage.client.deckeditor.table.TableModel;
import mage.client.util.FontSizeHelper;
import mage.client.util.sets.ConstructedFormats;
import mage.constants.CardType;
import mage.filter.FilterCard;
@ -76,7 +78,6 @@ import mage.filter.predicate.other.CardTextPredicate;
import mage.filter.predicate.other.ExpansionSetPredicate;
import mage.view.CardsView;
/**
*
* @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() {
sortSetting = SortSettingBase.getInstance();
initComponents();
cardGrid = new CardGrid();
makeTransparent();
initListViewComponents();
setGUISize();
currentView = mainModel; // by default we use List View
}
@ -178,7 +182,17 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
this.mainModel.clear();
}
public void switchToGrid(){
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() {
jToggleListView.setSelected(false);
jToggleCardView.setSelected(true);
currentView = cardGrid;
@ -199,7 +213,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
this.cbExpansionSet.setVisible(false);
this.limited = true;
this.cards.clear();
for (Card card: sideboard) {
for (Card card : sideboard) {
this.cards.add(card);
}
filterCards();
@ -268,7 +282,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
}
filter.add(Predicates.or(predicates));
if (this.cbExpansionSet.isVisible()) {
String expansionSelection = this.cbExpansionSet.getSelectedItem().toString();
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.CONSPIRACY);
if (this.cbExpansionSet.isVisible()) {
String expansionSelection = this.cbExpansionSet.getSelectedItem().toString();
if (!expansionSelection.equals("- All Sets")) {
@ -373,13 +384,12 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
List<Card> filteredCards = new ArrayList<>();
setCursor(new Cursor(Cursor.WAIT_CURSOR));
if (limited) {
for (Card card: cards) {
for (Card card : cards) {
if (filter.match(card, null)) {
filteredCards.add(card);
}
}
}
else {
} else {
List<CardInfo> foundCards = CardRepository.instance.findCards(buildCriteria());
for (CardInfo cardInfo : foundCards) {
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.cardCount.setText(String.valueOf(filteredCards.size()));
}
finally {
} finally {
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
}
@ -413,7 +422,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
public void removeCard(UUID cardId) {
this.mainModel.removeCard(cardId);
this.cardGrid.removeCard(cardId);
for (Card card: cards) {
for (Card card : cards) {
if (card.getId().equals(cardId)) {
cards.remove(card);
break;
@ -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.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <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);
}//GEN-LAST:event_jButtonRemoveFromSideboardActionPerformed
private void jButtonSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSearchActionPerformed
filterCards();
}//GEN-LAST:event_jButtonSearchActionPerformed

View file

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

View file

@ -24,14 +24,13 @@
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
*/
/*
/*
* DeckEditorPane.java
*
* Created on Dec 17, 2009, 9:21:42 AM
*/
package mage.client.deckeditor;
import java.awt.Component;
@ -44,14 +43,15 @@ import mage.client.MagePane;
import mage.client.constants.Constants.DeckEditorMode;
import mage.client.plugins.impl.Plugins;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class DeckEditorPane extends MagePane {
/** Creates new form TablesPane */
/**
* Creates new form TablesPane
*/
public DeckEditorPane() {
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
boolean initialized = false;
@ -75,14 +75,10 @@ public class DeckEditorPane extends MagePane {
public void show(DeckEditorMode mode, Deck deck, String name, UUID tableId, int time) {
if (mode == DeckEditorMode.SIDEBOARDING || mode == DeckEditorMode.LIMITED_BUILDING) {
this.setTitle("Deck Editor - " + tableId.toString());
}
else {
if (deck != null) {
this.setTitle("Deck Editor - " + deck.getName());
}
else {
this.setTitle("Deck Editor");
}
} else if (deck != null) {
this.setTitle("Deck Editor - " + deck.getName());
} else {
this.setTitle("Deck Editor");
}
this.deckEditorPanel1.showDeckEditor(mode, deck, tableId, time);
this.repaint();
@ -92,10 +88,10 @@ public class DeckEditorPane extends MagePane {
return this.deckEditorPanel1.getDeckEditorMode();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
@ -122,17 +118,21 @@ public class DeckEditorPane extends MagePane {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 885, Short.MAX_VALUE)
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 885, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 626, Short.MAX_VALUE)
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 626, Short.MAX_VALUE)
);
pack();
}
public DeckEditorPanel getPanel() {
return deckEditorPanel1;
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private mage.client.deckeditor.DeckEditorPanel deckEditorPanel1;
// 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 {
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 fcImportDeck;
private Deck deck = new Deck();
@ -109,20 +109,20 @@ public class DeckEditorPanel extends javax.swing.JPanel {
jSplitPane1.setOpaque(false);
countdown = new Timer(1000,
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (--timeout > 0) {
setTimeout(timeout);
} else {
if (updateDeckTask != null) {
updateDeckTask.cancel(true);
}
setTimeout(0);
countdown.stop();
removeDeckEditor();
}
@Override
public void actionPerformed(ActionEvent e) {
if (--timeout > 0) {
setTimeout(timeout);
} else {
if (updateDeckTask != null) {
updateDeckTask.cancel(true);
}
});
setTimeout(0);
countdown.stop();
removeDeckEditor();
}
}
});
}
/**
@ -147,6 +147,11 @@ public class DeckEditorPanel extends javax.swing.JPanel {
this.bigCard = null;
}
public void changeGUISize() {
this.cardSelector.changeGUISize();
this.deckArea.changeGUISize();
}
public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId, int time) {
if (deck != null) {
this.deck = deck;
@ -209,145 +214,145 @@ public class DeckEditorPanel extends javax.swing.JPanel {
component.clearCardEventListeners();
component.addCardEventListener(
new Listener<Event>() {
@Override
public void event(Event event) {
switch (event.getEventName()) {
case "double-click":
moveSelectorCardToDeck(event);
break;
case "alt-double-click":
if (mode == DeckEditorMode.FREE_BUILDING) {
moveSelectorCardToSideboard(event);
} else {
// because in match mode selector is used as sideboard the card goes to deck also for shift click
moveSelectorCardToDeck(event);
}
break;
case "remove-main":
DeckEditorPanel.this.deckArea.getDeckList().handleDoubleClick();
break;
case "remove-sideboard":
DeckEditorPanel.this.deckArea.getSideboardList().handleDoubleClick();
break;
@Override
public void event(Event event) {
switch (event.getEventName()) {
case "double-click":
moveSelectorCardToDeck(event);
break;
case "alt-double-click":
if (mode == DeckEditorMode.FREE_BUILDING) {
moveSelectorCardToSideboard(event);
} else {
// because in match mode selector is used as sideboard the card goes to deck also for shift click
moveSelectorCardToDeck(event);
}
refreshDeck();
}
});
break;
case "remove-main":
DeckEditorPanel.this.deckArea.getDeckList().handleDoubleClick();
break;
case "remove-sideboard":
DeckEditorPanel.this.deckArea.getSideboardList().handleDoubleClick();
break;
}
refreshDeck();
}
});
}
this.deckArea.clearDeckEventListeners();
this.deckArea.addDeckEventListener(
new Listener<Event>() {
@Override
public void event(Event event) {
if (mode.equals(DeckEditorMode.FREE_BUILDING)) {
switch (event.getEventName()) {
case "double-click": {
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getCards()) {
if (card.getId().equals(cardView.getId())) {
deck.getCards().remove(card);
break;
}
}
hidePopup();
refreshDeck();
break;
}
case "alt-double-click": {
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getCards()) {
if (card.getId().equals(cardView.getId())) {
deck.getCards().remove(card);
deck.getSideboard().add(card);
break;
}
}
hidePopup();
refreshDeck();
break;
}
case "set-number": {
setCardNumberToCardsList(event, deck.getCards());
}
}
} else {
// constructing phase or sideboarding during match -> card goes always to sideboard
switch (event.getEventName()) {
case "double-click":
case "alt-double-click": {
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getCards()) {
if (card.getId().equals(cardView.getId())) {
deck.getCards().remove(card);
deck.getSideboard().add(card);
cardSelector.loadSideboard(new ArrayList<>(deck.getSideboard()), getBigCard());
break;
}
}
hidePopup();
refreshDeck();
@Override
public void event(Event event) {
if (mode.equals(DeckEditorMode.FREE_BUILDING)) {
switch (event.getEventName()) {
case "double-click": {
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getCards()) {
if (card.getId().equals(cardView.getId())) {
deck.getCards().remove(card);
break;
}
}
hidePopup();
refreshDeck();
break;
}
case "alt-double-click": {
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getCards()) {
if (card.getId().equals(cardView.getId())) {
deck.getCards().remove(card);
deck.getSideboard().add(card);
break;
}
}
hidePopup();
refreshDeck();
break;
}
case "set-number": {
setCardNumberToCardsList(event, deck.getCards());
}
}
});
} else {
// constructing phase or sideboarding during match -> card goes always to sideboard
switch (event.getEventName()) {
case "double-click":
case "alt-double-click": {
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getCards()) {
if (card.getId().equals(cardView.getId())) {
deck.getCards().remove(card);
deck.getSideboard().add(card);
cardSelector.loadSideboard(new ArrayList<>(deck.getSideboard()), getBigCard());
break;
}
}
hidePopup();
refreshDeck();
break;
}
}
}
}
});
this.deckArea.addSideboardEventListener(
new Listener<Event>() {
@Override
public void event(Event event) {
if (mode.equals(DeckEditorMode.FREE_BUILDING)) {
// normal edit mode
switch (event.getEventName()) {
case "double-click":
// remove card from sideboard (don't add it to deck)
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getSideboard()) {
if (card.getId().equals(cardView.getId())) {
deck.getSideboard().remove(card);
break;
}
}
hidePopup();
refreshDeck();
@Override
public void event(Event event) {
if (mode.equals(DeckEditorMode.FREE_BUILDING)) {
// normal edit mode
switch (event.getEventName()) {
case "double-click":
// remove card from sideboard (don't add it to deck)
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getSideboard()) {
if (card.getId().equals(cardView.getId())) {
deck.getSideboard().remove(card);
break;
case "alt-double-click":
// remove card from sideboard
cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getSideboard()) {
if (card.getId().equals(cardView.getId())) {
deck.getSideboard().remove(card);
deck.getCards().add(card);
break;
}
}
hidePopup();
refreshDeck();
break;
case "set-number": {
setCardNumberToCardsList(event, deck.getSideboard());
}
}
} else {
// construct phase or sideboarding during match
switch (event.getEventName()) {
case "double-click":
case "alt-double-click":
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getSideboard()) {
if (card.getId().equals(cardView.getId())) {
deck.getSideboard().remove(card);
deck.getCards().add(card);
break;
}
}
hidePopup();
refreshDeck();
hidePopup();
refreshDeck();
break;
case "alt-double-click":
// remove card from sideboard
cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getSideboard()) {
if (card.getId().equals(cardView.getId())) {
deck.getSideboard().remove(card);
deck.getCards().add(card);
break;
}
}
hidePopup();
refreshDeck();
break;
case "set-number": {
setCardNumberToCardsList(event, deck.getSideboard());
}
}
});
} else {
// construct phase or sideboarding during match
switch (event.getEventName()) {
case "double-click":
case "alt-double-click":
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getSideboard()) {
if (card.getId().equals(cardView.getId())) {
deck.getSideboard().remove(card);
deck.getCards().add(card);
break;
}
}
hidePopup();
refreshDeck();
break;
}
}
}
});
refreshDeck();
this.setVisible(true);
@ -685,7 +690,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
} catch (GameException ex) {
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error loading deck", JOptionPane.ERROR_MESSAGE);
} catch (Exception ex) {
logger.fatal(ex);
LOGGER.fatal(ex);
} finally {
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
@ -717,7 +722,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
setCursor(new Cursor(Cursor.WAIT_CURSOR));
Sets.saveDeck(fileName, deck.getDeckCardLists());
} catch (Exception ex) {
logger.fatal(ex);
LOGGER.fatal(ex);
} finally {
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);
}
} catch (Exception ex) {
logger.fatal(ex);
LOGGER.fatal(ex);
} finally {
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
@ -872,7 +877,7 @@ class ImportFilter extends FileFilter {
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 UUID tableId;
private final Deck deck;
@ -897,7 +902,7 @@ class UpdateDeckTask extends SwingWorker<Void, Void> {
try {
get();
} catch (InterruptedException | ExecutionException ex) {
logger.fatal("Update Matches Task error", ex);
LOGGER.fatal("Update Matches Task error", ex);
} catch (CancellationException ex) {
}
}

View file

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

View file

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

View file

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

View file

@ -34,6 +34,8 @@
package mage.client.tournament;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
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_WIDTH;
import mage.client.util.ButtonColumn;
import mage.client.util.FontSizeHelper;
import mage.client.util.Format;
import mage.client.util.gui.TableUtil;
import mage.client.util.gui.countryBox.CountryCellRenderer;
@ -105,6 +108,8 @@ public class TournamentPanel extends javax.swing.JPanel {
tableMatches.createDefaultColumnsFromModel();
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.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() {
// save panel sizes and divider locations.
Rectangle rec = MageFrame.getDesktop().getBounds();

View file

@ -16,6 +16,13 @@ import mage.client.dialog.PreferencesDialog;
*/
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() {
int fontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_FONT_SIZE, 14);
return new java.awt.Font("Arial", 0, fontSize);
@ -42,9 +49,34 @@ public class FontSizeHelper {
}
public static void changeGUISize() {
setGUISize();
for (ChatPanelBasic chatPanel : MageFrame.getChatPanels().values()) {
chatPanel.changeGUISize(getChatFont());
}
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;
import org.apache.log4j.Logger;
import javax.swing.*;
import java.util.List;
import java.util.concurrent.CancellationException;
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
*/
@ -16,9 +16,9 @@ public class UpdateMemUsageTask extends SwingWorker<Void, Float> {
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) {
this.jLabelToDisplayInfo = jLabelToDisplayInfo;
@ -28,7 +28,7 @@ public class UpdateMemUsageTask extends SwingWorker<Void, Float> {
protected Void doInBackground() throws Exception {
while (!isCancelled()) {
float memUsage = MemoryUsageStatUtil.getMemoryFreeStatPercentage();
this.publish(memUsage >= 0 ? Float.valueOf(memUsage) : null);
this.publish(memUsage >= 0 ? memUsage : null);
Thread.sleep(MEM_USAGE_UPDATE_TIME);
}
return null;
@ -51,8 +51,9 @@ public class UpdateMemUsageTask extends SwingWorker<Void, Float> {
try {
get();
} catch (InterruptedException | ExecutionException ex) {
logger.fatal("Update Memory Usage error", ex);
} catch (CancellationException ex) {}
LOGGER.fatal("Update Memory Usage error", ex);
} catch (CancellationException ex) {
}
}
}

View file

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