Package heronarts.lx

Class LX

java.lang.Object
heronarts.lx.LX
Direct Known Subclasses:
GLX

public class LX extends Object
Core controller for a LX instance. Each instance drives a 3-d collection of nodes defined by a dynamic model.
  • Field Details

    • VERSION

      public static final String 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

      public static final LX.InitProfiler initProfiler
    • preferences

      public final LXPreferences preferences
      Global preferences stored in persistent file
    • flags

      public final LX.Flags flags
      Configuration flags
    • permissions

      public final LX.Permissions permissions
      Permissions
    • errorChanged

      public final MutableParameter errorChanged
      Parameter that is bang()-ed every time errors change
    • failure

      public StringParameter 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

      public final StringParameter statusMessage
      Parameter that can be watched by the UI to push status messages
    • structure

      public final LXStructure structure
      The lighting system structure
    • model

      protected LXModel model
      The pixel model.
    • clipboard

      public final LXClipboard clipboard
      Clipboard for copy/paste
    • engine

      public final LXEngine engine
      The animation engine.
    • command

      public final LXCommandEngine command
      Command engine, utilized by higher-level UIs to manage engine state and undo operations.
    • registry

      public final LXRegistry registry
      Registry for classes
    • scheduler

      public final LXScheduler scheduler
      The project scheduler
    • KEY_VERSION

      public static final String KEY_VERSION
      See Also:
    • KEY_TIMESTAMP

      public static final String KEY_TIMESTAMP
      See Also:
    • LOG_WARNINGS

      public static boolean LOG_WARNINGS
  • Constructor Details

    • LX

      public LX()
      Creates an LX instance with no nodes.
    • LX

      public LX(LXModel model)
      Constructs an LX instance with the given pixel model
      Parameters:
      model - Pixel model
    • LX

      public LX(LX.Flags flags)
    • LX

      public LX(LX.Flags flags, LXModel model)
  • Method Details

    • version

      public static String version()
      Returns the version of the library.
      Returns:
      String
    • logInitProfiler

      public static void logInitProfiler()
    • getPermissions

      protected LX.Permissions getPermissions()
    • fail

      protected void fail(Throwable x)
    • pushError

      public LX pushError(Throwable exception)
    • pushError

      public LX pushError(Throwable exception, String message)
    • pushError

      public LX pushError(String message)
    • pushError

      public LX pushError(LX.Error error)
    • popError

      public LX popError()
    • getError

      public LX.Error getError()
    • pushStatusMessage

      public LX pushStatusMessage(String message)
    • instantiateRegistry

      protected LXRegistry instantiateRegistry(LX lx)
      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

      public LX addListener(LX.Listener listener)
    • removeListener

      public LX removeListener(LX.Listener listener)
    • addProjectListener

      public LX addProjectListener(LX.ProjectListener listener)
    • removeProjectListener

      public LX removeProjectListener(LX.ProjectListener listener)
    • getComponent

      public LXComponent getComponent(int componentId)
      Gets a component by its raw component id
      Parameters:
      componentId - Component ID
      Returns:
      Component with that ID, or null if none exists
    • getProjectComponent

      public LXComponent getProjectComponent(int projectId)
      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

      public LXModel 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-360
      s - Saturation 0-100
      b - Brightness 0-100
      Returns:
      Color
    • hsa

      public static int hsa(float h, float s, float a)
      Shorthand for LXColor.hsa()
      Parameters:
      h - Hue 0-360
      s - Saturation 0-100
      a - Alpha 0-1
      Returns:
      Color
    • rgb

      public static int rgb(int r, int g, int b)
      Shorthand for LXColor.rgb()
      Parameters:
      r - Red 0-255
      g - Green 0-255
      b - Blue 0-255
      Returns:
      color
    • setSpeed

      public LX setSpeed(double speed)
      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

      public LX addEffects(LXEffect[] effects)
      Add multiple effects to the chain
      Parameters:
      effects - Array of effects
      Returns:
      this
    • addEffect

      public LX addEffect(LXEffect effect)
      Add an effect to the FX chain.
      Parameters:
      effect - Effect
      Returns:
      this
    • removeEffect

      public LX removeEffect(LXEffect effect)
      Remove an effect from the chain
      Parameters:
      effect - Effect
      Returns:
      this
    • setPaused

      public LX setPaused(boolean paused)
      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

      public LX togglePaused()
      Toggles the running state of the engine.
      Returns:
      this
    • goPrev

      public LX goPrev()
      Sets the main channel to the previous pattern.
      Returns:
      this
    • goNext

      public LX goNext()
      Sets the main channel to the next pattern.
      Returns:
      this
    • goPattern

      public LX goPattern(LXPattern pattern)
      Sets the main channel to a given pattern instance.
      Parameters:
      pattern - The pattern instance to run
      Returns:
      this
    • goIndex

      public LX goIndex(int i)
      Sets the main channel to a pattern of the given index
      Parameters:
      i - Index of the pattern to run
      Returns:
      this
    • disableAutoCycle

      public LX disableAutoCycle()
      Stops patterns from automatically rotating
      Returns:
      this
    • enableAutoCycle

      public LX enableAutoCycle(int autoCycleThreshold)
      Sets the patterns to rotate automatically
      Parameters:
      autoCycleThreshold - Number of milliseconds after which to cycle
      Returns:
      this
    • addOutput

      public LX addOutput(LXOutput output)
      Adds an output driver
      Parameters:
      output - Output
      Returns:
      this
    • setPatterns

      public LX setPatterns(LXPattern[] patterns)
      Specifies the set of patterns to be run.
      Parameters:
      patterns - Array of patterns
      Returns:
      this
    • getPatterns

      public List<LXPattern> getPatterns()
      Gets the current set of patterns on the main channel.
      Returns:
      The list of patters
    • setProject

      protected void setProject(File file, LX.ProjectListener.Change change)
    • getProject

      public File getProject()
    • autoSaveProject

      public void autoSaveProject()
    • saveProject

      public void saveProject()
    • saveProject

      public void saveProject(File file)
    • registerExternal

      public LX registerExternal(String key, LXSerializable serializable)
    • isLoading

      public boolean isLoading()
    • newProject

      public void newProject()
    • openProject

      public void openProject(File file)
    • setModelImportFlag

      public void setModelImportFlag(boolean modelImport)
    • setScheduleLoadingFlag

      public void setScheduleLoadingFlag(boolean scheduleLoading)
    • confirmChangesSaved

      protected final void confirmChangesSaved(String message, Runnable confirm)
    • showConfirmUnsavedProjectDialog

      protected void showConfirmUnsavedProjectDialog(String message, Runnable confirm)
    • confirmModelSaved

      protected final void confirmModelSaved()
    • showConfirmUnsavedModelDialog

      protected void showConfirmUnsavedModelDialog(File file, Runnable confirm)
    • getMediaPath

      public String 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

      public String getMediaPath(LX.Media type, File file)
      Gets the path to a file relative to a base media path. Useful for writing file names into project files.
      Parameters:
      type - Media type
      file - File
      Returns:
      Relative path to file, from media type base, or absolute if outside of media container
    • getMediaFolder

      public File getMediaFolder(LX.Media type)
      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

      public File getMediaFolder(LX.Media type, boolean create)
      Retrieves a file handle to the folder used to store the given type of media
      Parameters:
      type - Media type
      create - Create folder if true
      Returns:
      File handle to directory for storage of this type of media
    • getMediaFile

      public File getMediaFile(LX.Media type, String path)
      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 type
      path - File path relative to LX media dir, or absolute
      Returns:
      File handle to file that can be saved
    • getMediaFile

      public File getMediaFile(LX.Media type, String path, boolean create)
      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 type
      path - File path relative to LX media dir, or absolute
      create - Create folder if true
      Returns:
      File handle to file that can be saved
    • getMediaFile

      public File getMediaFile(String path)
      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

      public File getPresetFolder(LXComponent device)
      Get the folder to hold presets for a device
      Parameters:
      device - Device
      Returns:
      Folder that holds presets for this device
    • getPresetFile

      public File getPresetFile(LXComponent device, String name)
    • canInstantiate

      public boolean canInstantiate(Class<? extends LXComponent> clz)
    • instantiateModel

      public LXModel instantiateModel(String className) throws LX.InstantiationException
      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

      public LXFixture instantiateFixture(String className) throws LX.InstantiationException
      Throws:
      LX.InstantiationException
    • instantiateFixture

      public LXFixture instantiateFixture(Class<? extends LXFixture> cls) throws LX.InstantiationException
      Throws:
      LX.InstantiationException
    • instantiateModulator

      public LXModulator instantiateModulator(String className) throws LX.InstantiationException
      Throws:
      LX.InstantiationException
    • instantiateModulator

      public LXModulator instantiateModulator(Class<? extends LXModulator> cls) throws LX.InstantiationException
      Throws:
      LX.InstantiationException
    • instantiatePattern

      public LXPattern instantiatePattern(String className) throws LX.InstantiationException
      Throws:
      LX.InstantiationException
    • instantiatePattern

      public LXPattern instantiatePattern(Class<? extends LXPattern> cls) throws LX.InstantiationException
      Throws:
      LX.InstantiationException
    • instantiateEffect

      public LXEffect instantiateEffect(String className) throws LX.InstantiationException
      Throws:
      LX.InstantiationException
    • instantiateEffect

      public LXEffect instantiateEffect(Class<? extends LXEffect> cls) throws LX.InstantiationException
      Throws:
      LX.InstantiationException
    • instantiateBlend

      public LXBlend instantiateBlend(String className) throws LX.InstantiationException
      Throws:
      LX.InstantiationException
    • instantiateBlend

      public LXBlend instantiateBlend(Class<? extends LXBlend> cls) throws LX.InstantiationException
      Throws:
      LX.InstantiationException
    • instantiateStatic

      public Class<?> instantiateStatic(String className) throws ClassNotFoundException
      Throws:
      ClassNotFoundException
    • setSystemClipboardString

      public void setSystemClipboardString(String str)
    • bootstrapMediaPath

      protected static void bootstrapMediaPath(LX.Flags flags)
    • bootstrapMediaPath

      protected static File bootstrapMediaPath(LX.Flags flags, String dirName)
    • log

      public static void log(String message)
    • warning

      public static void warning(String message)
    • error

      public static void error(String message)
    • error

      public static void error(Throwable x)
    • error

      public static void error(Throwable x, String message)
    • _log

      protected static void _log(String prefix, String message)
    • _error

      protected static void _error(String prefix, Exception x, String message)
    • _error

      protected static void _error(String prefix, String message)
    • _log

      protected static void _log(PrintStream stream, String message)
    • _log

      protected static void _log(PrintStream stream, Throwable throwable, String prefix, String message)
    • getLogFile

      public static File getLogFile()
    • setLogFile

      public static void setLogFile(File file)
    • main

      public static void main(String[] args)
      Runs a headless version of LX
      Parameters:
      args - Command line arguments
    • headless

      public static void headless(LX.Flags flags, File projectFile)