Class StrokeMap

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class StrokeMap
    extends java.lang.Object
    implements java.lang.Cloneable, java.io.Serializable
    A storage structure that maps Comparable instances with Stroke instances.

    To support cloning and serialization, you should only use keys that are cloneable and serializable. Special handling for the Stroke instances is included in this class.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static long serialVersionUID
      For serialization.
      private java.util.Map store
      Storage for the keys and values.
    • Constructor Summary

      Constructors 
      Constructor Description
      StrokeMap()
      Creates a new (empty) map.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Resets the map to empty.
      java.lang.Object clone()
      Returns a clone of this StrokeMap.
      boolean containsKey​(java.lang.Comparable key)
      Returns true if the map contains the specified key, and false otherwise.
      boolean equals​(java.lang.Object obj)
      Tests this map for equality with an arbitrary object.
      java.awt.Stroke getStroke​(java.lang.Comparable key)
      Returns the stroke associated with the specified key, or null.
      void put​(java.lang.Comparable key, java.awt.Stroke stroke)
      Adds a mapping between the specified key and stroke values.
      private void readObject​(java.io.ObjectInputStream stream)
      Provides serialization support.
      private void writeObject​(java.io.ObjectOutputStream stream)
      Provides serialization support.
      • Methods inherited from class java.lang.Object

        finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • serialVersionUID

        static final long serialVersionUID
        For serialization.
        See Also:
        Constant Field Values
      • store

        private transient java.util.Map store
        Storage for the keys and values.
    • Constructor Detail

      • StrokeMap

        public StrokeMap()
        Creates a new (empty) map.
    • Method Detail

      • getStroke

        public java.awt.Stroke getStroke​(java.lang.Comparable key)
        Returns the stroke associated with the specified key, or null.
        Parameters:
        key - the key (null not permitted).
        Returns:
        The stroke, or null.
        Throws:
        java.lang.IllegalArgumentException - if key is null.
      • containsKey

        public boolean containsKey​(java.lang.Comparable key)
        Returns true if the map contains the specified key, and false otherwise.
        Parameters:
        key - the key.
        Returns:
        true if the map contains the specified key, and false otherwise.
      • put

        public void put​(java.lang.Comparable key,
                        java.awt.Stroke stroke)
        Adds a mapping between the specified key and stroke values.
        Parameters:
        key - the key (null not permitted).
        stroke - the stroke.
      • clear

        public void clear()
        Resets the map to empty.
      • equals

        public boolean equals​(java.lang.Object obj)
        Tests this map for equality with an arbitrary object.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - the object (null permitted).
        Returns:
        A boolean.
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Returns a clone of this StrokeMap.
        Overrides:
        clone in class java.lang.Object
        Returns:
        A clone of this instance.
        Throws:
        java.lang.CloneNotSupportedException - if any key is not cloneable.
      • writeObject

        private void writeObject​(java.io.ObjectOutputStream stream)
                          throws java.io.IOException
        Provides serialization support.
        Parameters:
        stream - the output stream.
        Throws:
        java.io.IOException - if there is an I/O error.
      • readObject

        private void readObject​(java.io.ObjectInputStream stream)
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException
        Provides serialization support.
        Parameters:
        stream - the input stream.
        Throws:
        java.io.IOException - if there is an I/O error.
        java.lang.ClassNotFoundException - if there is a classpath problem.