Class CSSClassManager


  • public class CSSClassManager
    extends java.lang.Object
    Manager class to track CSS classes used in a particular SVG document.
    Since:
    0.2
    Author:
    Erich Schubert
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.HashMap<java.lang.String,​CSSClass> store
      Store the contained CSS classes.
    • Constructor Summary

      Constructors 
      Constructor Description
      CSSClassManager()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      CSSClass addClass​(CSSClass clss)
      Add a single class to the map.
      boolean contains​(java.lang.String name)
      Check if a name is already used in the classes.
      CSSClass getClass​(java.lang.String name)
      Retrieve a single class by name only
      CSSClass getClass​(java.lang.String name, java.lang.Object owner)
      Retrieve a single class by name and owner
      java.util.Collection<CSSClass> getClasses()
      Get all CSS classes in this manager.
      org.w3c.dom.Element makeStyleElement​(org.w3c.dom.Document document)
      Make a (filled) CSS style element for the given document.
      boolean mergeCSSFrom​(CSSClassManager other)
      Merge CSS classes, for example to merge two plots.
      void removeClass​(CSSClass clss)
      Remove a single CSS class from the map.
      void serialize​(java.lang.StringBuilder buf)
      Serialize managed CSS classes to rule file.
      boolean testMergeable​(CSSClassManager other)
      Check whether or not CSS classes of two plots can be merged
      void updateStyleElement​(org.w3c.dom.Document document, org.w3c.dom.Element style)
      Update the text contents of an existing style element.
      • Methods inherited from class java.lang.Object

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

      • store

        private java.util.HashMap<java.lang.String,​CSSClass> store
        Store the contained CSS classes.
    • Constructor Detail

      • CSSClassManager

        public CSSClassManager()
    • Method Detail

      • removeClass

        public void removeClass​(CSSClass clss)
        Remove a single CSS class from the map. Note that classes are removed by reference, not by name!
        Parameters:
        clss - Class to remove
      • getClass

        public CSSClass getClass​(java.lang.String name)
        Retrieve a single class by name only
        Parameters:
        name - CSS class name
        Returns:
        existing (old) class
      • contains

        public boolean contains​(java.lang.String name)
        Check if a name is already used in the classes.
        Parameters:
        name - CSS class name
        Returns:
        true if the class name is already used.
      • serialize

        public void serialize​(java.lang.StringBuilder buf)
        Serialize managed CSS classes to rule file.
        Parameters:
        buf - String buffer
      • getClasses

        public java.util.Collection<CSSClass> getClasses()
        Get all CSS classes in this manager.
        Returns:
        CSS classes.
      • testMergeable

        public boolean testMergeable​(CSSClassManager other)
        Check whether or not CSS classes of two plots can be merged
        Parameters:
        other - Other class
        Returns:
        true if able to merge
      • updateStyleElement

        public void updateStyleElement​(org.w3c.dom.Document document,
                                       org.w3c.dom.Element style)
        Update the text contents of an existing style element.
        Parameters:
        document - Document element (factory)
        style - Style element
      • makeStyleElement

        public org.w3c.dom.Element makeStyleElement​(org.w3c.dom.Document document)
        Make a (filled) CSS style element for the given document.
        Parameters:
        document - Document
        Returns:
        Style element