org.concord.collisions.engine
Class JPartWorld

java.lang.Object
  |
  +--org.concord.collisions.engine.JPartWorld
All Implemented Interfaces:
java.awt.event.ActionListener, CCMassive, CCSimulator, java.util.EventListener
Direct Known Subclasses:
BedSpringWorld

public class JPartWorld
extends java.lang.Object
implements java.awt.event.ActionListener, CCSimulator, CCMassive

main class for kinetic engine contains methods for calculating positions/velocity of particles many methods are duplicated in GUIPanel class

Author:
Dmitry Markman
See Also:
GUIPanel

Inner Class Summary
static class JPartWorld.Distance2Line
           
 
Field Summary
static int ATOM_ATOM_COLLISION
          ATOM_ATOM_COLLISION JPartWorld generates CollisionsEvent if collision was between atom/atom getID method of that CollisionEvent will return ATOM_ATOM_COLLISION value
static int ATOM_DAEMON_COLLISION
          ATOM_DAEMON_COLLISION JPartWorld generates CollisionsEvent if collision was between atom/daemon getID method of that CollisionEvent will return ATOM_DAEMON_COLLISION value
static int ATOM_WALL_COLLISION
          ATOM_WALL_COLLISION JPartWorld generates CollisionsEvent if collision was between atom/wall getID method of that CollisionEvent will return ATOM_WALL_COLLISION value
static int DEFAULT_CALC_DT
           
static int DEFAULT_DRAW_DT
           
protected  boolean doPredictionCorrection
           
protected  float gravityX
           
protected  float gravityY
           
protected  int simulationState
           
 float totalAtomsEnergy
           
 float totalBoxesEnergy
           
 float totalWallsEnergy
           
static int TYPE_ATOM
           
static int TYPE_BOX
           
static int TYPE_DAEMON
           
static int TYPE_WALL
           
static java.lang.Object worldLock
           
 
Fields inherited from interface org.concord.shared.simulation.CCSimulator
SIM_RESET_STATE, SIM_RUN_STATE, SIM_STOP_STATE, SIM_UNDEF_STATE
 
Constructor Summary
JPartWorld()
           
JPartWorld(float calcTimerDT, float drawTimerDT)
          JPartWorld constructor user shouldn't create world directly GUIPanel constructor will create it for you
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          called by CCTimer
 void addCollisionsListener(CollisionsListener l)
          addCollisionsListener listener will be notified in case of any collision event
 void addSoundThread(int note)
          add Thread for playing sounds it will be moved to an other location
 void addStepListener(StepListener l, int intervalMillisec)
           
 void addWorldElement(JWorldElement element)
          addWorldElement add JWorldElement into the world
static JPartWorld.Distance2Line caclulateDistanceToLine(float xp, float yp, float x0, float y0, float x1, float y1)
           
static JPartWorld.Distance2Line caclulateDistanceToLine(float xp, float yp, float x0, float y0, float x1, float y1, boolean checkInside)
           
 float calculateAverageAtomsEnergyInRect(float x, float y, float w, float h)
          retrieves average kinetic energy for atoms existed inside of rectangle with given coordinates
 java.awt.Color calculateColor(float temperature)
          calculates color that corresponds to color dependence parameters
protected  float calculateStep()
           
 void calculateTotalAtomsEnergy()
          calculates total kinetic energy (atoms only)
 float calculateTotalAtomsEnergyInRect(float x, float y, float w, float h)
          retrieves total kinetic energy for atoms existed inside of rectangle with given coordinates
 float calculateTotalAtomsEnergyXInRect(float x, float y, float w, float h)
           
 float calculateTotalAtomsEnergyYInRect(float x, float y, float w, float h)
           
 void calculateTotalBoxesEnergy()
           
 void calculateTotalWallsEnergy()
          calculates total kinetic energy (walls only)
 void cancelColorTempDependencies()
          set color dependency parameters between element's temperature and element's color cancel color dependence
protected  float checkDTCollision(float sTime)
           
protected  float checkForSingleAtomAtomCollision(float sTime, JAtom atomA, JAtom atomB)
           
protected  float checkForSingleAtomBoxCollision(float sTime, JAtom atom, float xb, float yb, float r, JRigidBox box)
           
protected  float checkForSingleAtomDaemonCollision(float sTime, JAtom atom, float xb, float yb, float r, JDaemon daemon)
           
