org.concord.collisions.engine
Class JWorldElement

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

public abstract class JWorldElement
extends java.lang.Object
implements java.io.Serializable, java.beans.PropertyChangeListener, CCDraggable, CCMassive

See Also:
Serialized Form

Field Summary
protected  float acx
           
protected  float acy
           
protected  AreaListener areaListener
           
protected  java.util.Hashtable areaTables
           
protected  boolean collSensitive
           
protected  boolean controllable
           
protected static float DEFAULT_MAX_CONSTRAINT
           
protected static float DEFAULT_MIN_CONSTRAINT
           
protected  boolean doProjection
           
protected  boolean draggable
           
protected  java.util.Vector elementListeners
           
protected  boolean flashing
           
protected  int iconHeight
           
protected  int iconWidth
           
protected  int index
           
protected  CCImageViewer iviewer
           
 float mass
           
protected  java.lang.String name
           
protected  boolean pressedState
           
protected  java.util.Vector propertyListeners
           
protected  PassiveQTImage qtIcon
           
protected  PassiveQTMovie qtMovie
           
protected  java.awt.Rectangle[] rectsForListener
           
protected  boolean scaleIcon
           
protected  boolean showAcceleration
           
protected  boolean showVelocity
           
protected  boolean showVelocityNumber
           
 float suggestedCollisionTime
           
protected  javax.swing.ImageIcon swingIcon
           
protected static int vel_scale
           
protected  float vx
           
protected  float vy
           
 boolean wasLastStepCollision
           
 
Constructor Summary
JWorldElement()
           
 
Method Summary
 void addAreaListener(AreaListener l, int x, int y, int width, int height)
           
 void addAreaListener(AreaListener l, int id, int x, int y, int width, int height)
           
 void addAreaListener(AreaListener l, int id, PassiveElement pe)
           
 void addAreaListener(AreaListener l, PassiveElement pe)
           
 void addAreaToListen(AreaListener l, int x, int y, int width, int height)
           
 void addAreaToListen(AreaListener l, int id, int x, int y, int width, int height)
           
 void addAreaToListen(AreaListener l, int id, PassiveElement pe)
           
 void addAreaToListen(AreaListener l, PassiveElement pe)
           
 void addElementListener(ElementListener listener)
           
 void addElemMouseListener(ElemMouseListener l)
          Add a mouse listener
 void addNeighborX(JWorldElement element0, JWorldElement element1)
           
 void addNeighborY(JWorldElement element0, JWorldElement element1)
           
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void applyForce(CCForce force)
          Apply force to the JWorldElement.
 void assignIndNumber(int indNumber)
           
 void clearConstraints()
           
 void clearForces()
          remove all applied forces
 void clearIcon()
          sets icon to don't show
 void closeEverything()
           
protected  void createDefaultCalculator()
           
 CCDraggable findDraggable(float x, float y)
           
 float getAccelerationKoeff()
           
 JWorldElement getCollidedParticle()
           
 java.awt.Color getColor()
           
 boolean getDoProjection()
           
 float getDownConstraint()
           
 java.awt.Color getFlashingColor()
           
 float getFullEnergy()
           
 float getFullXEnergy()
           
 float getFullYEnergy()
           
 float getGravityX()
           
 float getGravityY()
           
 javax.swing.ImageIcon getIcon()
          returns the icon
 int getIconHeight()
          gets the height of the icon to show in pixels
 int getIconWidth()
          gets the width of the icon to show in pixels
 int getIndex()
           
 int getIndNumber()
           
 float getLeftConstraint()
           
 float getMass()
           
 java.lang.String getName()
           
 CCForce getNthForce(int index)
          Nth force applied to JWorldElement
 int getNumbAppliedForces()
          number of applied forces to JWorldElement
 JWorldElement getOwner()
           
 CCElementPositionChanger getPositionChanger()
           
 float getPotentialEnergy()
           
 PassiveQTImage getQTIcon()
          returns the qt icon
 PassiveQTMovie getQTMovie()
          returns the qt movie
 float getRightConstraint()
           
 boolean getShowAcceleration()
           
 boolean getShowVelocity()
           
 float getTemperature()
           
 float getUpConstraint()
           
static int getVelScale()
           
 float getVx()
           
 float getVy()
           
 JPartWorld getWorldModel()
           
abstract  float getX()
           
 float getX(CCUnit unit)
           
 float getXacceleration()
          X projection of acceleration cause by applied forces
 JWorldElement[] getXNeighbors()
           
