Class PivotingImageShaper


  • public class PivotingImageShaper
    extends java.lang.Object
    Provides Supplier methods that, given a BufferedImage, an Image, or the fileName of an image, will return a java.awt.Shape that is the contiguous traced outline of the opaque part of the image. This could be used to define an image for use in a Vertex, where the shape used for picking and edge-arrow placement follows the opaque part of an image that has a transparent background. The methods try to detect lines in order to minimize points in the path
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static int firstx
      the first x coordinate of the shape.
      (package private) static int sample
      the number of pixels to skip while sampling the images edges
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.awt.Shape bottomEdge​(java.awt.image.BufferedImage image, java.awt.geom.GeneralPath path, int start)
      trace the bottom of the image
      private static java.awt.geom.Point2D detectLine​(java.awt.geom.Point2D p1, java.awt.geom.Point2D p2, java.awt.geom.Point2D p, java.awt.geom.Line2D line, java.awt.geom.GeneralPath path)  
      static java.awt.Shape getShape​(java.awt.image.BufferedImage image)
      Given an image, possibly with a transparent background, return the Shape of the opaque part of the image
      private static java.awt.Shape leftEdge​(java.awt.image.BufferedImage image, java.awt.geom.GeneralPath path)
      trace the left side of the image
      private static java.awt.Shape rightEdge​(java.awt.image.BufferedImage image, java.awt.geom.GeneralPath path, int start)
      trace the right side of the image
      private static java.awt.Shape topEdge​(java.awt.image.BufferedImage image, java.awt.geom.GeneralPath path, int start)
      trace the top of the image
      • Methods inherited from class java.lang.Object

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

      • sample

        static int sample
        the number of pixels to skip while sampling the images edges
      • firstx

        static int firstx
        the first x coordinate of the shape. Used to discern when we are done
    • Constructor Detail

      • PivotingImageShaper

        public PivotingImageShaper()
    • Method Detail

      • getShape

        public static java.awt.Shape getShape​(java.awt.image.BufferedImage image)
        Given an image, possibly with a transparent background, return the Shape of the opaque part of the image
        Parameters:
        image - the image whose shape is being returned
        Returns:
        the Shape
      • detectLine

        private static java.awt.geom.Point2D detectLine​(java.awt.geom.Point2D p1,
                                                        java.awt.geom.Point2D p2,
                                                        java.awt.geom.Point2D p,
                                                        java.awt.geom.Line2D line,
                                                        java.awt.geom.GeneralPath path)
      • leftEdge

        private static java.awt.Shape leftEdge​(java.awt.image.BufferedImage image,
                                               java.awt.geom.GeneralPath path)
        trace the left side of the image
        Parameters:
        image -
        path -
        Returns:
      • bottomEdge

        private static java.awt.Shape bottomEdge​(java.awt.image.BufferedImage image,
                                                 java.awt.geom.GeneralPath path,
                                                 int start)
        trace the bottom of the image
        Parameters:
        image -
        path -
        start -
        Returns:
      • rightEdge

        private static java.awt.Shape rightEdge​(java.awt.image.BufferedImage image,
                                                java.awt.geom.GeneralPath path,
                                                int start)
        trace the right side of the image
        Parameters:
        image -
        path -
        start -
        Returns:
      • topEdge

        private static java.awt.Shape topEdge​(java.awt.image.BufferedImage image,
                                              java.awt.geom.GeneralPath path,
                                              int start)
        trace the top of the image
        Parameters:
        image -
        path -
        start -
        Returns: