/** * Converts horizontal dialog units and returns pixels. * Honors the resolution, dialog font size, platform, and l&f. * * @param dluX the horizontal dialog units * @param c a Component that provides the font and graphics * @return the given horizontal dialog units as pixels */ public int dialogUnitXAsPixel(int dluX, Component c) { return dialogUnitXAsPixel(dluX, getDialogBaseUnitsX(c)); }
/** * Returns the current {@link UnitConverter}. If it has not been initialized * before it will get an instance of {@link DefaultUnitConverter}. * * @return the current <code>UnitConverter</code> */ public static UnitConverter getUnitConverter() { if (unitConverter == null) { unitConverter = DefaultUnitConverter.getInstance(); } return unitConverter; }
/** * Computes and returns the initial <code>LayoutStyle</code>. * Checks the OS name and returns <code>MacLayoutStyle</code> * on Mac OS X and <code>WindowLayoutStyle</code> on all other platforms. * * @return MacLayoutStyle on Mac, WindowsLayoutStyle on all other platforms */ private static LayoutStyle initialLayoutStyle() { if (isOSMac()) return MacLayoutStyle.INSTANCE; return WindowsLayoutStyle.INSTANCE; }
/** * Converts Inches and returns pixels using the specified resolution. * * @param in the Inches * @param component the component that provides the graphics object * @return the given Inches as pixels */ public int inchAsPixel(double in, Component component) { return inchAsPixel(in, getScreenResolution(component)); }
/** * Converts Centimeters and returns pixels using the resolution of the * given component's graphics object. * * @param cm Centimeters * @param component the component that provides the graphics object * @return the given Centimeters as pixels */ public int centimeterAsPixel(double cm, Component component) { return centimeterAsPixel(cm, getScreenResolution(component)); }
/** * Converts DTP Points and returns pixels using the resolution of the * given component's graphics object. * * @param pt DTP Points * @param component the component that provides the graphics object * @return the given Points as pixels */ public int pointAsPixel(int pt, Component component) { return pointAsPixel(pt, getScreenResolution(component)); }
/** * Converts Millimeters and returns pixels using the resolution of the * given component's graphics object. * * @param mm Millimeters * @param component the component that provides the graphics object * @return the given Millimeters as pixels */ public int millimeterAsPixel(double mm, Component component) { return millimeterAsPixel(mm, getScreenResolution(component)); }
/** * Converts vertical dialog units and returns pixels. * Honors the resolution, dialog font size, platform, and l&f. * * @param dluY the vertical dialog units * @param c a Component that provides the font and graphics * @return the given vertical dialog units as pixels */ public int dialogUnitYAsPixel(int dluY, Component c) { return dialogUnitYAsPixel(dluY, getDialogBaseUnitsY(c)); }
/** * Lazily creates and returns a fallback for the dialog font * that is used to compute the dialog base units. * This fallback font is cached and will be reset if the L&F changes. * * @return the cached fallback font used to compute the dialog base units */ private Font getCachedDefaultDialogFont() { FormUtils.ensureValidCache(); if (cachedDefaultDialogFont == null) { cachedDefaultDialogFont = lookupDefaultDialogFont(); } return cachedDefaultDialogFont; }
/** * Lazily instantiates and returns the sole instance. * * @return the lazily instantiated sole instance */ public static DefaultUnitConverter getInstance() { if (instance == null) { instance = new DefaultUnitConverter(); } return instance; }
/** * Returns the cached or computed horizontal dialog base units. * * @param component a Component that provides the font and graphics * @return the horizontal dialog base units */ protected double getDialogBaseUnitsX(Component component) { return getDialogBaseUnits(component).x; }
/** * Lazily computes and answer the global dialog base units. * Should be re-computed if the l&f, platform, or screen changes. * * @return a cached DialogBaseUnits object used globally if no container is available */ private DialogBaseUnits getGlobalDialogBaseUnits() { if (cachedGlobalDialogBaseUnits == null) { cachedGlobalDialogBaseUnits = computeGlobalDialogBaseUnits(); } return cachedGlobalDialogBaseUnits; }
/** * Lazily checks and answers whether the Aqua look&feel is active. * * @return {@code true} if the current look&feel is Aqua * * @deprecated Replaced by {@link FormUtils#isLafAqua()}. */ public static boolean isLafAqua() { return FormUtils.isLafAqua(); }
/** * Converts Inches and returns pixels using the specified resolution. * * @param in * the Inches * @param component * the component that provides the graphics object * @return the given Inches as pixels */ public int inchAsPixel(double in, Component component) { return inchAsPixel(in, getScreenResolution(component)); }
/** * Converts Centimeters and returns pixels using the resolution of the * given component's graphics object. * * @param cm Centimeters * @param component the component that provides the graphics object * @return the given Centimeters as pixels */ @Override public int centimeterAsPixel(double cm, Component component) { return centimeterAsPixel(cm, getScreenResolution(component)); }
/** * Lazily creates and returns a fallback for the dialog font * that is used to compute the dialog base units. * This fallback font is cached and will be reset if the L&F changes. * * @return the cached fallback font used to compute the dialog base units */ private Font getCachedDefaultDialogFont() { FormUtils.ensureValidCache(); if (cachedDefaultDialogFont == null) { cachedDefaultDialogFont = lookupDefaultDialogFont(); } return cachedDefaultDialogFont; }
/** * Returns the current {@link UnitConverter}. If it has not been initialized * before it will get an instance of {@link DefaultUnitConverter}. * * @return the current {@code UnitConverter} */ public static UnitConverter getUnitConverter() { if (unitConverter == null) { unitConverter = DefaultUnitConverter.getInstance(); } return unitConverter; }
/** * Lazily instantiates and returns the sole instance. * * @return the lazily instantiated sole instance */ public static DefaultUnitConverter getInstance() { if (instance == null) { instance = new DefaultUnitConverter(); } return instance; }
/** * Returns the cached or computed vertical dialog base units * for the given component. * * @param component a Component that provides the font and graphics * @return the vertical dialog base units */ protected double getDialogBaseUnitsY(Component component) { return getDialogBaseUnits(component).y; }
/** * Lazily computes and answer the global dialog base units. * Should be re-computed if the l&f, platform, or screen changes. * * @return a cached DialogBaseUnits object used globally if no container is available */ private DialogBaseUnits getGlobalDialogBaseUnits() { if (cachedGlobalDialogBaseUnits == null) { cachedGlobalDialogBaseUnits = computeGlobalDialogBaseUnits(); } return cachedGlobalDialogBaseUnits; }