Class StyleSource

  • Direct Known Subclasses:
    MapCSSStyleSource

    public abstract class StyleSource
    extends SourceEntry
    A mappaint style (abstract class). Handles everything from parsing the style definition to application of the style to an osm primitive.
    • Field Detail

      • errors

        private final java.util.List<java.lang.Throwable> errors
      • warnings

        private final java.util.Set<java.lang.String> warnings
      • loaded

        protected boolean loaded
      • zipIcons

        public java.io.File zipIcons
        The zip file containing the icons for this style
      • icon

        public java.lang.String icon
        The following fields is additional information found in the header of the source file.
      • settings

        public final java.util.List<StyleSetting> settings
        List of settings for user customization.
      • settingValues

        public java.util.Map<java.lang.String,​java.lang.Object> settingValues
        Values of the settings for efficient lookup.
    • Constructor Detail

      • StyleSource

        protected StyleSource​(java.lang.String url,
                              java.lang.String name,
                              java.lang.String title)
        Constructs a new, active StyleSource.
        Parameters:
        url - URL that CachedFile understands
        name - The name for this StyleSource
        title - The title that can be used as menu entry
    • Method Detail

      • apply

        public abstract void apply​(MultiCascade mc,
                                   IPrimitive osm,
                                   double scale,
                                   boolean pretendWayIsClosed)
        Apply style to osm primitive. Adds properties to a MultiCascade. All active StyleSources add their properties on after the other. At a later stage, concrete painting primitives (lines, icons, text, ...) are derived from the MultiCascade.
        Parameters:
        mc - the current MultiCascade, empty for the first StyleSource
        osm - the primitive
        scale - the map scale
        pretendWayIsClosed - For styles that require the way to be closed, we pretend it is. This is useful for generating area styles from the (segmented) outer ways of a multipolygon.
        Since:
        13810 (signature)
      • loadStyleSource

        public void loadStyleSource()
        Loads the complete style source.
      • loadStyleSource

        public abstract void loadStyleSource​(boolean metadataOnly)
        Loads the style source.
        Parameters:
        metadataOnly - if true, only metadata are loaded
        Since:
        13845
      • getCachedFile

        public abstract CachedFile getCachedFile()
                                          throws java.io.IOException
        Returns a new CachedFile to the local file containing style source (can be a text file or an archive).
        Returns:
        A new CachedFile to the local file containing style source
        Throws:
        java.io.IOException - if any I/O error occurs.
        Since:
        7081
      • logError

        public void logError​(java.lang.Throwable e)
        Log an error that occurred with this style.
        Parameters:
        e - error
      • logWarning

        public void logWarning​(java.lang.String w)
        Log a warning that occurred with this style.
        Parameters:
        w - warnings
      • getErrors

        public java.util.Collection<java.lang.Throwable> getErrors()
        Replies the collection of errors that occurred with this style.
        Returns:
        collection of errors
      • getWarnings

        public java.util.Collection<java.lang.String> getWarnings()
        Replies the collection of warnings that occurred with this style.
        Returns:
        collection of warnings
      • isValid

        public boolean isValid()
        Determines if this style is valid (no error, no warning).
        Returns:
        true if this style has 0 errors and 0 warnings
      • init

        protected void init()
        Initialize the class.
      • getIconProvider

        public final ImageProvider getIconProvider()
        Image provider for source icon.
        Returns:
        image provider for styles icon
        Since:
        8097
      • getIcon

        public final javax.swing.ImageIcon getIcon()
        Image for source icon.
        Returns:
        styles icon for display
      • getToolTipText

        public java.lang.String getToolTipText()
        Return text to display as ToolTip.
        Returns:
        tooltip text containing error status
      • getBackgroundColorOverride

        public java.awt.Color getBackgroundColorOverride()
        Gets the background color that was set in this style
        Returns:
        The color or null if it was not set
      • isLoaded

        public final boolean isLoaded()
        Determines if the style has been loaded (initialized).
        Returns:
        true if the style has been loaded
        Since:
        13815