Class Units

java.lang.Object
com.oorian.css.units.Units
Direct Known Subclasses:
Ch, Cm, Em, Ex, In, Mm, Pc, Percent, Pt, Px, Rem, Vh, Vmax, Vmin, Vw

public abstract class Units extends Object
Abstract base class for CSS unit value types.

This class provides the foundation for all CSS unit value classes such as Px, Em, Rem, Percent, and viewport-relative units. Each unit type extends this class and implements the sizeToString() method to provide the appropriate CSS string representation.

Usage:


 Units pixels = new Px(16);
 Units ems = new Em(1.5f);
 Units percent = new Percent(50);
 element.setWidth(pixels);
 element.setPadding(ems);
 
Since:
2016
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Units

      public Units()
  • Method Details

    • sizeToString

      public abstract String sizeToString()
      Returns the CSS string representation of this unit value.
      Returns:
      the CSS value string (e.g., "16px", "1.5em", "50%")
    • toString

      public String toString()
      Overrides:
      toString in class Object