Package edu.uci.ics.jung.visualization
Class FourPassImageShaper
- java.lang.Object
-
- edu.uci.ics.jung.visualization.FourPassImageShaper
-
public class FourPassImageShaper 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
-
-
Constructor Summary
Constructors Constructor Description FourPassImageShaper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.awt.Shape
bottomEdge(java.awt.image.BufferedImage image)
trace the bottom of the imageprivate 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)
Checks to see if point p is on a line that passes thru points p1 and p2.static java.awt.Shape
getShape(java.awt.image.BufferedImage image)
private static java.awt.Shape
leftEdge(java.awt.image.BufferedImage image)
trace the left side of the imageprivate static java.awt.Shape
rightEdge(java.awt.image.BufferedImage image)
trace the right side of the imageprivate static java.awt.Shape
topEdge(java.awt.image.BufferedImage image)
trace the top of the image
-
-
-
Method Detail
-
getShape
public static java.awt.Shape getShape(java.awt.image.BufferedImage image)
-
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)
Checks to see if point p is on a line that passes thru points p1 and p2. If p is on the line, extend the line segment so that it is from p1 to the location of p. If the point p is not on the line, update my shape with a line extending to the old p2 location, make the old p2 the new p1, and make p2 the old p- Parameters:
p1
-p2
-p
-line
-path
-- Returns:
-
leftEdge
private static java.awt.Shape leftEdge(java.awt.image.BufferedImage image)
trace the left side of the image- Parameters:
image
-path
-- Returns:
-
bottomEdge
private static java.awt.Shape bottomEdge(java.awt.image.BufferedImage image)
trace the bottom of the image- Parameters:
image
-path
-start
-- Returns:
-
rightEdge
private static java.awt.Shape rightEdge(java.awt.image.BufferedImage image)
trace the right side of the image- Parameters:
image
-path
-start
-- Returns:
-
topEdge
private static java.awt.Shape topEdge(java.awt.image.BufferedImage image)
trace the top of the image- Parameters:
image
-path
-start
-- Returns:
-
-