abstract  float getXPotentialEnergy()
           
abstract  float getXTemperature()
           
abstract  float getY()
           
 float getY(CCUnit unit)
           
 float getYacceleration()
          Y projection of acceleration cause by applied forces
 JWorldElement[] getYNeighbors()
           
abstract  float getYPotentialEnergy()
           
abstract  float getYTemperature()
           
abstract  void initElement()
           
 boolean isCollisionSensitive()
           
 boolean isConstraintsWasSet()
           
 boolean isControllable()
           
 boolean isDraggable()
           
 boolean isEnabled()
          Determine if the JWorldElement is enabled.
 boolean isFlashing()
           
 boolean isMoveable()
           
abstract  boolean isPointInside(float px, float py)
           
 boolean isPointInside(java.awt.Point pt)
           
 boolean isPressedState()
           
 boolean isSelected()
           
 boolean isVisible()
          Determine if the JWorldElement is visible.
 void notifyAreaListener()
           
protected  void notifyElementListeners(ElementEvent evt)
           
 void notifyMouseListeners(float x, float y, int evtType)
           
protected  void notifyPropertyListeners(java.beans.PropertyChangeEvent evt)
           
abstract  void paint(java.awt.Graphics g, java.awt.Graphics sg)
           
abstract  void paintSelection(java.awt.Graphics g)
           
 void paintSelection(java.awt.Graphics g, int width, int height)
           
 void propertyChange(java.beans.PropertyChangeEvent evt)
           
 void rememberCurrAllAsInit()
           
abstract  void rememberCurrPosAsInit()
           
 void rememberCurrPropAsInit()
           
 void rememberCurrPropAsInit(java.lang.String name)
           
abstract  void rememberCurrVelAsInit()
           
 void removeAreaListener(AreaListener l)
           
 void removeAreaToListen(AreaListener l, int x, int y, int width, int height)
           
 void removeAreaToListen(AreaListener l, PassiveElement pe)
           
 void removeElementListener(ElementListener listener)
           
 void removeElemMouseListener(ElemMouseListener l)
          Remove a mouse listener
 void removeForce(CCForce force)
          Remove force applied to the JWorldElement.
 void removeForce(int index)
          Remove Nth force applied to the JWorldElement.
 void removePositionChanger()
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void reverseVx()
           
 void reverseVy()
           
 void select()
           
 void setAnimIcon(java.lang.String url, int width, int height)
           
 void setCollidedParticle(JWorldElement collidedParticle)
           
 void setCollisionSensitive(boolean b)
           
 void setColor(java.awt.Color color)
           
 void setColor(int r, int g, int b)
           
 void setConstraints(float xLeft, float yUp, float xRight, float yDown)
           
 void setControllable(boolean controllable)
           
 void setDoProjection(boolean b)
           
 void setDraggable(boolean draggable)
           
 void setEnabled(boolean enabled)
          Set the enabled state of the JWorldElement.
 void setFlashing(boolean flashing)
           
 void setForceCalculator(CCForceCalculator forceCalculator)
           
abstract  void setGeometry(java.lang.Object object)
           
 void setIcon(javax.swing.ImageIcon icon, int width, int height)
          sets icon to show, specifying width and height in pixels
 void setIcon(java.lang.String url, int width, int height)
          sets icon to show, specifying width and height in pixels
 void setIcon(java.lang.String url, int width, int height, boolean scale)
          sets icon to show, specifying width and height in pixels
 void setIconSize(int width, int height, boolean scale)
          sets the size of the icon to show, specifying width and height in pixels
 void setIndex(int index)
           
 void setMass(float newMass)
           
 void setName(java.lang.String name)
          set name's property
 void setOwner(JWorldElement owner)
           
 void setPositionChanger(CCElementPositionChanger positionChanger)
           
 void setPressedState(boolean pressedState)
           
 void setProperty(java.lang.String name, java.lang.Object val)
           
 void setQTIcon(PassiveQTImage qtIcon)
           
 void setQTIcon(java.lang.String url)
           
 void setQTMovie(PassiveQTMovie qtMovie)
           
 void setShowAcceleration(boolean b)
           
 void setShowVelocity(boolean b)
           
 void setVisible(boolean visible)
          Set the visible state of the JWorldElement.
 void setVx(float vx)
          set element's velocity
 void setVy(float vy)
           
 void setWorldModel(JPartWorld world)
           
 void setXConstraints(float xLeft, float xRight)
           
 void setYConstraints(float yUp, float yDown)
           
 void unselect()
           
 boolean wasCollision()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.concord.collisions.ui.CCDraggable
