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 Summary
Fields Modifier and Type Field Description private static ImageProviderdefaultIconProviderimage provider returning the default iconprivate java.util.List<java.lang.Throwable>errorsjava.lang.StringiconThe following fields is additional information found in the header of the source file.private ImageProviderimageIconProviderimage provider returning the icon for this styleprotected booleanloadedjava.util.Map<StyleSetting.StyleSettingGroup,java.util.List<StyleSetting>>settingGroupsMap of settings per group.java.util.List<StyleSetting>settingsList of settings for user customization.java.util.Map<java.lang.String,java.lang.Object>settingValuesValues of the settings for efficient lookup.private java.util.Set<java.lang.String>warningsjava.io.FilezipIconsThe zip file containing the icons for this style-
Fields inherited from class org.openstreetmap.josm.data.preferences.sources.SourceEntry
active, isZip, name, title, type, url, zipEntryPath
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedStyleSource(java.lang.String url, java.lang.String name, java.lang.String title)Constructs a new, activeStyleSource.protectedStyleSource(SourceEntry entry)Constructs a newStyleSource
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidapply(MultiCascade mc, IPrimitive osm, double scale, boolean pretendWayIsClosed)Apply style to osm primitive.voidcloseSourceInputStream(java.io.InputStream is)Closes the source input stream previously returned bygetSourceInputStream()and other linked resources, if applicable.java.awt.ColorgetBackgroundColorOverride()Gets the background color that was set in this styleabstract CachedFilegetCachedFile()Returns a newCachedFileto the local file containing style source (can be a text file or an archive).private static ImageProvidergetDefaultIconProvider()Image provider for default icon.java.util.Collection<java.lang.Throwable>getErrors()Replies the collection of errors that occurred with this style.javax.swing.ImageIcongetIcon()Image for source icon.ImageProvidergetIconProvider()Image provider for source icon.protected ImageProvidergetSourceIconProvider()Image provider for source icon.abstract java.io.InputStreamgetSourceInputStream()Returns a newInputStreamto the style source.java.lang.StringgetToolTipText()Return text to display as ToolTip.java.util.Collection<java.lang.String>getWarnings()Replies the collection of warnings that occurred with this style.protected voidinit()Initialize the class.booleanisLoaded()Determines if the style has been loaded (initialized).booleanisValid()Determines if this style is valid (no error, no warning).voidloadStyleSource()Loads the complete style source.abstract voidloadStyleSource(boolean metadataOnly)Loads the style source.voidlogError(java.lang.Throwable e)Log an error that occurred with this style.voidlogWarning(java.lang.String w)Log a warning that occurred with this style.-
Methods inherited from class org.openstreetmap.josm.data.preferences.sources.SourceEntry
equals, getDisplayString, getFileNamePart, getLocalSourceDir, getPrefName, getZipEntryDirName, hashCode, isLocal, toString
-
-
-
-
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
-
imageIconProvider
private ImageProvider imageIconProvider
image provider returning the icon for this style
-
defaultIconProvider
private static ImageProvider defaultIconProvider
image provider returning the default icon
-
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.
-
settingGroups
public final java.util.Map<StyleSetting.StyleSettingGroup,java.util.List<StyleSetting>> settingGroups
Map of settings per group.
-
-
Constructor Detail
-
StyleSource
protected StyleSource(java.lang.String url, java.lang.String name, java.lang.String title)
Constructs a new, activeStyleSource.- Parameters:
url- URL thatCachedFileunderstandsname- The name for this StyleSourcetitle- The title that can be used as menu entry
-
StyleSource
protected StyleSource(SourceEntry entry)
Constructs a newStyleSource- Parameters:
entry- The entry to copy the data (url, name, ...) from.
-
-
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 activeStyleSources 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 StyleSourceosm- the primitivescale- the map scalepretendWayIsClosed- 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- iftrue, only metadata are loaded- Since:
- 13845
-
getSourceInputStream
public abstract java.io.InputStream getSourceInputStream() throws java.io.IOException
Returns a newInputStreamto the style source. When finished,closeSourceInputStream(InputStream)must be called.- Returns:
- A new
InputStreamto the style source that must be closed by the caller - Throws:
java.io.IOException- if any I/O error occurs.- See Also:
closeSourceInputStream(InputStream)
-
getCachedFile
public abstract CachedFile getCachedFile() throws java.io.IOException
Returns a newCachedFileto the local file containing style source (can be a text file or an archive).- Returns:
- A new
CachedFileto the local file containing style source - Throws:
java.io.IOException- if any I/O error occurs.- Since:
- 7081
-
closeSourceInputStream
public void closeSourceInputStream(java.io.InputStream is)
Closes the source input stream previously returned bygetSourceInputStream()and other linked resources, if applicable.- Parameters:
is- The source input stream that must be closed- Since:
- 6289
- See Also:
getSourceInputStream()
-
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:
trueif this style has 0 errors and 0 warnings
-
init
protected void init()
Initialize the class.
-
getDefaultIconProvider
private static ImageProvider getDefaultIconProvider()
Image provider for default icon.- Returns:
- image provider for default styles icon
- Since:
- 8097
- See Also:
getIconProvider()
-
getSourceIconProvider
protected ImageProvider getSourceIconProvider()
Image provider for source icon. Uses default icon, when not else available.- Returns:
- image provider for styles icon
- Since:
- 8097
- See Also:
getIconProvider()
-
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
nullif it was not set
-
isLoaded
public final boolean isLoaded()
Determines if the style has been loaded (initialized).- Returns:
trueif the style has been loaded- Since:
- 13815
-
-