Class Font

  • All Implemented Interfaces:
    CssProperty, StateChangeInformer<CssProperty>, java.io.Serializable, java.lang.Cloneable


    public class Font
    extends AbstractCssProperty<Font>
    implements StateChangeInformer<CssProperty>
     font: font-style font-variant font-weight font-size/line-height font-family|caption|icon|menu|message-box|small-caption|status-bar|initial|inherit;
    
     The font shorthand property sets all the font properties in one declaration.
    
     The properties that can be set, are (in order): "font-style font-variant font-weight font-size/line-height font-family"
    
     The font-size and font-family values are required. If one of the other values are missing, the default values will be inserted, if any.
    
     Note: The line-height property sets the space between lines.
     Default value:  The default value of all the font properties
     Inherited:      yes
     Animatable:     yes, see individual properties. Read about animatable
     Version:        CSS1
     JavaScript syntax:      object.style.font="italic small-caps bold 12px/1.4 arial,sans-serif"
     
    Since:
    1.0.0
    See Also:
    Serialized Form
    • Constructor Detail

      • Font

        public Font​()
        The value initial will be assigned as the cssValue.
        Since:
        1.0.0
      • Font

        public Font​(java.lang.String cssValue)
        Parameters:
        cssValue - the css value to set.
      • Font

        public Font​(Font font)
        Parameters:
        font - the Font object from which the cssValue to set.And, null will throw NullValueException
    • Method Detail

      • getCssName

        public java.lang.String getCssName​()
        Specified by:
        getCssName in interface CssProperty
        Returns:
        the name portion in style, eg align-content for style align-content: center.
      • getCssValue

        public java.lang.String getCssValue​()
        Specified by:
        getCssValue in interface CssProperty
        Returns:
        the value portion in style, eg center for style align-content: center.
      • toString

        public java.lang.String toString​()
        Overrides:
        toString in class java.lang.Object
      • setCssValue

        public Font setCssValue​(java.lang.String cssValue)
        Specified by:
        setCssValue in class AbstractCssProperty<Font>
        Parameters:
        cssValue - the value should be in the format of italic small-caps bold 12px arial,sans-serif or initial/inherit. null is considered as an invalid value and it will throw NullValueException.
        Returns:
        the current object.
        Since:
        1.0.0
      • getExtractedSubCssValues

        protected static java.lang.String[] getExtractedSubCssValues​(java.lang.String cssValue)
        Parameters:
        cssValue -
        Returns:
        the sub properties
        Since:
        1.0.0
      • isValid

        public static boolean isValid​(java.lang.String cssValue)
        checks the given css value is valid for this class. It does't do a strict validation.
        Parameters:
        cssValue -
        Returns:
        Since:
        1.0.0
      • setAsInitial

        public void setAsInitial​()
        sets as initial
        Since:
        1.0.0
      • setAsInherit

        public void setAsInherit​()
        sets as inherit
        Since:
        1.0.0
      • setAsCaption

        public void setAsCaption​()
        sets as caption
        Since:
        1.0.0
      • setAsIcon

        public void setAsIcon​()
        sets as icon
        Since:
        1.0.0
      • setAsMenu

        public void setAsMenu​()
        sets as menu
        Since:
        1.0.0
      • setAsMessageBox

        public void setAsMessageBox​()
        sets as message-box
        Since:
        1.0.0
      • setAsSmallCaption

        public void setAsSmallCaption​()
        sets as small-caption
        Since:
        1.0.0
      • setAsStatusBar

        public void setAsStatusBar​()
        sets as status-bar
        Since:
        1.0.0
      • getFontSize

        public FontSize getFontSize​()
      • getLineHeight

        public LineHeight getLineHeight​()
        Returns:
        the lineHeight
        Since:
        1.0.0
      • getFontFamily

        public FontFamily getFontFamily​()
        Returns:
        the fontFamily
        Since:
        1.0.0
      • getFontVariant

        public FontVariant getFontVariant​()
      • getFontWeight

        public FontWeight getFontWeight​()
        Returns:
        the fontWeight
        Since:
        1.0.0
      • getFontStyle

        public FontStyle getFontStyle​()
      • setFontStyle

        public Font setFontStyle​(FontStyle fontStyle)
      • setFontWeight

        public Font setFontWeight​(FontWeight fontWeight)
      • setFontSize

        public Font setFontSize​(FontSize fontSize)
      • setLineHeight

        public Font setLineHeight​(LineHeight lineHeight)
      • setFontFamily

        public Font setFontFamily​(FontFamily fontFamily)
      • addPredefinedConstant

        protected void addPredefinedConstant​(java.lang.String constant)
        Since:
        1.0.0