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 Resolution
The jadice base resolution of 1/7200'th of an inch.static final Resolution
72 DPI (the same resolution asPOINTS
but with a different base unit).static final Resolution
96 DPI.static final Resolution
Points: 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 void
Create anAffineTransform
scaling the unit square with this resolution to the given size at base units.createTransform
(Dimension2D size, Unit u) Create anAffineTransform
scaling the unit square with this resolution to the given size at the given resolution.boolean
float
getMax()
Return the maximum of the two resolution components.float
getMin()
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()
float
getX()
Return the horizontal resolution.float
getY()
Return the vertical resolution.int
hashCode()
boolean
Return 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 asPOINTS
but 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:
true
if both components are equal.
-
createBaseTransform
Create anAffineTransform
scaling the unit square with this resolution to the given size at base units.- Parameters:
size
-- Returns:
- a scaling
AffineTransform
- See Also:
-
createTransform
-
createTransform
Create anAffineTransform
scaling 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 givenAffineTransform
is modified in place.- Parameters:
t
- the transform to augmentr
- the target resolution- Returns:
- the scaled transformation
-