java.lang.Object
one.jpro.platform.utils.UserPlatform
A utility class for detecting user platform properties.
This class supports both JPro (Web) and Desktop environments. It determines OS types using provided WebAPI values or system properties.
-
Constructor Summary
ConstructorsConstructorDescriptionUserPlatform(com.jpro.webapi.WebAPI webAPI) Creates a UserPlatform instance from a WebAPI. -
Method Summary
Modifier and TypeMethodDescriptionjavafx.scene.input.KeyCodeReturns the modifier key for the current platform.static javafx.scene.input.KeyCodegetModifierKey(com.jpro.webapi.WebAPI webAPI) Returns the modifier key for the platform determined by the given WebAPI.javafx.scene.input.KeyCombination.ModifierReturns the modifier key combination for the current platform.static javafx.scene.input.KeyCombination.ModifiergetModifierKeyCombination(com.jpro.webapi.WebAPI webAPI) Returns the modifier key combination for the platform determined by the given WebAPI.booleanisLinux()static booleanisLinux(com.jpro.webapi.WebAPI webAPI) Determines if the platform from the WebAPI is Linux.booleanisMac()static booleanisMac(com.jpro.webapi.WebAPI webAPI) Determines if the platform from the WebAPI is Mac.booleanisMobile()Determines if the platform is a mobile environment.static booleanisMobile(com.jpro.webapi.WebAPI webAPI) Determines if the platform from the WebAPI is mobile.booleanisWeb()Determines if the platform is a web (JPro) environment.static booleanisWeb(com.jpro.webapi.WebAPI webAPI) Determines if the current environment is web-based (JPro).booleanstatic booleanisWindows(com.jpro.webapi.WebAPI webAPI) Determines if the platform from the WebAPI is Windows.static UserPlatformUsed for unit test and example applicationstatic UserPlatformUsed for unit test and example applicationstatic UserPlatformsimulateWeb(String platform, String platformOld) Used for unit test and example application
-
Constructor Details
-
UserPlatform
public UserPlatform(com.jpro.webapi.WebAPI webAPI) Creates a UserPlatform instance from a WebAPI.- Parameters:
webAPI- the WebAPI instance to extract platform data
-
-
Method Details
-
simulateNative
Used for unit test and example application -
simulateNative
Used for unit test and example application -
simulateWeb
Used for unit test and example application -
isWindows
public boolean isWindows() -
isMac
public boolean isMac() -
isLinux
public boolean isLinux() -
isWeb
public boolean isWeb()Determines if the platform is a web (JPro) environment.- Returns:
trueif not a Desktop OS,falseotherwise
-
isMobile
public boolean isMobile()Determines if the platform is a mobile environment.- Returns:
trueif mobile,falseotherwise
-
getModifierKey
public javafx.scene.input.KeyCode getModifierKey()Returns the modifier key for the current platform. For macOS, it returnsKeyCode.META, otherwiseKeyCode.CONTROL.- Returns:
- the meta key code
-
getModifierKeyCombination
public javafx.scene.input.KeyCombination.Modifier getModifierKeyCombination()Returns the modifier key combination for the current platform. For macOS, it returnsKeyCombination.META_DOWN, otherwiseKeyCombination.CONTROL_DOWN.- Returns:
- the meta key code
-
getModifierKey
public static javafx.scene.input.KeyCode getModifierKey(com.jpro.webapi.WebAPI webAPI) Returns the modifier key for the platform determined by the given WebAPI.- Parameters:
webAPI- the WebAPI to determine the platform- Returns:
- the meta key code
-
getModifierKeyCombination
public static javafx.scene.input.KeyCombination.Modifier getModifierKeyCombination(com.jpro.webapi.WebAPI webAPI) Returns the modifier key combination for the platform determined by the given WebAPI.- Parameters:
webAPI- the WebAPI to determine the platform- Returns:
- the meta key code
-
isWindows
public static boolean isWindows(com.jpro.webapi.WebAPI webAPI) Determines if the platform from the WebAPI is Windows.- Parameters:
webAPI- the WebAPI instance- Returns:
trueif Windows,falseotherwise
-
isMac
public static boolean isMac(com.jpro.webapi.WebAPI webAPI) Determines if the platform from the WebAPI is Mac.- Parameters:
webAPI- the WebAPI instance- Returns:
trueif Mac,falseotherwise
-
isLinux
public static boolean isLinux(com.jpro.webapi.WebAPI webAPI) Determines if the platform from the WebAPI is Linux.- Parameters:
webAPI- the WebAPI instance- Returns:
trueif Linux,falseotherwise
-
isWeb
public static boolean isWeb(com.jpro.webapi.WebAPI webAPI) Determines if the current environment is web-based (JPro).This method checks the system property "javafx.platform" for the value "jpro".
- Returns:
trueif web-based,falseotherwise
-
isMobile
public static boolean isMobile(com.jpro.webapi.WebAPI webAPI) Determines if the platform from the WebAPI is mobile.- Parameters:
webAPI- the WebAPI instance- Returns:
trueif mobile,falseotherwise
-