org.concord.collisions.engine
Class JDisplDaemon

java.lang.Object
  |
  +--org.concord.collisions.engine.JWorldElement
        |
        +--org.concord.collisions.engine.JDaemon
              |
              +--org.concord.collisions.engine.JDisplDaemon
All Implemented Interfaces:
CCDraggable, CCMassive, java.util.EventListener, java.beans.PropertyChangeListener, java.io.Serializable

public class JDisplDaemon
extends JDaemon

Displacement daemon element in the world

A displacement daemon is a special daemon that affects only atoms when they collide with it.

It is displayed as an arrow. It changes the velocity of the atom (regardless of its previous velocity) to make it travel over the arrow and then stop at the end of the arrow. The speed of the atom while it is traveling over the displacement daemon depends on the speed mode of the daemon. By default, the atom will always travel through the daemon in 1 second, but the daemon can be set as make the atoms travel with a constant speed.

Author:
Ingrid Moncada, Dmitry Markman
See Also:
JDaemon, Serialized Form

Field Summary
protected  float arrowThickness
           
protected  boolean showDisplNumbers
           
static int SPEED_MODE_CONSTANT
           
static int SPEED_MODE_PROPORTIONAL
           
static int SPEED_MODE_TIMECONSTANT
           
protected  int speedMode
           
protected  float speedModeConstant
           
 
Fields inherited from class org.concord.collisions.engine.JDaemon
activationSteps, activeColor, collisionHistory, currentActivationStep, DEFAULT_PAINT_RADIUS, doCollisionsHistory, minDistance, 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
JDisplDaemon()
           
 
Method Summary
static JDisplDaemon createDisplDaemon(float x, float y, float w, float h, float displX, float displY)
          Creates a new displacement daemon.
 void doDrag(CCCoordinateTuner tuner, int x, int y)
           
 float getArrowThickness()
          Returns the thickness of the arrow that represents the displacement daemon
 float getDisplacementX()
          Returns the x component of the displacement of the daemon
 float getDisplacementY()
          Returns the y component of the displacement of the daemon
 boolean getShowDisplNumbers()
          Returns if the daemon should display explicitly the x,y components as numbers next to the arrow
 int getSpeedMode()
          Returns the speed mode of the daemon
 float getSpeedModeConstant()
          Returns the constant speed the atoms will have when they collide with the daemon when it is in constant speed mode.
 float getXTemperature()
           
 float getYTemperature()
           
protected  boolean isElemInDaemon(JWorldElement el)
           
 boolean isPointInside(float px, float py)
          Returns if a specific world coordinates point is inside the element or not
 boolean manageCollision(JWorldElement element)
          This method is called by JPartWorld when the booster 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, java.awt.Graphics sg)
           
 void resetDefaultColors()
          Reset default colors for the displacement daemon.
 void setArrowThickness(float v)
          Sets the thickness of the arrow that represents the displacement daemon
 void setDisplacement(float dx, float dy)
          Sets the displacement of the daemon (x and y coordinates that determine the length and direction of the arrow)
 void setGeometry(java.lang.Object object)
           
 void setShowDisplNumbers(boolean b)
          Sets if the daemon should display explicitly the x,y components as numbers next to the arrow
 void setSpeedMode(int v)
          Sets the speed mode of the daemon that will determine the actual speed of the atoms that collide with it.
 void setSpeedModeConstant(float v)
          Sets the constant speed the atoms will have when they collide with the daemon ONLY when the daemon is set in constant speed mode.
 
Methods inherited from class org.concord.collisions.engine.JDaemon
activate, addActivationStep, addActivationStep, addActivationStep, addDaemonListener, applyForce, checkingCollisionsSensitive, clearConditionExpression, clearFilter, closeEverything, deactivate, endDrag, evaluateExpression, getActivationStepTime, getActivationStepTime, getActiveCollision, getActiveColor, getCMPointX, getCMPointY, getCollisionHistory, getColor, getConditionExpression, getDraggableOwner, getDragMode, getEffectiveCollisionsRadius, getHeight, getInactiveColor, getNuclearElement, getWidth, getX, getXPotentialEnergy, getY, getYPotentialEnergy, hasCollided, hasCollidedWith, hasCollidedWithAt, initElement, isActive, isActiveCollision, isAlive, isAutomaticStart, isLooping, isPointInsideCenter, isTimed, paint, paintIcon, paintSelection, panelInfoSupport, rememberCurrPosAsInit, rememberCurrVelAsInit, removeActivationStep, removeActivationStep, removeActivationStep, removeAllActivationSteps, removeDaemonListener, reset, resetCollisionsSensitive, setActivationStepTime, setActiveColor, setAutomaticStart, setCMPointX, setCMPointY, setColorFilter, setConditionExpression, setDragMode, setEffectiveCollisionsRadius, setFilter, setGeometry, setGeometry, setIcon, setInactiveColor, setInfoDrawer, setLooping, shift, shiftV, start, startDrag, step
 
