Module qupath.fx

Class LocaleManager

java.lang.Object
qupath.fx.localization.LocaleManager

public class LocaleManager extends Object
Manage available locales, with consistent display and string conversion. This is useful to support presenting locales to a user for selection.

The implementation of this class assumes that the locales will always be shown to the user in the same language for consistency, which by default is US English. This can be changed by specifying a different base locale.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new locale manager using the default US base locale and considering locales identified by the JVM as being available.
    LocaleManager(Predicate<Locale> availableLocalesPredicate)
    Create a new locale manager using the default US base locale and specified predicate to determine which locales should be available to the user, applied to the list of all locales identified by the JVM.
    LocaleManager(Predicate<Locale> availableLocalesPredicate, boolean useCountryCodes)
    Create a new locale manager using the default US base locale and specified predicate to determine which locales should be available to the user, applied to the list of all locales identified by the JVM.
    LocaleManager(Locale baseLocale, Predicate<Locale> availableLocalesPredicate)
    Create a new locale manager using the specified base locale and predicate to determine which locales should be available to the user, applied to the list of all locales identified by the JVM.
    LocaleManager(Locale baseLocale, Predicate<Locale> availableLocalesPredicate, boolean useCountryCodes)
    Create a new locale manager using the specified base locale and predicate to determine which locales should be available to the user, applied to the list of all locales identified by the JVM.
  • Method Summary

    Modifier and Type
    Method
    Description
    javafx.collections.ObservableList<Locale>
    Get an observable list of all locales identified by the JVM.
    javafx.collections.ObservableList<Locale>
    Get an observable list of all locales identified by the JVM that match the current predicate.
    void
    Refresh the list of available locales, based on the current predicate.
    boolean
    Query whether country codes are considered.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LocaleManager

      public LocaleManager()
      Create a new locale manager using the default US base locale and considering locales identified by the JVM as being available.
    • LocaleManager

      public LocaleManager(Predicate<Locale> availableLocalesPredicate)
      Create a new locale manager using the default US base locale and specified predicate to determine which locales should be available to the user, applied to the list of all locales identified by the JVM.
      Parameters:
      availableLocalesPredicate - filter to apply to select which locales are available.
    • LocaleManager

      public LocaleManager(Predicate<Locale> availableLocalesPredicate, boolean useCountryCodes)
      Create a new locale manager using the default US base locale and specified predicate to determine which locales should be available to the user, applied to the list of all locales identified by the JVM.
      Parameters:
      availableLocalesPredicate - filter to apply to select which locales are available.
      useCountryCodes - if true, all locales are considered; if false, locales with specific country codes are skipped.
    • LocaleManager

      public LocaleManager(Locale baseLocale, Predicate<Locale> availableLocalesPredicate)
      Create a new locale manager using the specified base locale and predicate to determine which locales should be available to the user, applied to the list of all locales identified by the JVM.
      Parameters:
      baseLocale - the base locale to use when determining the language to display locales to the user.
      availableLocalesPredicate - filter to apply to select which locales are available.
    • LocaleManager

      public LocaleManager(Locale baseLocale, Predicate<Locale> availableLocalesPredicate, boolean useCountryCodes)
      Create a new locale manager using the specified base locale and predicate to determine which locales should be available to the user, applied to the list of all locales identified by the JVM.
      Parameters:
      baseLocale - the base locale to use when determining the language to display locales to the user.
      availableLocalesPredicate - filter to apply to select which locales are available.
      useCountryCodes - if true, all locales are considered; if false, locales with specific country codes are skipped.
  • Method Details

    • getAllLocales

      public javafx.collections.ObservableList<Locale> getAllLocales()
      Get an observable list of all locales identified by the JVM. This may optionally exclude country-specific locales, depending upon the value of useCountryCodes().
      Returns:
    • useCountryCodes

      public boolean useCountryCodes()
      Query whether country codes are considered. If this returns false, locales with a non-empty country code will be ignored completely (and will not be returned by calls to getAllLocales()).
      Returns:
      true if locales with non-empty country codes may be used, false otherwise
    • getAvailableLocales

      public javafx.collections.ObservableList<Locale> getAvailableLocales()
      Get an observable list of all locales identified by the JVM that match the current predicate.
      Returns:
    • refreshAvailableLocales

      public void refreshAvailableLocales()
      Refresh the list of available locales, based on the current predicate. This is useful if the application supports installing locales at runtime.