Class GenericFontIcon

  • All Implemented Interfaces:
    FontIcon, Resource, java.io.Serializable

    public class GenericFontIcon
    extends java.lang.Object
    implements FontIcon
    A generic implementation of FontIcon interface.
    Since:
    7.5.0
    Author:
    Vaadin Ltd
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      GenericFontIcon​(java.lang.String fontFamily, int codepoint)
      Creates a new instance of GenericFontIcon with given font family and codepoint.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      int getCodepoint()
      Returns the unicode codepoint (character location) for this icon within the font given in FontIcon.getFontFamily().
      java.lang.String getFontFamily()
      Returns the name (font family) of the font from which this icon comes.
      java.lang.String getHtml()
      Returns HTML that can be used to display the icon in places where HTML can be used, such as a Label with ContentMode.HTML.
      static java.lang.String getHtml​(java.lang.String fontFamily, int codePoint)
      Utility method for generating HTML that displays an icon from specific fontFamiliy with a given codePoint in the font.
      java.lang.String getMIMEType()
      Gets the MIME type of the resource.
      int hashCode()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GenericFontIcon

        public GenericFontIcon​(java.lang.String fontFamily,
                               int codepoint)
        Creates a new instance of GenericFontIcon with given font family and codepoint.
        Parameters:
        fontFamily - Name of the type face that is used to display icons
        codepoint - Numerical code point in the font
    • Method Detail

      • getFontFamily

        public java.lang.String getFontFamily()
        Description copied from interface: FontIcon
        Returns the name (font family) of the font from which this icon comes. The name is used to apply the correct font where the icon is used.
        Specified by:
        getFontFamily in interface FontIcon
        Returns:
      • getMIMEType

        public java.lang.String getMIMEType()
        Description copied from interface: Resource
        Gets the MIME type of the resource.
        Specified by:
        getMIMEType in interface Resource
        Returns:
        the MIME type of the resource.
      • getCodepoint

        public int getCodepoint()
        Description copied from interface: FontIcon
        Returns the unicode codepoint (character location) for this icon within the font given in FontIcon.getFontFamily().

        For example, 0x0021 would in a regular font be the codepoint for the exclamation-point character.
        When constructing icon fonts, it might be a good idea to use the codepoints in the "Private use area", from 0xE000 0xF8FF.

        Specified by:
        getCodepoint in interface FontIcon
        Returns:
      • getHtml

        public java.lang.String getHtml()
        Description copied from interface: FontIcon
        Returns HTML that can be used to display the icon in places where HTML can be used, such as a Label with ContentMode.HTML.
        Specified by:
        getHtml in interface FontIcon
        Returns:
        HTML needed to display icon
      • getHtml

        public static java.lang.String getHtml​(java.lang.String fontFamily,
                                               int codePoint)
        Utility method for generating HTML that displays an icon from specific fontFamiliy with a given codePoint in the font.
        Parameters:
        fontFamily - Name of the font family
        codePoint - Icon's character code point in the font
        Returns:
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object