Package adams.data.image
Class ImageAnchorHelper
- java.lang.Object
-
- adams.data.image.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 Summary
Constructors Constructor Description ImageAnchorHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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).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).static int
calculateX(int width, double x)
Calculates the actual X value.static int
calculateY(int height, double y)
Calculates the actual Y value.
-
-
-
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 useimg
- the image to use as basisuseAnchorAtPos
- 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 useimgWidth
- the image width to use as basisimgHeight
- the image height to use as basisuseAnchorAtPos
- whether to use the anchor at the position rather than the image- Returns:
- the top-left and bottom-right coordinates
-
-