pslib
Class VariantEmission

java.lang.Object
  extended by pslib.VariantEmission
All Implemented Interfaces:
PSBehaviour, PSConstants, PSEmission

public class VariantEmission
extends java.lang.Object
implements PSEmission, PSConstants

VariantEmission Class

The VariantEmission class implements the PSEmission interface allowing the automated emission of random particles with variant properties from the emitter to which it is assigned.

Unlike the TemplateEmission class, particle properties are derived entirely from the specified template and percentage variance.

This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/.

See Also:
TemplateEmission

Field Summary
 
Fields inherited from interface pslib.PSConstants
CAM2D_LOOK, CAM2D_RIGHT, CAM2D_UP, CORNER, INVERSE, INVERSE_TRIANGULAR, LEADING, LINEAR, MIDPOINT, NONE, STATIC, TRAILING, TRIANGULAR
 
Constructor Summary
VariantEmission(DynamicParticle t, int v, int ep, int mi, int ma)
          Create a new object instance with the specified variables
VariantEmission(WeightedList<DynamicParticle> t, int v, int ep, int mi, int ma)
          Create a new object instance with the specified variables
 
Method Summary
 void addListener(ParticleListener p)
          Attach a particle listener
 void clearListeners()
          Clear all attached particle listeners
 boolean removeListener(ParticleListener p)
          Remove a particle listener
 void setActive(boolean a)
          Set the active state of the behaviour
 void setEmissionProbability(int ep)
          Set the emission probability
 void setMaximumParticles(int p)
          Set the maximum emitted particles
 void setMinimumParticles(int p)
          Set the minimum emitted particles
 void setTemplate(DynamicParticle t)
          Set the particle template
 void setTemplate(WeightedList<DynamicParticle> t)
          Set the particle template list
 void setVariance(int v)
          Set the particle parameter variance
 void update(DynamicParticle p)
          Update the specified DynamicPartice (unused)
 void update(GenericEmitter e)
          Update the specified GenericEmitter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VariantEmission

public VariantEmission(DynamicParticle t,
                       int v,
                       int ep,
                       int mi,
                       int ma)
Create a new object instance with the specified variables

Parameters:
t - particle template
v - percentage variance
ep - emission probability
mi - minimum particles
ma - maximum particles

VariantEmission

public VariantEmission(WeightedList<DynamicParticle> t,
                       int v,
                       int ep,
                       int mi,
                       int ma)
Create a new object instance with the specified variables

Parameters:
t - particle template array
v - percentage variance
ep - emission probability
mi - minimum particles
ma - maximum particles
Method Detail

setTemplate

public final void setTemplate(DynamicParticle t)
Set the particle template

Parameters:
t - particle template

setTemplate

public final void setTemplate(WeightedList<DynamicParticle> t)
Set the particle template list

Parameters:
t - particle template list

setVariance

public final void setVariance(int v)
Set the particle parameter variance

Particle variations inherit the parameters of the template, with the specified +/- variance being applied to particle decay, alpha and size. Particle mass preserves the ratio between size and mass variables within the template particle.

Parameters:
v - percentage variance

setEmissionProbability

public final void setEmissionProbability(int ep)
Set the emission probability

Emission probability defines the likelihood of particle emission and takes the form 1:probability.

Parameters:
ep - emission probability

setMinimumParticles

public final void setMinimumParticles(int p)
Set the minimum emitted particles

Parameters:
p - minimum particles

setMaximumParticles

public final void setMaximumParticles(int p)
Set the maximum emitted particles

Parameters:
p - maximum particles

setActive

public final void setActive(boolean a)
Set the active state of the behaviour

A value of true will result in particle emission on the update routine of any emitters to which this behaviour is attached.

Specified by:
setActive in interface PSEmission
Parameters:
a -

update

public void update(GenericEmitter e)
Update the specified GenericEmitter

The update routine attaches random particles derived from the particle template to the specified emitter. References to created particles are sent to any attached listeners.

Default: true

Specified by:
update in interface PSEmission
Parameters:
e - GenericEmitter

update

public void update(DynamicParticle p)
Update the specified DynamicPartice (unused)

Specified by:
update in interface PSBehaviour
Parameters:
p - DynamicParticle

addListener

public final void addListener(ParticleListener p)
Attach a particle listener

Attached listeners will receive a reference to created particles upon emission. If this object is assigned as behaviour to multiple emitters, attached listeners will receive particles from each.

Parameters:
p - particle listener

removeListener

public final boolean removeListener(ParticleListener p)
Remove a particle listener

Parameters:
p - particle listener
Returns:
false if the listener does not exist

clearListeners

public final void clearListeners()
Clear all attached particle listeners