Class GLine
java.lang.Object
com.j3d.engine.react.events.EventEmitter
com.j3d.engine.react.events.EventEmitterAndListener
com.j3d.engine.scene.nodes.geometry.GObject
com.j3d.engine.scene.nodes.geometry.GLine
- All Implemented Interfaces:
EventEmitterInterface, EventListener, IdempotentEventListener<GPointMovedEvent, Vector3>, CanCopy, DecomposeWhenDrawn<Segment>, HasParents<GTri>, SceneObject, HasProperties
public final class GLine
extends GObject
implements HasParents<GTri>, IdempotentEventListener<GPointMovedEvent, Vector3>, DecomposeWhenDrawn<Segment>
GLine represents, you guessed it, a line.
A GLine's pivot is always defined as its midpoint.
A GLine is drawn by a parent GTri but otherwise is stored
alongside other GObjects within a Thing. And a GLine also
draws it's relevant GPoints
- Author:
- Lehlogonolo Poole
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate GPointThe startpoint of this lineprivate GPointThe endPoint of this line.private RenderState<Segment, GObject> Fields inherited from class GObject
col, pivotProperty, propertiesFields inherited from class EventEmitter
registered -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a parent to this object's set of parents.private voidaddProps()voidcopy(CopyProperties props) Copies the properties of this object based on the providedCopyProperties.private GLinevoidThe actual decomposition.booleanDeletes itselfbooleanstatic GLineConstructs a GLine.getA()Returns the start GPointgetB()Returns the end GPointFetches the actual decomposition list.Returns the duplicate object that events of typeTwill calculate/generate.static GLinegetInstance(HashSet<GLine> lines, GPoint A, GPoint B) Retrieves an existing GLine from a list if its points match the given points, or creates a new GLine if no match is found.static GLinegetOrCreateCopy(CopyProperties copyProperties, GLine original) Retrieves the set of all parent objects that this object belongs to.Creates a stream of this line's points.voidhandlePossibleDuplicates(EventType type, GPointMovedEvent payload) The handler to pass through for this specific type.inthashCode()booleanidenticalPoints(GPoint A, GPoint B) Checks if this GLine's points are identical to the given points, regardless of order.booleandoublelength()Calculates and returns the length of this line.voidonEvent(EventType event, EventPayload properties) onEvent is called byEventEmitterviaEventEmitter.broadcast(EventType, EventPayload).voidremoveParent(GTri parent) Removes a parent from this object's set of parents.toObject()Converts this SceneObject to aEngineObjectbeing a Jaiva-readableArrayListof data.toString()Methods inherited from class GObject
asReference, getColour, getId, getName, getPivot, getProperties, getTags, setColour, setId, setPivotMethods inherited from class EventEmitter
attachListener, broadcast, detachAll, detachListener, genericAttach, genericBroadcast, genericDetach, genericDetachAll, isAttachedMethods inherited from interface DecomposeWhenDrawn
invalidateAllMethods inherited from interface HasParents
addParents, clearParents, hasParentMethods inherited from interface SceneObject
tag
-
Field Details
-
pointA
The startpoint of this line -
pointB
The endPoint of this line. -
deletedState
private boolean deletedState -
parents
-
renderState
-
-
Constructor Details
-
GLine
-
-
Method Details
-
fromRaw
-
isDeletedState
public boolean isDeletedState()- Overrides:
isDeletedStatein classGObject
-
addProps
private void addProps() -
deleteSelf
public boolean deleteSelf()Description copied from class:GObjectDeletes itself- Overrides:
deleteSelfin classGObject- Returns:
- true if the line was deleted
-
getB
-
getA
-
length
public double length()Calculates and returns the length of this line.- Returns:
- a double representing the length of the line.
-
toString
-
getPointStream
-
getParents
Description copied from interface:HasParentsRetrieves the set of all parent objects that this object belongs to.- Specified by:
getParentsin interfaceHasParents<GTri>- Returns:
- A
HashSetcontaining all parent objects. Using a Set ensures that a parent can only be added once.
-
addParent
Description copied from interface:HasParentsAdds a parent to this object's set of parents.- Specified by:
addParentin interfaceHasParents<GTri>- Parameters:
parent- The parent object to add.
-
removeParent
Description copied from interface:HasParentsRemoves a parent from this object's set of parents.- Specified by:
removeParentin interfaceHasParents<GTri>- Parameters:
parent- The parent object to remove.
-
onEvent
Description copied from interface:EventListeneronEvent is called byEventEmitterviaEventEmitter.broadcast(EventType, EventPayload). Allowing the emitter to call any other object that implements this.- Specified by:
onEventin interfaceEventListener- Overrides:
onEventin classGObject- Parameters:
event- The type of eventproperties- The given event payload
-
getDupeObjectToCheck
Description copied from interface:IdempotentEventListenerReturns the duplicate object that events of typeTwill calculate/generate.- Specified by:
getDupeObjectToCheckin interfaceIdempotentEventListener<GPointMovedEvent, Vector3>- Returns:
- The duplicate object to check against.
-
handlePossibleDuplicates
Description copied from interface:IdempotentEventListenerThe handler to pass through for this specific type.- Specified by:
handlePossibleDuplicatesin interfaceIdempotentEventListener<GPointMovedEvent, Vector3>- Parameters:
type- The type of event.payload- The payload given.
-
copy
Description copied from interface:CanCopyCopies the properties of this object based on the providedCopyProperties. The implementation should handle how the copying is performed, potentially creating a new instance or modifying an existing one.- Specified by:
copyin interfaceCanCopy- Overrides:
copyin classGObject- Parameters:
props- The properties defining how the copy operation should be performed.- Throws:
InvalidCopyException- If the copy operation cannot be completed due to invalid properties or state.
-
copy
-
getOrCreateCopy
public static GLine getOrCreateCopy(CopyProperties copyProperties, GLine original) throws InvalidCopyException - Throws:
InvalidCopyException
-
explode
-
identicalPoints
-
getInstance
Retrieves an existing GLine from a list if its points match the given points, or creates a new GLine if no match is found.- Parameters:
lines- The list of existing GLines to search through.A- The first GPoint for comparison or new GLine creation.B- The second GPoint for comparison or new GLine creation.- Returns:
- An existing GLine with matching points, or a new GLine if none exists.
-
equals
-
hashCode
-
toSegment
-
decompose
public void decompose()Description copied from interface:DecomposeWhenDrawnThe actual decomposition.- Specified by:
decomposein interfaceDecomposeWhenDrawn<Segment>
-
genericRenderStateList
- Overrides:
genericRenderStateListin classGObject
-
getDecomposeList
Description copied from interface:DecomposeWhenDrawnFetches the actual decomposition list.- Specified by:
getDecomposeListin interfaceDecomposeWhenDrawn<Segment>- Returns:
- The arraylist of decomposed stuff
-
getEngineObjectType
- Specified by:
getEngineObjectTypein classGObject
-
toObject
Description copied from interface:SceneObjectConverts this SceneObject to aEngineObjectbeing a Jaiva-readableArrayListof data.- Specified by:
toObjectin interfaceSceneObject- Overrides:
toObjectin classGObject- Returns:
- An
EngineObject
-