fixed some mac issues

This commit is contained in:
hneemann 2017-06-09 12:29:50 +02:00
parent 097e48faf1
commit 8932e8597e
3 changed files with 22 additions and 13 deletions

View File

@ -11,7 +11,7 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import static de.neemann.digital.gui.Settings.isLinux;
import static de.neemann.gui.Screen.isLinux;
/**
* Starts a fitter to create a JEDEC file.

View File

@ -104,13 +104,5 @@ public final class Settings implements AttributeListener {
return settingsKeys;
}
/**
* @return true if running on a windows system
*/
public static boolean isLinux() {
String name = System.getProperty("os.name").toLowerCase();
return name.contains("linux");
}
}

View File

@ -19,6 +19,9 @@ import java.awt.geom.AffineTransform;
* Created by hneemann on 09.05.17.
*/
public final class Screen {
private static final String OS = System.getProperty("os.name").toLowerCase();
private static final boolean IS_LINUX = OS.contains("linux");
private static final boolean IS_MAC = OS.contains("mac");
private static final class InstanceHolder {
private static Screen instance = new Screen();
@ -58,6 +61,9 @@ public final class Screen {
* @return the default font scaling in percent
*/
public static int getDefaultFontScaling() {
if (IS_MAC) // macOS has its own retina handling
return 100;
int dpi = getDefaultScreenResolution();
int s = (dpi * 100) / 96;
if (s > 95 && s < 105)
@ -78,10 +84,13 @@ public final class Screen {
for (Object key : javax.swing.UIManager.getLookAndFeel().getDefaults().keySet()) {
if (key.toString().endsWith(".font"))
javax.swing.UIManager.put(key, font);
if (key.toString().endsWith(".icon") || key.toString().endsWith("Icon")) {
Icon icon = UIManager.getIcon(key);
if (icon != null)
javax.swing.UIManager.put(key, new ScaleIcon(icon, scaling));
if (!IS_MAC) { // macOS has its own icon handling
if (key.toString().endsWith(".icon") || key.toString().endsWith("Icon")) {
Icon icon = UIManager.getIcon(key);
if (icon != null)
javax.swing.UIManager.put(key, new ScaleIcon(icon, scaling));
}
}
}
UIManager.put("ScrollBar.width", size * 17 / 12);
@ -169,4 +178,12 @@ public final class Screen {
else
return new Dimension((int) (dimension.width * scaling), (int) (dimension.height * scaling));
}
/**
* @return true if running on a windows system
*/
public static boolean isLinux() {
return IS_LINUX;
}
}