Class DefaultMultiLevelModel

    • 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 by getLevelCount(int, int). The image bounds are computed by getModelBounds(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 by getModelBounds(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 interface MultiLevelModel
        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 interface MultiLevelModel
        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)
      • 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 interface MultiLevelModel
        Parameters:
        level - The resolution level, must be in the range 0 to levelCount-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 interface MultiLevelModel
        Parameters:
        level - The resolution level, must be in the range 0 to levelCount-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)
      • 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 the DEFAULT_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.