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

@ -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) {
}
}
}
}