pslib
Class BufferedParticle

java.lang.Object
  extended by pslib.GenericParticle
      extended by pslib.DynamicParticle
          extended by pslib.BufferedParticle
All Implemented Interfaces:
PSConstants
Direct Known Subclasses:
RibbonParticle

public class BufferedParticle
extends DynamicParticle

BufferedParticle Class

The BufferedParticle object extends the functionality of the DynamicParticle class by incorporating position, colour, decay and size buffers.

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/.


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
BufferedParticle(int b)
          Create a new object instance with the specified buffer size
BufferedParticle(int b, int d)
          Create a new object instance with the specified buffer size and decay
 
Method Summary
 BufferedParticle copy()
          Return a copy of this particle
protected  StaticParticle[] getBuffer()
          Return an array containing all buffered particles
 int getBufferSize()
          Return the current buffer size
protected  float getCumulativeLength()
          Return the cumulative length of the buffer trail
protected  PSVector[] getCumulativePositions()
          Return an array containing the positions of each buffered element relative to the preceding element
protected  PSVector[] getRelativePositions()
          Return an array containing the positions of each buffered element relative to the current particle position
protected  float[] getTaperValues()
          Return an array of buffer taper values
 void initialiseBuffer(StaticParticle p)
          Initialise the buffer with the specified StaticParticle object
 boolean isInitialised()
          Return true if the buffer is initialised
 void map(BufferedParticle p)
          Map the properties of this particle to that specified preserving references
 void resizeBuffer(int s)
          Resize the buffer
 void setPosition(PSVector p)
          Set the current particle position and update the buffer
 void setSpacing(float s)
          Set the minimum buffered element spacing
 
Methods inherited from class pslib.DynamicParticle
clearBehaviour, debug, debug, getBehaviour, getDecay, getDecayTime, getInitialDecayTime, getMass, getRenderAlpha, getRenderSize, getSnapshot, isDead, isDynamic, map, render, render, setAlphaEnvelope, setBehaviour, setBehaviour, setDecayTime, setMass, setSizeEnvelope, update
 
Methods inherited from class pslib.GenericParticle
getAlpha, getColour, getPosition, getSize, getVelocity, setAlpha, setColour, setColour, setSize, setVelocity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BufferedParticle

public BufferedParticle(int b)
Create a new object instance with the specified buffer size

Parameters:
b - buffer size

BufferedParticle

public BufferedParticle(int b,
                        int d)
Create a new object instance with the specified buffer size and decay

Parameters:
b - buffer size
d - decay (ms)
Method Detail

setPosition

public void setPosition(PSVector p)
Set the current particle position and update the buffer

Overrides:
setPosition in class GenericParticle
Parameters:
p - position

setSpacing

public void setSpacing(float s)
Set the minimum buffered element spacing

Default: 0

Parameters:
s - spacing

isInitialised

public final boolean isInitialised()
Return true if the buffer is initialised

Returns:
true if the buffer is initialised

initialiseBuffer

public final void initialiseBuffer(StaticParticle p)
Initialise the buffer with the specified StaticParticle object

Parameters:
p - StaticParticle

getBuffer

protected final StaticParticle[] getBuffer()
Return an array containing all buffered particles

Returns:
a StaticParticle array containing all buffered particles

getBufferSize

public final int getBufferSize()
Return the current buffer size

Returns:
the current buffer size

getRelativePositions

protected final PSVector[] getRelativePositions()
Return an array containing the positions of each buffered element relative to the current particle position

Returns:
an array containing the positions of each buffered element relative to the current particle position

getCumulativePositions

protected final PSVector[] getCumulativePositions()
Return an array containing the positions of each buffered element relative to the preceding element

Returns:
an array containing the positions of each buffered element relative to the preceding element

getCumulativeLength

protected final float getCumulativeLength()
Return the cumulative length of the buffer trail

The cumulative length is calculated by summing the distance between each buffer element and that preceding it.

Returns:
the cumulative length of the buffer trail

getTaperValues

protected final float[] getTaperValues()
Return an array of buffer taper values

The returned array contains a taper value for each element within the buffer. Taper values are based on the cumulative length of the buffer trail and the relative position of each element within the trail. Values range between 1 for the first buffer element and 0 for the last.

Returns:
an array of buffer taper values

resizeBuffer

public final void resizeBuffer(int s)
Resize the buffer

Parameters:
s - buffer size

copy

public BufferedParticle copy()
Return a copy of this particle

The returned contain an empty buffer the same size as that of the source particle and will adhere to the rules defined in DynamicParticle.map() .

Overrides:
copy in class DynamicParticle
Returns:
a copy of this particle
See Also:
DynamicParticle

map

public final void map(BufferedParticle p)
Map the properties of this particle to that specified preserving references

The returned object takes a copy of all BufferedParticle variables. DynamicParticle variables are mapped based on the rules defined in DynamicParticle.map().

Parameters:
p - particle
See Also:
DynamicParticle