protected  float checkForSingleAtomWallCollision(float sTime, JAtom atom, float xb, float yb, float r, JWall wall)
           
 void clearAllAtomsTrace()
          clear all traces
 void clearSound()
          set soundOn property to false so you won't be able to use sound threads
 void clearWorld()
          remove walls and atoms from the world
 void closeEverything()
           
 void continueSteps()
          continueSteps continues simulation all timers will be started
static float cos(float radian)
           
 void createSoundThreads()
           
 void distributeAtomsRandomly(int nAtoms, float x0, float y0, float width, float height, float minV, float maxV)
          distribute atoms in given rectangle (random position and velocity) with default mass and radius
 void distributeAtomsRandomly(int nAtoms, float r, float mass, float x0, float y0, float width, float height, float minV, float maxV)
          distribute atoms in given rectangle (random position and velocity)
 void distributeAtomsRandomlyConstVel(int nAtoms, float x0, float y0, float width, float height, float vel)
          distribute atoms in given rectangle (random position and const velocityvalue but random direction)
 void distributeAtomsRandomlyConstVel(int nAtoms, float r, float mass, float x0, float y0, float width, float height, float vel)
          distribute atoms in given rectangle (random position and const velocityvalue but random direction)
 void doOneStep()
          doOneStep does only one step all timers will be started
protected  JAtom findAtom(float x, float y)
           
 float getAccelerationKoeff()
           
 JAtom getAtomByName(java.lang.String name)
           
 java.util.Vector getAtoms()
           
 JRigidBox getBoxByName(java.lang.String name)
           
 java.util.Vector getBoxes()
           
 float getCalcDT()
           
 float getCalculateTime()
           
static float getCmFromPx(float px)
           
 CCPoint getCMPoint()
           
 float getCMPointX()
          calculates X coordinate of center of mass
 float getCMPointY()
          calculates Y coordinate of center of mass
static CCUnit getCmUnit()
           
 JDaemon getDaemonByName(java.lang.String name)
           
 java.util.Vector getDaemons()
           
static float getDefaultCalculateDT()
           
 float getDesirableSimulationDT()
           
 CCForceCalculator getForceCalculator()
           
 float getGravityX()
           
 float getGravityY()
           
 GUIPanel getGUIPanel()
           
 float getMass()
           
static float getNeedScreenResolution()
           
 CCCoordinateTuner getPanelToWorldCoordinateTuner()
           
static float getPxFromCm(float cm)
           
static CCUnit getPxUnit()
           
static float getScreenResolution()
           
 int getSimulationState()
           
 boolean getSoundOn()
           
static float getToolkitScreenResolution()
           
 float getTotalAtomsEnergy()
          retrieves total kinetic energy (atoms only) you should call calculateTotalAtomsEnergy immediately before this call
 float getTotalBoxesEnergy()
           
 float getTotalEnergy()
          retrieves total kinetic energy you should call calculateTotalWallsEnergy and calculateTotalAtomsEnergy immediately before this call
 float getTotalWallsEnergy()
          retrieves total kinetic energy (walls only) you should call calculateTotalWallsEnergy immediately before this call
 JWall getWallByName(java.lang.String name)
           
 java.util.Vector getWalls()
           
 JWorldElement getWorldElementByName(int type, java.lang.String name)
           
 CCCoordinateTuner getWorldToPanelCoordinateTuner()
           
 int howManyParticleInRect(int type, float x, float y, float w, float h)
          retrieves amount of particles of given type existed inside of rectangle with given coordinates
protected  void initElements()
           
 boolean isBedSpringMode()
           
 boolean isDoAACollisions()
           
 boolean isDoAWCollisions()
           
 boolean isDoCollisions()
           
 boolean isDoPredictionCorrection()
           
 boolean isRunning()
          isRunning
protected  void manageCollision(JWorldElement element)
           
 void nextStep()
          nextStep shouldn't be called directly calculates next simulation's step
protected  void notifyCollisionsListeners(JWorldElement gel, int id, int x, int y)
           
 void playChannel(int channel)
          play default note on given channel
 void playChannel(int channel, int note)
          play default note on given channel
static void pr()
           
static void pr(java.lang.String s)
           
 void redrawWorld()
           
