# 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`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `final Class`
  `getClass()`
  Returns the runtime class of an object.
  `int`
  `hashCode()`
  Returns a hash code value for the object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `final void`
  `wait()`
  Causes current thread to wait until another thread invokes the method or the method for this object.
  `final void`
  `wait(long timeout)`
  Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
  `final void`
  `wait(long timeout, int nanos)`
  Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

- ## 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.