Package heronarts.lx.pattern
Class LXPattern
- All Implemented Interfaces:
LXComponent.Renamable
,LXLoopTask
,LXPath
,LXPresetComponent
,LXSerializable
,LXMidiListener
,LXModulationContainer
,LXOscComponent
,LXParameterListener
- Direct Known Subclasses:
AlternatingPattern
,ChasePattern
,ChevronPattern
,DmxPattern
,GeometryTestPattern
,GradientPattern
,GraphicEqualizerPattern
,ImagePattern
,LifePattern
,LXModelPattern
,LXPattern.Placeholder
,NoisePattern
,OrboxPattern
,PlanesPattern
,ScriptPattern
,SlideshowPattern
,SolidPattern
,SoundObjectPattern
,SparklePattern
,TestPattern
public abstract class LXPattern
extends LXDeviceComponent
implements LXComponent.Renamable, LXOscComponent
A pattern is the core object that the animation engine uses to generate
colors for all the points.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Listener interface for objects which want to be notified when the pattern's set of effects are modifiedstatic class
Placeholder pattern for when a class is missingclass
Nested classes/interfaces inherited from class heronarts.lx.LXDeviceComponent
LXDeviceComponent.Midi
Nested classes/interfaces inherited from class heronarts.lx.LXComponent
LXComponent.Hidden, LXComponent.Renamable
Nested classes/interfaces inherited from interface heronarts.lx.LXSerializable
LXSerializable.Utils
-
Field Summary
Modifier and TypeFieldDescriptionfinal CompoundParameter
final ObjectParameter<LXBlend>
final BoundedParameter
Custom time for this pattern to cyclefinal BooleanParameter
final BooleanParameter
static final String
final LXPattern.Profiler
final TriggerParameter
protected double
Fields inherited from class heronarts.lx.LXDeviceComponent
controlsExpanded, controlsExpandedAux, controlsExpandedCue, controlSurfaceSemaphore, crashed, DEVICE_CATEGORY_NAME_SORT, DEVICE_VERSION_UNSPECIFIED, KEY_DEVICE_VERSION, midiFilter, modulation, modulationExpanded, remoteControlsChanged, view, viewPriority
Fields inherited from class heronarts.lx.LXLayeredComponent
colors, layers, palette
Fields inherited from class heronarts.lx.LXModelComponent
model
Fields inherited from class heronarts.lx.LXModulatorComponent
modulators
Fields inherited from class heronarts.lx.LXComponent
children, internalParameters, KEY_CHILDREN, KEY_CLASS, KEY_COMPONENT_ID, KEY_ID, KEY_INTERNAL, KEY_PARAMETER_PATH, KEY_PARAMETERS, KEY_PATH, KEY_RESET, label, legacyInternalParameters, legacyParameters, lx, modulationColor, modulationControlsExpanded, modulationsExpanded, parameters, presetFile
Fields inherited from interface heronarts.lx.LXPath
ROOT, ROOT_PREFIX, ROOT_SLASH
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
Method invoked by the mixer engine to notify a pattern that it is going to become activated.final LXPattern
final LXPattern
final void
addListener
(LXPattern.Listener listener) Clears a timer interval set to this pattern.final void
Method invoked by the mixer engine to notify a pattern that it is not going to be run.void
dispose()
Invoked when a component is being removed from the system and will no longer be used at all.final LXChannel
Gets the channel that this pattern is loaded in.double
getEffect
(int i) int
getIndex()
getPath()
Accessor for the path of this object.boolean
handleOscMessage
(OscMessage message, String[] parts, int index) Handles an OSC message sent to this component.final boolean
Tests whether there is an interval for this pattern.void
initCompositeDamping
(boolean wasActivePattern) final boolean
Determines whether this pattern is eligible to be run at the moment.boolean
isHiddenControl
(LXParameter parameter) Returns whether this parameter is visible in default remote control or device control UIsfinal boolean
Tests whether this pattern is in an eligible interval.boolean
isSnapshotControl
(LXParameter parameter) Returns whether this parameter is stored along with snapshotsvoid
load
(LX lx, JsonObject obj) Loads the LX component.void
midiDispatch
(LXShortMessage message) Dispatch a MIDI message to this device, and any of its modulators which should receive thatmoveEffect
(LXEffect effect, int index) protected void
onActive()
Subclasses may override this method.protected void
Subclasses may override this method.protected final void
onLoop
(double deltaMs) void
Subclasses may override this method.void
Subclasses may override this method.reloadEffect
(LXEffect effect) final LXPattern
removeEffect
(LXEffect effect) final void
removeListener
(LXPattern.Listener listener) protected abstract void
run
(double deltaMs) Main pattern loop function.void
save
(LX lx, JsonObject obj) Serializes the LX component.final LXPattern
setAutoCycleEligible
(boolean eligible) Sets whether this pattern is eligible for automatic selection.final LXPattern
setChannel
(LXChannel channel) Called by the engine when pattern is loaded onto a channel.void
setIndex
(int index) setInterval
(int begin, int end) Set an interval during which this pattern is allowed to run.final LXPattern
Toggles the eligibility state of this pattern.void
void
updateCompositeDamping
(double deltaMs, boolean dampingOn, double dampingTimeSecs) Methods inherited from class heronarts.lx.LXDeviceComponent
addControlSurface, clearCustomRemoteControls, getControlSurfaces, getCrash, getCrashStackTrace, getCustomRemoteControls, getDeviceVersion, getModelView, getModulationEngine, getRemoteControls, loop, removeControlSurface, removeCustomRemoteControl, resetRemoteControls, setCustomRemoteControls, setRemoteControls
Methods inherited from class heronarts.lx.LXLayeredComponent
addColor, addColor, addLayer, afterLayers, blendColor, blendColor, clearColors, getBuffer, getColor, getColor, getColors, getLayers, removeLayer, setBuffer, setBuffer, setColor, setColor, setColor, setColors, subtractColor
Methods inherited from class heronarts.lx.LXModelComponent
getModel, onModelChanged, setModel
Methods inherited from class heronarts.lx.LXModulatorComponent
addModulator, addModulator, addModulator, addModulator, addModulator, constructProfiler, getModulator, getModulators, moveModulator, removeModulator, startModulator
Methods inherited from class heronarts.lx.LXComponent
addArray, addChild, addInternalParameter, addLegacyInternalParameter, addLegacyParameter, addParameter, addParameter, addParameters, contains, copyParameters, getCategory, getChild, getComponentName, getComponentName, getComponentName, getDescription, getId, getLabel, getLX, getOscAddress, getOscLabel, getOscPath, getParameter, getParameters, getParent, hasParameter, isValidOscParameter, loadParameters, loadPreset, onParameterChanged, removeParameter, removeParameter, removeParameter, removeParameter, savePreset, setDescription, setParent, toOscQuery, toOscQuery, toOscQuery, toString, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface heronarts.lx.midi.LXMidiListener
aftertouchReceived, controlChangeReceived, noteOffReceived, noteOnReceived, pitchBendReceived, programChangeReceived
Methods inherited from interface heronarts.lx.osc.LXOscComponent
getOscAddress
Methods inherited from interface heronarts.lx.LXPath
getCanonicalLabel, getCanonicalLabel, getCanonicalPath, getCanonicalPath, isDescendant
Methods inherited from interface heronarts.lx.LXPresetComponent
getPresetClass, postProcessPreset
-
Field Details
-
enabled
-
recall
-
compositeMode
-
compositeLevel
-
hasCustomCycleTime
-
customCycleTimeSecs
Custom time for this pattern to cycle -
runMs
protected double runMs -
profiler
-
mutableEffects
-
effects
-
PATH_EFFECT
- See Also:
-
-
Constructor Details
-
LXPattern
-
-
Method Details
-
addListener
-
removeListener
-
isSnapshotControl
Description copied from class:LXDeviceComponent
Returns whether this parameter is stored along with snapshots- Overrides:
isSnapshotControl
in classLXDeviceComponent
- Parameters:
parameter
- Parameter- Returns:
- true if this can be included in snapshots
-
isHiddenControl
Description copied from class:LXDeviceComponent
Returns whether this parameter is visible in default remote control or device control UIs- Overrides:
isHiddenControl
in classLXDeviceComponent
- Parameters:
parameter
- Parameter to check- Returns:
- true if this should be hidden by default
-
getPath
Description copied from class:LXComponent
Accessor for the path of this object. Returns the path this component was registered with. Some subclasses may override this if path structure is dynamic.- Specified by:
getPath
in interfaceLXPath
- Overrides:
getPath
in classLXComponent
- Returns:
- path of this component relative to its parent
-
updateCompositeBlendOptions
public void updateCompositeBlendOptions() -
setIndex
public void setIndex(int index) -
getIndex
public int getIndex() -
getChannel
Gets the channel that this pattern is loaded in. May be null if the pattern is not yet loaded onto any channel.- Returns:
- Channel pattern is loaded onto
-
setChannel
Called by the engine when pattern is loaded onto a channel. This may only be called once, by the engine. Do not call directly.- Parameters:
channel
- Channel pattern is loaded onto- Returns:
- this
-
setInterval
Set an interval during which this pattern is allowed to run. Begin and end times are specified in minutes of the daytime. So midnight corresponds to the value of 0, 360 would be 6:00am, 1080 would be 18:00 (or 6:00pm)- Parameters:
begin
- Interval start timeend
- Interval end time- Returns:
- this
-
clearInterval
Clears a timer interval set to this pattern.- Returns:
- this
-
hasInterval
public final boolean hasInterval()Tests whether there is an interval for this pattern.- Returns:
- true if there is an interval
-
isInInterval
public final boolean isInInterval()Tests whether this pattern is in an eligible interval.- Returns:
- true if the pattern has an interval, and is currently in it.
-
setAutoCycleEligible
Sets whether this pattern is eligible for automatic selection.- Parameters:
eligible
- Whether eligible for auto-rotation- Returns:
- this
-
toggleAutoCycleEligible
Toggles the eligibility state of this pattern.- Returns:
- this
-
isAutoCycleEligible
public final boolean isAutoCycleEligible()Determines whether this pattern is eligible to be run at the moment. A pattern is eligible if its eligibility flag has not been set to false, and if it either has no interval, or is currently in its interval.- Returns:
- True if pattern is eligible to run now
-
initCompositeDamping
public void initCompositeDamping(boolean wasActivePattern) -
updateCompositeDamping
public void updateCompositeDamping(double deltaMs, boolean dampingOn, double dampingTimeSecs) -
getCompositeDampingLevel
public double getCompositeDampingLevel() -
addEffect
-
addEffect
-
removeEffect
-
reloadEffect
-
moveEffect
-
getEffects
-
getEffect
-
getEffect
-
handleOscMessage
Description copied from class:LXComponent
Handles an OSC message sent to this component. By default this method handles registered components and parameters, but subclasses may override this method to handle different types of OSC messages.- Specified by:
handleOscMessage
in interfaceLXOscComponent
- Overrides:
handleOscMessage
in classLXComponent
- Parameters:
message
- Full OSC message objectparts
- The OSC address pattern, broken into an array of partsindex
- Which index into the parts array corresponds to this component's children- Returns:
true
if the OSC message was handled and should be considered consumed,false
otherwise
-
onLoop
protected final void onLoop(double deltaMs) - Overrides:
onLoop
in classLXLayeredComponent
-
run
protected abstract void run(double deltaMs) Main pattern loop function. Invoked in a render loop. Subclasses must implement this function.- Parameters:
deltaMs
- Number of milliseconds elapsed since last invocation
-
activate
Method invoked by the mixer engine to notify a pattern that it is going to become activated. Not a user-facing API. -
deactivate
Method invoked by the mixer engine to notify a pattern that it is not going to be run. Not a user-facing API. -
onActive
protected void onActive()Subclasses may override this method. It will be invoked when the pattern is about to become active. Patterns may take care of any initialization needed or reset parameters if desired. -
onInactive
protected void onInactive()Subclasses may override this method. It will be invoked when the pattern is no longer active. Resources may be freed if desired. -
onTransitionStart
public void onTransitionStart()Subclasses may override this method. It will be invoked if a transition into this pattern is taking place. This will be called after onActive. This is not invoked on an already-running pattern. It is only called on the new pattern. -
onTransitionEnd
public void onTransitionEnd()Subclasses may override this method. It will be invoked when the transition into this pattern is complete. -
midiDispatch
Description copied from class:LXDeviceComponent
Dispatch a MIDI message to this device, and any of its modulators which should receive that- Overrides:
midiDispatch
in classLXDeviceComponent
- Parameters:
message
- Message
-
save
Description copied from class:LXComponent
Serializes the LX component. By default, all internal and user-facing parameters are serialized, as well as any explicitly registered child components. Note that child arrays are not serialized, or any other dynamic components. Subclasses may override to perform more saving, and are expected to callsuper.save(lx, obj)
at the appropriate time.- Specified by:
save
in interfaceLXSerializable
- Overrides:
save
in classLXDeviceComponent
- Parameters:
lx
- LX instanceobj
- Object to serialize into
-
load
Description copied from class:LXComponent
Loads the LX component. Restores the ID of the component, as well as its internal and user-facing parameters. Any explicitly registered children will be automatically loaded, so long as they are direct descendants. Dynamic arrays will not be automatically loaded, this is left to subclasses to implement.- Specified by:
load
in interfaceLXSerializable
- Overrides:
load
in classLXDeviceComponent
- Parameters:
lx
- LX instanceobj
- Object to deserialize
-
dispose
public void dispose()Description copied from class:LXComponent
Invoked when a component is being removed from the system and will no longer be used at all. This unregisters the component and should free up any resources and parameter listeners. Ideally after this method is called the object should be eligible for garbage collection. Subclasses are generally expected to override this method to handle their particular cleanup work. They should also generally callsuper.dispose()
at the appropriate time to perform the basic cleanup, which may need to happen either before or after cleaning up other objects.- Overrides:
dispose
in classLXDeviceComponent
-