Class GraphicsUtilities

java.lang.Object
se.datadosen.util.GraphicsUtilities

public class GraphicsUtilities
extends java.lang.Object
  • Constructor Summary

    Constructors 
    Constructor Description
    GraphicsUtilities()  
  • Method Summary

    Modifier and Type Method Description
    static java.awt.image.BufferedImage duplicate​(java.awt.Image image)
    Since v11
    static java.awt.Dimension fitWithinBounds​(int width, int height, java.awt.Dimension boundingBox)
    Used by recalculate bounds to make the image fitting exact to the component size, even if it is larger.
    static java.awt.image.BufferedImage getFasterScaledInstance​(java.awt.image.BufferedImage img, int targetWidth, int targetHeight, java.lang.Object hint, boolean progressiveBilinear)
    Convenience method that returns a scaled instance of the provided BufferedImage.
    static int getScale​(java.awt.GraphicsDevice device)
    Return the pixel scale factor.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getFasterScaledInstance

      public static java.awt.image.BufferedImage getFasterScaledInstance​(java.awt.image.BufferedImage img, int targetWidth, int targetHeight, java.lang.Object hint, boolean progressiveBilinear)
      Convenience method that returns a scaled instance of the provided BufferedImage.
      Parameters:
      img - the original 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)
      progressiveBilinear - if true, this method will use a multi-step scaling technique that provides higher quality than the usual one-step technique (only useful in down-scaling cases, where targetWidth or targetHeight is smaller than the original dimensions)
      Returns:
      a scaled version of the original BufferedImage
    • duplicate

      public static java.awt.image.BufferedImage duplicate​(java.awt.Image image)
      Since v11
      Parameters:
      image -
      Returns:
    • getScale

      public static int getScale​(java.awt.GraphicsDevice device)
      Return the pixel scale factor. 1 for ordinary displays, 2 and above for retina displays
      Parameters:
      device -
      Returns:
      Since:
      13.1
    • fitWithinBounds

      public static java.awt.Dimension fitWithinBounds​(int width, int height, java.awt.Dimension boundingBox)
      Used by recalculate bounds to make the image fitting exact to the component size, even if it is larger.
      Parameters:
      width - image width
      height - image height
      boundingBox - box around the image
      Returns:
      new image dimension
      Since:
      14.2