Class RenderingShape

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    Cycle, Diamond, Ellipse, Rectangle

    public abstract class RenderingShape
    extends java.lang.Object
    implements java.io.Serializable
    See Also:
    Serialized Form
    • Field Detail

      • renderingShapeClasses

        public static java.util.LinkedList<java.lang.Class<? extends RenderingShape>> renderingShapeClasses
      • strokeWidth

        public java.lang.Double strokeWidth
      • sizeBox

        public SizeBox sizeBox
        Provides a rough measure of the size of a shape via a Rectangle, applicable height every subclass of shape

        Two shapes with the same SizeBoxes should have roughly the same actual size in the final render.

    • Constructor Detail

      • RenderingShape

        public RenderingShape​(SizeBox s)
        Creates a RenderingShape with sensible default values, so that the final size of the rendered shape has similar dimensions as the rectangle of the given SizeBox
    • Method Detail

      • isShape

        public static boolean isShape​(java.lang.String s)
      • setWidth

        public void setWidth​(double width)
      • setHeight

        public void setHeight​(double height)
      • render

        public void render​(GralogGraphicsContext gc,
                           Vector2D center,
                           java.lang.String label,
                           GralogColor s,
                           GralogColor f)
        Renders a shape on the provided graphics context. RenderingShape will depend on the internal state of the shape object (e.g. parameters such as size, fill, color, etc..)
        Parameters:
        gc - The graphics context on which the shape is rendered
        label -
        s - Stroke color
        f - Filling color
      • containsCoordinate

        public abstract boolean containsCoordinate​(Vector2D point,
                                                   Vector2D center)
        Returns true if the given vector is overlapping with this shape
        Parameters:
        point - Vector that is being tested for overlapping
        Returns:
        True if the shape contains
      • getEdgePoint

        public abstract Vector2D getEdgePoint​(double alpha,
                                              Vector2D center)
        Calculates the (closest) point X on the edge of the shape so that (X-center) has an euler angle of alpha.
        Parameters:
        alpha - The angle of the point in degrees
        center - The point of reference for calculating X
        Returns:
        The closest such point as a Vector2D
      • getIntersection

        public abstract Vector2D getIntersection​(Vector2D lineStart,
                                                 Vector2D lineEnd,
                                                 Vector2D center)
        Calculates the point of intersection between a line and the shape (Basically a RayCast)
        Parameters:
        lineStart - Start of the line
        lineEnd - The end of the line INSIDE the shape. For a normal edge calculation, lineEnd = center
        center - The center of the object with this shape