Class ImageAnchorHelper


  • public class ImageAnchorHelper
    extends Object
    Helper class for dealing with the image anchor.
    Version:
    $Revision$
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • ImageAnchorHelper

        public ImageAnchorHelper()
    • Method Detail

      • calculateX

        public static int calculateX​(int width,
                                     double x)
        Calculates the actual X value.
        Parameters:
        x - the x (0-1: percent of original image width, >1 absolute pixels)
        width - the width to use as basis
        Returns:
        the actual X
      • calculateY

        public static int calculateY​(int height,
                                     double y)
        Calculates the actual Y value.
        Parameters:
        y - the y (0-1: percent of original image width, >1 absolute pixels)
        height - the height to use as basis
        Returns:
        the actual Y
      • calculateCorners

        public static Point[] calculateCorners​(BufferedImage img,
                                               ImageAnchor anchor,
                                               double x,
                                               double y,
                                               double width,
                                               double height,
                                               boolean useAnchorAtPos)
        Calculates the actual top-left (index 0) and bottom-right coordinates (index 1).
        Parameters:
        x - the x (0-1: percent of original image width, >1 absolute pixels)
        y - the y (0-1: percent of original image width, >1 absolute pixels)
        width - the width (0-1: percent of original image width, >1 absolute pixels)
        height - the height (0-1: percent of original image width, >1 absolute pixels)
        anchor - the anchor to use
        img - the image to use as basis
        useAnchorAtPos - whether to use the anchor at the position rather than the image
        Returns:
        the top-left and bottom-right coordinates
      • calculateCorners

        public static Point[] calculateCorners​(int imgWidth,
                                               int imgHeight,
                                               ImageAnchor anchor,
                                               double x,
                                               double y,
                                               double width,
                                               double height,
                                               boolean useAnchorAtPos)
        Calculates the actual top-left (index 0) and bottom-right coordinates (index 1).
        Parameters:
        x - the x (0-1: percent of original image width, >1 absolute pixels)
        y - the y (0-1: percent of original image width, >1 absolute pixels)
        width - the width (0-1: percent of original image width, >1 absolute pixels)
        height - the height (0-1: percent of original image width, >1 absolute pixels)
        anchor - the anchor to use
        imgWidth - the image width to use as basis
        imgHeight - the image height to use as basis
        useAnchorAtPos - whether to use the anchor at the position rather than the image
        Returns:
        the top-left and bottom-right coordinates