protected  void rememberCurrElementsPropertiesAsInit()
           
 void removeAtomFromWorld(JAtom atom)
          remove the atom with given name from the world
 void removeAtomFromWorld(java.lang.String name)
          remove the atom with given name from the world
 void removeAtomsFromWorld()
          remove atoms from the world
 void removeBoxesFromWorld()
           
 void removeBoxFromWorld(JRigidBox box)
           
 void removeBoxFromWorld(java.lang.String name)
           
 void removeCollisionsListener(CollisionsListener l)
          removeCollisionsListener
 void removeDaemonFromWorld(JDaemon daem)
          remove the given daemon from the world
 void removeDaemonFromWorld(java.lang.String name)
          remove the daemon with given name from the world
 void removeDaemonsFromWorld()
          remove daemons from the world
 void removeForceCalculator()
           
 void removeStepListener(StepListener l)
           
 void removeWallFromWorld(JWall wall)
          remove the wall with given name from the world
 void removeWallFromWorld(java.lang.String name)
          remove the wall with given name from the world
 void removeWallsFromWorld()
          remove walls from the world
 void reset()
          reset reset simulation all timers will be stopped
protected  void resetStepListeners()
           
 void reverseAllVelocityInTheWorld()
           
static int round(double val)
           
static int round(float val)
           
protected  void setBedSpringMode(boolean bedSpringMode)
           
 void setCMPointX(float x)
          set X coordinate of center of mass
 void setCMPointY(float y)
          set Y coordinate of center of mass
 void setColorTempDependencies(java.awt.Color minTempColor, float minTemperature, java.awt.Color maxTempColor, float maxTemperature)
          set color dependency parameters between element's temperature and element's color
 boolean setDesirableSimulationDT(float val)
          set desirable simulation dt you can do that only if only simulation isn't running
 void setDoAACollisions(boolean doAACollisions)
           
 void setDoAWCollisions(boolean doAWCollisions)
           
 void setDoCollisions(boolean doCollisions)
           
 void setDoPredictionCorrection(boolean doPredictionCorrection)
           
 void setForceCalculator(CCForceCalculator forceCalculator)
           
 void setGravity(float gravityX, float gravityY)
           
 void setGravityX(float gravityX)
           
 void setGravityY(float gravityY)
           
 void setGuiPanel(GUIPanel guiPanel)
           
static void setNeedScreenResolution(float needScreenResolution)
          set resolution
static void setNeedScreenResolution(float newValue, java.awt.Component c)
           
 void setPropertyForAtomsInRect(java.lang.String property, float x, float y, float w, float h, java.lang.Object val)
          set propertie's value for all atoms in given rectangle
 void setPropertyForWallsInRect(java.lang.String property, float x, float y, float w, float h, java.lang.Object val)
           
 void setSoundOn()
          set soundOn property to true so you can use sound threads
 void setSoundToggle()
           
static float sin(float radian)
           
 void start()
          start start simulation all timers will be started
 void stop()
          stop stop simulation all timers will be stopped
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

worldLock

public static java.lang.Object worldLock

DEFAULT_CALC_DT

public static final int DEFAULT_CALC_DT

DEFAULT_DRAW_DT

public static final int DEFAULT_DRAW_DT

ATOM_WALL_COLLISION

public static final int ATOM_WALL_COLLISION
ATOM_WALL_COLLISION JPartWorld generates CollisionsEvent if collision was between atom/wall getID method of that CollisionEvent will return ATOM_WALL_COLLISION value
See Also:
CollisionsEvent

ATOM_ATOM_COLLISION

public static final int ATOM_ATOM_COLLISION
ATOM_ATOM_COLLISION JPartWorld generates CollisionsEvent if collision was between atom/atom getID method of that CollisionEvent will return ATOM_ATOM_COLLISION value
See Also:
CollisionsEvent

ATOM_DAEMON_COLLISION

public static final int ATOM_DAEMON_COLLISION
ATOM_DAEMON_COLLISION JPartWorld generates CollisionsEvent if collision was between atom/daemon getID method of that CollisionEvent will return ATOM_DAEMON_COLLISION value
See Also:
CollisionsEvent

TYPE_ATOM

public static final int TYPE_ATOM

TYPE_WALL

public static final int TYPE_WALL

TYPE_BOX

public static final int TYPE_BOX

TYPE_DAEMON

public static final int TYPE_DAEMON

totalAtomsEnergy

public float totalAtomsEnergy

totalWallsEnergy

public float totalWallsEnergy

totalBoxesEnergy

public float totalBoxesEnergy

doPredictionCorrection

protected boolean doPredictionCorrection

simulationState

protected int simulationState

gravityX

protected float gravityX

gravityY

protected float gravityY
Constructor Detail

JPartWorld

public JPartWorld()

JPartWorld

public JPartWorld(float calcTimerDT,
                  float drawTimerDT)
JPartWorld constructor user shouldn't create world directly GUIPanel constructor will create it for you
Parameters:
guiPanel - panel where atoms/walls will be drawn
calcTimerDT - time interval in millisec for setup calculation timer
drawTimerDT - time interval in millisec for setup draw timer
See Also:
CCTimer
Method Detail

setDesirableSimulationDT

public boolean setDesirableSimulationDT(float val)
set desirable simulation dt you can do that only if only simulation isn't running
Parameters:
desirable - dt in millisec
Returns:
true parameter was set successfully or false if simulation is running

getDesirableSimulationDT

public float getDesirableSimulationDT()

createSoundThreads

public void createSoundThreads()

setGuiPanel

public void setGuiPanel(GUIPanel guiPanel)

getGUIPanel

public GUIPanel getGUIPanel()

getCalcDT

public float getCalcDT()

getAccelerationKoeff

public float getAccelerationKoeff()

getForceCalculator

public CCForceCalculator getForceCalculator()

setForceCalculator

public void setForceCalculator(CCForceCalculator forceCalculator)

removeForceCalculator

public void removeForceCalculator()

addStepListener

public void addStepListener(StepListener l,
                            int intervalMillisec)

removeStepListener

public void removeStepListener(StepListener l)

getDefaultCalculateDT

public static float getDefaultCalculateDT()

redrawWorld

public void redrawWorld()

getPanelToWorldCoordinateTuner

public CCCoordinateTuner getPanelToWorldCoordinateTuner()

getWorldToPanelCoordinateTuner

public CCCoordinateTuner getWorldToPanelCoordinateTuner()

sin

public static float sin(float radian)

cos

public static float cos(float radian)

addSoundThread

public void addSoundThread(int note)
add Thread for playing sounds it will be moved to an other location
Parameters:
note - current note for this channel
See Also:
CollisionsListener

addCollisionsListener

public void addCollisionsListener(CollisionsListener l)
addCollisionsListener listener will be notified in case of any collision event
Parameters:
l - listener to add
See Also:
CollisionsListener

removeCollisionsListener

public void removeCollisionsListener(CollisionsListener l)
removeCollisionsListener
Parameters:
l - listener to remove
See Also:
CollisionsListener

isRunning

public boolean isRunning()
isRunning
Specified by:
isRunning in interface CCSimulator
Returns:
true if simulation is running or false if simulation was reset

getSimulationState

public int getSimulationState()
Specified by:
getSimulationState in interface CCSimulator

stop

public void stop()
stop stop simulation all timers will be stopped
Specified by:
stop in interface CCSimulator
See Also:
JPartWorld#calculateTimer, JPartWorld#drawTimer, isRunning()

reset

public void reset()
reset reset simulation all timers will be stopped
Specified by:
reset in interface CCSimulator
See Also:
JPartWorld#calculateTimer, JPartWorld#drawTimer, isRunning()

resetStepListeners

protected void resetStepListeners()

doOneStep

public void doOneStep()
doOneStep does only one step all timers will be started
Specified by:
doOneStep in interface CCSimulator
See Also:
JPartWorld#calculateTimer, JPartWorld#drawTimer, isRunning()

continueSteps

public void continueSteps()
continueSteps continues simulation all timers will be started
Specified by:
continueSteps in interface CCSimulator
See Also:
JPartWorld#calculateTimer, JPartWorld#drawTimer, isRunning()

start

public void start()
start start simulation all timers will be started
Specified by:
start in interface CCSimulator
See Also:
JPartWorld#calculateTimer, JPartWorld#drawTimer, isRunning()

getCalculateTime

public float getCalculateTime()

addWorldElement

public void addWorldElement(JWorldElement element)
                     throws java.lang.Exception
addWorldElement add JWorldElement into the world
Parameters:
element - to add
See Also:
JWorldElement, JWall, JAtom

reverseAllVelocityInTheWorld