doDrag, endDrag, getDraggableOwner, getDragMode, panelInfoSupport, setDragMode, setInfoDrawer, startDrag
 
Methods inherited from interface org.concord.collisions.engine.CCMassive
getCMPointX, getCMPointY, setCMPointX, setCMPointY
 

Field Detail

mass

public float mass

name

protected java.lang.String name

suggestedCollisionTime

public float suggestedCollisionTime

wasLastStepCollision

public boolean wasLastStepCollision

index

protected int index

vx

protected float vx

vy

protected float vy

acx

protected float acx

acy

protected float acy

areaTables

protected java.util.Hashtable areaTables

DEFAULT_MIN_CONSTRAINT

protected static final float DEFAULT_MIN_CONSTRAINT

DEFAULT_MAX_CONSTRAINT

protected static final float DEFAULT_MAX_CONSTRAINT

controllable

protected boolean controllable

showVelocity

protected boolean showVelocity

doProjection

protected boolean doProjection

showAcceleration

protected boolean showAcceleration

showVelocityNumber

protected boolean showVelocityNumber

draggable

protected boolean draggable

collSensitive

protected boolean collSensitive

flashing

protected boolean flashing

areaListener

protected AreaListener areaListener

rectsForListener

protected java.awt.Rectangle[] rectsForListener

propertyListeners

protected java.util.Vector propertyListeners

elementListeners

protected java.util.Vector elementListeners

vel_scale

protected static int vel_scale

pressedState

protected boolean pressedState

swingIcon

protected javax.swing.ImageIcon swingIcon

qtIcon

protected PassiveQTImage qtIcon

qtMovie

protected PassiveQTMovie qtMovie

iconWidth

protected int iconWidth

iconHeight

protected int iconHeight

scaleIcon

protected boolean scaleIcon

iviewer

protected CCImageViewer iviewer
Constructor Detail

JWorldElement

public JWorldElement()
Method Detail

getVelScale

public static int getVelScale()

closeEverything

public void closeEverything()

addElementListener

public void addElementListener(ElementListener listener)

removeElementListener

public void removeElementListener(ElementListener listener)

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

addAreaListener

public void addAreaListener(AreaListener l,
                            int id,
                            int x,
                            int y,
                            int width,
                            int height)

addAreaListener

public void addAreaListener(AreaListener l,
                            int x,
                            int y,
                            int width,
                            int height)

addAreaListener

public void addAreaListener(AreaListener l,
                            int id,
                            PassiveElement pe)

addAreaListener

public void addAreaListener(AreaListener l,
                            PassiveElement pe)

addAreaToListen

public void addAreaToListen(AreaListener l,
                            int id,
                            PassiveElement pe)

addAreaToListen

public void addAreaToListen(AreaListener l,
                            PassiveElement pe)

addAreaToListen

public void addAreaToListen(AreaListener l,
                            int x,
                            int y,
                            int width,
                            int height)

addAreaToListen

public void addAreaToListen(AreaListener l,
                            int id,
                            int x,
                            int y,
                            int width,
                            int height)

removeAreaToListen

public void removeAreaToListen(AreaListener l,
                               PassiveElement pe)

removeAreaToListen

public void removeAreaToListen(AreaListener l,
                               int x,
                               int y,
                               int width,
                               int height)

removeAreaListener

public void removeAreaListener(AreaListener l)

setControllable

public void setControllable(boolean controllable)

isControllable

public boolean isControllable()

setFlashing

public void setFlashing(boolean flashing)

isFlashing

public boolean isFlashing()

setDraggable

public void setDraggable(boolean draggable)
Specified by:
setDraggable in interface CCDraggable

isDraggable

public boolean isDraggable()
Specified by:
isDraggable in interface CCDraggable

isCollisionSensitive

public boolean isCollisionSensitive()

setCollisionSensitive

public void setCollisionSensitive(boolean b)

setGeometry

public abstract void setGeometry(java.lang.Object object)
                          throws java.lang.Exception

paint

public abstract void paint(java.awt.Graphics g,
                           java.awt.Graphics sg)

setWorldModel

public void setWorldModel(JPartWorld world)

getWorldModel

public JPartWorld getWorldModel()

assignIndNumber

public void assignIndNumber(int indNumber)

