Class StyleSource
java.lang.Object
org.openstreetmap.josm.data.preferences.sources.SourceEntry
org.openstreetmap.josm.gui.mappaint.StyleSource
- Direct Known Subclasses:
MapCSSStyleSource
A mappaint style (abstract class).
Handles everything from parsing the style definition to application
of the style to an osm primitive.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static ImageProviderimage provider returning the default iconThe following fields is additional information found in the header of the source file.private ImageProviderimage provider returning the icon for this styleprotected booleanMap of settings per group.final List<StyleSetting>List of settings for user customization.Values of the settings for efficient lookup.The zip file containing the icons for this styleFields inherited from class org.openstreetmap.josm.data.preferences.sources.SourceEntry
active, isZip, name, title, type, url, zipEntryPath -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedStyleSource(String url, String name, String title) Constructs a new, activeStyleSource.protectedStyleSource(SourceEntry entry) Constructs a newStyleSource -
Method Summary
Modifier and TypeMethodDescriptionabstract voidapply(MultiCascade mc, IPrimitive osm, double scale, boolean pretendWayIsClosed) Apply style to osm primitive.voidCloses the source input stream previously returned bygetSourceInputStream()and other linked resources, if applicable.Gets the background color that was set in this styleabstract CachedFileReturns a newCachedFileto the local file containing style source (can be a text file or an archive).private static ImageProviderImage provider for default icon.Replies the collection of errors that occurred with this style.final ImageIcongetIcon()Image for source icon.final ImageProviderImage provider for source icon.protected ImageProviderImage provider for source icon.abstract InputStreamReturns a newInputStreamto the style source.Return text to display as ToolTip.Replies the collection of warnings that occurred with this style.protected voidinit()Initialize the class.final booleanisLoaded()Determines if the style has been loaded (initialized).booleanisValid()Determines if this style is valid (no error, no warning).voidLoads the complete style source.abstract voidloadStyleSource(boolean metadataOnly) Loads the style source.voidLog an error that occurred with this style.voidlogWarning(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 Details
-
errors
-
warnings
-
loaded
-
zipIcons
The zip file containing the icons for this style -
imageIconProvider
image provider returning the icon for this style -
defaultIconProvider
image provider returning the default icon -
icon
The following fields is additional information found in the header of the source file. -
settings
List of settings for user customization. -
settingValues
Values of the settings for efficient lookup. -
settingGroups
Map of settings per group.
-
-
Constructor Details
-
StyleSource
Constructs a new, activeStyleSource.- Parameters:
url- URL thatCachedFileunderstandsname- The name for this StyleSourcetitle- The title that can be used as menu entry
-
StyleSource
Constructs a newStyleSource- Parameters:
entry- The entry to copy the data (url, name, ...) from.
-
-
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 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
Loads the complete style source. -
loadStyleSource
Loads the style source.- Parameters:
metadataOnly- iftrue, only metadata are loaded- Since:
- 13845
-
getSourceInputStream
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:
IOException- if any I/O error occurs.- See Also:
-
getCachedFile
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:
IOException- if any I/O error occurs.- Since:
- 7081
-
closeSourceInputStream
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:
-
logError
Log an error that occurred with this style.- Parameters:
e- error
-
logWarning
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
Determines if this style is valid (no error, no warning).- Returns:
trueif this style has 0 errors and 0 warnings
-
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
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
nullif it was not set
-
isLoaded
Determines if the style has been loaded (initialized).- Returns:
trueif the style has been loaded- Since:
- 13815
-