Class PrismCmd
java.lang.Object
com.j3d.engine.interact.cmd.base.Command
com.j3d.engine.interact.cmd.commands.PrismCmd
- All Implemented Interfaces:
KeyedStatefulCommand,SemiStatefulCommand,StatefulCommand<Void>
A command to create a prism.
This command allows the user to define a prism by specifying the centre points and defining planes for its top and bottom faces. It als allows interactive adjustment of the prism's radius and number of sides using arrow keys, and provides a "gear" system to control the step size of radius adjustments.
The command operates in a stateful manner, displaying a visual ghost of the prism as it's being defined. Users can commit the prism creation with 'Enter' or cancel with 'Escape'.
Typical Usage:
prism (0,0,0) (0,10,0) (1,0,0) (0,0,1) - Creates a 3-sided prism (triangle) with radius 5,
bottom center at (0,0,0), top center at (0,10,0),
and faces aligned with the XZ plane.
p (1,1,1) (1,5,1) (1,0,0) (0,1,0) (1,0,0) (0,1,0) - Creates a prism with custom top and bottom plane definitions.
p plane:"xy" (0, 1, 0) (0, 10, 0) - Creates a prism who's faces lie on the XY plane using unordered
tagged arguments
p (0, 1, 0) (0, 10, 0) - Creates a prism who's faces are aligned with the XZ plane.
- Author:
- Lehlogonolo Poole
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) AxisPlane(package private) Vector3protected intThe index of the currently active step size in the gearTrain.protected J3KeyThe keybinding used to cycle through the gearTrain step sizes.protected double[]An array of step sizes (e.g., 1, 5, 20) that the user can cycle through.A list of temporary keybindings (e.g., arrow keys) active during this state.(package private) UUID(package private) int(package private) int(package private) AxisPlane(package private) Vector3Fields inherited from class com.j3d.engine.interact.cmd.base.Command
aliases, args, description, usages -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voideditRadius(boolean add) private voideditSides(boolean add) voidfinished(boolean success, SafeJLabel label) Method which clears all state related to this which can be keys ghost previews temporary listeners ...intGets the index of the currently active step size in the gear train.double[]Gets the array of available step sizes for the transformation (the "gear train").getKeys()Gets the list of temporaryJ3Keys that are active during this command's state.voidonEnter(Void object, SafeJLabel label) Called when the 'Enter' key is pressed.voidonEsc(Void object, SafeJLabel label) Called when the 'Escape' key is pressed.voidonStart(Void object, SafeJLabel label) Called when the command is first started.voidrun(Invoker invoker, SafeJLabel logLabel, String aliasUsed, Object[] args, ArrayList<TaggedArgValue<?>> taggedArgs) The method to be overridden by subclasses to implement command functionality.selfName()Returns the name of the specific command instance, used for creating unique key IDs.voidsetGearIndex(int index) Sets the current gear index, allowing the command to cycle through step sizes.Methods inherited from class com.j3d.engine.interact.cmd.base.Command
addNoArgUsage, aliases, aliasStream, args, dispatchToSubcommands, getUsages, hasNoArgs, parseUsages, usages, varTaggedArgsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.j3d.engine.interact.cmd.base.KeyedStatefulCommand
newGearKey, setDownKey, setKey, setKeyAsSideEffects, setLeftKey, setRightKey, setUpKeyMethods inherited from interface com.j3d.engine.interact.cmd.base.SemiStatefulCommand
fireMethods inherited from interface com.j3d.engine.interact.cmd.base.StatefulCommand
run, run
-
Field Details
-
gearTrain
protected double[] gearTrainAn array of step sizes (e.g., 1, 5, 20) that the user can cycle through. -
currentIndex
protected int currentIndexThe index of the currently active step size in the gearTrain. -
gear
The keybinding used to cycle through the gearTrain step sizes. -
keys
A list of temporary keybindings (e.g., arrow keys) active during this state. -
bottomFaceCenter
Vector3 bottomFaceCenter -
topFaceCenter
Vector3 topFaceCenter -
bottom
AxisPlane bottom -
top
AxisPlane top -
radius
int radius -
sides
int sides -
overlapId
UUID overlapId
-
-
Constructor Details
-
PrismCmd
public PrismCmd()
-
-
Method Details
-
editRadius
private void editRadius(boolean add) -
editSides
private void editSides(boolean add) -
run
public void run(Invoker invoker, SafeJLabel logLabel, String aliasUsed, Object[] args, ArrayList<TaggedArgValue<?>> taggedArgs) Description copied from class:CommandThe method to be overridden by subclasses to implement command functionality. -
onStart
Description copied from interface:StatefulCommandCalled when the command is first started.- Specified by:
onStartin interfaceStatefulCommand<Void>- Parameters:
object- The object that the command operates on.label- The SafeJLabel instance.
-
onEnter
Description copied from interface:StatefulCommandCalled when the 'Enter' key is pressed.- Specified by:
onEnterin interfaceStatefulCommand<Void>- Parameters:
object- The object that the command operates on.label- The SafeJLabel instance.
-
onEsc
Description copied from interface:StatefulCommandCalled when the 'Escape' key is pressed.- Specified by:
onEscin interfaceStatefulCommand<Void>- Parameters:
object- The object that the command operates on.label- The SafeJLabel instance.
-
finished
Description copied from interface:KeyedStatefulCommandMethod which clears all state related to this which can be- keys
- ghost previews
- temporary listeners
- ...
- Specified by:
finishedin interfaceKeyedStatefulCommand- Parameters:
success- Whether the command finished successfully or not. if the user had clicked escape or an error occurred that counts as an unsuccessful invocationlabel- The label.
-
getKeys
Description copied from interface:KeyedStatefulCommandGets the list of temporaryJ3Keys that are active during this command's state.- Specified by:
getKeysin interfaceKeyedStatefulCommand- Returns:
- An
ArrayListof active keys.
-
selfName
Description copied from interface:KeyedStatefulCommandReturns the name of the specific command instance, used for creating unique key IDs.- Specified by:
selfNamein interfaceKeyedStatefulCommand- Returns:
- The name of the command.
-
getGearTrain
public double[] getGearTrain()Description copied from interface:KeyedStatefulCommandGets the array of available step sizes for the transformation (the "gear train").- Specified by:
getGearTrainin interfaceKeyedStatefulCommand- Returns:
- An array of doubles representing different step magnitudes.
-
getGearIndex
public int getGearIndex()Description copied from interface:KeyedStatefulCommandGets the index of the currently active step size in the gear train.- Specified by:
getGearIndexin interfaceKeyedStatefulCommand- Returns:
- The current gear index.
-
setGearIndex
public void setGearIndex(int index) Description copied from interface:KeyedStatefulCommandSets the current gear index, allowing the command to cycle through step sizes.- Specified by:
setGearIndexin interfaceKeyedStatefulCommand- Parameters:
index- The new gear index.
-