pslib
Class TextParticle

java.lang.Object
  extended by pslib.GenericParticle
      extended by pslib.DynamicParticle
          extended by pslib.TextParticle
All Implemented Interfaces:
PSConstants

public class TextParticle
extends DynamicParticle

TextParticle Class

The TextParticle class extends the functionality of the DynamicParticle class by allowing text to be rendered at the particle location.

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
TextParticle(java.lang.String f, int s)
          Create a new object instance with the specified variables
TextParticle(java.lang.String f, int s, boolean aa, boolean mm, int d)
          Create a new object instance with the specified variables
TextParticle(java.lang.String f, int s, int d)
          Create a new object instance with the specified variables
 
Method Summary
 DynamicParticle copy()
          Return a copy of this particle
 PSVector getTextBounds()
          Return a vector containing the size of the text bounding box
 com.sun.opengl.util.j2d.TextRenderer getTextRenderer()
          Return a reference to the TextRenderer object employed by this particle
 void render(processing.opengl.PGraphicsOpenGL pgl)
          Render the text to the specified OpenGL renderer
 void render(processing.opengl.PGraphicsOpenGL pgl, PSVector cpv, PSVector ctv, PSVector cuv)
          Render the text to the specified OpenGL renderer
 void setAnchorPoint(int a)
          Set the text anchor point (CORNER/MIDPOINT)
 void setOffset(PSVector v)
          Set the text offset vector
 void setSmoothing(boolean s)
          Enable/disable smoothing
 void setText(java.lang.String t)
          Set the text string
 
Methods inherited from class pslib.DynamicParticle
clearBehaviour, debug, debug, getBehaviour, getDecay, getDecayTime, getInitialDecayTime, getMass, getRenderAlpha, getRenderSize, getSnapshot, isDead, isDynamic, map, setAlphaEnvelope, setBehaviour, setBehaviour, setDecayTime, setMass, setSizeEnvelope, update
 
Methods inherited from class pslib.GenericParticle
getAlpha, getColour, getPosition, getSize, getVelocity, setAlpha, setColour, setColour, setPosition, setSize, setVelocity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextParticle

public TextParticle(java.lang.String f,
                    int s)
Create a new object instance with the specified variables

Parameters:
f - font
s - font size

TextParticle

public TextParticle(java.lang.String f,
                    int s,
                    int d)
Create a new object instance with the specified variables

Parameters:
f - font
s - font size
d - decay time (ms);

TextParticle

public TextParticle(java.lang.String f,
                    int s,
                    boolean aa,
                    boolean mm,
                    int d)
Create a new object instance with the specified variables

Parameters:
f - font
s - font size
aa - anti-aliasing
mm - mipmap generation
d - decay time (ms)
Method Detail

setText

public final void setText(java.lang.String t)
Set the text string

Parameters:
t - text string

getTextBounds

public final PSVector getTextBounds()
Return a vector containing the size of the text bounding box

The bounding box differs from the rendered size, this should be calculated by scaling the returned vector by the value returned from getSize().

Returns:
a vector containing the size of the text bounding box

getTextRenderer

public final com.sun.opengl.util.j2d.TextRenderer getTextRenderer()
Return a reference to the TextRenderer object employed by this particle

Returns:
a reference to the TextRenderer object employed by this particle

setOffset

public final void setOffset(PSVector v)
Set the text offset vector

The text offset vector specifies an offset for the render location. By default the value is (0, 0, 0) resulting in the midpoint of the text being aligned to the location vector.

Parameters:
v -

setAnchorPoint

public final void setAnchorPoint(int a)
Set the text anchor point (CORNER/MIDPOINT)

The anchor point defines the point of the text bounding box that is used as the origin prior to translation. The MIDPOINT value uses the midpoint of the bounding box, whilst the CORNER value uses the lower left corner.

Default: CORNER

Parameters:
a - anchor point

setSmoothing

public final void setSmoothing(boolean s)
Enable/disable smoothing

Parameters:
s - smoothing

render

public void render(processing.opengl.PGraphicsOpenGL pgl)
Render the text to the specified OpenGL renderer

Overrides:
render in class DynamicParticle
Parameters:
pgl - OpenGL renderer

render

public void render(processing.opengl.PGraphicsOpenGL pgl,
                   PSVector cpv,
                   PSVector ctv,
                   PSVector cuv)
Render the text to the specified OpenGL renderer

Overrides:
render in class DynamicParticle
Parameters:
pgl - OpenGL renderer
cpv - camera position vector
ctv - camera target vector
cuv - camera up vector

copy

public DynamicParticle copy()
Return a copy of this particle

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