# Class StyleParser.ScalarValue

java.lang.Object
com.codename1.ui.plaf.StyleParser.ScalarValue

Enclosing class:
  `StyleParser`

public static class StyleParser.ScalarValue extends Object
Encapsulates a scalar value with a unit.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ScalarValue()`
  `ScalarValue(double value, byte unit)`
  Creates a new scalar value given magnitude and unit.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getPixelValue()`
  Gets the magnitude of this scalar value in pixels.
  `byte`
  `getUnit()`

  ###### Returns

  `double`
  `getValue()`

  ###### Returns

  `void`
  `setUnit(byte unit)`

  ###### Parameters

  `void`
  `setValue(double value)`

  ###### Parameters

  `String`
  `toString()`
  Returns the scalar value in CN1 style string format.
  `String`
  `toString(int decimalPlaces)`
  Formats this scalar value (including units) but rounding to the given number of decimal places.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### ScalarValue

    public ScalarValue(double value, byte unit)

    Creates a new scalar value given magnitude and unit.

    ###### Parameters

    - `value`: The value to set.

    - `unit`: The unit of the value. One of `#UNIT_INHERIT`, `Style#UNIT_TYPE_DIPS`, `Style#UNIT_TYPE_PIXELS`, or `Style#UNIT_TYPE_SCREEN_PERCENTAGE`.

  - ### ScalarValue

    public ScalarValue()

- ## Method Details

  - ### getUnit

    public byte getUnit()

    ###### Returns

    the unit of the value. One of `#UNIT_INHERIT`, `Style#UNIT_TYPE_DIPS`, `Style#UNIT_TYPE_PIXELS`, or `Style#UNIT_TYPE_SCREEN_PERCENTAGE`.

  - ### setUnit

    public void setUnit(byte unit)

    ###### Parameters

    - `unit`: the unit of the value. One of `#UNIT_INHERIT`, `Style#UNIT_TYPE_DIPS`, `Style#UNIT_TYPE_PIXELS`, or `Style#UNIT_TYPE_SCREEN_PERCENTAGE`.

  - ### getValue

    public double getValue()

    ###### Returns

    the value of the scalar.

  - ### setValue

    public void setValue(double value)

    ###### Parameters

    - `value`: the value of the scalar.

  - ### toString

    public String toString()
    Returns the scalar value in CN1 style string format. E.g. 12mm, 3px, 5%, or inherit
    Overrides:
      `toString` in class `Object`

  - ### toString

    public String toString(int decimalPlaces)

    Formats this scalar value (including units) but rounding to the given number of decimal places.

    ###### Parameters

    - `decimalPlaces`

  - ### getPixelValue

    public int getPixelValue()
    Gets the magnitude of this scalar value in pixels.