Class GraphicsUtils


  • public class GraphicsUtils
    extends java.lang.Object
    Utility methods for shapes and images.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private GraphicsUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.awt.image.BufferedImage convertRenderedImage​(java.awt.image.RenderedImage img)
      Converts a rendered image to a BufferedImage.
      static java.awt.Shape copyOf​(java.awt.Shape shape)
      Returns a shape that is more or less equivalent to the supplied shape.
      static java.awt.geom.GeneralPath createPolygon​(int[] xPoints, int[] yPoints, int nPoints, boolean close)
      Creates a polygon for from the specified x and y coordinates.
      • Methods inherited from class java.lang.Object

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

      • GraphicsUtils

        private GraphicsUtils()
    • Method Detail

      • copyOf

        public static java.awt.Shape copyOf​(java.awt.Shape shape)
        Returns a shape that is more or less equivalent to the supplied shape.
        Parameters:
        shape - the shape (null not permitted).
        Returns:
        A copy of the shape (it may not be the same class).
      • createPolygon

        public static java.awt.geom.GeneralPath createPolygon​(int[] xPoints,
                                                              int[] yPoints,
                                                              int nPoints,
                                                              boolean close)
        Creates a polygon for from the specified x and y coordinates.
        Parameters:
        xPoints - the x-points.
        yPoints - the y-points.
        nPoints - the number of points to use for the polyline.
        close - closed?
        Returns:
        A polygon.
      • convertRenderedImage

        public static java.awt.image.BufferedImage convertRenderedImage​(java.awt.image.RenderedImage img)
        Converts a rendered image to a BufferedImage. This utility method has come from a forum post by Jim Moore at:

        http://www.jguru.com/faq/view.jsp?EID=114602

        Parameters:
        img - the rendered image.
        Returns:
        A buffered image.