Interface VectorImage

  • All Known Implementing Classes:
    AbstractVectorImage, SubregionVectorImage, SVGVectorImage

    public interface VectorImage
    Interface implemented by classes that represent vector images. Described algorithmically, pure vector images can be scaled to arbitrary sizes without losing definition and becoming blocky as bitmap images do.
    Since:
    3.0
    Author:
    Chris Jennings
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.awt.image.BufferedImage createRasterImage​(double ppi)
      Creates a raster image from the vector image at the specified resolution, assuming that the image width and height are measured in points.
      java.awt.image.BufferedImage createRasterImage​(int width, int height, boolean fitToSize)
      Creates a raster image from the vector image with the specified width and height (in pixels).
      double getHeight()
      Returns the height of the image in an unspecified unit.
      double getWidth()
      Returns the width of the image in an unspecified unit.
      void paint​(java.awt.Graphics2D g, double x, double y)
      Paints the image at the specified location in the user coordinates of the provided graphics context.
      void paint​(java.awt.Graphics2D g, double x, double y, double width, double height, boolean fitToSize)
      Paints the image at the specified location and size in the user coordinates of the provided graphics context.
      void paint​(java.awt.Graphics2D g, java.awt.geom.Rectangle2D paintRectangle, boolean fitToSize)
      Paints the image to cover the specified rectangle in the user coordinates of the provided graphics context.
    • Method Detail

      • getWidth

        double getWidth()
        Returns the width of the image in an unspecified unit. Typically this reflects the "natural" size of the image in the unit used by the designer.
        Returns:
        the image width in image-specific units
      • getHeight

        double getHeight()
        Returns the height of the image in an unspecified unit. Typically this reflects the "natural" size of the image in the unit used by the designer.
        Returns:
        the image height in image-specific units
      • paint

        void paint​(java.awt.Graphics2D g,
                   double x,
                   double y)
        Paints the image at the specified location in the user coordinates of the provided graphics context.
        Parameters:
        g - the graphics context to render into
        x - the x-coordinate to render at
        y - the y-coordinate to render at
      • paint

        void paint​(java.awt.Graphics2D g,
                   double x,
                   double y,
                   double width,
                   double height,
                   boolean fitToSize)
        Paints the image at the specified location and size in the user coordinates of the provided graphics context. If the fitToSize parameter is true, then the aspect ratio of the vector image will be maintained. If the aspect ratio of the vector image does not match the specified width and height, then the vector image will be scaled to just fit within the specified size, and centered over the drawing area.
        Parameters:
        g - the graphics context to render into
        x - the x-coordinate to render at
        y - the y-coordinate to render at
        width - the width to paint the image at
        height - the height to paint the image at
        fitToSize - if true, the aspect ratio of the vector image will be maintained
      • paint

        void paint​(java.awt.Graphics2D g,
                   java.awt.geom.Rectangle2D paintRectangle,
                   boolean fitToSize)
        Paints the image to cover the specified rectangle in the user coordinates of the provided graphics context. If the fitToSize parameter is true, then the aspect ratio of the vector image will be maintained. If the aspect ratio of the vector image does not match the specified width and height, then the vector image will be scaled to just fit within the specified size, and centered over the drawing area.
        Parameters:
        g - the graphics context to render into
        paintRectangle - the rectangle that the image should cover
        fitToSize - if true, the aspect ratio of the vector image will be maintained
      • createRasterImage

        java.awt.image.BufferedImage createRasterImage​(double ppi)
        Creates a raster image from the vector image at the specified resolution, assuming that the image width and height are measured in points.
        Parameters:
        ppi - the resolution to render the image at
        Returns:
        a new bitmap image at the requested resolution
      • createRasterImage

        java.awt.image.BufferedImage createRasterImage​(int width,
                                                       int height,
                                                       boolean fitToSize)
        Creates a raster image from the vector image with the specified width and height (in pixels). If the fitToSize parameter is true, then the aspect ratio of the vector image will be maintained. If the aspect ratio of the vector image does not match the specified width and height, then the vector image will be scaled to just fit within the specified size, and centered over the drawing area.
        Parameters:
        width - the image width, in pixels
        height - the image height, in pixels
        fitToSize - if true, the aspect ratio of the vector image will be maintained
        Returns:
        a rendering of the vector image at the specified size