Top Description Fields Constructors Methods
com.sun.javafx.application.preferences

public final Class PlatformPreferences

extends AbstractMap<String, Object>
implements Preferences
Class Inheritance
All Implemented Interfaces
javafx.application.Platform.Preferences, javafx.collections.ObservableMap, javafx.beans.Observable, java.util.Map
Imports
com.sun.javafx.binding.MapExpressionHelper, javafx.application.ColorScheme, .Platform, javafx.beans.InvalidationListener, javafx.beans.property.ReadOnlyBooleanProperty, .ReadOnlyObjectProperty, javafx.collections.MapChangeListener, javafx.scene.paint.Color, java.io.Serializable, java.lang.reflect.Modifier, java.util.AbstractMap, .Collections, .HashMap, .List, .Map, .Set, .Objects, .Optional, java.util.concurrent.CopyOnWriteArrayList

Contains the implementation of a read-only map of platform preferences.

When the operating system signals that a preference has changed, the mappings are updated by calling the update(Map) method.

Field Summary

Modifier and TypeField and Description
private final Map<String, Object>
effectivePreferences

Contains the current set of effective preferences, i.e. the set of preferences that we know to be the current state of the world, and are exposed to users of this map.

private final List<InvalidationListener>
private final List<MapChangeListener<? super String, Object>>
private final Map<String, PreferenceMapping<?, ?>>
platformKeyMappings

Contains mappings from platform-specific keys to well-known keys, which are used in the implementation of the property-based API in PreferenceProperties.

private final Map<String, Class<?>>
platformKeys

Contains mappings from platform-specific keys to their types.

private final PreferenceProperties
properties

Contains the implementation of the property-based API.

private final Map<String, Object>

Constructor Summary

AccessConstructor and Description
public
PlatformPreferences(Map<String, Class<?>>
the platform-specific keys and the types of their values
platformKeys
,
Map<String, PreferenceMapping<?, ?>>
the platform-specific key mappings
platformKeyMappings
)

Initializes a new PlatformPreferences instance with the given platform-specific keys and key mappings.

Method Summary

Modifier and TypeMethod and Description
public ReadOnlyObjectProperty<Color>
accentColorProperty()

Implements javafx.application.Platform.Preferences.accentColorProperty.

The accent color, which can be used to highlight the active or important part of a control and make it stand out from the rest of the user interface.

public void
addListener(InvalidationListener
The listener to register
listener
)

Implements javafx.beans.Observable.addListener.

Adds an InvalidationListener which will be notified whenever the Observable becomes invalid.

public void
addListener(MapChangeListener<? super String, ? super Object>
the listener for listening to the list changes
listener
)

Implements javafx.collections.ObservableMap.addListener.

Add a listener to this observable map.

public ReadOnlyObjectProperty<Color>
public ReadOnlyObjectProperty<ColorScheme>
colorSchemeProperty()

Implements javafx.application.Platform.Preferences.colorSchemeProperty.

The platform color scheme, which specifies whether applications should prefer light text on dark backgrounds, or dark text on light backgrounds.

public Set<Map.Entry<String, Object>>
entrySet()

Implements abstract java.util.AbstractMap.entrySet.

Implements java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map.

private void
public ReadOnlyObjectProperty<Color>
foregroundColorProperty()

Implements javafx.application.Platform.Preferences.foregroundColorProperty.

The color used for foreground elements like text.

public Color
public Color
public Optional<Boolean>
getBoolean(String
the key
key
)

Implements javafx.application.Platform.Preferences.getBoolean.

Returns an optional Boolean to which the specified key is mapped.

public Optional<Color>
getColor(String
the key
key
)

Implements javafx.application.Platform.Preferences.getColor.

Returns an optional Color to which the specified key is mapped.

public ColorScheme
public Optional<Double>
getDouble(String
the key
key
)

Implements javafx.application.Platform.Preferences.getDouble.

Returns an optional Double to which the specified key is mapped.

public Color
public Optional<Integer>
getInteger(String
the key
key
)

Implements javafx.application.Platform.Preferences.getInteger.

Returns an optional Integer to which the specified key is mapped.

public Optional<String>
getString(String
the key
key
)

Implements javafx.application.Platform.Preferences.getString.

Returns an optional String to which the specified key is mapped.

public <T> Optional<T>
getValue(String
the key
key
,
Class<T>
the type of the value
type
)

Implements javafx.application.Platform.Preferences.getValue.

Returns an optional value to which the specified key is mapped.

private boolean
isArrayConvertible(Class<?> source, Class<?> target)

private boolean
isClassConvertible(Class<?> source, Class<?> target)

private boolean

Returns:

true if a casting conversion exists, false otherwise
isConvertible
(Class<?>
the source type
source
,
Class<?>
the target type
target
)

Determines whether a compile-time casting conversion exists from source to target.

private boolean
isInterfaceConvertible(Class<?> source, Class<?> target)

public boolean
public boolean
public boolean
public boolean
public ReadOnlyBooleanProperty
persistentScrollBarsProperty()

Implements javafx.application.Platform.Preferences.persistentScrollBarsProperty.

Specifies whether applications should always show scroll bars.

public ReadOnlyBooleanProperty
reducedDataProperty()

Implements javafx.application.Platform.Preferences.reducedDataProperty.

Specifies whether applications should minimize the amount of internet traffic, which users might request because they are on a metered network or a limited data plan.

public ReadOnlyBooleanProperty
reducedMotionProperty()

Implements javafx.application.Platform.Preferences.reducedMotionProperty.

Specifies whether applications should minimize the amount of non-essential animations, reducing discomfort for users who experience motion sickness or vertigo.

public ReadOnlyBooleanProperty
reducedTransparencyProperty()

Implements javafx.application.Platform.Preferences.reducedTransparencyProperty.

Specifies whether applications should minimize the amount of transparent or translucent layer effects, which can help to increase contrast and readability for some users.

public Object
remove(Object
key whose mapping is to be removed from the map
key
)

Overrides java.util.AbstractMap.remove.

Implements java.util.Map.remove.

Removes the mapping for a key from this map if it is present (optional operation).

public void
removeListener(InvalidationListener
The listener to remove
listener
)

Implements javafx.beans.Observable.removeListener.

Removes the given listener from the list of listeners, that are notified whenever the value of the Observable becomes invalid.

public void
removeListener(MapChangeListener<? super String, ? super Object>
a listener to remove
listener
)

Implements javafx.collections.ObservableMap.removeListener.

Tries to removed a listener from this observable map.

public void
update(Map<String, Object>
the new preference mappings
preferences
)

Updates this map of preferences with a new set of platform preferences.

Inherited from java.util.AbstractMap:
clearclonecontainsKeycontainsValueequalsgethashCodeisEmptykeySetputputAllsizetoStringvalues

Field Detail

effectivePreferencesback to summary
private final Map<String, Object> effectivePreferences

Contains the current set of effective preferences, i.e. the set of preferences that we know to be the current state of the world, and are exposed to users of this map.

invalidationListenersback to summary
private final List<InvalidationListener> invalidationListeners
mapChangeListenersback to summary
private final List<MapChangeListener<? super String, Object>> mapChangeListeners
platformKeyMappingsback to summary
private final Map<String, PreferenceMapping<?, ?>> platformKeyMappings

Contains mappings from platform-specific keys to well-known keys, which are used in the implementation of the property-based API in PreferenceProperties.

platformKeysback to summary
private final Map<String, Class<?>> platformKeys

Contains mappings from platform-specific keys to their types. This information is used to catch misuse of typed getters even if the preferences map doesn't contain the preference mapping at runtime.

propertiesback to summary
private final PreferenceProperties properties

Contains the implementation of the property-based API.

unmodifiableEffectivePreferencesback to summary
private final Map<String, Object> unmodifiableEffectivePreferences

Constructor Detail

PlatformPreferencesback to summary
public PlatformPreferences(Map<String, Class<?>> platformKeys, Map<String, PreferenceMapping<?, ?>> platformKeyMappings)

Initializes a new PlatformPreferences instance with the given platform-specific keys and key mappings.

