Class EarthImageWriter

java.lang.Object
noaa.coastwatch.io.EarthImageWriter

public class EarthImageWriter extends Object
The EarthImageWriter has a single static method that writes image data from an EarthDataView to one of various formats.
Since:
3.2.2
Author:
Peter Hollemans
  • Method Details

    • getInstance

      public static EarthImageWriter getInstance()
      Gets the singleton instance of this class.
      Returns:
      the singeton instance.
    • setFont

      public void setFont(Font font)
      Sets the font used for legends.
      Parameters:
      font - the new legend font.
    • write

      public Renderable write(EarthDataView view, EarthDataInfo info, boolean isVerbose, boolean hasLegends, IconElement logo, boolean isAntialiased, File file, String format, String worldFile, String tiffComp, int imageColors) throws IllegalArgumentException, IOException
      Writes the specified view to an image file. Note that if the image file is to contain legends, the view itself may be modified in size slightly to match the legend size. If this effect is undesired, the view should be cloned prior to passing to this routine.
      Parameters:
      view - the earth data view to write.
      info - the earth data information to use for the legends, or null to not show the information legend.
      isVerbose - the verbose flag, true to print verbose messages.
      hasLegends - the legends flag, true to draw color scale and information legends.
      logo - the logo to use for the legend. Ignored if hasLegends is false.
      isAntialiased - the antialias flag, true to antialias fonts and lines.
      file - the output file to write.
      format - the output file format: 'png', 'jpg', 'tif', 'gif', or 'pdf'.
      worldFile - the world file to write, or null for no world file. Correct world files can only be written if no legends are used and only for image formats, not PDF.
      tiffComp - the TIFF compression type: 'none', 'deflate', 'pack', 'lzw', or 'jpeg'.
      imageColors - the number of image colors to use or 0 to not restrict the image colors. If > 0, an indexed color model will be used for TIFF, PNG, GIF, and PDF output and antialiasing of lines turned off.
      Returns:
      a renderable object that may be used to show a preview of the written image file.
      Throws:
      IllegalArgumentException - if the specified format is not supported.
      IOException - if an error occurred writing the image data.
    • quantizeToIndex

      public static BufferedImage quantizeToIndex(BufferedImage image, IndexColorModel colorModel)
      Performs a color quantization of an image to a specific index color model.
      Parameters:
      image - the image to quantize.
      colorModel - the index color model to quantize the image with size <= 256 colors.
      Returns:
      the output quantized image.