Package armyc2.c5isr.renderer.utilities
Class ImageInfo
- java.lang.Object
-
- armyc2.c5isr.renderer.utilities.ImageInfo
-
- All Implemented Interfaces:
SymbolDimensionInfo
public class ImageInfo extends java.lang.Object implements SymbolDimensionInfo
Object that holds an image of the symbol and all the information needed to place the symbol on the screen.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ImageInfo()
ImageInfo(java.awt.image.BufferedImage image, int x, int y)
ImageInfo holds and image and holds the position at which the image should be drawn.ImageInfo(java.awt.image.BufferedImage image, int x, int y, int symbolCenterX, int symbolCenterY)
Deprecated.ImageInfo(java.awt.image.BufferedImage image, int x, int y, int symbolCenterX, int symbolCenterY, java.awt.geom.Rectangle2D symbolBounds)
ImageInfo holds and image and holds the position at which the image should be drawn.ImageInfo(java.awt.image.BufferedImage bi, java.awt.geom.Point2D centerPoint, java.awt.geom.Rectangle2D symbolBounds)
Creates a new ImageInfo object
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.Boolean
CanWriteImageFormat(java.lang.String format)
Determines if you can write your desired format.static java.awt.image.BufferedImage
CenterImageOnPoint(java.awt.image.BufferedImage image, java.awt.geom.Point2D point)
Takes an image and a center point and generates a new, bigger image that has the symbol centered in itjava.awt.image.BufferedImage
getImage()
The BufferedImagebyte[]
getImageAsByteArray()
returns the image as a byte[] representing a PNG.byte[]
getImageAsByteArrayWithMetaInfo()
Unlike SaveImageToFile, this only writes to PNGs and it includes positional metadata in the PNG.java.awt.geom.Rectangle2D
getImageBounds()
Dimension of the entire image.java.awt.Point
getPoint()
position of where the image should be drawnstatic java.awt.image.BufferedImage
getScaledInstance(java.awt.image.BufferedImage srcImage, int targetWidth, int targetHeight, java.lang.Object hint, boolean higherQuality, boolean keepProportion)
Convenience method that returns a scaled instance of the providedBufferedImage
.ImageInfo
getSquareImageInfo()
Adds padding as needed to make the image a nice square.java.awt.geom.Rectangle2D
getSymbolBounds()
minimum bounding rectangle for the core symbol.java.awt.Point
getSymbolCenterPoint()
The point the image should be centered on or the "anchor point".int
getSymbolCenterX()
The x value the image should be centered on or the "anchor point".int
getSymbolCenterY()
The y value the image should be centered on or the "anchor point".int
getX()
X position of where the image should be drawnint
getY()
Y position of where the image should be drawnjava.lang.Boolean
SaveImageToFile(java.lang.String filePath, java.lang.String imageFormat)
Save image to a file as a PNG or JPGjava.lang.Boolean
SaveImageToPNG(javax.imageio.stream.ImageOutputStream ios)
Unlike SaveImageToFile, this only writes to PNGs and it includes positional metadata in the PNG.
-
-
-
Field Detail
-
FormatPNG
public static final java.lang.String FormatPNG
- See Also:
- Constant Field Values
-
FormatJPG
public static final java.lang.String FormatJPG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ImageInfo
protected ImageInfo()
-
ImageInfo
public ImageInfo(java.awt.image.BufferedImage image, int x, int y)
ImageInfo holds and image and holds the position at which the image should be drawn. Use for Multipoint and single point graphics.- Parameters:
image
-BufferedImage
x
- position of where the image should be drawny
- position of where the image should be drawn
-
ImageInfo
public ImageInfo(java.awt.image.BufferedImage bi, java.awt.geom.Point2D centerPoint, java.awt.geom.Rectangle2D symbolBounds)
Creates a new ImageInfo object- Parameters:
bi
-BufferedImage
centerPoint
- can also be the anchor point of the symbol if it isn't the center of the image (action point)symbolBounds
-Rectangle2D
-
ImageInfo
public ImageInfo(java.awt.image.BufferedImage image, int x, int y, int symbolCenterX, int symbolCenterY)
Deprecated.ImageInfo holds and image and holds the position at which the image should be drawn. Use this if the image is a single point graphic.- Parameters:
image
-BufferedImage
x
- position of where the image should be drawny
- position of where the image should be drawnsymbolCenterX
- center point of image may be different from the center point of the symbol within the image. (single point graphics)symbolCenterY
- center point of image may be different from the center point of the symbol within the image. (single point graphics)
-
ImageInfo
public ImageInfo(java.awt.image.BufferedImage image, int x, int y, int symbolCenterX, int symbolCenterY, java.awt.geom.Rectangle2D symbolBounds)
ImageInfo holds and image and holds the position at which the image should be drawn. Use this if the image is a single point graphic.- Parameters:
image
-BufferedImage
x
- position of where the image should be drawny
- position of where the image should be drawnsymbolCenterX
- center point of image may be different center point of the symbol within the image. (single point graphics)symbolCenterY
- center point of image may be different center point of the symbol within the image. (single point graphics)symbolBounds
- minimum bounding rectangle for the core symbol. Does not include modifiers, display or otherwise.
-
-
Method Detail
-
getImage
public java.awt.image.BufferedImage getImage()
The BufferedImage- Returns:
- the actual image
-
getX
public int getX()
X position of where the image should be drawn- Returns:
Integer
-
getY
public int getY()
Y position of where the image should be drawn- Returns:
Integer
-
getPoint
public java.awt.Point getPoint()
position of where the image should be drawn- Returns:
Point
-
getSymbolCenterX
public int getSymbolCenterX()
The x value the image should be centered on or the "anchor point".- Specified by:
getSymbolCenterX
in interfaceSymbolDimensionInfo
- Returns:
Integer
-
getSymbolCenterY
public int getSymbolCenterY()
The y value the image should be centered on or the "anchor point".- Specified by:
getSymbolCenterY
in interfaceSymbolDimensionInfo
- Returns:
Integer
-
getSymbolCenterPoint
public java.awt.Point getSymbolCenterPoint()
The point the image should be centered on or the "anchor point".- Specified by:
getSymbolCenterPoint
in interfaceSymbolDimensionInfo
- Returns:
Point
-
getSymbolBounds
public java.awt.geom.Rectangle2D getSymbolBounds()
minimum bounding rectangle for the core symbol. Does not include modifiers, display or otherwise.- Specified by:
getSymbolBounds
in interfaceSymbolDimensionInfo
- Returns:
Rectangle2D
-
getImageBounds
public java.awt.geom.Rectangle2D getImageBounds()
Dimension of the entire image.- Specified by:
getImageBounds
in interfaceSymbolDimensionInfo
- Returns:
Rectangle2D
-
SaveImageToFile
public java.lang.Boolean SaveImageToFile(java.lang.String filePath, java.lang.String imageFormat)
Save image to a file as a PNG or JPG- Parameters:
filePath
- full path to the fileimageFormat
- "jpg" or "png"- Returns:
- true on success.
-
SaveImageToPNG
public java.lang.Boolean SaveImageToPNG(javax.imageio.stream.ImageOutputStream ios)
Unlike SaveImageToFile, this only writes to PNGs and it includes positional metadata in the PNG. Entered as tEXtEntry elements of tEXt metadata keywords are "centerPoint" and "bounds". Values formatted as "x=#,y=#" and "x=#,y=#,width=#,height=#" Bounds is the MBR of the symbol and does not include any modifiers.- Parameters:
ios
- full path to the file. Usage Like FileOutputStream out = new FileOutputStream(filePath); SaveImageToPNG(ImageIO.createImageOutputStream(out)); OR ByteArrayOutputStream bytes = new ByteArrayOutputStream(); SaveImageToPNG(ImageIO.createImageOutputStream(bytes)); ImageOutputStream is closed before SaveImageToPNG exits. Don't forget to close the streams when done.- Returns:
- true on success.
-
getImageAsByteArray
public byte[] getImageAsByteArray()
returns the image as a byte[] representing a PNG.- Returns:
byte
-
getImageAsByteArrayWithMetaInfo
public byte[] getImageAsByteArrayWithMetaInfo()
Unlike SaveImageToFile, this only writes to PNGs and it includes positional metadata in the PNG. Entered as tEXtEntry elements of tEXt metadata keywords are "centerPoint" and "bounds". Values formatted as "x=#,y=#" and "x=#,y=#,width=#,height=#" Bounds is the MBR of the symbol and does not include any modifiers.- Returns:
byte
-
CenterImageOnPoint
public static java.awt.image.BufferedImage CenterImageOnPoint(java.awt.image.BufferedImage image, java.awt.geom.Point2D point)
Takes an image and a center point and generates a new, bigger image that has the symbol centered in it- Parameters:
image
-BufferedImage
point
-Point2D
- Returns:
BufferedImage
-
CanWriteImageFormat
public static java.lang.Boolean CanWriteImageFormat(java.lang.String format)
Determines if you can write your desired format.- Parameters:
format
- "png", "jpg", "gif", etc...- Returns:
- true/false
-
getScaledInstance
public static java.awt.image.BufferedImage getScaledInstance(java.awt.image.BufferedImage srcImage, int targetWidth, int targetHeight, java.lang.Object hint, boolean higherQuality, boolean keepProportion)
Convenience method that returns a scaled instance of the providedBufferedImage
. NEEDS WORK. Alternate option is getScaledInstance off of the BufferedImage object.- Parameters:
srcImage
- The image to be scaled.targetWidth
- the desired width of the scaled instance, in pixelstargetHeight
- the desired height of the scaled instance, in pixelshint
- one of the rendering hints that corresponds toRenderingHints.KEY_INTERPOLATION
(e.g.RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR
,RenderingHints.VALUE_INTERPOLATION_BILINEAR
,RenderingHints.VALUE_INTERPOLATION_BICUBIC
)higherQuality
- if true, this method will use a multi-step scaling technique that provides higher quality than the usual one-step technique (only useful in downscaling cases, wheretargetWidth
ortargetHeight
is smaller than the original dimensions, and generally only when theBILINEAR
hint is specified). NEEDS WORK.keepProportion
- Don't stretch the original image to fit into the target height/width.- Returns:
- a scaled version of the original
BufferedImage
-
-