Class GraphicsUtils

java.lang.Object
de.erichseifert.vectorgraphics2d.util.GraphicsUtils

public abstract class GraphicsUtils extends Object
Abstract class that contains utility functions for working with graphics. For example, this includes font handling.
  • Field Details

  • Constructor Details

    • GraphicsUtils

      GraphicsUtils()
      Default constructor that prevents creation of class.
  • Method Details

    • hasAlpha

      public static boolean hasAlpha(Image image)
      This method returns true if the specified image has the possibility to store transparent pixels. Inspired by http://www.exampledepot.com/egs/java.awt.image/HasAlpha.html
      Parameters:
      image - Image that should be checked for alpha channel.
      Returns:
      true if the specified image can have transparent pixels, false otherwise
    • usesAlpha

      public static boolean usesAlpha(Image image)
      This method returns true if the specified image has at least one pixel that is not fully opaque.
      Parameters:
      image - Image that should be checked for non-opaque pixels.
      Returns:
      true if the specified image has transparent pixels, false otherwise
    • toBufferedImage

      public static BufferedImage toBufferedImage(RenderedImage image)
      Converts a rendered image instance to a BufferedImage.
      Parameters:
      image - Rendered image that should be converted.
      Returns:
      a buffered image containing the image pixels, or the original instance if the image already was of type BufferedImage.
    • toBufferedImage

      public static BufferedImage toBufferedImage(Image image)
      This method returns a buffered image with the contents of an image. Taken from http://www.exampledepot.com/egs/java.awt.image/Image2Buf.html
      Parameters:
      image - Image to be converted
      Returns:
      a buffered image with the contents of the specified image
    • clone

      public static Shape clone(Shape shape)
    • isLogicalFontFamily

      private static boolean isLogicalFontFamily(String family)
    • getPhysicalFont

      public static Font getPhysicalFont(Font logicalFont, String testText)
      Try to guess physical font from the properties of a logical font, like "Dialog", "Serif", "Monospaced" etc.
      Parameters:
      logicalFont - Logical font object.
      testText - Text used to determine font properties.
      Returns:
      An object of the first matching physical font. The original font object is returned if it was a physical font or no font matched.
    • getPhysicalFont

      public static Font getPhysicalFont(Font logicalFont)
    • getAlphaImage

      public static BufferedImage getAlphaImage(BufferedImage image)
    • equals

      public static boolean equals(Shape shapeA, Shape shapeB)