mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-10 22:17:13 -06:00
SystemInfo:
- renamed public fields from upper-case to mixed-case - added public fields for osVersion and javaVersion - fixed Mac -> MacOS - added orLater to Mojave
This commit is contained in:
@@ -35,7 +35,7 @@ class FlatInputMaps
|
||||
initBasicInputMaps( defaults );
|
||||
initTextComponentInputMaps( defaults );
|
||||
|
||||
if( SystemInfo.IS_MAC )
|
||||
if( SystemInfo.isMacOS )
|
||||
initMacInputMaps( defaults );
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class FlatInputMaps
|
||||
mac( "alt KP_DOWN", null ), "togglePopup"
|
||||
);
|
||||
|
||||
if( !SystemInfo.IS_MAC ) {
|
||||
if( !SystemInfo.isMacOS ) {
|
||||
modifyInputMap( defaults, "FileChooser.ancestorInputMap",
|
||||
"F2", "editFileName",
|
||||
"BACK_SPACE", "Go Up"
|
||||
@@ -93,7 +93,7 @@ class FlatInputMaps
|
||||
mac( "shift ctrl END", null ), "selectLastColumnExtendSelection"
|
||||
);
|
||||
|
||||
if( !SystemInfo.IS_MAC ) {
|
||||
if( !SystemInfo.isMacOS ) {
|
||||
modifyInputMap( defaults, "Tree.focusInputMap",
|
||||
"ADD", "expand",
|
||||
"SUBTRACT", "collapse"
|
||||
@@ -164,7 +164,7 @@ class FlatInputMaps
|
||||
"control shift O", "toggle-componentOrientation", // DefaultEditorKit.toggleComponentOrientation
|
||||
};
|
||||
|
||||
Object[] macCommonTextComponentBindings = SystemInfo.IS_MAC ? new Object[] {
|
||||
Object[] macCommonTextComponentBindings = SystemInfo.isMacOS ? new Object[] {
|
||||
// move caret one character (without selecting text)
|
||||
"ctrl B", backwardAction,
|
||||
"ctrl F", forwardAction,
|
||||
@@ -211,7 +211,7 @@ class FlatInputMaps
|
||||
"ENTER", JTextField.notifyAction,
|
||||
};
|
||||
|
||||
Object[] macSingleLineTextComponentBindings = SystemInfo.IS_MAC ? new Object[] {
|
||||
Object[] macSingleLineTextComponentBindings = SystemInfo.isMacOS ? new Object[] {
|
||||
// move caret to line begin/end (without selecting text)
|
||||
"UP", beginLineAction,
|
||||
"DOWN", endLineAction,
|
||||
@@ -289,7 +289,7 @@ class FlatInputMaps
|
||||
mac( "ctrl SPACE", "meta SPACE" ), "activate-link-action",
|
||||
};
|
||||
|
||||
Object[] macMultiLineTextComponentBindings = SystemInfo.IS_MAC ? new Object[] {
|
||||
Object[] macMultiLineTextComponentBindings = SystemInfo.isMacOS ? new Object[] {
|
||||
// move caret one line (without selecting text)
|
||||
"ctrl N", downAction,
|
||||
"ctrl P", upAction,
|
||||
@@ -579,7 +579,7 @@ class FlatInputMaps
|
||||
}
|
||||
|
||||
private static <T> T mac( T value, T macValue ) {
|
||||
return SystemInfo.IS_MAC ? macValue : value;
|
||||
return SystemInfo.isMacOS ? macValue : value;
|
||||
}
|
||||
|
||||
//---- class LazyInputMapEx -----------------------------------------------
|
||||
|
||||
@@ -147,12 +147,12 @@ public abstract class FlatLaf
|
||||
*/
|
||||
@Override
|
||||
public boolean getSupportsWindowDecorations() {
|
||||
if( SystemInfo.IS_JETBRAINS_JVM_11_OR_LATER &&
|
||||
SystemInfo.IS_WINDOWS_10_OR_LATER &&
|
||||
if( SystemInfo.isJetBrainsJVM_11_orLater &&
|
||||
SystemInfo.isWindows_10_orLater &&
|
||||
JBRCustomDecorations.isSupported() )
|
||||
return false;
|
||||
|
||||
return SystemInfo.IS_WINDOWS_10_OR_LATER;
|
||||
return SystemInfo.isWindows_10_orLater;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -187,7 +187,7 @@ public abstract class FlatLaf
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
if( SystemInfo.IS_MAC )
|
||||
if( SystemInfo.isMacOS )
|
||||
initializeAqua();
|
||||
|
||||
super.initialize();
|
||||
@@ -201,11 +201,11 @@ public abstract class FlatLaf
|
||||
mnemonicHandler.install();
|
||||
|
||||
// listen to desktop property changes to update UI if system font or scaling changes
|
||||
if( SystemInfo.IS_WINDOWS ) {
|
||||
if( SystemInfo.isWindows ) {
|
||||
// Windows 10 allows increasing font size independent of scaling:
|
||||
// Settings > Ease of Access > Display > Make text bigger (100% - 225%)
|
||||
desktopPropertyName = "win.messagebox.font";
|
||||
} else if( SystemInfo.IS_LINUX ) {
|
||||
} else if( SystemInfo.isLinux ) {
|
||||
// Linux/Gnome allows changing font in "Tweaks" app
|
||||
desktopPropertyName = "gnome.Gtk/FontName";
|
||||
|
||||
@@ -315,7 +315,7 @@ public abstract class FlatLaf
|
||||
String aquaLafClassName = "com.apple.laf.AquaLookAndFeel";
|
||||
BasicLookAndFeel aquaLaf;
|
||||
try {
|
||||
if( SystemInfo.IS_JAVA_9_OR_LATER ) {
|
||||
if( SystemInfo.isJava_9_orLater ) {
|
||||
Method m = UIManager.class.getMethod( "createLookAndFeel", String.class );
|
||||
aquaLaf = (BasicLookAndFeel) m.invoke( null, "Mac OS X" );
|
||||
} else
|
||||
@@ -391,7 +391,7 @@ public abstract class FlatLaf
|
||||
UIDefaultsLoader.loadDefaultsFromProperties( getClass(), addons, getAdditionalDefaults(), isDark(), defaults );
|
||||
|
||||
// use Aqua MenuBarUI if Mac screen menubar is enabled
|
||||
if( SystemInfo.IS_MAC && Boolean.getBoolean( "apple.laf.useScreenMenuBar" ) ) {
|
||||
if( SystemInfo.isMacOS && Boolean.getBoolean( "apple.laf.useScreenMenuBar" ) ) {
|
||||
defaults.put( "MenuBarUI", "com.apple.laf.AquaMenuBarUI" );
|
||||
|
||||
// add defaults necessary for AquaMenuBarUI
|
||||
@@ -435,17 +435,17 @@ public abstract class FlatLaf
|
||||
private void initFonts( UIDefaults defaults ) {
|
||||
FontUIResource uiFont = null;
|
||||
|
||||
if( SystemInfo.IS_WINDOWS ) {
|
||||
if( SystemInfo.isWindows ) {
|
||||
Font winFont = (Font) Toolkit.getDefaultToolkit().getDesktopProperty( "win.messagebox.font" );
|
||||
if( winFont != null )
|
||||
uiFont = createCompositeFont( winFont.getFamily(), winFont.getStyle(), winFont.getSize() );
|
||||
|
||||
} else if( SystemInfo.IS_MAC ) {
|
||||
} else if( SystemInfo.isMacOS ) {
|
||||
String fontName;
|
||||
if( SystemInfo.IS_MAC_OS_10_15_CATALINA_OR_LATER ) {
|
||||
if( SystemInfo.isMacOS_10_15_Catalina_orLater ) {
|
||||
// use Helvetica Neue font
|
||||
fontName = "Helvetica Neue";
|
||||
} else if( SystemInfo.IS_MAC_OS_10_11_EL_CAPITAN_OR_LATER ) {
|
||||
} else if( SystemInfo.isMacOS_10_11_ElCapitan_orLater ) {
|
||||
// use San Francisco Text font
|
||||
fontName = ".SF NS Text";
|
||||
} else {
|
||||
@@ -455,7 +455,7 @@ public abstract class FlatLaf
|
||||
|
||||
uiFont = createCompositeFont( fontName, Font.PLAIN, 13 );
|
||||
|
||||
} else if( SystemInfo.IS_LINUX ) {
|
||||
} else if( SystemInfo.isLinux ) {
|
||||
Font font = LinuxFontPolicy.getFont();
|
||||
uiFont = (font instanceof FontUIResource) ? (FontUIResource) font : new FontUIResource( font );
|
||||
}
|
||||
@@ -515,7 +515,7 @@ public abstract class FlatLaf
|
||||
}
|
||||
|
||||
private void putAATextInfo( UIDefaults defaults ) {
|
||||
if( SystemInfo.IS_JAVA_9_OR_LATER ) {
|
||||
if( SystemInfo.isJava_9_orLater ) {
|
||||
Object desktopHints = Toolkit.getDefaultToolkit().getDesktopProperty( DESKTOPFONTHINTS );
|
||||
if( desktopHints instanceof Map ) {
|
||||
@SuppressWarnings( "unchecked" )
|
||||
|
||||
@@ -39,7 +39,7 @@ import com.formdev.flatlaf.util.UIScale;
|
||||
class LinuxFontPolicy
|
||||
{
|
||||
static Font getFont() {
|
||||
return SystemInfo.IS_KDE ? getKDEFont() : getGnomeFont();
|
||||
return SystemInfo.isKDE ? getKDEFont() : getGnomeFont();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ class LinuxFontPolicy
|
||||
// Ubuntu font is rendered poorly (except if running in JetBrains VM)
|
||||
// --> use Liberation Sans font
|
||||
if( family.startsWith( "Ubuntu" ) &&
|
||||
!SystemInfo.IS_JETBRAINS_JVM &&
|
||||
!SystemInfo.isJetBrainsJVM &&
|
||||
!FlatSystemProperties.getBoolean( FlatSystemProperties.USE_UBUNTU_FONT, false ) )
|
||||
family = "Liberation Sans";
|
||||
|
||||
|
||||
@@ -71,13 +71,13 @@ class MnemonicHandler
|
||||
@Override
|
||||
public boolean postProcessKeyEvent( KeyEvent e ) {
|
||||
int keyCode = e.getKeyCode();
|
||||
if( SystemInfo.IS_MAC ) {
|
||||
if( SystemInfo.isMacOS ) {
|
||||
// Ctrl+Alt keys must be pressed on Mac
|
||||
if( keyCode == KeyEvent.VK_CONTROL || keyCode == KeyEvent.VK_ALT )
|
||||
showMnemonics( shouldShowMnemonics( e ) && e.isControlDown() && e.isAltDown(), e.getComponent() );
|
||||
} else {
|
||||
// Alt key must be pressed on Windows and Linux
|
||||
if( SystemInfo.IS_WINDOWS )
|
||||
if( SystemInfo.isWindows )
|
||||
return processKeyEventOnWindows( e );
|
||||
|
||||
if( keyCode == KeyEvent.VK_ALT )
|
||||
|
||||
@@ -144,9 +144,9 @@ class UIDefaultsLoader
|
||||
|
||||
// handle platform specific properties
|
||||
String platformPrefix =
|
||||
SystemInfo.IS_WINDOWS ? "[win]" :
|
||||
SystemInfo.IS_MAC ? "[mac]" :
|
||||
SystemInfo.IS_LINUX ? "[linux]" : "[unknown]";
|
||||
SystemInfo.isWindows ? "[win]" :
|
||||
SystemInfo.isMacOS ? "[mac]" :
|
||||
SystemInfo.isLinux ? "[linux]" : "[unknown]";
|
||||
for( String key : platformSpecificKeys ) {
|
||||
Object value = properties.remove( key );
|
||||
if( key.startsWith( platformPrefix ) )
|
||||
|
||||
@@ -306,7 +306,7 @@ public class FlatComboBoxUI
|
||||
updateEditorColors();
|
||||
|
||||
// macOS
|
||||
if( SystemInfo.IS_MAC && editor instanceof JTextComponent ) {
|
||||
if( SystemInfo.isMacOS && editor instanceof JTextComponent ) {
|
||||
// delegate actions from editor text field to combobox, which is necessary
|
||||
// because text field on macOS already handle those keys
|
||||
InputMap inputMap = ((JTextComponent)editor).getInputMap();
|
||||
|
||||
@@ -82,7 +82,7 @@ public class FlatMenuBarUI
|
||||
JMenuBar menuBar = (JMenuBar) e.getSource();
|
||||
JMenu menu = menuBar.getMenu( 0 );
|
||||
if( menu != null ) {
|
||||
MenuSelectionManager.defaultManager().setSelectedPath( SystemInfo.IS_WINDOWS
|
||||
MenuSelectionManager.defaultManager().setSelectedPath( SystemInfo.isWindows
|
||||
? new MenuElement[] { menuBar, menu }
|
||||
: new MenuElement[] { menuBar, menu, menu.getPopupMenu() } );
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public class FlatPopupFactory
|
||||
return new NonFlashingPopup( super.getPopup( owner, contents, x, y ), contents );
|
||||
|
||||
// macOS and Linux adds drop shadow to heavy weight popups
|
||||
if( SystemInfo.IS_MAC || SystemInfo.IS_LINUX ) {
|
||||
if( SystemInfo.isMacOS || SystemInfo.isLinux ) {
|
||||
Popup popup = getHeavyWeightPopup( owner, contents, x, y );
|
||||
if( popup == null )
|
||||
popup = super.getPopup( owner, contents, x, y );
|
||||
@@ -105,7 +105,7 @@ public class FlatPopupFactory
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
try {
|
||||
if( SystemInfo.IS_JAVA_9_OR_LATER ) {
|
||||
if( SystemInfo.isJava_9_orLater ) {
|
||||
if( java9getPopupMethod == null ) {
|
||||
java9getPopupMethod = PopupFactory.class.getDeclaredMethod(
|
||||
"getPopup", Component.class, Component.class, int.class, int.class, boolean.class );
|
||||
|
||||
@@ -69,7 +69,7 @@ public class FlatRootPaneUI
|
||||
{
|
||||
// check this field before using class JBRCustomDecorations to avoid unnecessary loading of that class
|
||||
static final boolean canUseJBRCustomDecorations
|
||||
= SystemInfo.IS_JETBRAINS_JVM_11_OR_LATER && SystemInfo.IS_WINDOWS_10_OR_LATER;
|
||||
= SystemInfo.isJetBrainsJVM_11_orLater && SystemInfo.isWindows_10_orLater;
|
||||
|
||||
protected JRootPane rootPane;
|
||||
protected FlatTitlePane titlePane;
|
||||
@@ -119,7 +119,7 @@ public class FlatRootPaneUI
|
||||
}
|
||||
|
||||
// enable dark window appearance on macOS when running in JetBrains Runtime
|
||||
if( SystemInfo.IS_JETBRAINS_JVM && SystemInfo.IS_MAC_OS_10_14_MOJAVE ) {
|
||||
if( SystemInfo.isJetBrainsJVM && SystemInfo.isMacOS_10_14_Mojave_orLater ) {
|
||||
LookAndFeel laf = UIManager.getLookAndFeel();
|
||||
boolean isDark = laf instanceof FlatLaf && ((FlatLaf)laf).isDark();
|
||||
c.putClientProperty( "jetbrains.awt.windowDarkAppearance", isDark );
|
||||
|
||||
@@ -472,7 +472,7 @@ public class FlatTitlePane
|
||||
int maximizedWidth = screenBounds.width;
|
||||
int maximizedHeight = screenBounds.height;
|
||||
|
||||
if( !SystemInfo.IS_JAVA_15_OR_LATER ) {
|
||||
if( !SystemInfo.isJava_15_orLater ) {
|
||||
// on Java 8 to 14, maximized x,y are 0,0 based on all screens in a multi-screen environment
|
||||
maximizedX = 0;
|
||||
maximizedY = 0;
|
||||
|
||||
@@ -191,7 +191,7 @@ public class JBRCustomDecorations
|
||||
initialized = true;
|
||||
|
||||
// requires JetBrains Runtime 11 and Windows 10
|
||||
if( !SystemInfo.IS_JETBRAINS_JVM_11_OR_LATER || !SystemInfo.IS_WINDOWS_10_OR_LATER )
|
||||
if( !SystemInfo.isJetBrainsJVM_11_orLater || !SystemInfo.isWindows_10_orLater )
|
||||
return;
|
||||
|
||||
if( !FlatSystemProperties.getBoolean( FlatSystemProperties.USE_JETBRAINS_CUSTOM_DECORATIONS, true ) )
|
||||
|
||||
@@ -117,10 +117,10 @@ public class HiDPIUtils
|
||||
* This methods computes a correction value for the Y position.
|
||||
*/
|
||||
public static float computeTextYCorrection( Graphics2D g ) {
|
||||
if( !useTextYCorrection() || !SystemInfo.IS_WINDOWS )
|
||||
if( !useTextYCorrection() || !SystemInfo.isWindows )
|
||||
return 0;
|
||||
|
||||
if( !SystemInfo.IS_JAVA_9_OR_LATER )
|
||||
if( !SystemInfo.isJava_9_orLater )
|
||||
return UIScale.getUserScaleFactor() > 1 ? -UIScale.scale( 0.625f ) : 0;
|
||||
|
||||
AffineTransform t = g.getTransform();
|
||||
|
||||
@@ -48,10 +48,10 @@ public class JavaCompatibility
|
||||
synchronized( JavaCompatibility.class ) {
|
||||
if( drawStringUnderlineCharAtMethod == null ) {
|
||||
try {
|
||||
Class<?> cls = Class.forName( SystemInfo.IS_JAVA_9_OR_LATER
|
||||
Class<?> cls = Class.forName( SystemInfo.isJava_9_orLater
|
||||
? "javax.swing.plaf.basic.BasicGraphicsUtils"
|
||||
: "sun.swing.SwingUtilities2" );
|
||||
drawStringUnderlineCharAtMethod = cls.getMethod( "drawStringUnderlineCharAt", SystemInfo.IS_JAVA_9_OR_LATER
|
||||
drawStringUnderlineCharAtMethod = cls.getMethod( "drawStringUnderlineCharAt", SystemInfo.isJava_9_orLater
|
||||
? new Class[] { JComponent.class, Graphics2D.class, String.class, int.class, float.class, float.class }
|
||||
: new Class[] { JComponent.class, Graphics.class, String.class, int.class, int.class, int.class } );
|
||||
} catch( Exception ex ) {
|
||||
@@ -62,7 +62,7 @@ public class JavaCompatibility
|
||||
}
|
||||
|
||||
try {
|
||||
if( SystemInfo.IS_JAVA_9_OR_LATER )
|
||||
if( SystemInfo.isJava_9_orLater )
|
||||
drawStringUnderlineCharAtMethod.invoke( null, c, g, text, underlinedIndex, (float) x, (float) y );
|
||||
else
|
||||
drawStringUnderlineCharAtMethod.invoke( null, c, g, text, underlinedIndex, x, y );
|
||||
|
||||
@@ -27,55 +27,57 @@ import java.util.StringTokenizer;
|
||||
public class SystemInfo
|
||||
{
|
||||
// platforms
|
||||
public static final boolean IS_WINDOWS;
|
||||
public static final boolean IS_MAC;
|
||||
public static final boolean IS_LINUX;
|
||||
public static final boolean isWindows;
|
||||
public static final boolean isMacOS;
|
||||
public static final boolean isLinux;
|
||||
|
||||
// OS versions
|
||||
public static final boolean IS_WINDOWS_10_OR_LATER;
|
||||
public static final boolean IS_MAC_OS_10_11_EL_CAPITAN_OR_LATER;
|
||||
public static final boolean IS_MAC_OS_10_14_MOJAVE;
|
||||
public static final boolean IS_MAC_OS_10_15_CATALINA_OR_LATER;
|
||||
public static final long osVersion;
|
||||
public static final boolean isWindows_10_orLater;
|
||||
public static final boolean isMacOS_10_11_ElCapitan_orLater;
|
||||
public static final boolean isMacOS_10_14_Mojave_orLater;
|
||||
public static final boolean isMacOS_10_15_Catalina_orLater;
|
||||
|
||||
// Java versions
|
||||
public static final boolean IS_JAVA_9_OR_LATER;
|
||||
public static final boolean IS_JAVA_11_OR_LATER;
|
||||
public static final boolean IS_JAVA_15_OR_LATER;
|
||||
public static final long javaVersion;
|
||||
public static final boolean isJava_9_orLater;
|
||||
public static final boolean isJava_11_orLater;
|
||||
public static final boolean isJava_15_orLater;
|
||||
|
||||
// Java VMs
|
||||
public static final boolean IS_JETBRAINS_JVM;
|
||||
public static final boolean IS_JETBRAINS_JVM_11_OR_LATER;
|
||||
public static final boolean isJetBrainsJVM;
|
||||
public static final boolean isJetBrainsJVM_11_orLater;
|
||||
|
||||
// UI toolkits
|
||||
public static final boolean IS_KDE;
|
||||
public static final boolean isKDE;
|
||||
|
||||
static {
|
||||
// platforms
|
||||
String osName = System.getProperty( "os.name" ).toLowerCase( Locale.ENGLISH );
|
||||
IS_WINDOWS = osName.startsWith( "windows" );
|
||||
IS_MAC = osName.startsWith( "mac" );
|
||||
IS_LINUX = osName.startsWith( "linux" );
|
||||
isWindows = osName.startsWith( "windows" );
|
||||
isMacOS = osName.startsWith( "mac" );
|
||||
isLinux = osName.startsWith( "linux" );
|
||||
|
||||
// OS versions
|
||||
long osVersion = scanVersion( System.getProperty( "os.version" ) );
|
||||
IS_WINDOWS_10_OR_LATER = (IS_WINDOWS && osVersion >= toVersion( 10, 0, 0, 0 ));
|
||||
IS_MAC_OS_10_11_EL_CAPITAN_OR_LATER = (IS_MAC && osVersion >= toVersion( 10, 11, 0, 0 ));
|
||||
IS_MAC_OS_10_14_MOJAVE = (IS_MAC && osVersion >= toVersion( 10, 14, 0, 0 ));
|
||||
IS_MAC_OS_10_15_CATALINA_OR_LATER = (IS_MAC && osVersion >= toVersion( 10, 15, 0, 0 ));
|
||||
osVersion = scanVersion( System.getProperty( "os.version" ) );
|
||||
isWindows_10_orLater = (isWindows && osVersion >= toVersion( 10, 0, 0, 0 ));
|
||||
isMacOS_10_11_ElCapitan_orLater = (isMacOS && osVersion >= toVersion( 10, 11, 0, 0 ));
|
||||
isMacOS_10_14_Mojave_orLater = (isMacOS && osVersion >= toVersion( 10, 14, 0, 0 ));
|
||||
isMacOS_10_15_Catalina_orLater = (isMacOS && osVersion >= toVersion( 10, 15, 0, 0 ));
|
||||
|
||||
// Java versions
|
||||
long javaVersion = scanVersion( System.getProperty( "java.version" ) );
|
||||
IS_JAVA_9_OR_LATER = (javaVersion >= toVersion( 9, 0, 0, 0 ));
|
||||
IS_JAVA_11_OR_LATER = (javaVersion >= toVersion( 11, 0, 0, 0 ));
|
||||
IS_JAVA_15_OR_LATER = (javaVersion >= toVersion( 15, 0, 0, 0 ));
|
||||
javaVersion = scanVersion( System.getProperty( "java.version" ) );
|
||||
isJava_9_orLater = (javaVersion >= toVersion( 9, 0, 0, 0 ));
|
||||
isJava_11_orLater = (javaVersion >= toVersion( 11, 0, 0, 0 ));
|
||||
isJava_15_orLater = (javaVersion >= toVersion( 15, 0, 0, 0 ));
|
||||
|
||||
// Java VMs
|
||||
IS_JETBRAINS_JVM = System.getProperty( "java.vm.vendor", "Unknown" )
|
||||
isJetBrainsJVM = System.getProperty( "java.vm.vendor", "Unknown" )
|
||||
.toLowerCase( Locale.ENGLISH ).contains( "jetbrains" );
|
||||
IS_JETBRAINS_JVM_11_OR_LATER = IS_JETBRAINS_JVM && IS_JAVA_11_OR_LATER;
|
||||
isJetBrainsJVM_11_orLater = isJetBrainsJVM && isJava_11_orLater;
|
||||
|
||||
// UI toolkits
|
||||
IS_KDE = (IS_LINUX && System.getenv( "KDE_FULL_SESSION" ) != null);
|
||||
isKDE = (isLinux && System.getenv( "KDE_FULL_SESSION" ) != null);
|
||||
}
|
||||
|
||||
public static long scanVersion( String version ) {
|
||||
|
||||
@@ -90,10 +90,10 @@ public class UIScale
|
||||
|
||||
jreHiDPI = false;
|
||||
|
||||
if( SystemInfo.IS_JAVA_9_OR_LATER ) {
|
||||
if( SystemInfo.isJava_9_orLater ) {
|
||||
// Java 9 and later supports per-monitor scaling
|
||||
jreHiDPI = true;
|
||||
} else if( SystemInfo.IS_JETBRAINS_JVM ) {
|
||||
} else if( SystemInfo.isJetBrainsJVM ) {
|
||||
// IntelliJ IDEA ships its own JetBrains Java 8 JRE that may supports per-monitor scaling
|
||||
// see com.intellij.ui.JreHiDpiUtil.isJreHiDPIEnabled()
|
||||
try {
|
||||
@@ -177,18 +177,18 @@ public class UIScale
|
||||
// default font size
|
||||
float fontSizeDivider = 12f;
|
||||
|
||||
if( SystemInfo.IS_WINDOWS ) {
|
||||
if( SystemInfo.isWindows ) {
|
||||
// Windows LaF uses Tahoma font rather than the actual Windows system font (Segoe UI),
|
||||
// and its size is always ca. 10% smaller than the actual system font size.
|
||||
// Tahoma 11 is used at 100%
|
||||
if( "Tahoma".equals( font.getFamily() ) )
|
||||
fontSizeDivider = 11f;
|
||||
} else if( SystemInfo.IS_MAC ) {
|
||||
} else if( SystemInfo.isMacOS ) {
|
||||
// default font size on macOS is 13
|
||||
fontSizeDivider = 13f;
|
||||
} else if( SystemInfo.IS_LINUX ) {
|
||||
} else if( SystemInfo.isLinux ) {
|
||||
// default font size for Unity and Gnome is 15 and for KDE it is 13
|
||||
fontSizeDivider = SystemInfo.IS_KDE ? 13f : 15f;
|
||||
fontSizeDivider = SystemInfo.isKDE ? 13f : 15f;
|
||||
}
|
||||
|
||||
return font.getSize() / fontSizeDivider;
|
||||
|
||||
@@ -59,9 +59,9 @@ class ControlBar
|
||||
className.equals( "com.sun.java.swing.plaf.motif.MotifLookAndFeel" ) )
|
||||
continue;
|
||||
|
||||
if( (SystemInfo.IS_WINDOWS && className.equals( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" )) ||
|
||||
(SystemInfo.IS_MAC && className.equals( "com.apple.laf.AquaLookAndFeel") ) ||
|
||||
(SystemInfo.IS_LINUX && className.equals( "com.sun.java.swing.plaf.gtk.GTKLookAndFeel") ) )
|
||||
if( (SystemInfo.isWindows && className.equals( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" )) ||
|
||||
(SystemInfo.isMacOS && className.equals( "com.apple.laf.AquaLookAndFeel") ) ||
|
||||
(SystemInfo.isLinux && className.equals( "com.sun.java.swing.plaf.gtk.GTKLookAndFeel") ) )
|
||||
name += " (F9)";
|
||||
else if( className.equals( MetalLookAndFeel.class.getName() ) )
|
||||
name += " (F12)";
|
||||
@@ -112,11 +112,11 @@ class ControlBar
|
||||
registerSwitchToLookAndFeel( KeyEvent.VK_F3, FlatIntelliJLaf.class.getName() );
|
||||
registerSwitchToLookAndFeel( KeyEvent.VK_F4, FlatDarculaLaf.class.getName() );
|
||||
|
||||
if( SystemInfo.IS_WINDOWS )
|
||||
if( SystemInfo.isWindows )
|
||||
registerSwitchToLookAndFeel( KeyEvent.VK_F9, "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" );
|
||||
else if( SystemInfo.IS_MAC )
|
||||
else if( SystemInfo.isMacOS )
|
||||
registerSwitchToLookAndFeel( KeyEvent.VK_F9, "com.apple.laf.AquaLookAndFeel" );
|
||||
else if( SystemInfo.IS_LINUX )
|
||||
else if( SystemInfo.isLinux )
|
||||
registerSwitchToLookAndFeel( KeyEvent.VK_F9, "com.sun.java.swing.plaf.gtk.GTKLookAndFeel" );
|
||||
registerSwitchToLookAndFeel( KeyEvent.VK_F12, MetalLookAndFeel.class.getName() );
|
||||
registerSwitchToLookAndFeel( KeyEvent.VK_F11, NimbusLookAndFeel.class.getName() );
|
||||
|
||||
@@ -32,7 +32,7 @@ public class FlatLafDemo
|
||||
|
||||
public static void main( String[] args ) {
|
||||
// on macOS enable screen menu bar
|
||||
if( SystemInfo.IS_MAC && System.getProperty( "apple.laf.useScreenMenuBar" ) == null )
|
||||
if( SystemInfo.isMacOS && System.getProperty( "apple.laf.useScreenMenuBar" ) == null )
|
||||
System.setProperty( "apple.laf.useScreenMenuBar", "true" );
|
||||
|
||||
SwingUtilities.invokeLater( () -> {
|
||||
|
||||
@@ -585,7 +585,7 @@ public class FlatDisabledIconsTest
|
||||
private static ImageIcon loadIcon( String iconName ) {
|
||||
ImageIcon icon = new ImageIcon( LightOrDarkIcon.class.getResource( iconName ) );
|
||||
|
||||
if( SystemInfo.IS_MAC || !MultiResolutionImageSupport.isAvailable() || !iconName.endsWith( ".png" ) )
|
||||
if( SystemInfo.isMacOS || !MultiResolutionImageSupport.isAvailable() || !iconName.endsWith( ".png" ) )
|
||||
return icon;
|
||||
|
||||
String iconName2x = iconName.replace( ".png", "@2x.png" );
|
||||
|
||||
@@ -62,7 +62,7 @@ public class FlatPaintingStringTest
|
||||
add( new JLabel( "flatlaf" ) );
|
||||
add( new JLabel( "0.25*scale" ) );
|
||||
add( new JLabel( "0.5*scale" ) );
|
||||
if( SystemInfo.IS_JAVA_9_OR_LATER ) {
|
||||
if( SystemInfo.isJava_9_orLater ) {
|
||||
add( new JLabel( "0.25" ) );
|
||||
add( new JLabel( "0.5" ) );
|
||||
add( new JLabel( "0.625" ) );
|
||||
@@ -76,7 +76,7 @@ public class FlatPaintingStringTest
|
||||
|
||||
YCorrectionFunction none = (g, scaleFactor) -> 0;
|
||||
YCorrectionFunction flatlaf = (g, scaleFactor) -> {
|
||||
return SystemInfo.IS_JAVA_9_OR_LATER
|
||||
return SystemInfo.isJava_9_orLater
|
||||
? HiDPIUtils.computeTextYCorrection( g )
|
||||
: (scaleFactor > 1 ? -(0.625f * scaleFactor) : 0);
|
||||
};
|
||||
@@ -100,7 +100,7 @@ public class FlatPaintingStringTest
|
||||
add( scaleFactor, flatlaf );
|
||||
add( scaleFactor, oneQSysScale );
|
||||
add( scaleFactor, halfSysScale );
|
||||
if( SystemInfo.IS_JAVA_9_OR_LATER ) {
|
||||
if( SystemInfo.isJava_9_orLater ) {
|
||||
add( scaleFactor, oneQ );
|
||||
add( scaleFactor, half );
|
||||
add( scaleFactor, fiveEights );
|
||||
@@ -115,7 +115,7 @@ public class FlatPaintingStringTest
|
||||
}
|
||||
|
||||
private void add( float scaleFactor, YCorrectionFunction correctionFunction ) {
|
||||
if( SystemInfo.IS_JAVA_9_OR_LATER ) {
|
||||
if( SystemInfo.isJava_9_orLater ) {
|
||||
add( new Painter( scaleFactor, correctionFunction, 0 ), "split 4, gapx 0 0" );
|
||||
add( new Painter( scaleFactor, correctionFunction, 0.25f ), "gapx 0 0" );
|
||||
add( new Painter( scaleFactor, correctionFunction, 0.5f ), "gapx 0 0" );
|
||||
@@ -161,7 +161,7 @@ public class FlatPaintingStringTest
|
||||
this.yOffset = yOffset;
|
||||
setBorder( new EmptyBorder( 2, 0, 2, 0 ) );
|
||||
|
||||
if( !SystemInfo.IS_JAVA_9_OR_LATER ) {
|
||||
if( !SystemInfo.isJava_9_orLater ) {
|
||||
Font font = getFont();
|
||||
setFont( font.deriveFont( (float) Math.round( font.getSize() * scaleFactor ) ) );
|
||||
}
|
||||
@@ -183,7 +183,7 @@ public class FlatPaintingStringTest
|
||||
FlatUIUtils.setRenderingHints( g2 );
|
||||
|
||||
// simulate component y position at a fraction
|
||||
if( scaleFactor > 1 && SystemInfo.IS_JAVA_9_OR_LATER )
|
||||
if( scaleFactor > 1 && SystemInfo.isJava_9_orLater )
|
||||
g2.translate( 0, yOffset );
|
||||
|
||||
int width = getWidth();
|
||||
@@ -199,7 +199,7 @@ public class FlatPaintingStringTest
|
||||
// g.drawLine( 0, height2 - 1, width2, height2 - 1 );
|
||||
|
||||
int baseline = (int) Math.round( (insets.top + fm.getAscent()) * scaleFactor2
|
||||
* (SystemInfo.IS_JAVA_9_OR_LATER ? scaleFactor : 1f) ) - 1;
|
||||
* (SystemInfo.isJava_9_orLater ? scaleFactor : 1f) ) - 1;
|
||||
int topline = height2 - baseline - 1;
|
||||
|
||||
g.setColor( Color.red );
|
||||
@@ -211,7 +211,7 @@ public class FlatPaintingStringTest
|
||||
g.translate( insets.left, 0 );
|
||||
|
||||
// scale
|
||||
if( SystemInfo.IS_JAVA_9_OR_LATER )
|
||||
if( SystemInfo.isJava_9_orLater )
|
||||
((Graphics2D)g).scale( scaleFactor, scaleFactor );
|
||||
|
||||
// compute Y correction
|
||||
@@ -244,7 +244,7 @@ public class FlatPaintingStringTest
|
||||
}
|
||||
|
||||
private int scale( int value ) {
|
||||
return SystemInfo.IS_JAVA_9_OR_LATER ? Math.round( value * scaleFactor ) : value;
|
||||
return SystemInfo.isJava_9_orLater ? Math.round( value * scaleFactor ) : value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,9 +104,9 @@ public class FlatTestFrame
|
||||
className.equals( "com.sun.java.swing.plaf.motif.MotifLookAndFeel" ) )
|
||||
continue;
|
||||
|
||||
if( (SystemInfo.IS_WINDOWS && className.equals( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" )) ||
|
||||
(SystemInfo.IS_MAC && className.equals( "com.apple.laf.AquaLookAndFeel" )) ||
|
||||
(SystemInfo.IS_LINUX && className.equals( "com.sun.java.swing.plaf.gtk.GTKLookAndFeel" )) )
|
||||
if( (SystemInfo.isWindows && className.equals( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" )) ||
|
||||
(SystemInfo.isMacOS && className.equals( "com.apple.laf.AquaLookAndFeel" )) ||
|
||||
(SystemInfo.isLinux && className.equals( "com.sun.java.swing.plaf.gtk.GTKLookAndFeel" )) )
|
||||
name += " (F9)";
|
||||
else if( className.equals( MetalLookAndFeel.class.getName() ) )
|
||||
name += " (F12)";
|
||||
@@ -117,13 +117,13 @@ public class FlatTestFrame
|
||||
}
|
||||
|
||||
String substanceLightClassName = "org.pushingpixels.substance.api.skin.SubstanceBusinessLookAndFeel";
|
||||
if( SystemInfo.IS_JAVA_9_OR_LATER && isClassAvailable( substanceLightClassName ) ) {
|
||||
if( SystemInfo.isJava_9_orLater && isClassAvailable( substanceLightClassName ) ) {
|
||||
lafModel.addElement( new LookAndFeelInfo( "Substance Business (F5)", substanceLightClassName ) );
|
||||
registerSwitchToLookAndFeel( "F5", substanceLightClassName );
|
||||
}
|
||||
|
||||
String substanceDarkClassName = "org.pushingpixels.substance.api.skin.SubstanceGraphiteAquaLookAndFeel";
|
||||
if( SystemInfo.IS_JAVA_9_OR_LATER && isClassAvailable( substanceDarkClassName ) ) {
|
||||
if( SystemInfo.isJava_9_orLater && isClassAvailable( substanceDarkClassName ) ) {
|
||||
lafModel.addElement( new LookAndFeelInfo( "Substance Graphite Aqua (Ctrl+F5)", substanceDarkClassName ) );
|
||||
registerSwitchToLookAndFeel( "ctrl F5", substanceDarkClassName );
|
||||
}
|
||||
@@ -141,7 +141,7 @@ public class FlatTestFrame
|
||||
}
|
||||
|
||||
String looksWindowsClassName = "com.jgoodies.looks.windows.WindowsLookAndFeel";
|
||||
if( SystemInfo.IS_WINDOWS && isClassAvailable( looksWindowsClassName ) ) {
|
||||
if( SystemInfo.isWindows && isClassAvailable( looksWindowsClassName ) ) {
|
||||
lafModel.addElement( new LookAndFeelInfo( "JGoodies Looks Windows (F7)", looksWindowsClassName ) );
|
||||
registerSwitchToLookAndFeel( "F7", looksWindowsClassName );
|
||||
}
|
||||
@@ -164,11 +164,11 @@ public class FlatTestFrame
|
||||
|
||||
registerSwitchToLookAndFeel( "F8", FlatTestLaf.class.getName() );
|
||||
|
||||
if( SystemInfo.IS_WINDOWS )
|
||||
if( SystemInfo.isWindows )
|
||||
registerSwitchToLookAndFeel( "F9", "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" );
|
||||
else if( SystemInfo.IS_MAC )
|
||||
else if( SystemInfo.isMacOS )
|
||||
registerSwitchToLookAndFeel( "F9", "com.apple.laf.AquaLookAndFeel" );
|
||||
else if( SystemInfo.IS_LINUX )
|
||||
else if( SystemInfo.isLinux )
|
||||
registerSwitchToLookAndFeel( "F9", "com.sun.java.swing.plaf.gtk.GTKLookAndFeel" );
|
||||
registerSwitchToLookAndFeel( "F12", MetalLookAndFeel.class.getName() );
|
||||
registerSwitchToLookAndFeel( "F11", NimbusLookAndFeel.class.getName() );
|
||||
|
||||
@@ -91,7 +91,7 @@ public class UIDefaultsDump
|
||||
dump( FlatLightLaf.class.getName(), dir );
|
||||
dump( FlatDarkLaf.class.getName(), dir );
|
||||
|
||||
if( SystemInfo.IS_WINDOWS ) {
|
||||
if( SystemInfo.isWindows ) {
|
||||
dump( FlatIntelliJLaf.class.getName(), dir );
|
||||
dump( FlatDarculaLaf.class.getName(), dir );
|
||||
}
|
||||
@@ -100,11 +100,11 @@ public class UIDefaultsDump
|
||||
// dump( MetalLookAndFeel.class.getName(), dir );
|
||||
// dump( NimbusLookAndFeel.class.getName(), dir );
|
||||
//
|
||||
// if( SystemInfo.IS_WINDOWS )
|
||||
// if( SystemInfo.isWindows )
|
||||
// dump( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel", dir );
|
||||
// else if( SystemInfo.IS_MAC )
|
||||
// else if( SystemInfo.isMacOS )
|
||||
// dump( "com.apple.laf.AquaLookAndFeel", dir );
|
||||
// else if( SystemInfo.IS_LINUX )
|
||||
// else if( SystemInfo.isLinux )
|
||||
// dump( "com.sun.java.swing.plaf.gtk.GTKLookAndFeel", dir );
|
||||
//
|
||||
// dump( "com.jgoodies.looks.plastic.PlasticLookAndFeel", dir );
|
||||
@@ -172,9 +172,9 @@ public class UIDefaultsDump
|
||||
? BasicLookAndFeel.class.getSimpleName()
|
||||
: lookAndFeel.getClass().getSimpleName();
|
||||
}
|
||||
String osSuffix = (SystemInfo.IS_MAC && lookAndFeel instanceof FlatLaf)
|
||||
String osSuffix = (SystemInfo.isMacOS && lookAndFeel instanceof FlatLaf)
|
||||
? "-mac"
|
||||
: ((SystemInfo.IS_LINUX && lookAndFeel instanceof FlatLaf)
|
||||
: ((SystemInfo.isLinux && lookAndFeel instanceof FlatLaf)
|
||||
? "-linux"
|
||||
: "");
|
||||
String javaVersion = System.getProperty( "java.version" );
|
||||
@@ -186,9 +186,9 @@ public class UIDefaultsDump
|
||||
File origFile = null;
|
||||
if( !osSuffix.isEmpty() && nameSuffix.isEmpty() )
|
||||
origFile = new File( dir, name + nameSuffix + "_" + javaVersion + ".txt" );
|
||||
else if( lookAndFeel instanceof FlatIntelliJLaf && SystemInfo.IS_WINDOWS )
|
||||
else if( lookAndFeel instanceof FlatIntelliJLaf && SystemInfo.isWindows )
|
||||
origFile = new File( dir, "FlatLightLaf_" + javaVersion + ".txt" );
|
||||
else if( lookAndFeel instanceof FlatDarculaLaf && SystemInfo.IS_WINDOWS )
|
||||
else if( lookAndFeel instanceof FlatDarculaLaf && SystemInfo.isWindows )
|
||||
origFile = new File( dir, "FlatDarkLaf_" + javaVersion + ".txt" );
|
||||
if( origFile != null ) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user