Class 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.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String FormatJPG  
      static java.lang.String FormatPNG  
    • 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 it
      java.awt.image.BufferedImage getImage()
      The BufferedImage
      byte[] 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 drawn
      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 provided BufferedImage.
      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 drawn
      int getY()
      Y position of where the image should be drawn
      java.lang.Boolean SaveImageToFile​(java.lang.String filePath, java.lang.String imageFormat)
      Save image to a file as a PNG or JPG
      java.lang.Boolean SaveImageToPNG​(javax.imageio.stream.ImageOutputStream ios)
      Unlike SaveImageToFile, this only writes to PNGs and it includes positional metadata in the PNG.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 drawn
        y - 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 drawn
        y - position of where the image should be drawn
        symbolCenterX - 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 drawn
        y - position of where the image should be drawn
        symbolCenterX - 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 interface SymbolDimensionInfo
        Returns:
        Integer
      • getSymbolCenterY

        public int getSymbolCenterY()
        The y value the image should be centered on or the "anchor point".
        Specified by:
        getSymbolCenterY in interface SymbolDimensionInfo
        Returns:
        Integer
      • getSymbolCenterPoint

        public java.awt.Point getSymbolCenterPoint()
        The point the image should be centered on or the "anchor point".
        Specified by:
        getSymbolCenterPoint in interface SymbolDimensionInfo
        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 interface SymbolDimensionInfo
        Returns:
        Rectangle2D
      • getImageBounds

        public java.awt.geom.Rectangle2D getImageBounds()
        Dimension of the entire image.
        Specified by:
        getImageBounds in interface SymbolDimensionInfo
        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 file
        imageFormat - "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 provided BufferedImage. 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 pixels
        targetHeight - the desired height of the scaled instance, in pixels
        hint - one of the rendering hints that corresponds to RenderingHints.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, where targetWidth or targetHeight is smaller than the original dimensions, and generally only when the BILINEAR 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
      • getSquareImageInfo

        public ImageInfo getSquareImageInfo()
        Adds padding as needed to make the image a nice square.
        Returns:
        ImageInfo