Package com.bc.ceres.glevel.support
Class DefaultMultiLevelModel
- java.lang.Object
-
- com.bc.ceres.glevel.support.DefaultMultiLevelModel
-
- All Implemented Interfaces:
MultiLevelModel
public class DefaultMultiLevelModel extends Object implements MultiLevelModel
A default implementation for a theMultiLevelModel
interface.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MAX_LEVEL_PIXEL_COUNT
-
Constructor Summary
Constructors Constructor Description DefaultMultiLevelModel(int levelCount, AffineTransform imageToModelTransform, int width, int height)
Constructs a a new model for a multi level source.DefaultMultiLevelModel(int levelCount, AffineTransform imageToModelTransform, Rectangle2D modelBounds)
Constructs a a new model for a multi level source.DefaultMultiLevelModel(AffineTransform imageToModelTransform, int width, int height)
Constructs a a new model for a multi level source.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkLevel(int level)
AffineTransform
getImageToModelTransform(int level)
Gets a copy (non-life object) of the affine transformation from image to model coordinates for the given level.int
getLevel(double scale)
Gets the resolution level for a given scaling factor, e.g.int
getLevelCount()
Gets the number of resolution levels, which is always greater than zero.static int
getLevelCount(int width, int height)
Computes the number of levels using theDEFAULT_MAX_LEVEL_PIXEL_COUNT
constant.Rectangle2D
getModelBounds()
Gets the bounding box in model coordinates.static Rectangle2D
getModelBounds(AffineTransform i2mTransform, int width, int height)
Computes the image bounding box in model coordinates.static Rectangle2D
getModelBounds(AffineTransform i2mTransform, RenderedImage levelZeroImage)
Computes the image bounding box in model coordinates.AffineTransform
getModelToImageTransform(int level)
Gets a copy (non-life object) of the affine transformation from model to image coordinates for the given level.double
getScale(int level)
Gets the scale for a given resolution level, e.g.protected static double
log2(double v)
protected static double
pow2(double v)
void
setModelBounds(Rectangle2D modelBounds)
-
-
-
Field Detail
-
DEFAULT_MAX_LEVEL_PIXEL_COUNT
public static final int DEFAULT_MAX_LEVEL_PIXEL_COUNT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultMultiLevelModel
public DefaultMultiLevelModel(AffineTransform imageToModelTransform, int width, int height)
Constructs a a new model for a multi level source. The number of levels is computed bygetLevelCount(int, int)
. The image bounds are computed bygetModelBounds(java.awt.geom.AffineTransform, int, int)
.- Parameters:
imageToModelTransform
- The affine transformation from image to model coordinates.width
- The width of the image in pixels at level zero.height
- The height of the image in pixels at level zero.
-
DefaultMultiLevelModel
public DefaultMultiLevelModel(int levelCount, AffineTransform imageToModelTransform, int width, int height)
Constructs a a new model for a multi level source. The image bounds are computed bygetModelBounds(java.awt.geom.AffineTransform, int, int)
.- Parameters:
levelCount
- The number of levels.imageToModelTransform
- The affine transformation from image to model coordinates.width
- The width of the image in pixels at level zero.height
- The height of the image in pixels at level zero.
-
DefaultMultiLevelModel
public DefaultMultiLevelModel(int levelCount, AffineTransform imageToModelTransform, Rectangle2D modelBounds)
Constructs a a new model for a multi level source.- Parameters:
levelCount
- The number of levels.imageToModelTransform
- The affine transformation from image to model coordinates.modelBounds
- The image bounds in model coordinates.
-
-
Method Detail
-
getLevelCount
public int getLevelCount()
Description copied from interface:MultiLevelModel
Gets the number of resolution levels, which is always greater than zero.- Specified by:
getLevelCount
in interfaceMultiLevelModel
- Returns:
- The number of resolution levels.
-
getLevel
public int getLevel(double scale)
Description copied from interface:MultiLevelModel
Gets the resolution level for a given scaling factor, e.g.level=log(scale)/log(2)
.- Specified by:
getLevel
in interfaceMultiLevelModel
- Parameters:
scale
- The scaling factor, will always be a greater than or equal to 1.- Returns:
- The resolution level, must be in the range 0 to
levelCount
-1. - See Also:
MultiLevelSource.getImage(int)
-
getScale
public double getScale(int level)
Description copied from interface:MultiLevelModel
Gets the scale for a given resolution level, e.g.scale=pow(2,level)
.- Specified by:
getScale
in interfaceMultiLevelModel
- Parameters:
level
- The resolution level, must be in the range 0 tolevelCount
-1.- Returns:
- The scaling factor, must be greater than or equal to 1.
getLevel(scale)
shall returnlevel
. - See Also:
MultiLevelSource.getImage(int)
-
getImageToModelTransform
public final AffineTransform getImageToModelTransform(int level)
Description copied from interface:MultiLevelModel
Gets a copy (non-life object) of the affine transformation from image to model coordinates for the given level.- Specified by:
getImageToModelTransform
in interfaceMultiLevelModel
- Parameters:
level
- The resolution level, must be in the range 0 tolevelCount
-1.- Returns:
- The affine transformation from image to model coordinates.
-
getModelToImageTransform
public final AffineTransform getModelToImageTransform(int level)
Description copied from interface:MultiLevelModel
Gets a copy (non-life object) of the affine transformation from model to image coordinates for the given level.- Specified by:
getModelToImageTransform
in interfaceMultiLevelModel
- Parameters:
level
- The resolution level, must be in the range 0 tolevelCount
-1.- Returns:
- The affine transformation from model to image coordinates.
-
pow2
protected static double pow2(double v)
-
log2
protected static double log2(double v)
-
checkLevel
protected void checkLevel(int level)
-
getModelBounds
public Rectangle2D getModelBounds()
Description copied from interface:MultiLevelModel
Gets the bounding box in model coordinates.- Specified by:
getModelBounds
in interfaceMultiLevelModel
- Returns:
- The bounding box, may be
null
if unspecified.
-
setModelBounds
public void setModelBounds(Rectangle2D modelBounds)
-
getModelBounds
public static Rectangle2D getModelBounds(AffineTransform i2mTransform, RenderedImage levelZeroImage)
Computes the image bounding box in model coordinates.- Parameters:
i2mTransform
- The affine transformation from image to model coordinates.levelZeroImage
- The image at level zero.- Returns:
- The number of levels.
-
getModelBounds
public static Rectangle2D getModelBounds(AffineTransform i2mTransform, int width, int height)
Computes the image bounding box in model coordinates.- Parameters:
i2mTransform
- The affine transformation from image to model coordinates.width
- The width of the image in pixels at level zero.height
- The height of the image in pixels at level zero.- Returns:
- The number of levels.
-
getLevelCount
public static int getLevelCount(int width, int height)
Computes the number of levels using theDEFAULT_MAX_LEVEL_PIXEL_COUNT
constant.- Parameters:
width
- The width of the image in pixels at level zero.height
- The height of the image in pixels at level zero.- Returns:
- The number of levels.
-
-