|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.concord.collisions.engine.JWorldElement | +--org.concord.collisions.engine.JDaemon
Daemon elements in the world
Daemons are objects that, when active, affect other elements in the world when they collide.
By default, daemons are active all the time (non-timed daemons), but they can become timed daemons and be "programmed" to activate at specific times and durations (activation steps). Timed daemons can be looping, that means that after the last activation step, they start automatically again from the beginning. By default, daemons activate the first time automatically, as soon as the world starts, but they can be set non-automatic, so they require to be activated manually. Daemons can have a filter too, that filters the elements that are affected by it.
JWorldElement
, Serialized FormField Summary | |
protected java.util.Vector |
activationSteps
|
protected java.awt.Color |
activeColor
|
protected java.util.Vector |
collisionHistory
|
protected int |
currentActivationStep
|
protected static int |
DEFAULT_PAINT_RADIUS
|
protected boolean |
doCollisionsHistory
|
static float |
minDistance
|
protected java.awt.Color |
timeColor
|
Fields inherited from class org.concord.collisions.engine.JWorldElement |
acx, acy, areaListener, areaTables, collSensitive, controllable, DEFAULT_MAX_CONSTRAINT, DEFAULT_MIN_CONSTRAINT, doProjection, draggable, elementListeners, flashing, iconHeight, iconWidth, index, iviewer, mass, name, pressedState, propertyListeners, qtIcon, qtMovie, rectsForListener, scaleIcon, showAcceleration, showVelocity, showVelocityNumber, suggestedCollisionTime, swingIcon, vel_scale, vx, vy, wasLastStepCollision |
Constructor Summary | |
JDaemon()
|
Method Summary | |
protected void |
activate()
|
void |
addActivationStep(org.concord.collisions.engine.DaemonActivationStep dStep)
Add an activation step to the daemon |
void |
addActivationStep(float time)
Add a time (in milliseconds) in which the daemon will activate. |
void |
addActivationStep(float time,
float duration)
Add a time and duration (in milliseconds) in which the daemon will activate |
void |
addDaemonListener(DaemonListener l)
Add a daemon listener |
void |
applyForce(CCForce force)
JDaemon doesn't support applying forces |
protected void |
checkingCollisionsSensitive()
|
void |
clearConditionExpression()
clear evaluation condition |
void |
clearFilter()
Clears the filter of elements that will be affected after a collision. |
void |
closeEverything()
|
protected void |
deactivate()
|
void |
doDrag(CCCoordinateTuner tuner,
int x,
int y)
|
void |
endDrag(CCCoordinateTuner tuner,
int x,
int y)
|
protected boolean |
evaluateExpression(JWorldElement element)
|
float |
getActivationStepTime()
Retrieve the time (in SECONDS) when the daemon will activate next. |
float |
getActivationStepTime(int i)
Retrieve the time (in SECONDS) when the daemon will activate in a given activation time. |
org.concord.collisions.engine.ElementCollisionInfo |
getActiveCollision(JWorldElement element)
Retrieve the info of the active collision with an element |
java.awt.Color |
getActiveColor()
|
float |
getCMPointX()
calculates X coordinate of center of mass |
float |
getCMPointY()
calculates Y coordinate of center of mass |
java.util.Vector |
getCollisionHistory()
Get the collision history of the daemon |
java.awt.Color |
getColor()
|
java.lang.String |
getConditionExpression()
Returns expression used for evaluation condition of successful collision with daemon |
java.lang.Object |
getDraggableOwner()
|
int |
getDragMode()
|
float |
getEffectiveCollisionsRadius()
|
float |
getHeight()
Get the height of the daemon |
java.awt.Color |
getInactiveColor()
|
JWorldElement |
getNuclearElement()
|
float |
getWidth()
Get the width of the daemon |
float |
getX()
Get the x position of the daemon |
float |
getXPotentialEnergy()
|
float |
getY()
Get the y position of the daemon |
float |
getYPotentialEnergy()
|
boolean |
hasCollided()
Determine if the daemon has collided with any element at any time |
boolean |
hasCollidedWith(JWorldElement element)
Determine if the daemon has collided with a given element at any time |
boolean |
hasCollidedWithAt(JWorldElement element,
int indexActStep)
Determine if the daemon has collided with a given element at a given activation step |
void |
initElement()
|
boolean |
isActive()
Determine if the daemon is active |
boolean |
isActiveCollision(JWorldElement element)
Determine if the daemon is still colliding with a given element |
boolean |
isAlive()
Determine if the daemon is alive |
boolean |
isAutomaticStart()
Determine if it is an automatic daemon |
protected boolean |
isElemInDaemon(JWorldElement el)
|
boolean |
isLooping()
Determine if it is a looping daemon |
boolean |
isPointInside(float px,
float py)
Returns if a specific world coordinates point is inside the element or not |
boolean |
isPointInsideCenter(float px,
float py)
Returns if a specific world coordinates point is inside the CENTER (only the core) of the element or not |
boolean |
isTimed()
Returns if the daemon will activate with activation times (timed) or not. |
boolean |
manageCollision(JWorldElement element)
This method is called by JPartWorld when the daemon collides with an element |
boolean |
manageNoCollision(JWorldElement element)
This method is called by JPartWorld every step while the daemon is colliding with an element |
void |
paint(java.awt.Graphics g)
|
void |
paintIcon(java.awt.Graphics g)
|
void |
paintSelection(java.awt.Graphics g)
|
boolean |
panelInfoSupport()
|
void |
rememberCurrPosAsInit()
|
void |
rememberCurrVelAsInit()
|
void |
removeActivationStep(org.concord.collisions.engine.DaemonActivationStep dStep)
Remove a specific activation step of the daemon |
void |
removeActivationStep(float time)
Prevent a daemon to activate in the exact given time |
void |
removeActivationStep(int index)
Remove a specific activation step of the daemon, given the index |
void |
removeAllActivationSteps()
Remove all the activation steps of the daemon |
void |
removeDaemonListener(DaemonListener l)
Remove a daemon listener |
void |
reset()
Reset the daemon (kill it) |
protected void |
resetCollisionsSensitive()
|
void |
setActivationStepTime(float time)
Set a time (in SECONDS) in which the daemon will activate. |
void |
setActiveColor(java.awt.Color col)
set color to show when the daemon is active |
void |
setAutomaticStart(boolean b)
Set automatic daemon or not automatic daemon |
void |
setCMPointX(float x)
set X coordinate of center of mass |
void |
setCMPointY(float y)
set Y coordinate of center of mass |
void |
setColorFilter(boolean b)
Turns off and on the color filter of the daemon. |
void |
setConditionExpression(java.lang.String expression)
Set the expression used for evaluation condition of successful collision with daemon |
void |
setDragMode(int dragMode)
|
void |
setEffectiveCollisionsRadius(float f)
Sets the minimal distance to center of mass of daemon when collisions may occur |
void |
setFilter(JWorldElementFilter f)
Sets the filter of elements that will be affected after a collision. |
void |
setGeometry(float x,
float y)
set geometry's parameters |
void |
setGeometry(float x,
float y,
float width,
float height)
set geometry's parameters |
void |
setIcon(java.lang.String url)
Sets icon to show. |
void |
setInactiveColor(java.awt.Color col)
set color to show when the daemon is inactive |
void |
setInfoDrawer(CCInfoDrawer infoDrawer)
|
void |
setLooping(boolean b)
Set looping daemon or not looping daemon |
void |
shift(float dt)
|
void |
shiftV(float dt)
|
void |
start()
Start running the daemon |
void |
startDrag(int x,
int y)
|
void |
step(float worldTime)
This method is called by JPartWorld every step |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final int DEFAULT_PAINT_RADIUS
protected java.util.Vector activationSteps
protected int currentActivationStep
protected java.awt.Color activeColor
protected java.util.Vector collisionHistory
public static float minDistance
protected java.awt.Color timeColor
protected boolean doCollisionsHistory
Constructor Detail |
public JDaemon()
Method Detail |
public int getDragMode()
public void setDragMode(int dragMode)
public float getXPotentialEnergy()
getXPotentialEnergy
in class JWorldElement
public float getYPotentialEnergy()
getYPotentialEnergy
in class JWorldElement
public void shift(float dt)
public void shiftV(float dt)
public float getX()
getX
in class JWorldElement
public float getY()
getY
in class JWorldElement
public float getWidth()
public float getHeight()
public void setGeometry(float x, float y, float width, float height) throws java.lang.Exception
x
- daemon's x coordinatey
- daemon's y coordinatew
- daemon's width (minimum 1)h
- daemon's height (minimum 1)public void setGeometry(float x, float y)
x
- daemon's x coordinatey
- daemon's y coordinatew
- daemon's width (minimum 1)h
- daemon's height (minimum 1)public boolean isLooping()
public void setLooping(boolean b)
public boolean isAlive()
public boolean isActive()
public void start()
protected void activate()
protected void deactivate()
public void initElement()
initElement
in class JWorldElement
public void rememberCurrPosAsInit()
rememberCurrPosAsInit
in class JWorldElement
public void rememberCurrVelAsInit()
rememberCurrVelAsInit
in class JWorldElement
public void reset()
public boolean isAutomaticStart()
public void setAutomaticStart(boolean b)
public void addActivationStep(float time) throws java.lang.IllegalArgumentException
This method checks if the step is valid according to the list of steps the daemon already has
time
- activation time of the step to addpublic void addActivationStep(float time, float duration) throws java.lang.IllegalArgumentException
This method checks if the step is valid according to the list of steps the daemon already has
time
- activation time of the step to addduration
- duration time of the step to addpublic void addActivationStep(org.concord.collisions.engine.DaemonActivationStep dStep) throws java.lang.IllegalArgumentException
This method checks if the step is valid according to the list of steps the daemon already has
dStep
- DaemonActivationStep object to addpublic void removeAllActivationSteps()
public void removeActivationStep(int index)
If the index is out of range, it does not throw any exception
index
- index of the step to removepublic void removeActivationStep(float time)
This method removes a specific activation step of the daemon, given the exact activation time
time
- activation time of the step to removepublic void removeActivationStep(org.concord.collisions.engine.DaemonActivationStep dStep)
dStep
- DaemonActivationStep object to removepublic void step(float worldTime)
worldTime
- current world timeprotected void checkingCollisionsSensitive()
protected void resetCollisionsSensitive()
public boolean manageCollision(JWorldElement element)
element
- element the daemon collided withpublic boolean manageNoCollision(JWorldElement element)
element
- element the daemon stopped colliding withpublic java.util.Vector getCollisionHistory()
public boolean hasCollided()
public boolean hasCollidedWith(JWorldElement element)
public boolean hasCollidedWithAt(JWorldElement element, int indexActStep)
public boolean isActiveCollision(JWorldElement element)
public org.concord.collisions.engine.ElementCollisionInfo getActiveCollision(JWorldElement element)
public void addDaemonListener(DaemonListener l)
l
- daemon listener to addpublic void closeEverything()
closeEverything
in class JWorldElement
public void removeDaemonListener(DaemonListener l)
l
- daemon listener to removepublic java.awt.Color getActiveColor()
public void setActiveColor(java.awt.Color col)
color
- to be setpublic void setInactiveColor(java.awt.Color col)
color
- to be setpublic float getEffectiveCollisionsRadius()
CCMassive.getCMPointX()
,
CCMassive.getCMPointY()
public void setEffectiveCollisionsRadius(float f)
CCMassive.getCMPointX()
,
CCMassive.getCMPointY()
public java.awt.Color getInactiveColor()
public java.awt.Color getColor()
getColor
in class JWorldElement
public void paintSelection(java.awt.Graphics g)
paintSelection
in class JWorldElement
public void paint(java.awt.Graphics g)
public void paintIcon(java.awt.Graphics g)
public void startDrag(int x, int y)
public void doDrag(CCCoordinateTuner tuner, int x, int y)
public void endDrag(CCCoordinateTuner tuner, int x, int y)
public java.lang.Object getDraggableOwner()
public boolean panelInfoSupport()
public void setInfoDrawer(CCInfoDrawer infoDrawer)
public void applyForce(CCForce force)
applyForce
in class JWorldElement
CCUnsuppOperationException
- public float getActivationStepTime()
Of all the activation steps, this method returns the inmediate next time the daemon will activate.
public float getActivationStepTime(int i)
public void setActivationStepTime(float time)
This method adds (if there were no activation steps) or replaces an activation step at the beginning of all the activation steps that the daemon already has.
Usually this method is used if working with a daemon that activates only one time. Calling this method with time 0 may turn the daemon into a non-timed daemon, if it had only one activation step before
time
- activation timepublic boolean isTimed()
Timed daemons will activate according to their activation steps. Non-timed daemons will activate from the beginning (if they are automatic) and will remain always active
public void setFilter(JWorldElementFilter f)
JWorldElementFilter
public void clearFilter()
public void setColorFilter(boolean b)
setFilter(org.concord.collisions.engine.JWorldElementFilter)
public void setIcon(java.lang.String url)
By default the icon is as big as the daemon.
url
- url of the icon filepublic float getCMPointX()
public float getCMPointY()
public void setCMPointX(float x) throws CCUnimplOperationException
CCMassive
org.concord.collisions.engine.CCMassive
x
- desired X coordinate of center of masspublic void setCMPointY(float y) throws CCUnimplOperationException
CCMassive
org.concord.collisions.engine.CCMassive
y
- desired Y coordinate of center of masspublic boolean isPointInside(float px, float py)
isPointInside
in class JWorldElement
px
- world x coordinate of the pointpy
- world y coordinate of the pointJWorldElement.isPointInside(java.awt.Point)
protected boolean isElemInDaemon(JWorldElement el)
public boolean isPointInsideCenter(float px, float py)
px
- world x coordinate of the pointpy
- world y coordinate of the pointisPointInside(float, float)
public JWorldElement getNuclearElement()
public java.lang.String getConditionExpression()
public void setConditionExpression(java.lang.String expression)
expression
- evaluation expression
exprerssion could contain:public void clearConditionExpression()
protected boolean evaluateExpression(JWorldElement element)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |