Class GLine
java.lang.Object
com.j3d.engine.react.events.EventEmitter
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 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 TypeFieldDescriptionprotected booleanprotected GPointThe startpoint of this lineprotected GPointThe endPoint of this line.private RenderState<Segment, GObject> Fields inherited from class com.j3d.engine.scene.nodes.geometry.GObject
col, pivotProperty, propertiesFields inherited from class com.j3d.engine.react.events.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.protected GLinevoidbooleanDeletes itselfbooleanstatic GLineConstructs a GLine.getA()Returns the start GPointgetB()Returns the end GPointReturns 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()toString()Methods inherited from class com.j3d.engine.scene.nodes.geometry.GObject
asReference, getColour, getId, getName, getPivot, getProperties, setColour, setId, setPivotMethods inherited from class com.j3d.engine.react.events.EventEmitter
attachListener, broadcast, detachAll, detachListener, genericAttach, genericBroadcast, genericDetach, genericDetachAll, isAttachedMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.j3d.engine.scene.nodes.geometry.base.DecomposeWhenDrawn
invalidateAllMethods inherited from interface com.j3d.engine.scene.nodes.geometry.base.HasParents
addParents, clearParents, hasParent
-
Field Details
-
pointA
The startpoint of this line -
pointB
The endPoint of this line. -
deletedState
protected boolean deletedState -
parents
-
renderState
-
-
Constructor Details
-
GLine
Default Constructor- Parameters:
A- The start pointB- THe end point
-
-
Method Details
-
fromRaw
Constructs a GLine.- Parameters:
id- The id of the line defined by the fileA- The first constructed GPoint reference.B- The second constructed GPoint reference.- Returns:
- A GLine
-
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
Returns the end GPoint- Returns:
- GPoint
-
getA
Returns the start GPoint- Returns:
- start
-
length
public double length()Calculates and returns the length of this line.- Returns:
- a double representing the length of the line.
-
toString
-
getPointStream
Creates a stream of this line's points.- Returns:
- A stream of GPoints
-
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
Checks if this GLine's points are identical to the given points, regardless of order.- Parameters:
A- The first GPoint to compare.B- The second GPoint to compare.- Returns:
- true if the points match, false otherwise.
-
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
public int hashCode() -
toSegment
-
decompose
public void decompose()- Specified by:
decomposein interfaceDecomposeWhenDrawn<Segment>
-
genericRenderStateList
- Overrides:
genericRenderStateListin classGObject
-
getDecomposeList
- Specified by:
getDecomposeListin interfaceDecomposeWhenDrawn<Segment>
-
getEngineObjectType
- Specified by:
getEngineObjectTypein classGObject
-
toObject
-