getIndNumber

public int getIndNumber()

setCollidedParticle

public void setCollidedParticle(JWorldElement collidedParticle)

wasCollision

public boolean wasCollision()

getCollidedParticle

public JWorldElement getCollidedParticle()

getMass

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

setMass

public void setMass(float newMass)
             throws java.beans.PropertyVetoException

getName

public java.lang.String getName()
Returns:
name property

setName

public void setName(java.lang.String name)
set name's property
Parameters:
name - property

setColor

public void setColor(java.awt.Color color)

setColor

public void setColor(int r,
                     int g,
                     int b)

getColor

public java.awt.Color getColor()

getFlashingColor

public java.awt.Color getFlashingColor()

setVx

public void setVx(float vx)
set element's velocity

reverseVx

public void reverseVx()

notifyElementListeners

protected void notifyElementListeners(ElementEvent evt)

notifyPropertyListeners

protected void notifyPropertyListeners(java.beans.PropertyChangeEvent evt)

getVx

public float getVx()

setVy

public void setVy(float vy)

reverseVy

public void reverseVy()

getVy

public float getVy()

getX

public abstract float getX()

getY

public abstract float getY()

getX

public float getX(CCUnit unit)

getY

public float getY(CCUnit unit)

setConstraints

public void setConstraints(float xLeft,
                           float yUp,
                           float xRight,
                           float yDown)

setYConstraints

public void setYConstraints(float yUp,
                            float yDown)

setXConstraints

public void setXConstraints(float xLeft,
                            float xRight)

clearConstraints

public void clearConstraints()

isConstraintsWasSet

public boolean isConstraintsWasSet()

getLeftConstraint

public float getLeftConstraint()

getUpConstraint

public float getUpConstraint()

getRightConstraint

public float getRightConstraint()

getDownConstraint

public float getDownConstraint()

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object val)

isMoveable

public boolean isMoveable()

getTemperature

public float getTemperature()

getXTemperature

public abstract float getXTemperature()

getYTemperature

public abstract float getYTemperature()

getPotentialEnergy

public float getPotentialEnergy()

getXPotentialEnergy

public abstract float getXPotentialEnergy()

getYPotentialEnergy

public abstract float getYPotentialEnergy()

getFullEnergy

public float getFullEnergy()

getFullXEnergy

public float getFullXEnergy()

getFullYEnergy

public float getFullYEnergy()

notifyAreaListener

public void notifyAreaListener()

getShowVelocity

public boolean getShowVelocity()

setShowVelocity

public void setShowVelocity(boolean b)

getDoProjection

public boolean getDoProjection()

setDoProjection

public void setDoProjection(boolean b)

getShowAcceleration

public boolean getShowAcceleration()

setShowAcceleration

public void setShowAcceleration(boolean b)

setPressedState

public void setPressedState(boolean pressedState)
Specified by:
setPressedState in interface CCDraggable

isPressedState

public boolean isPressedState()
Specified by:
isPressedState in interface CCDraggable

getGravityX

public float getGravityX()

getGravityY

public float getGravityY()

getAccelerationKoeff

public float getAccelerationKoeff()

getOwner

public JWorldElement getOwner()

setOwner

public void setOwner(JWorldElement owner)

isVisible

public boolean isVisible()
Determine if the JWorldElement is visible.
Returns:
true if JWorldElement is visible.

setVisible

public void setVisible(boolean visible)
Set the visible state of the JWorldElement.
Parameters:
visible - if true, shows this object; otherwise, hides it

isEnabled

public boolean isEnabled()
Determine if the JWorldElement is enabled.
Returns:
true if JWorldElement is enabled.

setEnabled

public void setEnabled(boolean enabled)
Set the enabled state of the JWorldElement.
Parameters:
enabled - if false, this object will be ignored by JPartWorld;

clearForces

public void clearForces()
remove all applied forces

applyForce

public void applyForce(CCForce force)
Apply force to the JWorldElement.
Parameters:
new - force to apply to JWorldElement

removeForce

public void removeForce(CCForce force)
Remove force applied to the JWorldElement.
Parameters:
force - to remove from forces applied to JWorldElement

removeForce

public void removeForce(int index)
Remove Nth force applied to the JWorldElement.
Parameters:
index - of force to remove from forces applied to JWorldElement

getNumbAppliedForces

public int getNumbAppliedForces()
number of applied forces to JWorldElement
Returns:
number of applied forces to JWorldElement

