Package com.levigo.jadice.document
Class Resolution
java.lang.Object
com.levigo.jadice.document.Resolution
A resolution specifies a point density in two dimensions (horizontal, vertical) relative to a
certain measurement unit.
Please note that this class is immutable, i.e. it is safe to pass around instances of it without
cloning.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ResolutionThe jadice base resolution of 1/7200'th of an inch.static final Resolution72 DPI (the same resolution asPOINTSbut with a different base unit).static final Resolution96 DPI.static final ResolutionPoints: 1/72'th of an inch (72 DPI). -
Constructor Summary
ConstructorsConstructorDescriptionCreate the default base resolution.Resolution(float r) Create a uniform resolution (one being identical in both horizontally and vertically) based on a unit of dots per inch.Resolution(float horizontal, float vertical) Create a new resolution using dots per inch.Resolution(float w, float h, Unit u) Resolution(Dimension2D d, Unit u) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCreate anAffineTransformscaling the unit square with this resolution to the given size at base units.createTransform(Dimension2D size, Unit u) Create anAffineTransformscaling the unit square with this resolution to the given size at the given resolution.booleanfloatgetMax()Return the maximum of the two resolution components.floatgetMin()Return the minimum of the two resolution components.getSize(Dimension2D size) Return the physical size of a grid of the given size with this resolution.getSize(Dimension2D size, Unit u) Return the physical size of a grid of the given size with this resolution.getUnit()floatgetX()Return the horizontal resolution.floatgetY()Return the vertical resolution.inthashCode()booleanReturn whether the resolution is homogeneous, i.e. identical in both directions.scale(AffineTransform t, Resolution r) Augment the given transform so that it scale the unit square with this resolution to the given target resolution.toString()
-
Field Details
-
BASE_RESOLUTION
The jadice base resolution of 1/7200'th of an inch. -
POINTS
Points: 1/72'th of an inch (72 DPI). -
DPI72
72 DPI (the same resolution asPOINTSbut with a different base unit). -
DPI96
96 DPI.
-
-
Constructor Details
-
Resolution
public Resolution()Create the default base resolution.- See Also:
-
Resolution
public Resolution(float horizontal, float vertical) Create a new resolution using dots per inch.- Parameters:
horizontal-vertical-- See Also:
-
Resolution
-
Resolution
-
Resolution
public Resolution(float r) Create a uniform resolution (one being identical in both horizontally and vertically) based on a unit of dots per inch.- Parameters:
r-
-
-
Method Details
-
assertComponentsValid
protected void assertComponentsValid() -
toString
-
getUnit
-
convertTo
-
getSize
Return the physical size of a grid of the given size with this resolution. The returned size will use the same unit as the resolution base unit.- Parameters:
size-- Returns:
- the physical size
- Throws:
NullPointerException- if the given size parameter isnull
-
getSize
Return the physical size of a grid of the given size with this resolution. The returned size will use the same unit as the resolution base unit.- Parameters:
size-- Returns:
- the physical size
-
getX
public float getX()Return the horizontal resolution.- Returns:
- the horizontal resolution component
-
getY
public float getY()Return the vertical resolution.- Returns:
- the vertical resolution component
-
getMax
public float getMax()Return the maximum of the two resolution components.- Returns:
- the maximum resolution
-
getMin
public float getMin()Return the minimum of the two resolution components.- Returns:
- the minimum resolution
-
isHomogenous
public boolean isHomogenous()Return whether the resolution is homogeneous, i.e. identical in both directions.- Returns:
trueif both components are equal.
-
createBaseTransform
Create anAffineTransformscaling the unit square with this resolution to the given size at base units.- Parameters:
size-- Returns:
- a scaling
AffineTransform - See Also:
-
createTransform
-
createTransform
Create anAffineTransformscaling the unit square with this resolution to the given size at the given resolution.- Parameters:
size-u-- Returns:
- a scaling
AffineTransform
-
hashCode
public int hashCode() -
equals
-
scale
Augment the given transform so that it scale the unit square with this resolution to the given target resolution. Please note: the givenAffineTransformis modified in place.- Parameters:
t- the transform to augmentr- the target resolution- Returns:
- the scaled transformation
-