Class Handle
java.lang.Object
com.j3d.engine.interact.cmd.commands.transform.handles.Handle
Represents a single, interactive 3D handle (gizmo) used for manipulating objects in the scene.
A handle is a visual component (e.g., an arrow or a cube) that the user can click and drag to perform a transformation (like translate, rotate, or scale) along a specific axis. This class encapsulates the handle's 3D position, its type (axis), its selection state, and the logic required to draw it on the screen.
- Author:
- Lehlogonolo Poole
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BiConsumer<Graphics2D, ScreenPoint> private Consumer<Graphics2D> private Consumer<Graphics2D> private final HandleTypeprivate Vector3private boolean -
Constructor Summary
ConstructorsConstructorDescriptionHandle(HandleType handleType, Vector3 position, BiConsumer<Graphics2D, ScreenPoint> draw) Constructs a new Handle. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()draw(Graphics2D g) Renders the handle on the screen.extraDetail(Consumer<Graphics2D> extraDetail) Sets an optional drawing function for rendering extra details when the handle is selected.extraDetailRegardless(Consumer<Graphics2D> extraDetail) getPos()Gets the current 3D position of the handle.Returns the type (axis) of this handle.voidselected()Marks the handle as selected.voidUpdates the 3D position of the handle.toSp()Converts the handle's 3D world position to a 2D screen position.voidunselect()Marks the handle as not selected.
-
Field Details
-
handleType
-
position
-
selected
private boolean selected -
draw
-
extraDetail
-
extraDetailRegardless
-
-
Constructor Details
-
Handle
Constructs a new Handle.- Parameters:
handleType- The type or axis of this handle (X, Y, or Z).position- The initial 3D position of the handle in world space.draw- ABiConsumercontaining the logic to draw the handle's shape on the screen, given aGraphics2Dcontext and a 2DScreenPoint.
-
-
Method Details
-
extraDetail
Sets an optional drawing function for rendering extra details when the handle is selected.- Parameters:
extraDetail- AConsumerto draw additional visual feedback.- Returns:
- This Handle instance for method chaining.
-
extraDetailRegardless
-
clear
public void clear() -
draw
Renders the handle on the screen.This method projects the handle's 3D position to a 2D screen point and executes the drawing logic. If the handle is selected, it also renders its name and any extra details.
- Parameters:
g- TheGraphics2Dcontext to draw on.- Returns:
- This Handle instance.
-
toSp
Converts the handle's 3D world position to a 2D screen position.- Returns:
- The calculated
ScreenPoint.
-
handleType
Returns the type (axis) of this handle.- Returns:
- The
HandleType.
-
setPos
Updates the 3D position of the handle.- Parameters:
newPos- The new positionVector3in world space.
-
unselect
public void unselect()Marks the handle as not selected. -
selected
public void selected()Marks the handle as selected. -
getPos
Gets the current 3D position of the handle.- Returns:
- The position
Vector3.
-