Class StyleSource

java.lang.Object
org.openstreetmap.josm.data.preferences.sources.SourceEntry
org.openstreetmap.josm.gui.mappaint.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 Details

  • Constructor Details

  • Method Details

    • 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
    • getSourceInputStream

      public abstract InputStream getSourceInputStream() throws IOException
      Returns a new InputStream to the style source. When finished, closeSourceInputStream(InputStream) must be called.
      Returns:
      A new InputStream to the style source that must be closed by the caller
      Throws:
      IOException - if any I/O error occurs.
      See Also:
    • getCachedFile

      public abstract CachedFile getCachedFile() throws 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:
      IOException - if any I/O error occurs.
      Since:
      7081
    • closeSourceInputStream

      Closes the source input stream previously returned by getSourceInputStream() and other linked resources, if applicable.
      Parameters:
      is - The source input stream that must be closed
      Since:
      6289
      See Also:
    • logError

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

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

      Replies the collection of errors that occurred with this style.
      Returns:
      collection of errors
    • 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.
    • getDefaultIconProvider

      Image provider for default icon.
      Returns:
      image provider for default styles icon
      Since:
      8097
      See Also:
    • getSourceIconProvider

      Image provider for source icon. Uses default icon, when not else available.
      Returns:
      image provider for styles icon
      Since:
      8097
      See Also:
    • getIconProvider

      Image provider for source icon.
      Returns:
      image provider for styles icon
      Since:
      8097
    • getIcon

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

      Return text to display as ToolTip.
      Returns:
      tooltip text containing error status
    • 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