Class JWTIconFontMapper

java.lang.Object
com.jadice.web.util.icon.client.iconfont.JWTIconFontMapper

public class JWTIconFontMapper extends Object
In some cases, for example when selecting the image for an annotation, we need to get the icon by the name of the annotation. The same icon can be requested by different names (for examples in different annotation profiles the open polygon is either called polygon or open polygon). In other cases the requested name and the icon differs. In this class mappings from a requested name to an IconFont can be defined. If a name is requested but no mapping is defined JWTIconFont.valueOf(String) is called.
  • Constructor Details

    • JWTIconFontMapper

      public JWTIconFontMapper()
  • Method Details

    • get

      public static JWTIconFontMapper get()
    • getMappingForName

      public IconFont getMappingForName(String name)
      Returns the defined mapping. If no mapping is defined returns the matching value of JWTIconFont.valueOf(String). If there is no matching JWTIconFont null will be returned.
      Parameters:
      name - the name for which the mapping should be returned
      Returns:
      the mapping or null
    • getMappingForNameWithFallback

      public IconFont getMappingForNameWithFallback(String name)
      Returns the defined mapping. If no mapping is defined returns the matching value of JWTIconFont.valueOf(String). If there is no matching JWTIconFont the JWTIconFont.MISSING_ICON will be returned.
      Parameters:
      name - the name for which the mapping should be returned
      Returns:
      the mapping or the fallback icon
    • resetMappings

      public void resetMappings()
      Deletes all defined mappings.
    • addMapping

      public void addMapping(String name, IconFont font)
      Adds a new mapping.
      Parameters:
      name - the name for the mapping
      font - the font which should be returned when calling getMappingForName(String) or getMappingForNameWithFallback(String)