Class SimpleStyleableMap<K,V>

java.lang.Object
java.util.AbstractMap<K,V>
org.jhotdraw8.fxbase.styleable.SimpleStyleableMap<K,V>
Type Parameters:
K - key type
V - value type
All Implemented Interfaces:
Map<K,V>, javafx.beans.Observable, javafx.collections.ObservableMap<K,V>, StyleableMap<K,V>

public class SimpleStyleableMap<K,V> extends AbstractMap<K,V> implements StyleableMap<K,V>
A map which stores its values in an array, and which can share its keys with other SimpleStyleableMaps.

This map stores one distinct value for each StyleOrigin.

Author:
Werner Randelshofer
  • Constructor Details

    • SimpleStyleableMap

      public SimpleStyleableMap()
      Creates a new instance which supports insertion of new keys.
    • SimpleStyleableMap

      public SimpleStyleableMap(Map<K,Integer> keyMap)
      Creates a new instance which uses the provided key map.

      The key map can be shared with other instances, provided that the key map is immutable.

      All entries in the key map must contain distinct integer values in the range [0, keyMap.size() - 1].

      Parameters:
      keyMap - a map which maps from keys to indices. The indices must be in the range [0,keyMap.size()-1].
  • Method Details

    • entrySet

      public Set<Map.Entry<K,V>> entrySet(@Nullable javafx.css.StyleOrigin origin)
      Specified by:
      entrySet in interface StyleableMap<K,V>
    • addListener

      public void addListener(javafx.beans.InvalidationListener listener)
      Specified by:
      addListener in interface javafx.beans.Observable
    • addListener

      public void addListener(javafx.collections.MapChangeListener<? super K,? super V> observer)
      Specified by:
      addListener in interface javafx.collections.ObservableMap<K,V>
    • callObservers

      protected void callObservers(javafx.css.StyleOrigin origin, javafx.collections.MapChangeListener.Change<K,V> change)
    • clear

      public void clear()
      Clears the map.
      Specified by:
      clear in interface Map<K,V>
      Overrides:
      clear in class AbstractMap<K,V>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<K,V>
      Overrides:
      containsKey in class AbstractMap<K,V>
    • containsKey

      public <T extends K> boolean containsKey(@Nullable javafx.css.StyleOrigin origin, T key)
      Specified by:
      containsKey in interface StyleableMap<K,V>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<K,V>
      Overrides:
      containsValue in class AbstractMap<K,V>
    • containsValue

      public boolean containsValue(javafx.css.StyleOrigin origin, @Nullable Object value)
    • entrySet

      public Set<Map.Entry<K,V>> entrySet()
      Specified by:
      entrySet in interface Map<K,V>
      Specified by:
      entrySet in class AbstractMap<K,V>
    • get

      public @Nullable V get(Object key)
      Specified by:
      get in interface Map<K,V>
      Overrides:
      get in class AbstractMap<K,V>
    • getOrDefault

      public @Nullable V getOrDefault(Object key, @Nullable V defaultValue)
      Specified by:
      getOrDefault in interface Map<K,V>
    • get

      public @Nullable V get(javafx.css.StyleOrigin origin, K key)
      Specified by:
      get in interface StyleableMap<K,V>
    • getOrDefault

      public @Nullable V getOrDefault(javafx.css.StyleOrigin origin, K key, @Nullable V defaultValue)
    • getOrDefault

      protected @Nullable V getOrDefault(int originOrdinal, Object key, @Nullable V defaultValue)
    • getMap

      public Map<K,V> getMap(javafx.css.StyleOrigin origin)
      Specified by:
      getMap in interface StyleableMap<K,V>
    • getStyleOrigin

      public @Nullable javafx.css.StyleOrigin getStyleOrigin(K key)
      Specified by:
      getStyleOrigin in interface StyleableMap<K,V>
    • removeKey

      public V removeKey(javafx.css.StyleOrigin origin, K key)
      Description copied from interface: StyleableMap
      Removes the specified key from the specified style origin and puts the provided defaulting method for the key in place.
      Specified by:
      removeKey in interface StyleableMap<K,V>
      Parameters:
      origin - the style origin
      key - the key
    • getStyledMap

      public Map<K,V> getStyledMap()
      Specified by:
      getStyledMap in interface StyleableMap<K,V>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<K,V>
      Overrides:
      isEmpty in class AbstractMap<K,V>
    • keySet

      public Set<K> keySet()
      Specified by:
      keySet in interface Map<K,V>
      Overrides:
      keySet in class AbstractMap<K,V>
    • put

      public @Nullable V put(K key, V value)
      Specified by:
      put in interface Map<K,V>
      Overrides:
      put in class AbstractMap<K,V>
    • put

      public @Nullable V put(javafx.css.StyleOrigin styleOrigin, K key, V value)
      Specified by:
      put in interface StyleableMap<K,V>
    • put

      protected @Nullable V put(int originOrdinal, K key, V value)
    • remove

      public @Nullable V remove(Object key)
      Specified by:
      remove in interface Map<K,V>
      Overrides:
      remove in class AbstractMap<K,V>
    • removeAll

      public void removeAll(javafx.css.StyleOrigin origin)
      Specified by:
      removeAll in interface StyleableMap<K,V>
    • resetStyledValues

      public void resetStyledValues()
      Specified by:
      resetStyledValues in interface StyleableMap<K,V>
    • removeListener

      public void removeListener(javafx.beans.InvalidationListener listener)
      Specified by:
      removeListener in interface javafx.beans.Observable
    • removeListener

      public void removeListener(javafx.collections.MapChangeListener<? super K,? super V> observer)
      Specified by:
      removeListener in interface javafx.collections.ObservableMap<K,V>
    • getIdentityHash

      public int getIdentityHash()
    • size

      public int size()
      Specified by:
      size in interface Map<K,V>
      Overrides:
      size in class AbstractMap<K,V>
    • values

      public Collection<V> values()
      Specified by:
      values in interface Map<K,V>
      Overrides:
      values in class AbstractMap<K,V>
    • size

      public int size(@Nullable javafx.css.StyleOrigin origin)