public void reverseAllVelocityInTheWorld()

nextStep

public void nextStep()
nextStep shouldn't be called directly calculates next simulation's step
Specified by:
nextStep in interface CCSimulator
See Also:
CCTimer

calculateStep

protected float calculateStep()

manageCollision

protected void manageCollision(JWorldElement element)

checkForSingleAtomAtomCollision

protected float checkForSingleAtomAtomCollision(float sTime,
                                                JAtom atomA,
                                                JAtom atomB)

checkDTCollision

protected float checkDTCollision(float sTime)

checkForSingleAtomBoxCollision

protected float checkForSingleAtomBoxCollision(float sTime,
                                               JAtom atom,
                                               float xb,
                                               float yb,
                                               float r,
                                               JRigidBox box)

checkForSingleAtomDaemonCollision

protected float checkForSingleAtomDaemonCollision(float sTime,
                                                  JAtom atom,
                                                  float xb,
                                                  float yb,
                                                  float r,
                                                  JDaemon daemon)

checkForSingleAtomWallCollision

protected float checkForSingleAtomWallCollision(float sTime,
                                                JAtom atom,
                                                float xb,
                                                float yb,
                                                float r,
                                                JWall wall)

playChannel

public void playChannel(int channel)
play default note on given channel
Parameters:
channel - number of channel you should add channel via addSoundThread method
See Also:
CCTimer

playChannel

public void playChannel(int channel,
                        int note)
play default note on given channel
Parameters:
channel - number of channel you should add channel via addSoundThread method
note - note to play. current note value for this channel will be changed to note
See Also:
CCTimer

notifyCollisionsListeners

protected void notifyCollisionsListeners(JWorldElement gel,
                                         int id,
                                         int x,
                                         int y)

getWalls

public java.util.Vector getWalls()
Returns:
vector that contains all instances of JWall added to the world
See Also:
JWall

getAtoms

public java.util.Vector getAtoms()
Returns:
vector that contains all instances of JAtom added to the world
See Also:
JAtom

getBoxes

public java.util.Vector getBoxes()

getDaemons

public java.util.Vector getDaemons()
Returns:
vector that contains all instances of JDaemon added to the world
See Also:
JDaemon

clearWorld

public void clearWorld()
remove walls and atoms from the world
See Also:
addWorldElement(org.concord.collisions.engine.JWorldElement), JWall, JAtom

closeEverything

public void closeEverything()

initElements

protected void initElements()

rememberCurrElementsPropertiesAsInit

protected void rememberCurrElementsPropertiesAsInit()

removeAtomsFromWorld

public void removeAtomsFromWorld()
remove atoms from the world
See Also:
addWorldElement(org.concord.collisions.engine.JWorldElement), clearWorld(), JAtom

removeDaemonsFromWorld

public void removeDaemonsFromWorld()
remove daemons from the world
See Also:
addWorldElement(org.concord.collisions.engine.JWorldElement), clearWorld(), JDaemon

removeDaemonFromWorld

public void removeDaemonFromWorld(java.lang.String name)
remove the daemon with given name from the world
Parameters:
name - name of the daemon to be removed
See Also:
JDaemon

removeDaemonFromWorld

public void removeDaemonFromWorld(JDaemon daem)
remove the given daemon from the world
Parameters:
daem - daemon to be removed
See Also:
JDaemon

removeAtomFromWorld

public void removeAtomFromWorld(java.lang.String name)
remove the atom with given name from the world
Parameters:
name - name of the atom to be removed
See Also:
JAtom

removeAtomFromWorld

public void removeAtomFromWorld(JAtom atom)
remove the atom with given name from the world
Parameters:
atom - atom to be removed
See Also:
JAtom

removeWallFromWorld

public void removeWallFromWorld(java.lang.String name)
remove the wall with given name from the world
Parameters:
name - name of the wall to be removed
See Also:
JWall

removeWallFromWorld

public void removeWallFromWorld(JWall wall)
remove the wall with given name from the world
Parameters:
wall - the wall to be removed
See Also:
JWall

removeWallsFromWorld

public void removeWallsFromWorld()
remove walls from the world
See Also:
addWorldElement(org.concord.collisions.engine.JWorldElement), clearWorld(), JWall

removeBoxFromWorld

public void removeBoxFromWorld(java.lang.String name)

removeBoxFromWorld