Methods inherited from class org.concord.collisions.engine.JWorldElement
addAreaListener, addAreaListener, addAreaListener, addAreaListener, addAreaToListen, addAreaToListen, addAreaToListen, addAreaToListen, addElementListener, addElemMouseListener, addNeighborX, addNeighborY, addPropertyChangeListener, assignIndNumber, clearConstraints, clearForces, clearIcon, createDefaultCalculator, findDraggable, getAccelerationKoeff, getCollidedParticle, getDoProjection, getDownConstraint, getFlashingColor, getFullEnergy, getFullXEnergy, getFullYEnergy, getGravityX, getGravityY, getIcon, getIconHeight, getIconWidth, getIndex, getIndNumber, getLeftConstraint, getMass, getName, getNthForce, getNumbAppliedForces, getOwner, getPositionChanger, getPotentialEnergy, getQTIcon, getQTMovie, getRightConstraint, getShowAcceleration, getShowVelocity, getTemperature, getUpConstraint, getVelScale, getVx, getVy, getWorldModel, getX, getXacceleration, getXNeighbors, getY, getYacceleration, getYNeighbors, isCollisionSensitive, isConstraintsWasSet, isControllable, isDraggable, isEnabled, isFlashing, isMoveable, isPointInside, isPressedState, isSelected, isVisible, notifyAreaListener, notifyElementListeners, notifyMouseListeners, notifyPropertyListeners, paintSelection, propertyChange, rememberCurrAllAsInit, rememberCurrPropAsInit, rememberCurrPropAsInit, removeAreaListener, removeAreaToListen, removeAreaToListen, removeElementListener, removeElemMouseListener, removeForce, removeForce, removePositionChanger, removePropertyChangeListener, reverseVx, reverseVy, select, setAnimIcon, setCollidedParticle, setCollisionSensitive, setColor, setColor, setConstraints, setControllable, setDoProjection, setDraggable, setEnabled, setFlashing, setForceCalculator, setIcon, setIcon, setIcon, setIconSize, setIndex, setMass, setName, setOwner, setPositionChanger, setPressedState, setProperty, setQTIcon, setQTIcon, setQTMovie, setShowAcceleration, setShowVelocity, setVisible, setVx, setVy, setWorldModel, setXConstraints, setYConstraints, unselect, wasCollision
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPEED_MODE_TIMECONSTANT

public static final int SPEED_MODE_TIMECONSTANT

SPEED_MODE_CONSTANT

public static final int SPEED_MODE_CONSTANT

SPEED_MODE_PROPORTIONAL

public static final int SPEED_MODE_PROPORTIONAL

speedMode

protected int speedMode

speedModeConstant

protected float speedModeConstant

showDisplNumbers

protected boolean showDisplNumbers

arrowThickness

protected float arrowThickness
Constructor Detail

JDisplDaemon

public JDisplDaemon()
Method Detail

createDisplDaemon

public static JDisplDaemon createDisplDaemon(float x,
                                             float y,
                                             float w,
                                             float h,
                                             float displX,
                                             float displY)
Creates a new displacement daemon.

It is created in the given position (x,y) and with a displacement of (displX,displY). The w and h parameters are only used to give a width and height on the center of the daemon when the displacement is 0 and it needs to be dragged.

Parameters:
x - daemon's x coordinate
y - daemon's y coordinate
w - daemon's graphical width (minimum 1)
h - daemon's graphical height (minimum 1)
displX - daemon's displacement in x
displY - daemon's displacement in y

setGeometry

public void setGeometry(java.lang.Object object)
                 throws java.lang.Exception
Overrides:
setGeometry in class JWorldElement

