Move getDPI to GUIUtil.

This commit is contained in:
Kevin Ruland 2011-12-12 21:24:01 +00:00
parent 27ee867e27
commit 50feb2c612
3 changed files with 25 additions and 23 deletions

View File

@ -9,7 +9,7 @@ import java.util.List;
import javax.swing.JPanel;
import net.sf.openrocket.util.Prefs;
import net.sf.openrocket.gui.util.GUIUtil;
import net.sf.openrocket.util.StateChangeListener;
@ -32,7 +32,7 @@ public abstract class AbstractScaleFigure extends JPanel implements ScaleFigure
public AbstractScaleFigure() {
this.dpi = Prefs.getDPI();
this.dpi = GUIUtil.getDPI();
this.scaling = 1.0;
this.scale = dpi / 0.0254 * scaling;

View File

@ -7,6 +7,7 @@ import java.awt.Font;
import java.awt.Image;
import java.awt.KeyboardFocusManager;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@ -108,7 +109,26 @@ public class GUIUtil {
}
}
/**
* Return the DPI setting of the monitor. This is either the setting provided
* by the system or a user-specified DPI setting.
*
* @return the DPI setting to use.
*/
public static double getDPI() {
int dpi = Prefs.getInt("DPI", 0); // Tenths of a dpi
if (dpi < 10) {
dpi = Toolkit.getDefaultToolkit().getScreenResolution() * 10;
}
if (dpi < 10)
dpi = 960;
return (dpi) / 10.0;
}
/**
* Set suitable options for a single-use disposable dialog. This includes

View File

@ -3,7 +3,6 @@ package net.sf.openrocket.util;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Toolkit;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@ -591,31 +590,14 @@ public class Prefs {
}
/**
* Return the DPI setting of the monitor. This is either the setting provided
* by the system or a user-specified DPI setting.
*
* @return the DPI setting to use.
*/
public static double getDPI() {
int dpi = PREFNODE.getInt("DPI", 0); // Tenths of a dpi
if (dpi < 10) {
dpi = Toolkit.getDefaultToolkit().getScreenResolution() * 10;
}
if (dpi < 10)
dpi = 960;
return (dpi) / 10.0;
}
public static double getDefaultMach() {
// TODO: HIGH: implement custom default mach number
return 0.3;
}
public static int getInt( String key, int defaultValue ) {
return PREFNODE.getInt(key, defaultValue);
}
public static Material getDefaultComponentMaterial(