|
|||||||||
| Home >> All >> nextapp >> [ echo overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
nextapp.echo
Class Extent

java.lang.Objectnextapp.echo.Extent
- All Implemented Interfaces:
- java.lang.Comparable, java.io.Serializable
- public class Extent
- extends java.lang.Object
- implements java.lang.Comparable, java.io.Serializable
- extends java.lang.Object
A representation of a linear distance with units.
Extent objects are immutable once constructed.
| Field Summary | |
static int |
CM
Centimeter units. |
static int |
EM
Em units (height of font). |
static int |
EX
Ex units (height of character 'x' in font). |
static int |
IN
Inch units. |
static int |
MM
Millimeter units. |
static int |
PC
Picas (1pc = 12pt) |
static int |
PERCENT
Percentage units. |
static int |
PT
Points (1pt = 1/72in). |
static int |
PX
Pixel units. |
private int |
units
|
private int |
value
|
| Constructor Summary | |
Extent(int value,
int units)
Creates a new Extent. |
|
| Method Summary | |
static Extent |
add(Extent a,
Extent b)
Adds one Extent to another, returning the sum as a new
Extent. |
int |
compareTo(java.lang.Object o)
Compares this object with another, and returns a numerical result based on the comparison. |
boolean |
equals(java.lang.Object o)
Determine whether this Object is semantically equal to another Object. |
int |
getUnits()
Returns the units of the Extent. |
int |
getValue()
Returns the value of the Extent. |
boolean |
isComparableTo(Extent that)
Determines whether this Extent can be compared to another
Extent to determine which is a greater length. |
boolean |
isEnglish()
Determines if the Extent has English units, i.e., the
units are of type IN (inches), PC (picas), or
PT (points). |
boolean |
isPercentage()
Determines if the Extent has percentage-based units. |
boolean |
isPrint()
Determines if this Extent has 'print' based units, i.e.,
the units are in real dimensions, such as SI or English values, rather
than screen-based units such as pixels or percentages. |
boolean |
isSI()
Determines if the Extent has SI (Metric) units, i.e., the
units are of type MM (millimeters) or CM
(centimeters). |
int |
toMm()
Returns the value of the extent in millimeters. |
int |
toPoint()
Returns the value of the extent in points. |
java.lang.String |
toString()
Returns a string describing the state of the Extent. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
PX
public static final int PX
- Pixel units.
- See Also:
- Constant Field Values
PERCENT
public static final int PERCENT
- Percentage units.
- See Also:
- Constant Field Values
PT
public static final int PT
- Points (1pt = 1/72in).
- See Also:
- Constant Field Values
CM
public static final int CM
- Centimeter units.
- See Also:
- Constant Field Values
MM
public static final int MM
- Millimeter units.
- See Also:
- Constant Field Values
IN
public static final int IN
- Inch units.
- See Also:
- Constant Field Values
EM
public static final int EM
- Em units (height of font).
- See Also:
- Constant Field Values
EX
public static final int EX
- Ex units (height of character 'x' in font).
- See Also:
- Constant Field Values
PC
public static final int PC
- Picas (1pc = 12pt)
- See Also:
- Constant Field Values
value
private int value
units
private int units
| Constructor Detail |
Extent
public Extent(int value,
int units)
- Creates a new
Extent.
| Method Detail |
add
public static Extent add(Extent a, Extent b)
- Adds one
Extentto another, returning the sum as a newExtent. Null is returned if theExtents have incompatible units.
compareTo
public int compareTo(java.lang.Object o)
- Description copied from interface:
java.lang.Comparable - Compares this object with another, and returns a numerical result based
on the comparison. If the result is negative, this object sorts less
than the other; if 0, the two are equal, and if positive, this object
sorts greater than the other. To translate this into boolean, simply
perform
o1.compareTo(o2) <op> 0, where op is one of <, <=, =, !=, >, or >=.You must make sure that the comparison is mutual, ie.
sgn(x.compareTo(y)) == -sgn(y.compareTo(x))(where sgn() is defined as -1, 0, or 1 based on the sign). This includes throwing an exception in either direction if the two are not comparable; hence,compareTo(null)should always throw an Exception.You should also ensure transitivity, in two forms:
x.compareTo(y) > 0 && y.compareTo(z) > 0impliesx.compareTo(z) > 0; andx.compareTo(y) == 0impliesx.compareTo(z) == y.compareTo(z).- Specified by:
compareToin interfacejava.lang.Comparable
equals
public boolean equals(java.lang.Object o)
- Description copied from class:
java.lang.Object - Determine whether this Object is semantically equal
to another Object.
There are some fairly strict requirements on this method which subclasses must follow:
- It must be transitive. If
a.equals(b)andb.equals(c), thena.equals(c)must be true as well. - It must be symmetric.
a.equals(b)andb.equals(a)must have the same value. - It must be reflexive.
a.equals(a)must always be true. - It must be consistent. Whichever value a.equals(b) returns on the first invocation must be the value returned on all later invocations.
a.equals(null)must be false.- It must be consistent with hashCode(). That is,
a.equals(b)must implya.hashCode() == b.hashCode(). The reverse is not true; two objects that are not equal may have the same hashcode, but that has the potential to harm hashing performance.
This is typically overridden to throw a java.lang.ClassCastException if the argument is not comparable to the class performing the comparison, but that is not a requirement. It is legal for
a.equals(b)to be true even thougha.getClass() != b.getClass(). Also, it is typical to never cause a java.lang.NullPointerException.In general, the Collections API (
java.util) use theequalsmethod rather than the==operator to compare objects. However, java.util.IdentityHashMap is an exception to this rule, for its own good reasons.The default implementation returns
this == o. - It must be transitive. If
getValue
public int getValue()
- Returns the value of the
Extent.
getUnits
public int getUnits()
- Returns the units of the
Extent.
isComparableTo
public boolean isComparableTo(Extent that)
- Determines whether this
Extentcan be compared to anotherExtentto determine which is a greater length.
isEnglish
public boolean isEnglish()
- Determines if the
Extenthas English units, i.e., the units are of typeIN(inches),PC(picas), orPT(points).
isSI
public boolean isSI()
- Determines if the
Extenthas SI (Metric) units, i.e., the units are of typeMM(millimeters) orCM(centimeters).
isPercentage
public boolean isPercentage()
- Determines if the
Extenthas percentage-based units.
isPrint
public boolean isPrint()
- Determines if this
Extenthas 'print' based units, i.e., the units are in real dimensions, such as SI or English values, rather than screen-based units such as pixels or percentages.
toMm
public int toMm()
- Returns the value of the extent in millimeters.
toPoint
public int toPoint()
- Returns the value of the extent in points.
toString
public java.lang.String toString()
- Returns a string describing the state of the Extent.
For debugging purposes only, do not rely on formatting.
|
|||||||||
| Home >> All >> nextapp >> [ echo overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
nextapp.echo.Extent