Interface UnitSizeHandler


  • public interface UnitSizeHandler

    Definition of an interface for performing size calculations in a manner independent of a certain component model.

    This interface is used by the Unit class to perform unit to pixel calculations. For some unit types access to certain internal details of the affected components is needed, e.g. to the font for determining the font size. This interface has the purpose of abstracting such direct accesses, so that there can be multiple implementations for different GUI libraries (e.g. Swing and SWT).

    Version:
    $Id: UnitSizeHandler.java 205 2012-01-29 18:29:57Z oheger $
    Author:
    Oliver Heger
    • Method Detail

      • getFontSize

        double getFontSize​(Object component,
                           boolean y)
        Determines the font size of the given component for the specified orientation. An implementation must extract the font of the passed in component (after it has been correctly casted) and then determine the average font size either in X- or Y-direction.
        Parameters:
        component - the component
        y - the orientation flag ( true for Y or vertical, false for X or horizontal
        Returns:
        the font size
      • getScreenResolution

        int getScreenResolution()
        Returns the screen resolution in dots per inch (dpi).
        Returns:
        the screen resolution in dpi