Package swingtree
Class UI.Font
java.lang.Object
java.awt.Font
swingtree.UI.Font
- All Implemented Interfaces:
Serializable
- Enclosing class:
- UI
This class represents a SwingTree font and is used to specify the font of a component.
It is a subclass of
Font
and provides additional functionality.
The appearance of a font is primarily based on the font family name which is used to find a font on the system.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Font
This constant is aFont
object with a font name of "" (empty string), a font style of -1 (undefined) and a font size of 0.Fields inherited from class java.awt.Font
BOLD, CENTER_BASELINE, DIALOG, DIALOG_INPUT, HANGING_BASELINE, ITALIC, LAYOUT_LEFT_TO_RIGHT, LAYOUT_NO_LIMIT_CONTEXT, LAYOUT_NO_START_CONTEXT, LAYOUT_RIGHT_TO_LEFT, MONOSPACED, name, PLAIN, pointSize, ROMAN_BASELINE, SANS_SERIF, SERIF, size, style, TRUETYPE_FONT, TYPE1_FONT
-
Method Summary
Modifier and TypeMethodDescriptionstatic UI.Font
static UI.Font
of
(String name, UI.FontStyle style, int size) A factory method that creates a newFont
object with the specified font nameUI.FontStyle
and size.static UI.Font
of
(Map<? extends AttributedCharacterIterator.Attribute, ?> attributes) Creates a newFont
object from a map of attributes where the key is an attribute and the value is the value of the attribute.Returns an updated version of this font with the font (family) name changed to the specified value.withSize
(int size) Returns an updated version of this font with the font size changed to the specified value.withStyle
(UI.FontStyle style) Returns an updated version of this font with the font style changed to the specified value.Methods inherited from class java.awt.Font
canDisplay, canDisplay, canDisplayUpTo, canDisplayUpTo, canDisplayUpTo, createFont, createFont, createFonts, createFonts, createGlyphVector, createGlyphVector, createGlyphVector, createGlyphVector, decode, deriveFont, deriveFont, deriveFont, deriveFont, deriveFont, deriveFont, equals, getAttributes, getAvailableAttributes, getBaselineFor, getFamily, getFamily, getFont, getFont, getFont, getFontName, getFontName, getItalicAngle, getLineMetrics, getLineMetrics, getLineMetrics, getLineMetrics, getMaxCharBounds, getMissingGlyphCode, getName, getNumGlyphs, getPSName, getSize, getSize2D, getStringBounds, getStringBounds, getStringBounds, getStringBounds, getStyle, getTransform, hashCode, hasLayoutAttributes, hasUniformLineMetrics, isBold, isItalic, isPlain, isTransformed, layoutGlyphVector, textRequiresLayout, toString
-
Field Details
-
UNDEFINED
This constant is aFont
object with a font name of "" (empty string), a font style of -1 (undefined) and a font size of 0. Its identity is used to represent the absence of a font being specified, and it is used as a safe replacement for null, meaning that when the style engine of a component encounters it, it will pass it onto theComponent.setFont(java.awt.Font)
method as null. Passing null to this method means that the look and feel determines the font.
-
-
Method Details
-
of
A factory method that creates a newFont
object with the specified font nameUI.FontStyle
and size. This maps directly to the constructor ofFont(String, int, int)
.- Parameters:
name
- The font name, which may be anything depending on what fonts are loaded on the system.style
- The style of the font, which is one of the constantsUI.FontStyle.PLAIN
,size
- The point size of the font.- Returns:
- A new
Font
object with the specified font name, style and size.
-
of
Creates a newFont
object from a map of attributes where the key is an attribute and the value is the value of the attribute. SeeTextAttribute
for a list of common attributes. These attributes define the style of the font.- Parameters:
attributes
- A map of attributes that define the style of the font.- Returns:
- A new
Font
object with the specified attributes.
-
of
- Parameters:
font
- The font to convert to a font.- Returns:
- The SwingTree native font object.
-
withName
Returns an updated version of this font with the font (family) name changed to the specified value.- Parameters:
name
- The font name, which may be anything depending on what fonts are loaded on the system.- Returns:
- A new
Font
object with the font name changed. - Throws:
NullPointerException
- If the font name is null.
-
withStyle
Returns an updated version of this font with the font style changed to the specified value.- Parameters:
style
- The style of the font, which is one of the constantsUI.FontStyle.PLAIN
,UI.FontStyle.BOLD
orUI.FontStyle.ITALIC
.- Returns:
- A new
Font
object with the font style changed.
-
withSize
Returns an updated version of this font with the font size changed to the specified value.- Parameters:
size
- The point size of the font.- Returns:
- A new
Font
object with the font size changed.
-