Class Margin

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


    public class Margin
    extends AbstractCssProperty<Margin>
    implements StateChangeInformer<CssProperty>
     The margin shorthand property sets all the margin properties in one declaration. This property can have from one to four values.
    
     Examples:
    
         margin:10px 5px 15px 20px;
             top margin is 10px
             right margin is 5px
             bottom margin is 15px
             left margin is 20px
    
         margin:10px 5px 15px;
             top margin is 10px
             right and left margin are 5px
             bottom margin is 15px
    
         margin:10px 5px;
             top and bottom margin are 10px
             right and left margin are 5px
    
         margin:10px;
             all four margins are 10px
    
     Note: Negative values are not allowed.
     Default value:  0
     Inherited:      no
     Animatable:     yes
    
     Version:        CSS1
     JavaScript syntax:      object.style.margin="100px 20px"
     
    Since:
    1.0.0
    See Also:
    Serialized Form
    • Field Detail

      • LOGGER

        public static final java.util.logging.Logger LOGGER
    • Constructor Detail

      • Margin

        public Margin​()
        The initial will be set as the value
      • Margin

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

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

      • setValue

        public Margin setValue​(java.lang.String value)
        the margin length to set. The alternative method setCssValue can also be used.
        Parameters:
        value -
        Returns:
        the current object
        Since:
        1.0.0
      • 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
      • getValue

        public java.lang.String getValue​()
        gets the value, getCssValue method can also be used to get the same value.
        Returns:
        the value in String.
        Since:
        1.0.0
      • setCssValue

        public Margin setCssValue​(java.lang.String cssValue)
        Specified by:
        setCssValue in class AbstractCssProperty<Margin>
        Parameters:
        cssValue - the value should be a length value, for example 5px. null is considered as an invalid value and it will throw NullValueException.And an empty string is also considered as an invalid value and it will throw InvalidValueException.
        Returns:
        the current object.
        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
      • setAsAuto

        public void setAsAuto​()
        sets as inherit
        Since:
        1.0.0
      • getMarginTop

        public MarginTop getMarginTop​()
        Returns:
        the marginTop
        Since:
        1.0.0
      • setMargin

        public void setMargin​(MarginTop marginTop,
                              MarginRight marginRight,
                              MarginBottom marginBottom,
                              MarginLeft marginLeft)
        sets the top, right, bottom & left width in Margin. If the given argument is already used by another object, then the existing/cloned object will be used. And throws NullValueException if any of the given argument is null.
        Parameters:
        marginTop -
        marginRight -
        marginBottom -
        marginLeft -
        Since:
        1.0.0
      • getMarginRight

        public MarginRight getMarginRight​()
        Returns:
        the marginRight
        Since:
        1.0.0
      • getMarginBottom

        public MarginBottom getMarginBottom​()
        Returns:
        the marginBottom
        Since:
        1.0.0
      • getMarginLeft

        public MarginLeft getMarginLeft​()
        Returns:
        the marginLeft
        Since:
        1.0.0
      • hasPredefinedConstantValue

        public boolean hasPredefinedConstantValue​()
        Returns:
        true if its cssValue is any of the values initial, inherit or transparent.
        Since:
        1.0.0
      • isValid

        public static boolean isValid​(java.lang.String cssValue)
        Since:
        1.0.0