added dpi setting under linux

This commit is contained in:
hneemann 2017-06-06 17:39:27 +02:00
parent 93a576c2e1
commit 5783cf6a82
7 changed files with 54 additions and 23 deletions

View File

@ -11,6 +11,8 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import static de.neemann.digital.gui.Settings.isLinux;
/**
* Starts a fitter to create a JEDEC file.
* Created by hneemann on 10.03.17.
@ -62,11 +64,6 @@ public class StartATF1502Fitter implements ExpressionToFileExporter.PostProcess
}
}
private boolean isLinux() {
String name = System.getProperty("os.name").toLowerCase();
return name.contains("linux");
}
@Override
public String toString() {
return Lang.get("msg_startExternalFitter");

View File

@ -361,4 +361,20 @@ public final class Keys {
= new Key<>("inverterConfig", new InverterConfig());
/**
* the screen resolution
*/
public static final Key<Integer> SETTINGS_SCREEN_RESOLUTION =
new Key.KeyInteger("screenResolution", getDefaultScreenResolution())
.setComboBoxValues(new Integer[]{95, 120, 150, 180, 200, 250, 300})
.setMin(95)
.setMax(400);
private static int getDefaultScreenResolution() {
try {
return Toolkit.getDefaultToolkit().getScreenResolution();
} catch (HeadlessException e) {
return 95;
}
}
}

View File

@ -560,7 +560,8 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
if (modified != null) {
FormatToExpression.setDefaultFormat(modified.get(Keys.SETTINGS_EXPRESSION_FORMAT));
if (!Settings.getInstance().getAttributes().equalsKey(Keys.SETTINGS_LANGUAGE, modified)
|| !Settings.getInstance().getAttributes().equalsKey(Keys.SETTINGS_IEEE_SHAPES, modified)) {
|| !Settings.getInstance().getAttributes().equalsKey(Keys.SETTINGS_IEEE_SHAPES, modified)
|| !Settings.getInstance().getAttributes().equalsKey(Keys.SETTINGS_SCREEN_RESOLUTION, modified)) {
Lang.setLanguage(modified.get(Keys.SETTINGS_LANGUAGE));
JOptionPane.showMessageDialog(Main.this, Lang.get("msg_restartNeeded"));
}

View File

@ -34,6 +34,8 @@ public final class Settings implements AttributeListener {
INT_LIST.add(Keys.SETTINGS_EXPRESSION_FORMAT);
INT_LIST.add(Keys.SETTINGS_DEFAULT_TREESELECT);
INT_LIST.add(Keys.SETTINGS_ATF1502_FITTER);
if (isLinux())
INT_LIST.add(Keys.SETTINGS_SCREEN_RESOLUTION);
}
private static final class SettingsHolder {
@ -99,5 +101,14 @@ public final class Settings implements AttributeListener {
e.printStackTrace();
}
}
/**
* @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

@ -6,6 +6,9 @@ package de.neemann.gui;
* Linux : getScreenResolution() = 95
*/
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.gui.Settings;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.AffineTransform;
@ -36,25 +39,22 @@ public final class Screen {
Font font = new JLabel().getFont();
float scaling = 1;
int size = 12;
try {
int s = Math.round(Toolkit.getDefaultToolkit().getScreenResolution() * 12 / 96f);
if (s > 12) {
scaling = s / 12f;
size = s;
font = font.deriveFont((float) s);
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));
}
int screenResolution = Settings.getInstance().get(Keys.SETTINGS_SCREEN_RESOLUTION);
int s = Math.round(screenResolution * 12 / 96f);
if (s > 12) {
scaling = s / 12f;
size = s;
font = font.deriveFont((float) s);
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));
}
UIManager.put("ScrollBar.width", size * 17 / 12);
}
} catch (HeadlessException e) {
// run with defaults if headless
UIManager.put("ScrollBar.width", size * 17 / 12);
}
this.scaling = scaling;
this.size = size;

View File

@ -661,6 +661,9 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
<string name="key_defTreeSelect_tt">Wenn gesetzt, wird die Baumansicht beim Start automatisch aktiviert.</string>
<string name="key_inverterConfig">inverse Eingänge</string>
<string name="key_inverterConfig_tt">Es können die Eingänge ausgewählt werden, welche invertiert werden sollen.</string>
<string name="key_screenResolution">Bildschirmauflösung [DPI]</string>
<string name="key_screenResolution_tt">Es kommt vor, dass das OS eine falsche Bildschirmauflösung liefert.
In diesem Fall kann hier ein eigener Wert gesetzt werden.</string>
<string name="mod_insertWire">Leitung eingefügt.</string>
<string name="mod_insertCopied">Aus Zwischenablage eingefügt.</string>

View File

@ -651,6 +651,9 @@ The names of the variables may not be unique.</string>
<string name="key_defTreeSelect_tt">If set, the component tree view is enabled at startup.</string>
<string name="key_inverterConfig">inverted Inputs</string>
<string name="key_inverterConfig_tt">You can select the inputs that are to be inverted.</string>
<string name="key_screenResolution">Screen Resolution [DPI]</string>
<string name="key_screenResolution_tt">Sometimes the OS reports a wrong screen resolution.
In this case, a different value can be set here.</string>
<string name="mod_insertWire">Inserted wire.</string>
<string name="mod_insertCopied">Insert from clipboard.</string>