Package com.algo.rendering.shapes
Class RenderingShape
- java.lang.Object
-
- com.algo.rendering.shapes.RenderingShape
-
- All Implemented Interfaces:
java.io.Serializable
public abstract class RenderingShape extends java.lang.Object implements java.io.Serializable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.LinkedList<java.lang.Class<? extends RenderingShape>>
renderingShapeClasses
SizeBox
sizeBox
Provides a rough measure of the size of a shape via a Rectangle, applicable height every subclass of shapejava.lang.Double
strokeWidth
-
Constructor Summary
Constructors Constructor Description 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 Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract boolean
containsCoordinate(Vector2D point, Vector2D center)
Returns true if the given vector is overlapping with this shapeabstract 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.abstract Vector2D
getIntersection(Vector2D lineStart, Vector2D lineEnd, Vector2D center)
Calculates the point of intersection between a line and the shape (Basically a RayCast)static boolean
isShape(java.lang.String s)
void
render(GralogGraphicsContext gc, Vector2D center, GralogColor s, GralogColor f)
void
render(GralogGraphicsContext gc, Vector2D center, java.lang.String label, GralogColor s, GralogColor f)
Renders a shape on the provided graphics context.void
setHeight(double height)
void
setWidth(double width)
-
-
-
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 shapeTwo 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 renderedlabel
-s
- Stroke colorf
- Filling color
-
render
public void render(GralogGraphicsContext gc, Vector2D center, GralogColor s, GralogColor f)
-
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 degreescenter
- 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 linelineEnd
- The end of the line INSIDE the shape. For a normal edge calculation, lineEnd = centercenter
- The center of the object with this shape
-
-