Package com.nomagic.awt
Class ContainerShape
- java.lang.Object
-
- com.nomagic.awt.ContainerShape
-
@OpenApiAll public class ContainerShape extends java.lang.Object
This shape can have rectangles, ellipses and lines. The shape form is the union of all contained shapes.
-
-
Constructor Summary
Constructors Constructor Description ContainerShape()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEllipse(java.awt.Rectangle el)
Add ellipse.void
addShape(Line line)
Add line.void
addShape(java.awt.geom.RoundRectangle2D rect)
Add rectangle shape.void
addShape(java.awt.Polygon polygon)
Add Polygon.void
addShape(java.awt.Rectangle rect)
Add rectangle shape.static ContainerShape
createPolygonContainerShape(int[] x, int[] y)
Creates container shape from polygon points.static ContainerShape
createPolygonContainerShape(ContainerShape shape, int[] x, int[] y)
Creates container shape from polygon points.java.util.List<java.awt.Rectangle>
getEllipses()
Returns contained ellipsesjava.util.List<Line>
getLines()
Returns contained lines.java.util.List<java.awt.Polygon>
getPolygons()
Returns polygonsjava.util.List<java.awt.Rectangle>
getRectangles()
Returns contained rectangles.java.util.List<java.awt.geom.RoundRectangle2D>
getRoundRectangles()
Returns round rectanglesjava.awt.Point
intersection(int ax, int ay, int bx, int by)
Computes the intersection of this shape (intersection with any of contained shapes) with the specified line.java.awt.Point
intersection(java.awt.Point a, java.awt.Point b)
boolean
intersects(java.awt.Rectangle bounds)
Indicates if container shape intersects with specified bounds.
-
-
-
Method Detail
-
intersection
@CheckForNull public java.awt.Point intersection(java.awt.Point a, java.awt.Point b)
-
intersection
@CheckForNull public java.awt.Point intersection(int ax, int ay, int bx, int by)
Computes the intersection of this shape (intersection with any of contained shapes) with the specified line. Returns a new point that represents the intersection of two shapes.- Parameters:
ax
- first point of lineay
- first point of linebx
- second point of lineby
- second point of line- Returns:
- the shapes intersection point
-
addShape
public void addShape(java.awt.Rectangle rect)
Add rectangle shape.
-
addShape
public void addShape(java.awt.geom.RoundRectangle2D rect)
Add rectangle shape.
-
addShape
public void addShape(Line line)
Add line.
-
addEllipse
public void addEllipse(java.awt.Rectangle el)
Add ellipse.
-
addShape
public void addShape(java.awt.Polygon polygon)
Add Polygon.
-
getEllipses
public java.util.List<java.awt.Rectangle> getEllipses()
Returns contained ellipses- Returns:
- ellipses
-
getRectangles
public java.util.List<java.awt.Rectangle> getRectangles()
Returns contained rectangles.- Returns:
- rectangle
-
getLines
public java.util.List<Line> getLines()
Returns contained lines.- Returns:
- lines
-
getRoundRectangles
public java.util.List<java.awt.geom.RoundRectangle2D> getRoundRectangles()
Returns round rectangles- Returns:
- round rectangles
-
getPolygons
public java.util.List<java.awt.Polygon> getPolygons()
Returns polygons- Returns:
- polygons
-
createPolygonContainerShape
public static ContainerShape createPolygonContainerShape(int[] x, int[] y)
Creates container shape from polygon points.- Parameters:
x
- array of x coordinates.y
- array of y coordinates.- Returns:
- created container shape.
-
createPolygonContainerShape
public static ContainerShape createPolygonContainerShape(ContainerShape shape, int[] x, int[] y)
Creates container shape from polygon points.- Parameters:
shape
- container shape to modify.x
- array of x coordinates.y
- array of y coordinates.- Returns:
- created container shape.
-
intersects
public boolean intersects(java.awt.Rectangle bounds)
Indicates if container shape intersects with specified bounds.- Parameters:
bounds
- bounds to check.- Returns:
- true if container shape intersects with specified bounds, false otherwise.
-
-