Class ShapeParticle
- All Implemented Interfaces:
ITimeToLive
- Direct Known Subclasses:
EllipseParticle, LineParticle, PolygonParticle, RectangleParticle
Represents a particle with a specific shape.
This abstract class defines the behavior and rendering logic for particles
that are represented by geometric shapes. Subclasses must implement the getShape(Point2D) method to define the specific shape of the
particle.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedShapeParticle(float width, float height) Creates a new shape particle with the specified dimensions. -
Method Summary
Modifier and TypeMethodDescriptiongetBoundingBox(Point2D origin) Retrieves the bounding box of the particle.protected abstract ShapeRetrieves the shape of the particle based on the emitter's origin.voidrender(Graphics2D g, Point2D emitterOrigin) Renders the particle on the specified graphics context.Methods inherited from class Particle
getAbsoluteLocation, getAbsoluteX, getAbsoluteY, getAccelerationX, getAccelerationY, getAliveTime, getAngle, getCollisionType, getColor, getCustomRenderType, getDeltaAngle, getDeltaHeight, getDeltaWidth, getHeight, getOpacity, getOutlineThickness, getRenderLocation, getTimeToLive, getVelocityX, getVelocityY, getWidth, getX, getY, hasRayCastCollision, init, isAntiAliased, isContinuousCollisionEnabled, isFading, isFadingOnCollision, isOutlineOnly, isStoppingOnCollision, setAccelerationX, setAccelerationY, setAngle, setAntiAliasing, setCollisionType, setColor, setContinuousCollision, setCustomRenderType, setDeltaAngle, setDeltaHeight, setDeltaWidth, setFade, setFadeOnCollision, setHeight, setOutlineOnly, setOutlineThickness, setStopOnCollision, setTimeToLive, setVelocityX, setVelocityY, setWidth, setX, setY, timeToLiveReached, update, usesCustomRenderType
-
Constructor Details
-
ShapeParticle
protected ShapeParticle(float width, float height) Creates a new shape particle with the specified dimensions.- Parameters:
width- the width of the particleheight- the height of the particle
-
-
Method Details
-
getShape
Retrieves the shape of the particle based on the emitter's origin.
This method must be implemented by subclasses to define the specific shape of the particle.
- Parameters:
emitterOrigin- the origin point of the emitter- Returns:
- the shape of the particle
-
getBoundingBox
Retrieves the bounding box of the particle.
The bounding box is calculated based on the particle's shape and the specified origin point.
- Overrides:
getBoundingBoxin classParticle- Parameters:
origin- the origin point of the emitter- Returns:
- the bounding box of the particle as a
Rectangle2D
-
render
Renders the particle on the specified graphics context.
The rendering behavior depends on whether the particle is outline-only or a specific subclass such as
LineParticle. The particle's color, opacity, and anti-aliasing settings are applied during rendering.
-