Class ContainerShape

java.lang.Object
com.nomagic.awt.ContainerShape

@OpenApiAll public class ContainerShape extends Object
This shape can have rectangles, ellipses and lines. The shape form is the union of all contained shapes.
  • Constructor Details

    • ContainerShape

      public ContainerShape()
  • Method Details

    • intersection

      @CheckForNull public Point intersection(Point a, Point b)
    • intersection

      @CheckForNull public 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 line
      ay - first point of line
      bx - second point of line
      by - second point of line
      Returns:
      the shapes intersection point
    • addShape

      public void addShape(Rectangle rect)
      Add rectangle shape.
    • addShape

      public void addShape(RoundRectangle2D rect)
      Add rectangle shape.
    • addShape

      public void addShape(Line line)
      Add line.
    • addEllipse

      public void addEllipse(Rectangle el)
      Add ellipse.
    • addShape

      public void addShape(Polygon polygon)
      Add Polygon.
    • getEllipses

      public List<Rectangle> getEllipses()
      Returns contained ellipses
      Returns:
      ellipses
    • getRectangles

      public List<Rectangle> getRectangles()
      Returns contained rectangles.
      Returns:
      rectangle
    • getLines

      public List<Line> getLines()
      Returns contained lines.
      Returns:
      lines
    • getRoundRectangles

      public List<RoundRectangle2D> getRoundRectangles()
      Returns round rectangles
      Returns:
      round rectangles
    • getPolygons

      public List<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(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.