com.levigo.jadice.document
Class Resolution

java.lang.Object
  extended by com.levigo.jadice.document.Resolution

public class Resolution
extends Object

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
static Resolution BASE_RESOLUTION
          The jadice base resolution of 1/7200'th of an inch.
static Resolution DPI72
          72 DPI (the same resolution as POINTS but with a different base unit).
static Resolution DPI96
          96 DPI.
static Resolution POINTS
          Points: 1/72'th of an inch (72 DPI).
 
Constructor Summary
Resolution()
          Create the default base resolution.
Resolution(Dimension2D d, Unit u)
           
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)
           
 
Method Summary
protected  void assertComponentsValid()
           
 Resolution clone()
           
 Resolution convertTo(Unit u)
           
 AffineTransform createBaseTransform(Dimension2D size)
          Create an AffineTransform scaling the unit square with this resolution to the given size at base units.
 AffineTransform createTransform(Dimension2D size, Unit u)
          Create an AffineTransform scaling the unit square with this resolution to the given size at the given resolution.
 AffineTransform createTransform(Resolution r)
           
 boolean equals(Object obj)
           
 float getMax()
          Return the maximum of the two resolution components.
 float getMin()
          Return the minimum of the two resolution components.
 Dimension2D getSize(Dimension2D size)
          Return the physical size of a grid of the given size with this resolution.
 Dimension2D getSize(Dimension2D size, Unit u)
          Return the physical size of a grid of the given size with this resolution.
 Unit getUnit()
           
 float getX()
          Return the horizontal resolution.
 float getY()
          Return the vertical resolution.
 int hashCode()
           
 boolean isHomogenous()
          Return whether the resolution is homogeneous, i.e.
 AffineTransform scale(AffineTransform t, Resolution r)
          Augment the given transform so that it scale the unit square with this resolution to the given target resolution.
 Dimension toDimension()
          Deprecated. 
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BASE_RESOLUTION

public static final Resolution BASE_RESOLUTION
The jadice base resolution of 1/7200'th of an inch.


POINTS

public static final Resolution POINTS
Points: 1/72'th of an inch (72 DPI).


DPI72

public static final Resolution DPI72
72 DPI (the same resolution as POINTS but with a different base unit).


DPI96

public static final Resolution DPI96
96 DPI.

Constructor Detail

Resolution

public Resolution()
Create the default base resolution.

See Also:
Document.BASE_RESOLUTION

Resolution

public Resolution(float horizontal,
                  float vertical)
Create a new resolution using dots per inch.

Parameters:
horizontal -
vertical -
See Also:
Unit.Inch

Resolution

public Resolution(float w,
                  float h,
                  Unit u)

Resolution

public Resolution(Dimension2D d,
                  Unit u)

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 Detail

assertComponentsValid

protected void assertComponentsValid()

clone

public Resolution clone()
Overrides:
clone in class Object

toString

public String toString()
Overrides:
toString in class Object

toDimension

@Deprecated
public Dimension toDimension()
Deprecated. 


getUnit

public Unit getUnit()

convertTo

public Resolution convertTo(Unit u)

getSize

public Dimension2D getSize(Dimension2D size)
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 is null

getSize

public Dimension2D getSize(Dimension2D size,
                           Unit u)
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

public AffineTransform createBaseTransform(Dimension2D size)
Create an AffineTransform scaling the unit square with this resolution to the given size at base units.

Parameters:
size -
Returns:
a scaling AffineTransform
See Also:
Document.BASE_RESOLUTION

createTransform

public AffineTransform createTransform(Resolution r)

createTransform

public AffineTransform createTransform(Dimension2D size,
                                       Unit u)
Create an AffineTransform 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()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

scale

public AffineTransform scale(AffineTransform t,
                             Resolution r)
Augment the given transform so that it scale the unit square with this resolution to the given target resolution. Please note: the given AffineTransform is modified in place.

Parameters:
t - the transform to augment
r - the target resolution
Returns:
the scaled transformation


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.