Class PropertiesBasedStyleLibrary

  • All Implemented Interfaces:
    StyleLibrary

    public class PropertiesBasedStyleLibrary
    extends java.lang.Object
    implements StyleLibrary
    Style library loading the parameters from a properties file.
    Since:
    0.3
    Author:
    Erich Schubert
    • Field Detail

      • LOG

        private static final Logging LOG
        Logger
      • DEFAULT_SCHEME_NAME

        public static final java.lang.String DEFAULT_SCHEME_NAME
        Name of the default color scheme.
        See Also:
        Constant Field Values
      • DEFAULT_SCHEME_FILENAME

        public static final java.lang.String DEFAULT_SCHEME_FILENAME
        File name of the default color scheme.
        See Also:
        Constant Field Values
      • DEFAULT_PROPERTIES_EXTENSION

        public static final java.lang.String DEFAULT_PROPERTIES_EXTENSION
        File extension
        See Also:
        Constant Field Values
      • DEFAULT_PROPERTIES_PATH

        private static final java.lang.String DEFAULT_PROPERTIES_PATH
        Default properties path
      • LIST_SEPARATOR

        public static final java.lang.String LIST_SEPARATOR
        Separator for lists.
        See Also:
        Constant Field Values
      • PROP_LINES_LIBRARY

        public static final java.lang.String PROP_LINES_LIBRARY
        Property string for the line style library
        See Also:
        Constant Field Values
      • PROP_MARKER_LIBRARY

        public static final java.lang.String PROP_MARKER_LIBRARY
        Property string for the marker style library
        See Also:
        Constant Field Values
      • properties

        private java.util.Properties properties
        Properties file to use.
      • name

        private java.lang.String name
        Style scheme name
      • cache

        private java.util.Map<java.lang.String,​java.lang.Object> cache
        Cache
      • markerlib

        private MarkerLibrary markerlib
        Marker library to use
    • Constructor Detail

      • PropertiesBasedStyleLibrary

        public PropertiesBasedStyleLibrary()
        Constructor without a properties file name.
      • PropertiesBasedStyleLibrary

        public PropertiesBasedStyleLibrary​(java.lang.String filename,
                                           java.lang.String name)
        Constructor with a given file name.
        Parameters:
        filename - Name of properties file.
        name - NAme for this style
    • Method Detail

      • getName

        protected java.lang.String getName()
        Get the style scheme name.
        Returns:
        the name
      • getCached

        private <T> T getCached​(java.lang.String prefix,
                                java.lang.String postfix,
                                java.lang.Class<T> cls)
        Get a value from the cache (to avoid repeated parsing)
        Type Parameters:
        T - Type
        Parameters:
        prefix - Tree name
        postfix - Property name
        cls - Class restriction
        Returns:
        Resulting value
      • setCached

        private <T> void setCached​(java.lang.String prefix,
                                   java.lang.String postfix,
                                   T data)
        Set a cache value
        Type Parameters:
        T - Type
        Parameters:
        prefix - Tree name
        postfix - Property name
        data - Data
      • getPropertyValue

        protected java.lang.String getPropertyValue​(java.lang.String prefix,
                                                    java.lang.String postfix)
        Retrieve the property value for a particular path + type pair.
        Parameters:
        prefix - Path
        postfix - Type
        Returns:
        Value
      • getColor

        public java.lang.String getColor​(java.lang.String key)
        Description copied from interface: StyleLibrary
        Retrieve a color for an item
        Specified by:
        getColor in interface StyleLibrary
        Parameters:
        key - Reference name
        Returns:
        color in CSS/SVG valid format: hexadecimal (#aabbcc) or names such as "red"
      • getBackgroundColor

        public java.lang.String getBackgroundColor​(java.lang.String key)
        Description copied from interface: StyleLibrary
        Retrieve background color for an item
        Specified by:
        getBackgroundColor in interface StyleLibrary
        Parameters:
        key - Reference name
        Returns:
        color in CSS/SVG valid format: hexadecimal (#aabbcc) or names such as "red"
      • getTextColor

        public java.lang.String getTextColor​(java.lang.String key)
        Description copied from interface: StyleLibrary
        Retrieve text color for an item
        Specified by:
        getTextColor in interface StyleLibrary
        Parameters:
        key - Reference name
        Returns:
        color in CSS/SVG valid format: hexadecimal (#aabbcc) or names such as "red"
      • getColorSet

        public ColorLibrary getColorSet​(java.lang.String key)
        Description copied from interface: StyleLibrary
        Retrieve colorset for an item
        Specified by:
        getColorSet in interface StyleLibrary
        Parameters:
        key - Reference name
        Returns:
        color library
      • getLineWidth

        public double getLineWidth​(java.lang.String key)
        Description copied from interface: StyleLibrary
        Get line width
        Specified by:
        getLineWidth in interface StyleLibrary
        Parameters:
        key - Key
        Returns:
        line width as double
      • getTextSize

        public double getTextSize​(java.lang.String key)
        Description copied from interface: StyleLibrary
        Get text size
        Specified by:
        getTextSize in interface StyleLibrary
        Parameters:
        key - Key
        Returns:
        line width as double
      • getFontFamily

        public java.lang.String getFontFamily​(java.lang.String key)
        Description copied from interface: StyleLibrary
        Get font family
        Specified by:
        getFontFamily in interface StyleLibrary
        Parameters:
        key - Key
        Returns:
        font family CSS string
      • getSize

        public double getSize​(java.lang.String key)
        Description copied from interface: StyleLibrary
        Get generic size
        Specified by:
        getSize in interface StyleLibrary
        Parameters:
        key - Key
        Returns:
        size as double
      • getOpacity

        public double getOpacity​(java.lang.String key)
        Description copied from interface: StyleLibrary
        Get opacity
        Specified by:
        getOpacity in interface StyleLibrary
        Parameters:
        key - Key
        Returns:
        size as double