Package heronarts.lx
Class LX
java.lang.Object
heronarts.lx.LX
- Direct Known Subclasses:
GLX
Core controller for a LX instance. Each instance drives a 3-d collection of
nodes defined by a dynamic model.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
static class
static class
static interface
Listener for top-level eventsstatic enum
static interface
static interface
-
Field Summary
Modifier and TypeFieldDescriptionfinal LXClipboard
Clipboard for copy/pastefinal LXCommandEngine
Command engine, utilized by higher-level UIs to manage engine state and undo operations.final LXEngine
The animation engine.final MutableParameter
Parameter that is bang()-ed every time errors changeThis parameter will be set if a critical, unrecoverable error occurs.final LX.Flags
Configuration flagsstatic final double
static final float
static final LX.InitProfiler
static final String
static final String
static boolean
protected LXModel
The pixel model.final LX.Permissions
Permissionsstatic final float
final LXPreferences
Global preferences stored in persistent filefinal LXRegistry
Registry for classesfinal LXScheduler
The project schedulerfinal StringParameter
Parameter that can be watched by the UI to push status messagesfinal LXStructure
The lighting system structurestatic final double
static final float
static final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static void
protected static void
protected static void
_log
(PrintStream stream, String message) protected static void
_log
(PrintStream stream, Throwable throwable, String prefix, String message) protected static void
Add an effect to the FX chain.addEffects
(LXEffect[] effects) Add multiple effects to the chainaddListener
(LX.Listener listener) Adds an output driveraddProjectListener
(LX.ProjectListener listener) void
protected static void
bootstrapMediaPath
(LX.Flags flags) protected static File
bootstrapMediaPath
(LX.Flags flags, String dirName) boolean
canInstantiate
(Class<? extends LXComponent> clz) protected final void
confirmChangesSaved
(String message, Runnable confirm) protected final void
Stops patterns from automatically rotatingvoid
dispose()
Shut down resources of the LX instance.enableAutoCycle
(int autoCycleThreshold) Sets the patterns to rotate automaticallystatic void
static void
static void
protected void
getComponent
(int componentId) Gets a component by its raw component idgetError()
static File
getMediaFile
(LX.Media type, String path) Retrieves a file handle to a file that can be saved.getMediaFile
(LX.Media type, String path, boolean create) Retrieves a file handle to a file that can be saved.getMediaFile
(String path) Retrieves a file handle to a file that can be saved.getMediaFolder
(LX.Media type) Retrieves a file handle to the folder used to store the given type of mediagetMediaFolder
(LX.Media type, boolean create) Retrieves a file handle to the folder used to store the given type of mediaGet the root media path for storage of LX-related objects and extensionsgetMediaPath
(LX.Media type, File file) Gets the path to a file relative to a base media path.getModel()
Returns the model in useGets the current set of patterns on the main channel.protected LX.Permissions
getPresetFile
(LXComponent device, String name) getPresetFolder
(LXComponent device) Get the folder to hold presets for a devicegetProjectComponent
(int projectId) Gets a component by its id from the project file (which may have been remapped)goIndex
(int i) Sets the main channel to a pattern of the given indexgoNext()
Sets the main channel to the next pattern.Sets the main channel to a given pattern instance.goPrev()
Sets the main channel to the previous pattern.static void
static int
hsa
(float h, float s, float a) Shorthand for LXColor.hsa()static int
hsb
(float h, float s, float b) Shorthand for LXColor.hsb()instantiateBlend
(Class<? extends LXBlend> cls) instantiateBlend
(String className) <T extends LXComponent>
TinstantiateComponent
(Class<? extends T> cls, Class<T> type) <T extends LXComponent>
TinstantiateComponent
(String className, Class<T> type) instantiateEffect
(Class<? extends LXEffect> cls) instantiateEffect
(String className) instantiateFixture
(Class<? extends LXFixture> cls) instantiateFixture
(String className) instantiateModel
(String className) instantiateModulator
(Class<? extends LXModulator> cls) instantiateModulator
(String className) instantiatePattern
(Class<? extends LXPattern> cls) instantiatePattern
(String className) protected LXRegistry
Subclasses may override to provide an enhanced registry with support for more typesClass<?>
instantiateStatic
(String className) boolean
boolean
isPaused()
Whether the engine is currently running.static void
static void
static void
Runs a headless version of LXvoid
void
openProject
(File file) popError()
pushStatusMessage
(String message) registerExternal
(String key, LXSerializable serializable) removeEffect
(LXEffect effect) Remove an effect from the chainremoveListener
(LX.Listener listener) removeProjectListener
(LX.ProjectListener listener) static int
rgb
(int r, int g, int b) Shorthand for LXColor.rgb()void
void
saveProject
(File file) static void
setLogFile
(File file) void
setModelImportFlag
(boolean modelImport) setPatterns
(LXPattern[] patterns) Specifies the set of patterns to be run.setPaused
(boolean paused) Pause the engine from runningprotected void
setProject
(File file, LX.ProjectListener.Change change) void
setScheduleLoadingFlag
(boolean scheduleLoading) setSpeed
(double speed) Sets the speed of the entire system.void
protected void
showConfirmUnsavedModelDialog
(File file, Runnable confirm) protected void
showConfirmUnsavedProjectDialog
(String message, Runnable confirm) Toggles the running state of the engine.static String
version()
Returns the version of the library.static void
-
Field Details
-
VERSION
- See Also:
-
HALF_PI
public static final double HALF_PI- See Also:
-
TWO_PI
public static final double TWO_PI- See Also:
-
PIf
public static final float PIf- See Also:
-
HALF_PIf
public static final float HALF_PIf- See Also:
-
TWO_PIf
public static final float TWO_PIf- See Also:
-
initProfiler
-
preferences
Global preferences stored in persistent file -
flags
Configuration flags -
permissions
Permissions -
errorChanged
Parameter that is bang()-ed every time errors change -
failure
This parameter will be set if a critical, unrecoverable error occurs. It will only be set one time, and it should be assumed that the engine is no longer running if this is the case. -
statusMessage
Parameter that can be watched by the UI to push status messages -
structure
The lighting system structure -
model
The pixel model. -
clipboard
Clipboard for copy/paste -
engine
The animation engine. -
command
Command engine, utilized by higher-level UIs to manage engine state and undo operations. -
registry
Registry for classes -
scheduler
The project scheduler -
KEY_VERSION
- See Also:
-
KEY_TIMESTAMP
- See Also:
-
LOG_WARNINGS
public static boolean LOG_WARNINGS
-
-
Constructor Details
-
LX
public LX()Creates an LX instance with no nodes. -
LX
Constructs an LX instance with the given pixel model- Parameters:
model
- Pixel model
-
LX
-
LX
-
-
Method Details
-
version
Returns the version of the library.- Returns:
- String
-
logInitProfiler
public static void logInitProfiler() -
getPermissions
-
fail
-
pushError
-
pushError
-
pushError
-
pushError
-
popError
-
getError
-
pushStatusMessage
-
instantiateRegistry
Subclasses may override to provide an enhanced registry with support for more types- Parameters:
lx
- LX instance- Returns:
- LXRegistry to use for dynamic class stuff
-
addListener
-
removeListener
-
addProjectListener
-
removeProjectListener
-
getComponent
Gets a component by its raw component id- Parameters:
componentId
- Component ID- Returns:
- Component with that ID, or null if none exists
-
getProjectComponent
Gets a component by its id from the project file (which may have been remapped)- Parameters:
projectId
- Component ID from loaded project file- Returns:
- Component with that ID in the project file, may have a different component ID now
-
getModel
Returns the model in use- Returns:
- model
-
dispose
public void dispose()Shut down resources of the LX instance. -
hsb
public static int hsb(float h, float s, float b) Shorthand for LXColor.hsb()- Parameters:
h
- Hue 0-360s
- Saturation 0-100b
- Brightness 0-100- Returns:
- Color
-
hsa
public static int hsa(float h, float s, float a) Shorthand for LXColor.hsa()- Parameters:
h
- Hue 0-360s
- Saturation 0-100a
- Alpha 0-1- Returns:
- Color
-
rgb
public static int rgb(int r, int g, int b) Shorthand for LXColor.rgb()- Parameters:
r
- Red 0-255g
- Green 0-255b
- Blue 0-255- Returns:
- color
-
setSpeed
Sets the speed of the entire system. Default is 1.0, any modification will mutate deltaMs values system-wide.- Parameters:
speed
- Coefficient, 1 is normal speed- Returns:
- this
-
addEffects
Add multiple effects to the chain- Parameters:
effects
- Array of effects- Returns:
- this
-
addEffect
Add an effect to the FX chain.- Parameters:
effect
- Effect- Returns:
- this
-
removeEffect
Remove an effect from the chain- Parameters:
effect
- Effect- Returns:
- this
-
setPaused
Pause the engine from running- Parameters:
paused
- Whether to pause the engine to pause- Returns:
- this
-
isPaused
public boolean isPaused()Whether the engine is currently running.- Returns:
- State of the engine
-
togglePaused
Toggles the running state of the engine.- Returns:
- this
-
goPrev
Sets the main channel to the previous pattern.- Returns:
- this
-
goNext
Sets the main channel to the next pattern.- Returns:
- this
-
goPattern
Sets the main channel to a given pattern instance.- Parameters:
pattern
- The pattern instance to run- Returns:
- this
-
goIndex
Sets the main channel to a pattern of the given index- Parameters:
i
- Index of the pattern to run- Returns:
- this
-
disableAutoCycle
Stops patterns from automatically rotating- Returns:
- this
-
enableAutoCycle
Sets the patterns to rotate automatically- Parameters:
autoCycleThreshold
- Number of milliseconds after which to cycle- Returns:
- this
-
addOutput
Adds an output driver- Parameters:
output
- Output- Returns:
- this
-
setPatterns
Specifies the set of patterns to be run.- Parameters:
patterns
- Array of patterns- Returns:
- this
-
getPatterns
Gets the current set of patterns on the main channel.- Returns:
- The list of patters
-
setProject
-
getProject
-
autoSaveProject
public void autoSaveProject() -
saveProject
public void saveProject() -
saveProject
-
registerExternal
-
isLoading
public boolean isLoading() -
newProject
public void newProject() -
openProject
-
setModelImportFlag
public void setModelImportFlag(boolean modelImport) -
setScheduleLoadingFlag
public void setScheduleLoadingFlag(boolean scheduleLoading) -
confirmChangesSaved
-
showConfirmUnsavedProjectDialog
-
confirmModelSaved
protected final void confirmModelSaved() -
showConfirmUnsavedModelDialog
-
getMediaPath
Get the root media path for storage of LX-related objects and extensions- Returns:
- File path to root storage location of LX-related content
-
getMediaPath
Gets the path to a file relative to a base media path. Useful for writing file names into project files.- Parameters:
type
- Media typefile
- File- Returns:
- Relative path to file, from media type base, or absolute if outside of media container
-
getMediaFolder
Retrieves a file handle to the folder used to store the given type of media- Parameters:
type
- Media type- Returns:
- File handle to directory for storage of this type of media
-
getMediaFolder
Retrieves a file handle to the folder used to store the given type of media- Parameters:
type
- Media typecreate
- Create folder if true- Returns:
- File handle to directory for storage of this type of media
-
getMediaFile
Retrieves a file handle to a file that can be saved. Path is given relative to the root LX media directory, unless the given path is absolute.- Parameters:
type
- Media typepath
- File path relative to LX media dir, or absolute- Returns:
- File handle to file that can be saved
-
getMediaFile
Retrieves a file handle to a file that can be saved. Path is given relative to the root LX media directory, unless the given path is absolute.- Parameters:
type
- Media typepath
- File path relative to LX media dir, or absolutecreate
- Create folder if true- Returns:
- File handle to file that can be saved
-
getMediaFile
Retrieves a file handle to a file that can be saved. Path is given relative to the root LX media directory, unless the given path is absolute.- Parameters:
path
- File path relative to LX media dir, or absolute- Returns:
- File handle to file that can be saved
-
getPresetFolder
Get the folder to hold presets for a device- Parameters:
device
- Device- Returns:
- Folder that holds presets for this device
-
getPresetFile
-
canInstantiate
-
instantiateModel
- Throws:
LX.InstantiationException
-
instantiateComponent
public <T extends LXComponent> T instantiateComponent(String className, Class<T> type) throws LX.InstantiationException - Throws:
LX.InstantiationException
-
instantiateComponent
public <T extends LXComponent> T instantiateComponent(Class<? extends T> cls, Class<T> type) throws LX.InstantiationException - Throws:
LX.InstantiationException
-
instantiateFixture
- Throws:
LX.InstantiationException
-
instantiateFixture
public LXFixture instantiateFixture(Class<? extends LXFixture> cls) throws LX.InstantiationException - Throws:
LX.InstantiationException
-
instantiateModulator
- Throws:
LX.InstantiationException
-
instantiateModulator
public LXModulator instantiateModulator(Class<? extends LXModulator> cls) throws LX.InstantiationException - Throws:
LX.InstantiationException
-
instantiatePattern
- Throws:
LX.InstantiationException
-
instantiatePattern
public LXPattern instantiatePattern(Class<? extends LXPattern> cls) throws LX.InstantiationException - Throws:
LX.InstantiationException
-
instantiateEffect
- Throws:
LX.InstantiationException
-
instantiateEffect
- Throws:
LX.InstantiationException
-
instantiateBlend
- Throws:
LX.InstantiationException
-
instantiateBlend
- Throws:
LX.InstantiationException
-
instantiateStatic
- Throws:
ClassNotFoundException
-
setSystemClipboardString
-
bootstrapMediaPath
-
bootstrapMediaPath
-
log
-
warning
-
error
-
error
-
error
-
_log
-
_error
-
_error
-
_log
-
_log
-
getLogFile
-
setLogFile
-
main
Runs a headless version of LX- Parameters:
args
- Command line arguments
-
headless
-