DESY ACOP Beans Home

com.cosylab.gui.components.util
Class FontHelper

java.lang.Object
  extended by com.cosylab.gui.components.util.FontHelper

public final class FontHelper
extends java.lang.Object

Helper class that provides simple access to Font UI resources

Version:
$id$
Author:
Jernej Kamenik
See Also:
MetalLookAndFeel, Font

Constructor Summary
FontHelper()
           
 
Method Summary
static java.awt.Font calculateFittingFont(java.awt.Component comp, java.awt.Font oldFont, java.lang.String text, int columns, int minFontSize, int maxFontSize)
          Calculates new font, which would fit provided text inside component.
static java.awt.Font getDefaultFont()
          Returns the default Font
static java.lang.String getDefaultFontName()
          Returns the default Font name
static int getDefaultFontSize()
          Returns the default Font size
static java.awt.Font getFont(java.lang.String name, int style, int size)
          Returns a new Font with the specified attributes
static java.awt.Font getFontWithName(java.lang.String name, java.awt.Font inFont)
          Returns the specified Font with its name changed to the specified name.
static java.awt.Font getFontWithSize(int size, java.awt.Font inFont)
          Returns the specified Font with its size changed to the specified size.
static java.awt.Font getFontWithStyle(int style, java.awt.Font inFont)
          Returns the specified Font with its style changed to the specified style.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FontHelper

public FontHelper()
Method Detail

getDefaultFontName

public static java.lang.String getDefaultFontName()
Returns the default Font name

Returns:
String name
See Also:
MetalLookAndFeel.getControlTextFont()

getDefaultFontSize

public static int getDefaultFontSize()
Returns the default Font size

Returns:
int size
See Also:
MetalLookAndFeel.getControlTextFont()

getDefaultFont

public static java.awt.Font getDefaultFont()
Returns the default Font

Returns:
Font
See Also:
MetalLookAndFeel.getUserTextFont()

getFontWithStyle

public static java.awt.Font getFontWithStyle(int style,
                                             java.awt.Font inFont)
Returns the specified Font with its style changed to the specified style.

Parameters:
style - style
inFont - inFont
Returns:
Font

getFontWithName

public static java.awt.Font getFontWithName(java.lang.String name,
                                            java.awt.Font inFont)
Returns the specified Font with its name changed to the specified name.

Parameters:
name - name
inFont - inFont
Returns:
Font

getFontWithSize

public static java.awt.Font getFontWithSize(int size,
                                            java.awt.Font inFont)
Returns the specified Font with its size changed to the specified size.

Parameters:
size - size
inFont - inFont
Returns:
Font

getFont

public static java.awt.Font getFont(java.lang.String name,
                                    int style,
                                    int size)
Returns a new Font with the specified attributes

Parameters:
name - name
style - style
size - size
Returns:
Font

calculateFittingFont

public static java.awt.Font calculateFittingFont(java.awt.Component comp,
                                                 java.awt.Font oldFont,
                                                 java.lang.String text,
                                                 int columns,
                                                 int minFontSize,
                                                 int maxFontSize)
Calculates new font, which would fit provided text inside component.

Parameters:
comp - the Component in which text should fit
oldFont - old font
text - a text to be fitted
columns - number of character columns to fit in component
minFontSize - minimal allowed font size
maxFontSize - maximal allowed font size
Returns:
new font, if calculation failes, old font is returned


Copyright © 2010. All Rights Reserved.