setSpeedMode

public void setSpeedMode(int v)
Sets the speed mode of the daemon that will determine the actual speed of the atoms that collide with it.

Parameters:
v - represents the speed the atom will have after colliding with the daemon:
  • SPEED_MODE_TIMECONSTANT atom will always travel the daemon in 1 sec
  • SPEED_MODE_CONSTANT atom will travel the daemon at a constant speed regardless of the lenght of the arrow (see setSpeedModeConstant)
  • SPEED_MODE_PROPORTIONAL the atom's speed is calculated taking x and y separately, so the time an atom will take to travel from one point to another will be always the same regardless of the path

getSpeedMode

public int getSpeedMode()
Returns the speed mode of the daemon
Returns:
speed mode that will determine the speed of the atoms that collide with the daemon
See Also:
setSpeedMode(int)

setSpeedModeConstant

public void setSpeedModeConstant(float v)
Sets the constant speed the atoms will have when they collide with the daemon ONLY when the daemon is set in constant speed mode.

To use this velocity on the atoms, the speed mode of the daemon has to be set on SPEED_MODE_CONSTANT

Parameters:
v - constant speed the atom will have after colliding with the daemon
See Also:
setSpeedMode(int)

getSpeedModeConstant

public float getSpeedModeConstant()
Returns the constant speed the atoms will have when they collide with the daemon when it is in constant speed mode.

This velocity is used in atoms only if the speed mode of the daemon is SPEED_MODE_CONSTANT

Returns:
constant speed the atom will have after colliding with the daemon
See Also:
setSpeedMode(int)

setDisplacement

public void setDisplacement(float dx,
                            float dy)
Sets the displacement of the daemon (x and y coordinates that determine the length and direction of the arrow)
Parameters:
dx - x coordinate of the displacement
dy - y coordinate of the displacement

getDisplacementX

public float getDisplacementX()
Returns the x component of the displacement of the daemon
Returns:
displacement in the x axis

getDisplacementY

public float getDisplacementY()
Returns the y component of the displacement of the daemon
Returns:
displacement in the y axis

getArrowThickness

public float getArrowThickness()
Returns the thickness of the arrow that represents the displacement daemon
Returns:
thickness of the arrow

setArrowThickness

public void setArrowThickness(float v)
Sets the thickness of the arrow that represents the displacement daemon
Parameters:
v - thickness of the arrow. Has to be a positive value

paint

public void paint(java.awt.Graphics g,
                  java.awt.Graphics sg)
Overrides:
paint in class JWorldElement

getXTemperature

public float getXTemperature()
Overrides:
getXTemperature in class JWorldElement

getYTemperature

public float getYTemperature()
Overrides:
getYTemperature in class JWorldElement

manageCollision

public boolean manageCollision(JWorldElement element)
This method is called by JPartWorld when the booster collides with an element
Overrides:
manageCollision in class JDaemon
Parameters:
element - element the booster collided with

manageNoCollision

public boolean manageNoCollision(JWorldElement element)
This method is called by JPartWorld every step while the daemon is colliding with an element
Overrides:
manageNoCollision in class JDaemon
Parameters:
element - element the daemon is colliding with

isElemInDaemon

protected boolean isElemInDaemon(JWorldElement el)
Overrides:
isElemInDaemon in class JDaemon

isPointInside

public boolean isPointInside(float px,
                             float py)
Description copied from class: JDaemon
Returns if a specific world coordinates point is inside the element or not
Overrides:
isPointInside in class JDaemon
Following copied from class: org.concord.collisions.engine.JDaemon
Parameters:
px - world x coordinate of the point
py - world y coordinate of the point
See Also:
JWorldElement.isPointInside(java.awt.Point)

resetDefaultColors

public void resetDefaultColors()
Reset default colors for the displacement daemon.

Sets the default colors for displ daemons: blue for active and inactive


doDrag

public void doDrag(CCCoordinateTuner tuner,
                   int x,
                   int y)
Overrides:
doDrag in class JDaemon

setShowDisplNumbers

public void setShowDisplNumbers(boolean b)
Sets if the daemon should display explicitly the x,y components as numbers next to the arrow

getShowDisplNumbers

public boolean getShowDisplNumbers()
Returns if the daemon should display explicitly the x,y components as numbers next to the arrow