Class Layer
- All Implemented Interfaces:
SceneObjectList,SceneObject,HasProperties,Serializable,Cloneable,Iterable<Thing>,Collection<Thing>,List<Thing>,RandomAccess,SequencedCollection<Thing>
Layer is a fundamental concept in the rendering pipeline, representing a
collection of Thing instances that are rendered together. The
SceneManager processes these layers in a specific order, drawing the
contents of each layer to the screen.
The Layer class extends ArrayList, providing a
way to manage the objects within it. You can add, remove, and
reorder objects in a layer to dynamically change the scene's composition.
- Layers allow you to group related
Things, making it easier to manage complex scenes.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprivate booleanprivate booleanprivate final Stringprivate final BiConsumer<Layer, DefaultMutableTreeNode> private DefaultMutableTreeNodeprivate TreeNodeIdentity<Layer> private final UUIDFields inherited from class java.util.AbstractList
modCount -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddProps()Deletes the object.voiddraw(Graphics2D graphics2D) Draws allThinginstances in this layer using the providedGraphics2Dcontext.static LayerCreates a Layer from raw data.getId()The ID of a layer is irrelevant as it's label is used as it's identifierReturns theTreeNodeIdentityfor the given object to use within theLayerTreegetName()Returns the identifier of this layerBiConsumer<? extends SceneObjectList, DefaultMutableTreeNode> The callback for when the object is selected in the tree.The actual tree node for the representation of this object withinLayerTreevoidAn internal delete method which all implementors should override for instantaneous deletion.voidA method to initialise anything swing related within the constructor.booleanLabels the object as for deletion.booleanisHidden()Whether the given object is hidden or notvoidsetForDeletion(boolean forDeletion) Marks the object for deletion.voidsetHidden(boolean hidden) Hides the object.squashWith(Layer otherlayer) Merges the contents of anotherLayerinto this layer.Toggles the visibility of the object.toString()Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class java.util.AbstractCollection
containsAllMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
containsAll, reversedMethods inherited from interface com.j3d.engine.scene.nodes.SceneObjectList
toggleSaved
-
Field Details
-
identifier
-
UUIDidentifer
-
BACKGROUND_ID
- See Also:
-
onSelectCallback
-
forDeletion
private boolean forDeletion -
properties
-
treeNodeIdentity
-
treeNode
-
-
Constructor Details
-
Layer
Default Constructor- Parameters:
id- The identifier of the layer.invokeSwingHooks- Whether to invoke swing hooks
-
Layer
Default Constructor- Parameters:
id- The identifier of the layer.
-
Layer
public Layer()Default Constructor. This constructor should not be used by a user as this instantiates the default layer.
-
-
Method Details
-
fromRaw
Creates a Layer from raw data. Specifically used for loading from files.- Parameters:
id- The identifier of the layer.hidden- Whether the layer is hidden.- Returns:
- The created Layer.
-
usableLayersStream
-
invokeSwingHooks
public void invokeSwingHooks()Description copied from interface:SceneObjectListA method to initialise anything swing related within the constructor. This is typically called within the SceneObjectList's constructor who needs to create an object outside the EDT thread.A use case (the current use case) would be when an SceneObjectList is loaded from disk to memory and the
Spinnerdialog is blocking the EDT thread. After the throbber has finished, you may call invokeSwingHooks safely rather than fighting with a blocked EDT thread.- Specified by:
invokeSwingHooksin interfaceSceneObjectList
-
getName
Returns the identifier of this layer- Specified by:
getNamein interfaceSceneObject- Returns:
- The identifier of this layer
-
getId
The ID of a layer is irrelevant as it's label is used as it's identifier- Specified by:
getIdin interfaceSceneObject- Returns:
- The UUID of this layer
-
getProperties
Description copied from interface:HasPropertiesReturns anArrayListofPropertyobjects associated with this instance. Each property can hold a value of a specific type and have a specific key type.- Specified by:
getPropertiesin interfaceHasProperties- Returns:
- an ArrayList of properties.
-
addProps
private void addProps() -
squashWith
Merges the contents of anotherLayerinto this layer. AllGObjects from theotherlayerare added to this layer. Theotherlayeritself remains unchanged.- Parameters:
otherlayer- TheLayerwhose contents are to be merged into this layer.- Returns:
- An
Actionrepresenting the squash operation, which can be undone if needed.
-
draw
Draws allThinginstances in this layer using the providedGraphics2Dcontext. The drawing order is determined by the distance of eachThing's centroid from the camera position, ensuring proper depth representation in the rendered scene.- Parameters:
graphics2D- TheGraphics2Dcontext used for drawing.
-
instantDelete
public void instantDelete()Description copied from interface:SceneObjectListAn internal delete method which all implementors should override for instantaneous deletion.This method should not be called by a user interface things. However, any object overriding the method must provide a way to delete everything relating to it.
- Specified by:
instantDeletein interfaceSceneObjectList
-
getIdentity
Description copied from interface:SceneObjectListReturns theTreeNodeIdentityfor the given object to use within theLayerTree- Specified by:
getIdentityin interfaceSceneObjectList- Returns:
- The identity
-
getTreeNode
Description copied from interface:SceneObjectListThe actual tree node for the representation of this object withinLayerTree- Specified by:
getTreeNodein interfaceSceneObjectList- Returns:
- The tree node
-
getOnSelect
Description copied from interface:SceneObjectListThe callback for when the object is selected in the tree.- Specified by:
getOnSelectin interfaceSceneObjectList- Returns:
- The callback
-
toString
- Overrides:
toStringin classAbstractCollection<Thing>
-
isHidden
public boolean isHidden()Description copied from interface:SceneObjectListWhether the given object is hidden or not- Specified by:
isHiddenin interfaceSceneObjectList- Returns:
- true if hidden, false otherwise
-
isForDeletion
public boolean isForDeletion()Description copied from interface:SceneObjectListLabels the object as for deletion. Has similar implications as being hidden however it will be cleaned up later and won't be available on lists.- Specified by:
isForDeletionin interfaceSceneObjectList- Returns:
- true if the object was marked for deletion
-
setForDeletion
public void setForDeletion(boolean forDeletion) Description copied from interface:SceneObjectListMarks the object for deletion.- Specified by:
setForDeletionin interfaceSceneObjectList
-
toggleVisibility
Description copied from interface:SceneObjectListToggles the visibility of the object.- Specified by:
toggleVisibilityin interfaceSceneObjectList- Returns:
- An action that toggles the visibility of the object and returns the new visibility state.
-
deleteLater
Description copied from interface:SceneObjectListDeletes the object.The use of the word "later" is because the action of deletion is only ever done once the Action object is out of the history's bounds. At that point
CleanableAction.cleanup()is called, which actually deletes.- Specified by:
deleteLaterin interfaceSceneObjectList- Returns:
- An action that deletes the object.
-
setHidden
public void setHidden(boolean hidden) Description copied from interface:SceneObjectListHides the object. This is for internal use. GUI and other user things should make use ofSceneObjectList.toggleVisibility()instead.- Specified by:
setHiddenin interfaceSceneObjectList
-