public void removeBoxFromWorld(JRigidBox box)

removeBoxesFromWorld

public void removeBoxesFromWorld()

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
called by CCTimer
Specified by:
actionPerformed in interface java.awt.event.ActionListener
See Also:
CCTimer

calculateTotalAtomsEnergy

public void calculateTotalAtomsEnergy()
calculates total kinetic energy (atoms only)

calculateTotalWallsEnergy

public void calculateTotalWallsEnergy()
calculates total kinetic energy (walls only)

calculateTotalBoxesEnergy

public void calculateTotalBoxesEnergy()

getTotalEnergy

public float getTotalEnergy()
retrieves total kinetic energy you should call calculateTotalWallsEnergy and calculateTotalAtomsEnergy immediately before this call
See Also:
calculateTotalAtomsEnergy(), calculateTotalWallsEnergy()

getTotalAtomsEnergy

public float getTotalAtomsEnergy()
retrieves total kinetic energy (atoms only) you should call calculateTotalAtomsEnergy immediately before this call
See Also:
calculateTotalAtomsEnergy()

getTotalWallsEnergy

public float getTotalWallsEnergy()
retrieves total kinetic energy (walls only) you should call calculateTotalWallsEnergy immediately before this call
See Also:
calculateTotalWallsEnergy()

getTotalBoxesEnergy

public float getTotalBoxesEnergy()

calculateTotalAtomsEnergyInRect

public float calculateTotalAtomsEnergyInRect(float x,
                                             float y,
                                             float w,
                                             float h)
retrieves total kinetic energy for atoms existed inside of rectangle with given coordinates
Parameters:
x - the most left coordinate of rectangle (GUIPanel relative)
y - the most top coordinate of rectangle (GUIPanel relative)
w - width of rectangle
h - height of rectangle
Returns:
total kinetic energy for atoms existed inside of rectangle with given coordinates

calculateAverageAtomsEnergyInRect

public float calculateAverageAtomsEnergyInRect(float x,
                                               float y,
                                               float w,
                                               float h)
retrieves average kinetic energy for atoms existed inside of rectangle with given coordinates
Parameters:
x - the most left coordinate of rectangle (GUIPanel relative)
y - the most top coordinate of rectangle (GUIPanel relative)
w - width of rectangle
h - height of rectangle
Returns:
total kinetic energy for atoms existed inside of rectangle with given coordinates

calculateTotalAtomsEnergyXInRect

public float calculateTotalAtomsEnergyXInRect(float x,
                                              float y,
                                              float w,
                                              float h)

calculateTotalAtomsEnergyYInRect

public float calculateTotalAtomsEnergyYInRect(float x,
                                              float y,
                                              float w,
                                              float h)

howManyParticleInRect

public int howManyParticleInRect(int type,
                                 float x,
                                 float y,
                                 float w,
                                 float h)
retrieves amount of particles of given type existed inside of rectangle with given coordinates
Parameters:
type - it could be TYPE_ATOM for atoms and TYPE_WALL for walls (not implemented yet)
x - the most left coordinate of rectangle (GUIPanel relative)
y - the most top coordinate of rectangle (GUIPanel relative)
w - width of rectangle
h - height of rectangle
Returns:
amount of particles of given type existed inside of rectangle with given coordinates

round

public static int round(float val)

round

public static int round(double val)

getAtomByName

public JAtom getAtomByName(java.lang.String name)
Parameters:
name - name of the atom, should be set with setName method
Returns:
instance of JAtom with given name
See Also:
JAtom

getWallByName

public JWall getWallByName(java.lang.String name)
Parameters:
name - name of the wall, should be set with setName method
Returns:
instance of JWall with given name
See Also:
JWall

getBoxByName

public JRigidBox getBoxByName(java.lang.String name)
Parameters:
name - name of the box, should be set with setName method
Returns:
instance of JRigidBox with given name
See Also:
JRigidBox

getDaemonByName

public JDaemon getDaemonByName(java.lang.String name)
Parameters:
name - name of the daemon, should be set with setName method
Returns:
instance of JDaemon with given name
See Also:
JDaemon

getWorldElementByName

public JWorldElement getWorldElementByName(int type,
                                           java.lang.String name)
Parameters:
name - name of the JWorldElement, should be set with setName method
Returns:
instance of JWorldElement of given type with given name
See Also:
JAtom, JWall

setSoundOn

public void setSoundOn()
set soundOn property to true so you can use sound threads
See Also:
addSoundThread(int)

getSoundOn

public boolean getSoundOn()

clearSound

public void clearSound()
set soundOn property to false so you won't be able to use sound threads
See Also:
addSoundThread(int)

setSoundToggle

public void setSoundToggle()

distributeAtomsRandomly

public void distributeAtomsRandomly(int nAtoms,
                                    float x0,
                                    float y0,
                                    float width,
                                    float height,
                                    float minV,
                                    float maxV)
distribute atoms in given rectangle (random position and velocity) with default mass and radius
Parameters:
nAtoms - desired numbers of atoms to be distributed
x0 - x coordinate of left top corner of rectangle (GUIPanel relative)
y0 - y coordinate of left top corner of rectangle (GUIPanel relative)
width - of rectangle
height - of rectangle
minV - minimum value for velocity projection's
maxV - maximum value for velocity projection's
See Also:
addSoundThread(int)

distributeAtomsRandomly

public void distributeAtomsRandomly(int nAtoms,
                                    float r,
                                    float mass,
                                    float x0,
                                    float y0,
                                    float width,
                                    float height,
                                    float minV,
                                    float maxV)
distribute atoms in given rectangle (random position and velocity)
Parameters:
nAtoms - desired numbers of atoms to be distributed
r - atom's radius
mass - atom's mass
x0 - x coordinate of left top corner of rectangle (GUIPanel relative)
y0 - y coordinate of left top corner of rectangle (GUIPanel relative)
width - of rectangle
height - of rectangle
minV - minimum value for velocity projection's
maxV - maximum value for velocity projection's
See Also:
addSoundThread(int)

distributeAtomsRandomlyConstVel

public void distributeAtomsRandomlyConstVel(int nAtoms,
                                            float x0,
                                            float y0,
                                            float width,
                                            float height,
                                            float vel)
distribute atoms in given rectangle (random position and const velocityvalue but random direction)
Parameters:
nAtoms - desired numbers of atoms to be distributed
x0 - x coordinate of left top corner of rectangle (GUIPanel relative)
y0 - y coordinate of left top corner of rectangle (GUIPanel relative)
width - of rectangle
height - of rectangle
vel - desirable atom's velocity
See Also:
addSoundThread(int)

distributeAtomsRandomlyConstVel

public void distributeAtomsRandomlyConstVel(int nAtoms,
                                            float r,
                                            float mass,
                                            float x0,
                                            float y0,
                                            float width,
                                            float height,
                                            float vel)
distribute atoms in given rectangle (random position and const velocityvalue but random direction)
Parameters:
nAtoms - desired numbers of atoms to be distributed
r - atom's radius
mass - atom's mass
x0 - x coordinate of left top corner of rectangle (GUIPanel relative)
y0 - y coordinate of left top corner of rectangle (GUIPanel relative)
width - of rectangle
height - of rectangle
vel - desirable atom's velocity
See Also:
addSoundThread(int)

setPropertyForAtomsInRect

public void setPropertyForAtomsInRect(java.lang.String property,
                                      float x,
                                      float y,
                                      float w,
                                      float h,
                                      java.lang.Object val)
set propertie's value for all atoms in given rectangle
Parameters:
property - propertie's name currently supported:
color atom's color
showvel show velocity vector
toggleshowvel toggle show velocity propertie value
velcolor velocity vector's color
trace trace property (GUIPanel should be ready for drawing trace)
x - x coordinate of left top corner of rectangle (GUIPanel relative)
y - y coordinate of left top corner of rectangle (GUIPanel relative)
w - of rectangle
h - of rectangle
val
- for color and velcolor property it should be java.awt.Color instance
for showvel and trace property it should be java.lang.Boolean instance
for toggleshowvel this parameter is ignored
See Also:
JAtom, GUIPanel, Color, Boolean

setPropertyForWallsInRect

public void setPropertyForWallsInRect(java.lang.String property,
                                      float x,
                                      float y,
                                      float w,
                                      float h,
                                      java.lang.Object val)

clearAllAtomsTrace

public void clearAllAtomsTrace()
clear all traces

pr

public static void pr(java.lang.String s)

pr

public static void pr()

setColorTempDependencies

public void setColorTempDependencies(java.awt.Color minTempColor,
                                     float minTemperature,
                                     java.awt.Color maxTempColor,
                                     float maxTemperature)
set color dependency parameters between element's temperature and element's color
Parameters:
minTempColor - color that corresponds to minimum Temperature
minTemperature - low temperature constraint
maxTempColor - color that corresponds to maximum Temperature
maxTemperature - high temperature constraint

cancelColorTempDependencies

public void cancelColorTempDependencies()
set color dependency parameters between element's temperature and element's color cancel color dependence
See Also:
setColorTempDependencies

calculateColor

public java.awt.Color calculateColor(float temperature)
calculates color that corresponds to color dependence parameters
Parameters:
temperature. - if color dependency parameters were not set or were wrong than null will be returned
Returns:
color
See Also:
setColorTempDependencies

getGravityX

public float getGravityX()

getGravityY

public float getGravityY()

setGravityX

public void setGravityX(float gravityX)

setGravityY

public void setGravityY(float gravityY)

setGravity

public void setGravity(float gravityX,
                       float gravityY)

getCMPointX

public float getCMPointX()
Description copied from interface: CCMassive
calculates X coordinate of center of mass
Specified by:
getCMPointX in interface CCMassive
Following copied from interface: org.concord.collisions.engine.CCMassive
Returns:
x coordinate of element's center of mass

getCMPointY

public float getCMPointY()
Description copied from interface: CCMassive
calculates Y coordinate of center of mass
Specified by:
getCMPointY in interface CCMassive
Following copied from interface: org.concord.collisions.engine.CCMassive
Returns:
y coordinate of element's center of mass

setCMPointX

public void setCMPointX(float x)
                 throws CCUnimplOperationException
Description copied from interface: CCMassive
set X coordinate of center of mass
Specified by:
setCMPointX in interface CCMassive
Following copied from interface: org.concord.collisions.engine.CCMassive
Parameters:
x - desired X coordinate of center of mass

setCMPointY

public void setCMPointY(float y)
                 throws CCUnimplOperationException
Description copied from interface: CCMassive
set Y coordinate of center of mass
Specified by:
setCMPointY in interface CCMassive
Following copied from interface: org.concord.collisions.engine.CCMassive
Parameters:
y - desired Y coordinate of center of mass

getMass

public float getMass()
Specified by:
getMass in interface CCMassive

getCMPoint

public CCPoint getCMPoint()

isDoAACollisions

public boolean isDoAACollisions()

setDoAACollisions

public void setDoAACollisions(boolean doAACollisions)

isDoAWCollisions

public boolean isDoAWCollisions()

setDoAWCollisions

public void setDoAWCollisions(boolean doAWCollisions)

setDoCollisions

public void setDoCollisions(boolean doCollisions)

isDoCollisions

public boolean isDoCollisions()

isBedSpringMode

public boolean isBedSpringMode()

setBedSpringMode

protected void setBedSpringMode(boolean bedSpringMode)

getCmUnit

public static CCUnit getCmUnit()

getPxUnit

public static CCUnit getPxUnit()

getPxFromCm

public static float getPxFromCm(float cm)

getCmFromPx

public static float getCmFromPx(float px)

findAtom

protected JAtom findAtom(float x,
                         float y)

caclulateDistanceToLine

public static JPartWorld.Distance2Line caclulateDistanceToLine(float xp,
                                                               float yp,
                                                               float x0,
                                                               float y0,
                                                               float x1,
                                                               float y1)

caclulateDistanceToLine

public static JPartWorld.Distance2Line caclulateDistanceToLine(float xp,
                                                               float yp,
                                                               float x0,
                                                               float y0,
                                                               float x1,
                                                               float y1,
                                                               boolean checkInside)

getNeedScreenResolution

public static float getNeedScreenResolution()

getScreenResolution

public static float getScreenResolution()

setNeedScreenResolution

public static void setNeedScreenResolution(float needScreenResolution)
set resolution
Parameters:
needScreenResolution - pixels/cm

setNeedScreenResolution

public static void setNeedScreenResolution(float newValue,
                                           java.awt.Component c)

getToolkitScreenResolution

public static float getToolkitScreenResolution()

setDoPredictionCorrection

public void setDoPredictionCorrection(boolean doPredictionCorrection)

isDoPredictionCorrection

public boolean isDoPredictionCorrection()