Class FontSpec

  • All Implemented Interfaces:
    Serializable

    @NotThreadSafe
    @MustImplementEqualsAndHashcode
    public class FontSpec
    extends Object
    implements Serializable
    Defines a text font specification containing the font, the font size and the text color.
    Author:
    Philip Helger
    See Also:
    Serialized Form
    • Field Detail

      • DEFAULT_COLOR

        public static final Color DEFAULT_COLOR
        The default font color: black
    • Constructor Detail

      • FontSpec

        public FontSpec​(@Nonnull
                        PreloadFont aPreloadFont,
                        @Nonnegative
                        float fFontSize)
        Constructor with a PreloadFont and a font size, using the default color DEFAULT_COLOR.
        Parameters:
        aPreloadFont - Preload font to use. May not be null.
        fFontSize - Font size to use. Must be > 0.
      • FontSpec

        public FontSpec​(@Nonnull
                        PreloadFont aPreloadFont,
                        @Nonnegative
                        float fFontSize,
                        @Nonnull
                        Color aColor)
        Constructor with a PreloadFont, a font size and a custom color.
        Parameters:
        aPreloadFont - Preload font to use. May not be null.
        fFontSize - Font size to use. Must be > 0.
        aColor - The color to use. May not be null.
    • Method Detail

      • getPreloadFont

        @Nonnull
        public final PreloadFont getPreloadFont()
        Returns:
        The font to use. Never null.
      • getPreloadFontID

        @Nonnull
        @Nonempty
        public final String getPreloadFontID()
        Returns:
        The ID of the font to use. Never null.
      • getFontSize

        @Nonnegative
        public final float getFontSize()
        Returns:
        The font size in points. Always > 0.
      • getColor

        @Nonnull
        public final Color getColor()
        Returns:
        The text color to use.
      • getCloneWithDifferentFont

        @Nonnull
        public FontSpec getCloneWithDifferentFont​(@Nonnull
                                                  PreloadFont aNewFont)
        Return a clone of this object but with a different font.
        Parameters:
        aNewFont - The new font to use. Must not be null.
        Returns:
        this if the fonts are equal - a new object otherwise.
      • getCloneWithDifferentFontSize

        @Nonnull
        public FontSpec getCloneWithDifferentFontSize​(float fNewFontSize)
        Return a clone of this object but with a different font size.
        Parameters:
        fNewFontSize - The new font size to use. Must be > 0.
        Returns:
        this if the font sizes are equal - a new object otherwise.
      • getCloneWithDifferentColor

        @Nonnull
        public FontSpec getCloneWithDifferentColor​(@Nonnull
                                                   Color aNewColor)
        Return a clone of this object but with a different color.
        Parameters:
        aNewColor - The new color to use. May not be null.
        Returns:
        this if the colors are equal - a new object otherwise.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object