Package org.geotools.mbstyle.sprite
Class SpriteIndex
Object
SpriteIndex
Wrapper that takes the sprite index file (as a JSONObject) for a Mapbox Sprite Sheet and parses the all the
individual icons as
SpriteIndex.IconInfo objects. For example:
{
"goldfish": {
"height": 32,
"pixelRatio": 1,
"width": 32,
"x": 64,
"y": 64
},
"owl": {
"height": 64,
"pixelRatio": 1,
"width": 64,
"x": 0,
"y": 0
}
}
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classWrapper for parsing the properties of an individual sprite index entry (JSONObject) for a single icon. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet information about a single icon from the indexImmutableMap<String,SpriteIndex.IconInfo> getIcons()Get the names and data of all icons in the indexprotected static SpriteIndex.IconInfoparseIconInfoFromIndex(JSONObject iconIndex, String iconName) Parse theSpriteIndex.IconInfofor the provided iconName in the provided icon index.
-
Constructor Details
-
SpriteIndex
- Parameters:
spriteIndexUrl- The URL of the sprite index file (used for error messages).json- The sprite index file as aJSONObject.
-
-
Method Details
-
parseIconInfoFromIndex
Parse theSpriteIndex.IconInfofor the provided iconName in the provided icon index.- Parameters:
iconIndex- The icon index file.iconName- The name of the icon in the index file.- Returns:
- An
SpriteIndex.IconInfofor the icon.
-
getIcons
Get the names and data of all icons in the index- Returns:
- An immutable map of the icon name to the corresponding
SpriteIndex.IconInfo
-
getIcon
Get information about a single icon from the index- Parameters:
iconName- Name of the icon- Returns:
- Info object describing the icons
-