Class UserPlatform

java.lang.Object
one.jpro.platform.utils.UserPlatform

public class UserPlatform extends Object
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

    Constructors
    Constructor
    Description
    UserPlatform(com.jpro.webapi.WebAPI webAPI)
    Creates a UserPlatform instance from a WebAPI.
  • Method Summary

    Modifier and Type
    Method
    Description
    javafx.scene.input.KeyCode
    Returns the modifier key for the current platform.
    static javafx.scene.input.KeyCode
    getModifierKey(com.jpro.webapi.WebAPI webAPI)
    Returns the modifier key for the platform determined by the given WebAPI.
    javafx.scene.input.KeyCombination.Modifier
    Returns the modifier key combination for the current platform.
    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.
    boolean
     
    static boolean
    isLinux(com.jpro.webapi.WebAPI webAPI)
    Determines if the platform from the WebAPI is Linux.
    boolean
     
    static boolean
    isMac(com.jpro.webapi.WebAPI webAPI)
    Determines if the platform from the WebAPI is Mac.
    boolean
    Determines if the platform is a mobile environment.
    static boolean
    isMobile(com.jpro.webapi.WebAPI webAPI)
    Determines if the platform from the WebAPI is mobile.
    boolean
    Determines if the platform is a web (JPro) environment.
    static boolean
    isWeb(com.jpro.webapi.WebAPI webAPI)
    Determines if the current environment is web-based (JPro).
    boolean
     
    static boolean
    isWindows(com.jpro.webapi.WebAPI webAPI)
    Determines if the platform from the WebAPI is Windows.
    Used for unit test and example application
    Used for unit test and example application
    simulateWeb(String platform, String platformOld)
    Used for unit test and example application

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static UserPlatform simulateNative()
      Used for unit test and example application
    • simulateNative

      public static UserPlatform simulateNative(String s)
      Used for unit test and example application
    • simulateWeb

      public static UserPlatform simulateWeb(String platform, String platformOld)
      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:
      true if not a Desktop OS, false otherwise
    • isMobile

      public boolean isMobile()
      Determines if the platform is a mobile environment.
      Returns:
      true if mobile, false otherwise
    • getModifierKey

      public javafx.scene.input.KeyCode getModifierKey()
      Returns the modifier key for the current platform. For macOS, it returns KeyCode.META, otherwise KeyCode.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 returns KeyCombination.META_DOWN, otherwise KeyCombination.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:
      true if Windows, false otherwise
    • 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:
      true if Mac, false otherwise
    • 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:
      true if Linux, false otherwise
    • 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:
      true if web-based, false otherwise
    • 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:
      true if mobile, false otherwise