public abstract class UnitConverter

  1. Object
  2. UnitConverter

Fields

public static final int UNABLE = -87654312Value to return if this converter can not handle the unit sent in as an argument to the convert method.

Constructors

public UnitConverter()

Methods

public abstract int convertToPixels(float value, String unit, boolean isHor, float refValue, ContainerWrapper parent, ComponentWrapper comp)Converts value to pixels.

Inherited methods

Field details

UNABLE

public static final int UNABLE = -87654312
Value to return if this converter can not handle the unit sent in as an argument to the convert method.

Constructor details

UnitConverter

public UnitConverter()

Method details

convertToPixels

public abstract int convertToPixels(float value, String unit, boolean isHor, float refValue, ContainerWrapper parent, ComponentWrapper comp)
Converts value to pixels.

Parameters

value float
The value to be converted.
unit String
The unit of value. Never null and at least one character.
isHor boolean
If the value is horizontal (true) or vertical (false).
refValue float
Some reference value that may of may not be used. If the unit is percent for instance this value is the value to take the percent from. Usually the size of the parent component in the appropriate dimension.
parent ContainerWrapper

The parent of the target component that value is to be applied to. Might for instance be needed to get the screen that the component is on in a multi screen environment.

May be null in which case a “best guess” value should be returned.

comp ComponentWrapper
The component, if applicable, or null if none.

Returns

The number of pixels if unit is handled by this converter, UnitConverter.UNABLE if not.