Parameters
platformKeys:Map<String, Class<?>>

the platform-specific keys and the types of their values

platformKeyMappings:Map<String, PreferenceMapping<?, ?>>

the platform-specific key mappings

Exceptions
NullPointerException:
if platformKeys or platformKeyMappings is null or contains null keys or values

Method Detail

accentColorPropertyback to summary
public ReadOnlyObjectProperty<Color> accentColorProperty()

Implements javafx.application.Platform.Preferences.accentColorProperty.

Doc from javafx.application.Platform.Preferences.accentColorProperty.

The accent color, which can be used to highlight the active or important part of a control and make it stand out from the rest of the user interface. It is usually a vivid color that contrasts with the foreground and background colors.

If the platform does not report an accent color, this property defaults to vivid blue (corresponding to the hex color value #157EFB).

Returns:ReadOnlyObjectProperty<Color>

the accentColor property

Annotations
@Override
addListenerback to summary
public void addListener(InvalidationListener listener)

Implements javafx.beans.Observable.addListener.

Doc from javafx.beans.Observable.addListener.

Adds an InvalidationListener which will be notified whenever the Observable becomes invalid. If the same listener is added more than once, then it will be notified more than once. That is, no check is made to ensure uniqueness.

Note that the same actual InvalidationListener instance may be safely registered for different Observables.

The Observable stores a strong reference to the listener which will prevent the listener from being garbage collected and may result in a memory leak. It is recommended to either unregister a listener by calling removeListener after use or to use an instance of WeakInvalidationListener avoid this situation.

Parameters
listener:InvalidationListener

The listener to register

Annotations
@Override
addListenerback to summary
public void addListener(MapChangeListener<? super String, ? super Object> listener)

Implements javafx.collections.ObservableMap.addListener.

Doc from javafx.collections.ObservableMap.addListener.

Add a listener to this observable map.

Parameters
listener:MapChangeListener<? super String, ? super Object>

the listener for listening to the list changes

Annotations
@Override
backgroundColorPropertyback to summary
public ReadOnlyObjectProperty<Color> backgroundColorProperty()

Implements javafx.application.Platform.Preferences.backgroundColorProperty.

Doc from javafx.application.Platform.Preferences.backgroundColorProperty.

The color used for background regions.

If the platform does not report a background color, this property defaults to WHITE.

Returns:ReadOnlyObjectProperty<Color>

the backgroundColor property

Annotations
@Override
colorSchemePropertyback to summary
public ReadOnlyObjectProperty<ColorScheme> colorSchemeProperty()

Implements javafx.application.Platform.Preferences.colorSchemeProperty.

Doc from javafx.application.Platform.Preferences.colorSchemeProperty.

The platform color scheme, which specifies whether applications should prefer light text on dark backgrounds, or dark text on light backgrounds.

If the platform does not report color preferences, this property defaults to LIGHT.

Returns:ReadOnlyObjectProperty<ColorScheme>

the colorScheme property

Annotations
@Override
entrySetback to summary
public Set<Map.Entry<String, Object>> entrySet()

Implements abstract java.util.AbstractMap.entrySet.

Implements java.util.Map.entrySet.

Doc from java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation, or through the setValue operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

Returns:Set<Map.Entry<String, Object>>

a set view of the mappings contained in this map

Annotations
@Override
fireValueChangedEventback to summary
private void fireValueChangedEvent(Map<String, ChangedValue> changedEntries)
foregroundColorPropertyback to summary
public ReadOnlyObjectProperty<Color> foregroundColorProperty()

Implements javafx.application.Platform.Preferences.foregroundColorProperty.

Doc from javafx.application.Platform.Preferences.foregroundColorProperty.

The color used for foreground elements like text.

If the platform does not report a foreground color, this property defaults to BLACK.

Returns:ReadOnlyObjectProperty<Color>

the foregroundColor property

Annotations
@Override
getAccentColorback to summary
public Color getAccentColor()

Implements javafx.application.Platform.Preferences.getAccentColor.

Annotations
@Override
getBackgroundColorback to summary
public Color getBackgroundColor()

Implements javafx.application.Platform.Preferences.getBackgroundColor.

Annotations
@Override
getBooleanback to summary
public Optional<Boolean> getBoolean(String key)

Implements javafx.application.Platform.Preferences.getBoolean.

Doc from javafx.application.Platform.Preferences.getBoolean.

Returns an optional Boolean to which the specified key is mapped.

Parameters
key:String

the key

Returns:Optional<Boolean>

the optional Boolean to which the key is mapped

Annotations
@Override
getColorback to summary
public Optional<Color> getColor(String key)

Implements javafx.application.Platform.Preferences.getColor.

Doc from javafx.application.Platform.Preferences.getColor.

Returns an optional Color to which the specified key is mapped.

Parameters
key:String

the key

Returns:Optional<Color>

the optional Color instance to which the key is mapped

Annotations
@Override
getColorSchemeback to summary
public ColorScheme getColorScheme()

Implements javafx.application.Platform.Preferences.getColorScheme.

Annotations
@Override
getDoubleback to summary
public Optional<Double> getDouble(String key)

Implements javafx.application.Platform.Preferences.getDouble.

Doc from javafx.application.Platform.Preferences.getDouble.

Returns an optional Double to which the specified key is mapped.

Parameters
key:String

the key

Returns:Optional<Double>

the optional Double to which the key is mapped

Annotations
@Override
getForegroundColorback to summary
public Color getForegroundColor()

Implements javafx.application.Platform.Preferences.getForegroundColor.

Annotations
@Override
getIntegerback to summary
public Optional<Integer> getInteger(String key)

Implements javafx.application.Platform.Preferences.getInteger.

Doc from javafx.application.Platform.Preferences.getInteger.

Returns an optional Integer to which the specified key is mapped.

Parameters
key:String

the key

Returns:Optional<Integer>

the optional Integer to which the key is mapped

Annotations
@Override
getStringback to summary
public Optional<String> getString(String key)

Implements javafx.application.Platform.Preferences.getString.

Doc from javafx.application.Platform.Preferences.getString.

Returns an optional String to which the specified key is mapped.

Parameters
key:String

the key

Returns:Optional<String>

the optional String to which the key is mapped

Annotations
@Override
getValueback to summary
public <T> Optional<T> getValue(String key, Class<T> type)

Implements javafx.application.Platform.Preferences.getValue.

Doc from javafx.application.Platform.Preferences.getValue.

Returns an optional value to which the specified key is mapped.

Parameters
<T>
the type of the value
key:String

the key

type:Class<T>

the type of the value

Returns:Optional<T>

the optional value to which the key is mapped

Annotations
@Override
isArrayConvertibleback to summary
private boolean isArrayConvertible(Class<?> source, Class<?> target)
isClassConvertibleback to summary
private boolean isClassConvertible(Class<?> source, Class<?> target)
isConvertibleback to summary
private boolean isConvertible(Class<?> source, Class<?> target)

Determines whether a compile-time casting conversion exists from source to target. This is an implementation of JLS 5.5.1 (Reference Type Casting).

Parameters
source:Class<?>

the source type

target:Class<?>

the target type

Returns:boolean

true if a casting conversion exists, false otherwise

isInterfaceConvertibleback to summary
private boolean isInterfaceConvertible(Class<?> source, Class<?> target)
isPersistentScrollBarsback to summary
public boolean isPersistentScrollBars()

Implements javafx.application.Platform.Preferences.isPersistentScrollBars.

Annotations
@Override
isReducedDataback to summary
public boolean isReducedData()

Implements javafx.application.Platform.Preferences.isReducedData.

Annotations
@Override
isReducedMotionback to summary
public boolean isReducedMotion()

Implements javafx.application.Platform.Preferences.isReducedMotion.

Annotations
@Override
isReducedTransparencyback to summary
public boolean isReducedTransparency()

Implements javafx.application.Platform.Preferences.isReducedTransparency.

Annotations
@Override
persistentScrollBarsPropertyback to summary
public ReadOnlyBooleanProperty persistentScrollBarsProperty()

Implements javafx.application.Platform.Preferences.persistentScrollBarsProperty.

Doc from javafx.application.Platform.Preferences.persistentScrollBarsProperty.

Specifies whether applications should always show scroll bars. If not set, an application may choose to hide scroll bars that are not actively used, or make them smaller or less noticeable.

If the platform does not report this preference, this property defaults to false.

Returns:ReadOnlyBooleanProperty

the persistentScrollBars property

Annotations
@Override
reducedDataPropertyback to summary
public ReadOnlyBooleanProperty reducedDataProperty()

Implements javafx.application.Platform.Preferences.reducedDataProperty.

Doc from javafx.application.Platform.Preferences.reducedDataProperty.

Specifies whether applications should minimize the amount of internet traffic, which users might request because they are on a metered network or a limited data plan.

If the platform does not report this preference, this property defaults to false.

Returns:ReadOnlyBooleanProperty

the reducedData property

Annotations
@Override
reducedMotionPropertyback to summary
public ReadOnlyBooleanProperty reducedMotionProperty()

Implements javafx.application.Platform.Preferences.reducedMotionProperty.

Doc from javafx.application.Platform.Preferences.reducedMotionProperty.

Specifies whether applications should minimize the amount of non-essential animations, reducing discomfort for users who experience motion sickness or vertigo.

If the platform does not report this preference, this property defaults to false.

Returns:ReadOnlyBooleanProperty

the reducedMotion property

Annotations
@Override
reducedTransparencyPropertyback to summary
public ReadOnlyBooleanProperty reducedTransparencyProperty()

Implements javafx.application.Platform.Preferences.reducedTransparencyProperty.

Doc from javafx.application.Platform.Preferences.reducedTransparencyProperty.

Specifies whether applications should minimize the amount of transparent or translucent layer effects, which can help to increase contrast and readability for some users.

If the platform does not report this preference, this property defaults to false.

Returns:ReadOnlyBooleanProperty

the reducedTransparency property

Annotations
@Override
removeback to summary
public Object remove(Object key)

Overrides java.util.AbstractMap.remove.

Implements java.util.Map.remove.

Doc from java.util.Map.remove.

Removes the mapping for a key from this map if it is present (optional operation). More formally, if this map contains a mapping from key k to value v such that Objects.equals(key, k), that mapping is removed. (The map can contain at most one such mapping.)

Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.

If this map permits null values, then a return value of null does not necessarily indicate that the map contained no mapping for the key; it's also possible that the map explicitly mapped the key to null.

The map will not contain a mapping for the specified key once the call returns.

Parameters
key:Object

key whose mapping is to be removed from the map

Returns:Object

the previous value associated with key, or null if there was no mapping for key.

Annotations
@Override
removeListenerback to summary
public void removeListener(InvalidationListener listener)

Implements javafx.beans.Observable.removeListener.

Doc from javafx.beans.Observable.removeListener.

Removes the given listener from the list of listeners, that are notified whenever the value of the Observable becomes invalid.

If the given listener has not been previously registered (i.e. it was never added) then this method call is a no-op. If it had been previously added then it will be removed. If it had been added more than once, then only the first occurrence will be removed.

Parameters
listener:InvalidationListener

The listener to remove

Annotations
@Override
removeListenerback to summary
public void removeListener(MapChangeListener<? super String, ? super Object> listener)

Implements javafx.collections.ObservableMap.removeListener.

Doc from javafx.collections.ObservableMap.removeListener.

Tries to removed a listener from this observable map. If the listener is not attached to this map, nothing happens.

Parameters
listener:MapChangeListener<? super String, ? super Object>

a listener to remove

Annotations
@Override
updateback to summary
public void update(Map<String, Object> preferences)

Updates this map of preferences with a new set of platform preferences. The specified preferences may include all available preferences, or only the changed preferences. The absence of a mapping in the specified preferences does not indicate that it should be removed; instead, a key must be explicitly mapped to null to remove the mapping. Consequently, this map will never contain null values.

Parameters
preferences:Map<String, Object>

the new preference mappings

Exceptions
NullPointerException:
if preferences is null