Package com.j3d.engine.interact.macros
Class MacroUtils
java.lang.Object
com.j3d.engine.interact.macros.MacroUtils
Da Macro Utils. Basically the single instance manager of all the macros in J3Engine, this class is responsible for:
- Providing the entire set of macros from the user's macros folder and the keys map
-
Updating both ends when a new macro is added or a key is changed. Although thats specific to
MacrosEditor -
Removing all
J3Keyin the globalKeyBindingswhen macros change and the same for theEngineFrame.getMacroJMenu()where the macros are clickable via the JMenu -
Holding the single instances to the
MacroRecorderandMacroRunner
StaticRefs.getMacroUtils() at any time.- Author:
- Lehlogonolo Poole
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionList of classes theMacroRecorderwill ignore when listening forEventType.COMMAND_FIREDThe key map of macros.private final MacroRecorderRecorder instanceprivate final MacroRunnerRunner instanceThe map of macros that exist or were discoveredThe registered list ofJ3Keyrepresenting these macros such thattearDownAndUpdate()can purge all the keys when rebuilding. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a new macro into the list and to the user's macros folder as a new file.private voiddiscover()Discovers macros from the user's macro's foldr and the keys map along with it.gets the current key map of keystrokes to macro entriesGets the macro recorderGets the macro runnerGets the current macros in the enginevoidsetMacroKeys(HashMap<KeyStroke, String> macroKeys) Sets the key map to a new map.private voidRemoves all macros inKeyBindingsglobal instance and removes the JMenu items fromEngineFrame.getMacroJMenu()and rebuilds it from scratch.
-
Field Details
-
macroRecorder
Recorder instance -
macroRunner
Runner instance -
macros
The map of macros that exist or were discovered -
macroKeys
The key map of macros. A macro might be defined inmacrosbut not in in macro keys. That implies the macro was freshly added and currently does not have a key association. -
registeredKeys
The registered list ofJ3Keyrepresenting these macros such thattearDownAndUpdate()can purge all the keys when rebuilding. -
commandsToIgnore
List of classes theMacroRecorderwill ignore when listening forEventType.COMMAND_FIRED
-
-
Constructor Details
-
MacroUtils
public MacroUtils()Default Constructor.This has the added job of instantiating
MacroRecorderandMacroRunnerand attaching them as listeners to the instances they wish to listen to
-
-
Method Details
-
discover
private void discover()Discovers macros from the user's macro's foldr and the keys map along with it. -
addMacro
Adds a new macro into the list and to the user's macros folder as a new file.- Parameters:
macro- The macro to add- Throws:
IOException- ifMacrosFoldercould not add the new macro.
-
getMacros
Gets the current macros in the engine- Returns:
- A shallow-copy of
macros
-
getMacroKeys
gets the current key map of keystrokes to macro entries- Returns:
- A shallow-copy of
macroKeys
-
getMacroRecorder
Gets the macro recorder- Returns:
- Returns the
MacroRecorderinstance
-
getMacroRunner
Gets the macro runner- Returns:
- Returns the
MacroRunnerinstance
-
setMacroKeys
Sets the key map to a new map.- Parameters:
macroKeys- The new keys to write in memory and on disk.
-
tearDownAndUpdate
private void tearDownAndUpdate()Removes all macros inKeyBindingsglobal instance and removes the JMenu items fromEngineFrame.getMacroJMenu()and rebuilds it from scratch.- See Also:
-