|
JSR-62 (Final) | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Font
The Font
class represents fonts.
Field Summary | |
static int |
BOLD
The bold style constant. |
static int |
ITALIC
The italicized style constant. |
protected String |
name
The logical name of this Font , as passed to the
constructor. |
static int |
PLAIN
The plain style constant. |
protected int |
size
The point size of this Font , rounded to integer. |
protected int |
style
The style of this Font , as passed to the constructor. |
Constructor Summary | |
Font(String name,
int style,
int size)
Creates a new Font from the specified name, style and
point size. |
Method Summary | |
static Font |
decode(String str)
Returns the Font that the
str argument describes. |
boolean |
equals(Object obj)
Compares this Font object to the specified
Object . |
String |
getFamily()
Returns the family name of this Font . |
static Font |
getFont(String nm)
Returns a Font object from the system properties list. |
static Font |
getFont(String nm,
Font font)
Gets the specified Font from the system properties
list. |
String |
getName()
Returns the logical name of this Font . |
int |
getSize()
Returns the point size of this Font , rounded to
an integer. |
int |
getStyle()
Returns the style of this Font . |
int |
hashCode()
Returns a hashcode for this Font . |
boolean |
isBold()
Indicates whether or not this Font object's style is
BOLD. |
boolean |
isItalic()
Indicates whether or not this Font object's style is
ITALIC. |
boolean |
isPlain()
Indicates whether or not this Font object's style is
PLAIN. |
String |
toString()
Converts this Font object to a String
representation. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int PLAIN
public static final int BOLD
public static final int ITALIC
protected String name
Font
, as passed to the
constructor.
getName()
protected int style
Font
, as passed to the constructor.
This style can be PLAIN, BOLD, ITALIC, or BOLD+ITALIC.
getStyle()
protected int size
Font
, rounded to integer.
getSize()
Constructor Detail |
public Font(String name, int style, int size)
Font
from the specified name, style and
point size.
name
- the font name. This can be a logical font name or a
font face name. A logical name must be either: Dialog, DialogInput,
Monospaced, Serif, SansSerif, or Symbol. If name
is
null
, the name
of the new
Font
is set to Default.style
- the style constant for the Font
The style argument is an integer bitmask that may
be PLAIN, or a bitwise union of BOLD and/or ITALIC
(for example, ITALIC or BOLD|ITALIC). Any other
bits set in the style parameter are ignored.
If the style argument does not conform to one of the expected
integer bitmasks then the style is set to PLAIN.size
- the point size of the Font
GraphicsEnvironment.getAvailableFontFamilyNames()
Method Detail |
public String getFamily()
Font
. For example,
Helvetica could be returned as a family name for the font
face name of Helvetica Bold.
Use getName
to get the logical name of the font.
String
that is the family name of this
Font
.getName()
public String getName()
Font
.
Use getFamily
to get the family name of the font.
String
representing the logical name of
this Font
.getFamily()
public int getStyle()
Font
. The style can be
PLAIN, BOLD, ITALIC, or BOLD+ITALIC.
Font
isPlain()
,
isBold()
,
isItalic()
public int getSize()
Font
, rounded to
an integer.
Most users are familiar with the idea of using point size to
specify the size of glyphs in a font. This point size defines a
measurement between the baseline of one line to the baseline of the
following line in a single spaced text document. The point size is
based on typographic points, approximately 1/72 of an inch.
The Java(tm)2D API adopts the convention that one point is equivalent to one unit in user coordinates. When using a normalized transform for converting user space coordinates to device space coordinates 72 user space units equal 1 inch in device space. In this case one point is 1/72 of an inch.
Font
in 1/72 of an
inch units.public boolean isPlain()
Font
object's style is
PLAIN.
true
if this Font
has a
PLAIN sytle;
false
otherwise.getStyle()
public boolean isBold()
Font
object's style is
BOLD.
true
if this Font
object's
style is BOLD;
false
otherwise.getStyle()
public boolean isItalic()
Font
object's style is
ITALIC.
true
if this Font
object's
style is ITALIC;
false
otherwise.getStyle()
public static Font getFont(String nm)
Font
object from the system properties list.
nm
- the property name
Font
object that the property name
describes.public static Font decode(String str)
Font
that the
str
argument describes.
To ensure that this method returns the desired Font,
format the str
parameter in
one of two ways:
"fontfamilyname-style-pointsize" or
"fontfamilyname style pointsize"
in which style is one of the three
case-insensitive strings:
"BOLD"
, "BOLDITALIC"
, or
"ITALIC"
, and pointsize is a decimal
representation of the point size.
For example, if you want a font that is Arial, bold, and
a point size of 18, you would call this method with:
"Arial-BOLD-18".
The default size is 12 and the default style is PLAIN.
If you don't specify a valid size, the returned
Font
has a size of 12. If you don't specify
a valid style, the returned Font has a style of PLAIN.
If you do not provide a valid font family name in
the str
argument, this method still returns
a valid font with a family name of "dialog".
To determine what font family names are available on
your system, use the
GraphicsEnvironment.getAvailableFontFamilyNames()
method.
If str
is null
, a new Font
is returned with the family name "dialog", a size of 12 and a
PLAIN style.
str
- the name of the font, or null
Font
object that str
describes, or a new default Font
if
str
is null
.getFamily()
public static Font getFont(String nm, Font font)
Font
from the system properties
list. As in the getProperty
method of
System
, the first
argument is treated as the name of a system property to be
obtained. The String
value of this
property is then interpreted as a Font
object.
The property value should be one of the following forms:
"BOLD"
, "BOLDITALIC"
, or
"ITALIC"
, and point size is a decimal
representation of the point size.
The default style is PLAIN
. The default point size
is 12.
If the specified property is not found, the font
argument is returned instead.
nm
- the case-insensitive property namefont
- a default Font
to return if property
nm
is not defined
Font
value of the property.decode(String)
public int hashCode()
Font
.
hashCode
in class Object
Font
.Object.equals(java.lang.Object)
,
Hashtable
public boolean equals(Object obj)
Font
object to the specified
Object
.
equals
in class Object
obj
- the Object
to compare.
true
if the objects are the same;
false
otherwise.Boolean.hashCode()
,
Hashtable
public String toString()
Font
object to a String
representation.
toString
in class Object
String
representation of this
Font
object.
|
JSR-62 (Final) | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |