|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbb.gui.FontUtil.FontRank
public static class FontUtil.FontRank
The main purpose of this class is simply to record a Font and some associated rank of that Font. The semantic meaning of that rank is determined by the user.
This class is multithread safe: it is immutable (both its immediate state, as well as the deep state of its fields).
Field Summary | |
---|---|
private Font |
font
|
private double |
rank
|
Constructor Summary | |
---|---|
FontUtil.FontRank(Font font,
double rank)
Constructs a new FontRank instance from the supplied arguments. |
|
FontUtil.FontRank(Font font,
String s)
Simply calls this( font, . |
Method Summary | |
---|---|
int |
compareTo(FontUtil.FontRank other)
Tries to order this and other by their ranks: returns Double.compare( other.rank, this.rank ) if that result is ! |
boolean |
equals(Object obj)
Only returns true if obj is another FontRank instance whose font and rank fields equal this. |
Font |
getFont()
|
double |
getRank()
|
int |
hashCode()
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private final Font font
private final double rank
Constructor Detail |
---|
public FontUtil.FontRank(Font font, String s)
this( font, findDisplayableCharPercent
(font, s) )
.
In other words, it ranks font based on what percent of characters it can display.
public FontUtil.FontRank(Font font, double rank) throws IllegalArgumentException
IllegalArgumentException
- if font is nullMethod Detail |
---|
public Font getFont()
public double getRank()
public final boolean equals(Object obj) throws IllegalStateException
equals
in class Object
IllegalStateException
- if obj is another FontRank instance whose font field equals this, but whose rank field differs; this is meant to detect subtle bugspublic final int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
public int compareTo(FontUtil.FontRank other) throws IllegalArgumentException, IllegalStateException
Double.compare( other.rank, this.rank )
if that result is != 0.
Else tries to order this and other by their names:
returns this.font.getName().compareTo( other.font.getName() )
if that result is != 0.
Else tries to order this and other by their sizes:
returns
if that result is != 0.
Math2.compare
( this.font.getSize(), other.font.getSize() )
Else tries to order this and other by their styles:
returns
if that result is != 0.
Math2.compare
( this.font.getStyle() - other.font.getStyle() )
Else returns 0 if this.
is true.
This is the only circumstance in which 0 will ever be returned, thus,
this ordering is consistent with equals (see equals
(other)Comparable
for more discussion).
Else throws an IllegalStateException.
compareTo
in interface Comparable<FontUtil.FontRank>
IllegalArgumentException
- if other is null
IllegalStateException
- if run out of criteria to order this and other
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |