org.concord.collisions.engine
Class JAtom

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

public class JAtom
extends JWorldElement
implements java.io.Serializable

one of implementation of JWorldElement abstract class

Author:
Dmitry Markman
See Also:
Serialized Form

Inner Class Summary
static class JAtom.AtomDraggable
           
static class JAtom.VelocityDraggable
           
 
Field Summary
static float DEFAULT_MASS
           
static float DEFAULT_RADIUS
           
protected  boolean drawAllVelocityComponents
           
protected  boolean drawOnlyFrame
           
 boolean flashState
          creates instance of the JAtom class with default mass and default radius
protected  float r
           
protected  java.awt.Color traceColor
           
protected  java.awt.Color velColor
           
protected  int widthr
           
 
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
JAtom()
           
 
Method Summary
 void addNeighborX(JWorldElement element0, JWorldElement element1)
           
 void addNeighborY(JWorldElement element0, JWorldElement element1)
           
 void calculateAcceleration()
           
 void clearTrace()
          clears trace
 void correctV(float dt)
           
static JAtom createAtom(float ax, float ay, float avx, float avy)
          factory method (default radius and mass).
static JAtom createAtom(float ax, float ay, float ar, float avx, float avy)
          factory method (default mass).
static JAtom createAtom(GUIPanel panel, float ax, float ay, float avx, float avy)
          factory method (default radius and mass).
static JAtom createAtom(GUIPanel panel, float ax, float ay, float ar, float avx, float avy)
          factory method (default mass).
static JAtom createMotionlessAtom(float ax, float ay)
          factory method (default mass).
static JAtom createMotionlessAtom(float ax, float ay, float r)
          factory method (default mass).
 void doDrag(CCCoordinateTuner tuner, int x, int y)
           
protected  void emptyTrace()
           
 void endDrag(CCCoordinateTuner tuner, int x, int y)
           
 CCDraggable getAtomDraggable(int dragMode)
           
 float getCMPointX()
          calculates X coordinate of center of mass
 float getCMPointY()
          calculates Y coordinate of center of mass
 java.awt.Color getColor()
           
 java.lang.Object getDraggableOwner()
           
 int getDragMode()
           
 boolean getDrawAllVelocityComponents()
           
 boolean getDrawOnlyFrame()
           
 CCDraggable getForceDraggable(float x, float y)
           
 int getNumbDrawTracePoints()
           
 int getNumbSkipTracePoints()
           
 float getR()
           
 java.awt.Color getTraceColor()
           
 java.awt.Color getVelColor()
           
 CCDraggable getVelocityDraggable(char whichVelocity)
           
 int getVelXArrowEnd()
           
 int getVelYArrowEnd()
           
 float getX()
           
 JWorldElement[] getXNeighbors()
           
 float getXPotentialEnergy()
           
 float getXTemperature()
           
 float getY()
           
 JWorldElement[] getYNeighbors()
           
 float getYPotentialEnergy()
           
 float getYTemperature()
           
 void initElement()
           
 boolean isDoTrace()
           
 boolean isPointInside(float px, float py)
           
 void notifyAreaListener()
           
 void paint(java.awt.Graphics g, java.awt.Graphics sg)
           
 void paintAtom(java.awt.Graphics g, java.awt.Graphics sg)
           
 void paintForces(java.awt.Graphics g)
           
 void paintSelection(java.awt.Graphics g)
           
 void paintTrace(java.awt.Graphics g)
           
 boolean panelInfoSupport()
           
 void rememberCurrPosAsInit()
           
 void rememberCurrVelAsInit()
           
 void setAnimIcon(java.lang.String url)
           
 void setCMPointX(float x)
          set X coordinate of center of mass
 void setCMPointY(float y)
          set Y coordinate of center of mass
 void setCoord(float x, float y)
          set atom's coordinates
 void setDoTrace(boolean dotrace)
           
 void setDragMode(int m)
           
 void setDrawAllVelocityComponents(boolean drawAllVelocityComponents)
           
 void setDrawOnlyFrame(boolean drawOnlyFrame)
           
 void setGeometry(float x, float y, float r)
          set geometry's parameters
 void setGeometry(GUIPanel panel, float x, float y, float r)
          set geometry's parameters
 void setGeometry(java.lang.Object object)
           
 void setIcon(java.lang.String url)
          sets icon to show by default the icon is as big as the atom and scales with it!!!
 void setInfoDrawer(CCInfoDrawer infoDrawer)
           
 void setNumbDrawTracePoints(int numbDrawTracePoints)
           
 void setNumbSkipTracePoints(int numbSkipTracePoints)
           
 void setProperty(java.lang.String name, java.lang.Object val)
          set propertie's value
 void setR(float r)
           
 void setTraceColor(java.awt.Color traceColor)
          set trace's color
 void setTraceProperties(int traceLength)
           
 void setTraceProperties(int traceLength, int drawPoints, int skipPoints)
           
 void setVelColor(java.awt.Color velColor)
          set color for velocity's arrows
 void setVx(float vx)
          set element's velocity
 void setVy(float vy)
           
 void shift(float dt)
          shift atom
 void shiftV(float dt)
           
 void startDrag(int x, int y)
           
 
Methods inherited from class org.concord.collisions.engine.JWorldElement
addAreaListener, addAreaListener, addAreaListener, addAreaListener, addAreaToListen, addAreaToListen, addAreaToListen, addAreaToListen, addElementListener, addElemMouseListener, addPropertyChangeListener, applyForce, assignIndNumber, clearConstraints, clearForces, clearIcon, closeEverything, 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, getY, getYacceleration, isCollisionSensitive, isConstraintsWasSet, isControllable, isDraggable, isEnabled, isFlashing, isMoveable, isPointInside, isPressedState, isSelected, isVisible, 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, setQTIcon, setQTIcon, setQTMovie, setShowAcceleration, setShowVelocity, setVisible, 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

r

protected float r

widthr

protected int widthr

DEFAULT_MASS

public static final float DEFAULT_MASS

DEFAULT_RADIUS

public static final float DEFAULT_RADIUS

velColor

protected java.awt.Color velColor

traceColor

protected java.awt.Color traceColor

drawOnlyFrame

protected boolean drawOnlyFrame

drawAllVelocityComponents

protected boolean drawAllVelocityComponents

flashState

public boolean flashState
creates instance of the JAtom class with default mass and default radius
Constructor Detail

JAtom

public JAtom()
Method Detail

initElement

public void initElement()
Overrides:
initElement in class JWorldElement

rememberCurrPosAsInit

public void rememberCurrPosAsInit()
Overrides:
rememberCurrPosAsInit in class JWorldElement

rememberCurrVelAsInit

public void rememberCurrVelAsInit()
Overrides:
rememberCurrVelAsInit in class JWorldElement

createAtom

public static JAtom createAtom(float ax,
                               float ay,
                               float avx,
                               float avy)
factory method (default radius and mass).
Parameters:
ax - atom's x coordinate
ay - atom's y coordinate
avx - atom's horizontal velocity
avy - atom's vertical velocity
Returns:
JAtom instance

createAtom

public static JAtom createAtom(float ax,
                               float ay,
                               float ar,
                               float avx,
                               float avy)
factory method (default mass).
Parameters:
ax - atom's x coordinate
ay - atom's y coordinate
r - atom's radius (minimum 1)
avx - atom's horizontal velocity
avy - atom's vertical velocity
Returns:
JAtom instance

createAtom

public static JAtom createAtom(GUIPanel panel,
                               float ax,
                               float ay,
                               float avx,
                               float avy)
factory method (default radius and mass).
Parameters:
ax - atom's x coordinate
ay - atom's y coordinate
avx - atom's horizontal velocity
avy - atom's vertical velocity
Returns:
JAtom instance

createAtom

public static JAtom createAtom(GUIPanel panel,
                               float ax,
                               float ay,
                               float ar,
                               float avx,
                               float avy)
factory method (default mass).
Parameters:
ax - atom's x coordinate
ay - atom's y coordinate
r - atom's radius (minimum 1)
avx - atom's horizontal velocity
avy - atom's vertical velocity
Returns:
JAtom instance

createMotionlessAtom

public static JAtom createMotionlessAtom(float ax,
                                         float ay)
factory method (default mass). creates motionless atom with default radius
Parameters:
ax - atom's x coordinate
ay - atom's y coordinate
Returns:
JAtom instance

createMotionlessAtom

public static JAtom createMotionlessAtom(float ax,
                                         float ay,
                                         float r)
factory method (default mass). creates motionless atom
Parameters:
ax - atom's x coordinate
ay - atom's y coordinate
r - atom's radius (minimum 1)
Returns:
JAtom instance

setGeometry

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

setGeometry

public void setGeometry(float x,
                        float y,
                        float r)
                 throws java.lang.Exception
set geometry's parameters
Parameters:
x - atom's x coordinate
y - atom's y coordinate
r - atom's radius (minimum 1)

setGeometry

public void setGeometry(GUIPanel panel,
                        float x,
                        float y,
                        float r)
                 throws java.lang.Exception
set geometry's parameters
Parameters:
x - atom's x coordinate
y - atom's y coordinate
r - atom's radius (minimum 1)

paint

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

paintForces

public void paintForces(java.awt.Graphics g)

paintTrace

public void paintTrace(java.awt.Graphics g)

getColor

public java.awt.Color getColor()
Overrides:
getColor in class JWorldElement

getVelXArrowEnd

public int getVelXArrowEnd()

getVelYArrowEnd

public int getVelYArrowEnd()

getDrawOnlyFrame

public boolean getDrawOnlyFrame()

setDrawOnlyFrame

public void setDrawOnlyFrame(boolean drawOnlyFrame)

getDrawAllVelocityComponents

public boolean getDrawAllVelocityComponents()

setDrawAllVelocityComponents

public void setDrawAllVelocityComponents(boolean drawAllVelocityComponents)

paintSelection

public void paintSelection(java.awt.Graphics g)
Overrides:
paintSelection in class JWorldElement

paintAtom

public void paintAtom(java.awt.Graphics g,
                      java.awt.Graphics sg)

getVelColor

public java.awt.Color getVelColor()
Returns:
color of velocity's arrows

setVelColor

public void setVelColor(java.awt.Color velColor)
set color for velocity's arrows
Parameters:
color - to be set

getTraceColor

public java.awt.Color getTraceColor()
Returns:
trace's color\

setTraceColor

public void setTraceColor(java.awt.Color traceColor)
set trace's color
Parameters:
color - to be set

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object val)
set propertie's value
Overrides:
setProperty in class JWorldElement
Parameters:
property - propertie's name currently supported:
color atom's color
showvel show velocity vector
showvelnumber show velocity values in numbers
toggleshowvel toggle show velocity propertie value
velcolor velocity vector's color
trace trace property (GUIPanel should be ready for drawing trace)
showaccel show acceleration vector
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:
Color, Boolean

isDoTrace

public boolean isDoTrace()

setDoTrace

public void setDoTrace(boolean dotrace)

getX

public float getX()
Overrides:
getX in class JWorldElement
Returns:
atom's x coordinate

getY

public float getY()
Overrides:
getY in class JWorldElement
Returns:
atom's y coordinate

getCMPointX

public float getCMPointX()
calculates X coordinate of center of mass
Returns:
x coordinate of wall's center of mass

getCMPointY

public float getCMPointY()
calculates Y coordinate of center of mass
Returns:
y coordinate of wall's center of mass

setCMPointX

public void setCMPointX(float x)
                 throws CCUnimplOperationException
Description copied from interface: CCMassive
set X coordinate of center of mass
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
Following copied from interface: org.concord.collisions.engine.CCMassive
Parameters:
y - desired Y coordinate of center of mass

getR

public float getR()
Returns:
atom's radius

setR

public void setR(float r)

setVx

public void setVx(float vx)
Description copied from class: JWorldElement
set element's velocity
Overrides:
setVx in class JWorldElement

setVy

public void setVy(float vy)
Overrides:
setVy in class JWorldElement

setIcon

public void setIcon(java.lang.String url)
sets icon to show by default the icon is as big as the atom and scales with it!!!
Parameters:
url - url of the icon file

setAnimIcon

public void setAnimIcon(java.lang.String url)

setCoord

public void setCoord(float x,
                     float y)
set atom's coordinates
Parameters:
x - atom's x coordinate
y - atom's y coordinate

shift

public void shift(float dt)
shift atom
Parameters:
dx - atom's delta x
dy - atom's delta y

calculateAcceleration

public void calculateAcceleration()

shiftV

public void shiftV(float dt)

correctV

public void correctV(float dt)

emptyTrace

protected void emptyTrace()

setTraceProperties

public void setTraceProperties(int traceLength,
                               int drawPoints,
                               int skipPoints)

setTraceProperties

public void setTraceProperties(int traceLength)

clearTrace

public void clearTrace()
clears trace
See Also:
GUIPanel.setTracePossible(boolean)

getXPotentialEnergy

public float getXPotentialEnergy()
Overrides:
getXPotentialEnergy in class JWorldElement

getYPotentialEnergy

public float getYPotentialEnergy()
Overrides:
getYPotentialEnergy in class JWorldElement

getXTemperature

public float getXTemperature()
Overrides:
getXTemperature in class JWorldElement
Returns:
atom's "temperature"

getYTemperature

public float getYTemperature()
Overrides:
getYTemperature in class JWorldElement

notifyAreaListener

public void notifyAreaListener()
Overrides:
notifyAreaListener in class JWorldElement

getDraggableOwner

public java.lang.Object getDraggableOwner()

panelInfoSupport

public boolean panelInfoSupport()

setInfoDrawer

public void setInfoDrawer(CCInfoDrawer infoDrawer)

startDrag

public void startDrag(int x,
                      int y)

doDrag

public void doDrag(CCCoordinateTuner tuner,
                   int x,
                   int y)

endDrag

public void endDrag(CCCoordinateTuner tuner,
                    int x,
                    int y)

getVelocityDraggable

public CCDraggable getVelocityDraggable(char whichVelocity)

getAtomDraggable

public CCDraggable getAtomDraggable(int dragMode)

getForceDraggable

public CCDraggable getForceDraggable(float x,
                                     float y)

getXNeighbors

public JWorldElement[] getXNeighbors()
Overrides:
getXNeighbors in class JWorldElement

getYNeighbors

public JWorldElement[] getYNeighbors()
Overrides:
getYNeighbors in class JWorldElement

addNeighborX

public void addNeighborX(JWorldElement element0,
                         JWorldElement element1)
Overrides:
addNeighborX in class JWorldElement

addNeighborY

public void addNeighborY(JWorldElement element0,
                         JWorldElement element1)
Overrides:
addNeighborY in class JWorldElement

isPointInside

public boolean isPointInside(float px,
                             float py)
Overrides:
isPointInside in class JWorldElement

getNumbDrawTracePoints

public int getNumbDrawTracePoints()

setNumbDrawTracePoints

public void setNumbDrawTracePoints(int numbDrawTracePoints)

getNumbSkipTracePoints

public int getNumbSkipTracePoints()

setNumbSkipTracePoints

public void setNumbSkipTracePoints(int numbSkipTracePoints)

getDragMode

public int getDragMode()

setDragMode

public void setDragMode(int m)