prefuse.util.force
Class AbstractForce

java.lang.Object
  extended by prefuse.util.force.AbstractForce
All Implemented Interfaces:
Force
Direct Known Subclasses:
CircularWallForce, DragForce, GravitationalForce, NBodyForce, SpringForce, WallForce

public abstract class AbstractForce
extends java.lang.Object
implements Force

Abstract base class for force functions in a force simulation. This skeletal version provides support for storing and retrieving float-valued parameters of the force function. Subclasses should use the protected field params to store parameter values.

Author:
jeffrey heer

Field Summary
protected  float[] maxValues
           
protected  float[] minValues
           
protected  float[] params
           
 
Constructor Summary
AbstractForce()
           
 
Method Summary
 void getForce(ForceItem item)
          Throws an UnsupportedOperationException.
 void getForce(Spring spring)
          Throws an UnsupportedOperationException.
 float getMaxValue(int i)
          Get the suggested maximum value for a parameter.
 float getMinValue(int i)
          Get the suggested minimum value for a parameter.
 float getParameter(int i)
          Returns the specified, numbered parameter.
 int getParameterCount()
          Returns the number of parameters (e.g., gravitational constant or spring force coefficient) affecting this force function.
 java.lang.String getParameterName(int i)
          Gets the text name of the requested parameter.
protected abstract  java.lang.String[] getParameterNames()
           
 void init(ForceSimulator fsim)
          Initialize this force function.
 boolean isItemForce()
          Returns false.
 boolean isSpringForce()
          Returns false.
 void setMaxValue(int i, float val)
          Set the suggested maximum value for a parameter.
 void setMinValue(int i, float val)
          Set the suggested minimum value for a parameter.
 void setParameter(int i, float val)
          Sets the specified parameter value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

params

protected float[] params

minValues

protected float[] minValues

maxValues

protected float[] maxValues
Constructor Detail

AbstractForce

public AbstractForce()
Method Detail

init

public void init(ForceSimulator fsim)
Initialize this force function. This default implementation does nothing. Subclasses should override this method with any needed initialization.

Specified by:
init in interface Force
Parameters:
fsim - the encompassing ForceSimulator

getParameterCount

public int getParameterCount()
Description copied from interface: Force
Returns the number of parameters (e.g., gravitational constant or spring force coefficient) affecting this force function.

Specified by:
getParameterCount in interface Force
Returns:
the number of parameters
See Also:
Force.getParameterCount()

getParameter

public float getParameter(int i)
Description copied from interface: Force
Returns the specified, numbered parameter.

Specified by:
getParameter in interface Force
Parameters:
i - the index of the parameter to return
Returns:
the parameter value
See Also:
Force.getParameter(int)

getMinValue

public float getMinValue(int i)
Description copied from interface: Force
Get the suggested minimum value for a parameter. This value is not strictly enforced, but is used by interface components that allow force parameters to be varied.

Specified by:
getMinValue in interface Force
Parameters:
i - the parameter index
Returns:
the suggested minimum value.
See Also:
Force.getMinValue(int)

getMaxValue

public float getMaxValue(int i)
Description copied from interface: Force
Get the suggested maximum value for a parameter. This value is not strictly enforced, but is used by interface components that allow force parameters to be varied.

Specified by:
getMaxValue in interface Force
Parameters:
i - the parameter index
Returns:
the suggested maximum value.
See Also:
Force.getMaxValue(int)

getParameterName

public java.lang.String getParameterName(int i)
Description copied from interface: Force
Gets the text name of the requested parameter.

Specified by:
getParameterName in interface Force
Parameters:
i - the index of the parameter
Returns:
a String containing the name of this parameter
See Also:
Force.getParameterName(int)

setParameter

public void setParameter(int i,
                         float val)
Description copied from interface: Force
Sets the specified parameter value.

Specified by:
setParameter in interface Force
Parameters:
i - the index of the parameter
val - the new value of the parameter
See Also:
Force.setParameter(int, float)

setMinValue

public void setMinValue(int i,
                        float val)
Description copied from interface: Force
Set the suggested minimum value for a parameter. This value is not strictly enforced, but is used by interface components that allow force parameters to be varied.

Specified by:
setMinValue in interface Force
Parameters:
i - the parameter index
val - the suggested minimum value to use
See Also:
Force.setMinValue(int, float)

setMaxValue

public void setMaxValue(int i,
                        float val)
Description copied from interface: Force
Set the suggested maximum value for a parameter. This value is not strictly enforced, but is used by interface components that allow force parameters to be varied.

Specified by:
setMaxValue in interface Force
Parameters:
i - the parameter index
val - the suggested maximum value to use
See Also:
Force.setMaxValue(int, float)

getParameterNames

protected abstract java.lang.String[] getParameterNames()

isItemForce

public boolean isItemForce()
Returns false.

Specified by:
isItemForce in interface Force
Returns:
true if this force function processes Force instances
See Also:
Force.isItemForce()

isSpringForce

public boolean isSpringForce()
Returns false.

Specified by:
isSpringForce in interface Force
Returns:
true if this force function processes Spring instances
See Also:
Force.isSpringForce()

getForce

public void getForce(ForceItem item)
Throws an UnsupportedOperationException.

Specified by:
getForce in interface Force
Parameters:
item - the ForceItem on which to compute updated forces
See Also:
Force.getForce(prefuse.util.force.ForceItem)

getForce

public void getForce(Spring spring)
Throws an UnsupportedOperationException.

Specified by:
getForce in interface Force
Parameters:
spring - the Spring on which to compute updated forces
See Also:
Force.getForce(prefuse.util.force.Spring)


Copyright © 2007 Regents of the University of California