getNthForce

public CCForce getNthForce(int index)
Nth force applied to JWorldElement
Parameters:
index - of force applied to JWorldElement
Returns:
Nth applied forces to JWorldElement

getXacceleration

public float getXacceleration()
X projection of acceleration cause by applied forces
Returns:
X projection of acceleration cause by applied forces

getYacceleration

public float getYacceleration()
Y projection of acceleration cause by applied forces
Returns:
Y projection of acceleration cause by applied forces

createDefaultCalculator

protected void createDefaultCalculator()

setForceCalculator

public void setForceCalculator(CCForceCalculator forceCalculator)

addNeighborX

public void addNeighborX(JWorldElement element0,
                         JWorldElement element1)

addNeighborY

public void addNeighborY(JWorldElement element0,
                         JWorldElement element1)

getXNeighbors

public JWorldElement[] getXNeighbors()

getYNeighbors

public JWorldElement[] getYNeighbors()

setPositionChanger

public void setPositionChanger(CCElementPositionChanger positionChanger)

getPositionChanger

public CCElementPositionChanger getPositionChanger()

removePositionChanger

public void removePositionChanger()

initElement

public abstract void initElement()

rememberCurrPosAsInit

public abstract void rememberCurrPosAsInit()

rememberCurrVelAsInit

public abstract void rememberCurrVelAsInit()

rememberCurrPropAsInit

public void rememberCurrPropAsInit()

rememberCurrPropAsInit

public void rememberCurrPropAsInit(java.lang.String name)

rememberCurrAllAsInit

public void rememberCurrAllAsInit()

getIndex

public int getIndex()

setIndex

public void setIndex(int index)

setQTMovie

public void setQTMovie(PassiveQTMovie qtMovie)

setQTIcon

public void setQTIcon(PassiveQTImage qtIcon)

setQTIcon

public void setQTIcon(java.lang.String url)

setIcon

public void setIcon(javax.swing.ImageIcon icon,
                    int width,
                    int height)
sets icon to show, specifying width and height in pixels
Parameters:
icon - swing icon already created

setIcon

public void setIcon(java.lang.String url,
                    int width,
                    int height)
sets icon to show, specifying width and height in pixels
Parameters:
url - url of the icon file
width - width of the icon in pixels
height - height of the icon in pixels
scale - indicates whether the icon will be scaled if the atom changes size

setIcon

public void setIcon(java.lang.String url,
                    int width,
                    int height,
                    boolean scale)
sets icon to show, specifying width and height in pixels
Parameters:
url - url of the icon file
width - width of the icon in pixels
height - height of the icon in pixels
scale - indicates whether the icon will be scaled if the atom changes size

setAnimIcon

public void setAnimIcon(java.lang.String url,
                        int width,
                        int height)

setIconSize

public void setIconSize(int width,
                        int height,
                        boolean scale)
sets the size of the icon to show, specifying width and height in pixels
Parameters:
width - width of the icon in pixels
height - height of the icon in pixels
scale - indicates whether the icon will be scaled if the atom changes size

clearIcon

public void clearIcon()
sets icon to don't show

getIcon

public javax.swing.ImageIcon getIcon()
returns the icon

getIconHeight

public int getIconHeight()
gets the height of the icon to show in pixels

getIconWidth

public int getIconWidth()
gets the width of the icon to show in pixels

getQTIcon

public PassiveQTImage getQTIcon()
returns the qt icon

getQTMovie

public PassiveQTMovie getQTMovie()
returns the qt movie

isPointInside

public boolean isPointInside(java.awt.Point pt)

isPointInside

public abstract boolean isPointInside(float px,
                                      float py)

notifyMouseListeners

public void notifyMouseListeners(float x,
                                 float y,
                                 int evtType)
Specified by:
notifyMouseListeners in interface CCDraggable

addElemMouseListener

public void addElemMouseListener(ElemMouseListener l)
Add a mouse listener
Parameters:
l - mouse listener to add

removeElemMouseListener

public void removeElemMouseListener(ElemMouseListener l)
Remove a mouse listener
Parameters:
l - mouse listener to remove

isSelected

public boolean isSelected()

select

public void select()

unselect

public void unselect()

paintSelection

public abstract void paintSelection(java.awt.Graphics g)

paintSelection

public void paintSelection(java.awt.Graphics g,
                           int width,
                           int height)

findDraggable

public CCDraggable findDraggable(float x,
                                 float y)