[API REVIEW] RT-27883: move Size and SizeUnits to public API

David Grieve david.grieve at oracle.com
Thu Jan 24 08:22:30 PST 2013


http://javafx-jira.kenai.com/browse/RT-27883

Size and SizeUnit are used for CSS values and units. These currently live in the com.sun.javafx.css package. These classes need to be moved to javafx.css in order to remove raw types from generics in the CSS public API. Some methods in the com.sun.javafx.css API should be renamed to make their purpose clearer. 

Size: 
public double getValue() - return the number part of the css value 
public SizeUnits getUnits() - return the units, e.g. - em, px, % 
public boolean isFontRelative() - return true if the units are font-relative (em or ex) 
public double actualValue(Font font) - calculate the actual value using the size of the given font if the units are font-relative or percentage 
public double actualValue(double multiplier) - calculate the actual value using the multiplier if the units are font-relative or percentage 
public double actualValue() - same as actualValue(1.0) 

Note: actualValue returns the calculated value _rounded to the nearest 10th_ which is suitable for pixels 

enum SizeUnits 

public boolean isFontRelative() - return true if the units are font-relative (em or ex) 
public double calculateValue(Font font) - calculate the actual value using the size of the given font if the units are font-relative or percentage 
public double calculateValue(double multiplier) - calculate the actual value using the multiplier if the units are font-relative or percentage 

Note: calculateValue returns the calculated value without rounding.

SizeUnits enums are:  PERCENT, CM, IN, MM, PC, PT, PX, EM, EX,  DEG, GRAD, RAD, TURN


More information about the openjfx-dev mailing list