Class BorderWidth

All Implemented Interfaces:
CssProperty, StateChangeInformer<CssProperty>, Serializable, Cloneable

public class BorderWidth extends AbstractCssProperty<BorderWidth> implements StateChangeInformer<CssProperty>

 border-width: medium|thin|thick|length|initial|inherit;

 The border-width property sets the width of an element's four borders. This property can have from one to four values.

 Examples:

     border-width:thin medium thick 10px;
         top border is thin
         right border is medium
         bottom border is thick
         left border is 10px

     border-width:thin medium thick;
         top border is thin
         right and left borders are medium
         bottom border is thick

     border-width:thin medium;
         top and bottom borders are thin
         right and left borders are medium

     border-width:thin;
         all four borders are thin

 Note: Always declare the border-style property before the border-width property. An element must have borders before you can set the width.
 
Since:
1.0.0
See Also:
  • Field Details

  • Constructor Details

    • BorderWidth

      public BorderWidth()
      The medium will be set as the value
    • BorderWidth

      public BorderWidth(String cssValue)
      Parameters:
      cssValue - the css value to set.
    • BorderWidth

      public BorderWidth(BorderWidth borderBottomWidth)
      Parameters:
      borderBottomWidth - the BorderBottomWidth object from which the cssValue to set.And, null will throw NullValueException
    • BorderWidth

      public BorderWidth(float percent)
      Parameters:
      percent - the percentage value to set. The cssLengthUnit will automatically set to %.
      Since:
      1.0.0
    • BorderWidth

      public BorderWidth(float value, CssLengthUnit cssLengthUnit)
      Parameters:
      value -
      cssLengthUnit -
  • Method Details

    • setValue

      public BorderWidth setValue(float value, CssLengthUnit cssLengthUnit)
      Parameters:
      value -
      cssLengthUnit -
      Returns:
      the current object
      Since:
      1.0.0
    • setPercent

      public void setPercent(float percent)
      Parameters:
      percent - the percent to set
      Since:
      1.0.0
    • getCssName

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

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

      public String toString()
      Overrides:
      toString in class Object
    • setCssValue

      public BorderWidth setCssValue(String cssValue)
      Specified by:
      setCssValue in class AbstractCssProperty<BorderWidth>
      Parameters:
      cssValue - the value should be in the format of 55px or 95%. null is considered as an invalid value and it will throw NullValueException.
      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
    • setAsMedium

      public void setAsMedium()
      sets as medium.
      Since:
      1.0.0
    • setAsThin

      public void setAsThin()
      sets as thin.
      Since:
      1.0.0
    • setAsThick

      public void setAsThick()
      sets as thick.
      Since:
      1.0.0
    • setBorderWidth

      public void setBorderWidth(BorderTopWidth borderTopWidth, BorderRightWidth borderRightWidth, BorderBottomWidth borderBottomWidth, BorderLeftWidth borderLeftWidth)
      sets the top, right, bottom and left width in BorderWidth. 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:
      borderTopWidth -
      borderRightWidth -
      borderBottomWidth -
      borderLeftWidth -
      Since:
      1.0.0
    • getBorderTopWidth

      public BorderTopWidth getBorderTopWidth()
      Returns:
      the borderTopWidth
      Since:
      1.0.0
    • getBorderRightWidth

      public BorderRightWidth getBorderRightWidth()
      Returns:
      the borderRightWidth
      Since:
      1.0.0
    • getBorderBottomWidth

      public BorderBottomWidth getBorderBottomWidth()
      Returns:
      the borderBottomWidth
      Since:
      1.0.0
    • getBorderLeftWidth

      public BorderLeftWidth getBorderLeftWidth()
      Returns:
      the borderLeftWidth
      Since:
      1.0.0
    • stateChanged

      public void stateChanged(CssProperty stateChangedObject)
      Specified by:
      stateChanged in interface StateChangeInformer<CssProperty>
    • isValid

      public static boolean isValid(String cssValue)
      validates if the given cssValue is valid for this class.
      Parameters:
      cssValue - the value to check.
      Returns:
      true if valid and false if invalid.
      Since:
      1.0.0
    • hasPredefinedConstantValue

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