use of org.apache.pivot.wtk.NumberRuler in project pivot by apache.
the class NumberRulerSkin method getPreferredWidth.
@Override
public int getPreferredWidth(int height) {
NumberRuler ruler = (NumberRuler) getComponent();
Orientation orientation = ruler.getOrientation();
if (orientation == Orientation.VERTICAL) {
int textSize = ruler.getTextSize();
FontRenderContext fontRenderContext = Platform.getFontRenderContext();
char[] digits = new char[textSize];
Arrays.fill(digits, '0');
String text = new String(digits);
Rectangle2D stringBounds = font.getStringBounds(text, fontRenderContext);
return (int) Math.ceil(stringBounds.getWidth()) + padding;
}
return 0;
}
Aggregations