Package org.geotools.mbstyle.sprite
Class SpriteIndex
- Object
-
- SpriteIndex
-
public class SpriteIndex extends Object
Wrapper that takes the sprite index file (as a JSONObject) for a Mapbox Sprite Sheet and parses the all the individual icons asSpriteIndex.IconInfoobjects. 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 Classes Modifier and Type Class Description static classSpriteIndex.IconInfoWrapper for parsing the properties of an individual sprite index entry (JSONObject) for a single icon.
-
Constructor Summary
Constructors Constructor Description SpriteIndex(String spriteIndexUrl, JSONObject json)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SpriteIndex.IconInfogetIcon(String iconName)Get 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 Detail
-
SpriteIndex
public SpriteIndex(String spriteIndexUrl, JSONObject json)
- Parameters:
spriteIndexUrl- The URL of the sprite index file (used for error messages).json- The sprite index file as aJSONObject.
-
-
Method Detail
-
parseIconInfoFromIndex
protected static SpriteIndex.IconInfo parseIconInfoFromIndex(JSONObject iconIndex, String iconName)
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
public ImmutableMap<String,SpriteIndex.IconInfo> 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
public SpriteIndex.IconInfo getIcon(String iconName)
Get information about a single icon from the index- Parameters:
iconName- Name of the icon- Returns:
- Info object describing the icons
-
-