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

Richard Bair richard.bair at oracle.com
Thu Jan 24 11:22:24 PST 2013


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

OK in general.

> 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) 

How often is actualValue() used? Is it worth having that convenience API in there?

> enum SizeUnits 
> 
> public boolean isFontRelative() - return true if the units are font-relative (em or ex) 

Why do we have this method here and in Size? It seems like Size doesn't need it, as I can just getUnits().isFontRelative()?

> 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 

How does this work? Do these methods simply return a multiplier?

Richard


More information about the openjfx-dev mailing list