org.opensourcephysics.drawing2d
Class ElementSpring

java.lang.Object
  extended by org.opensourcephysics.drawing2d.Element
      extended by org.opensourcephysics.drawing2d.ElementSegment
          extended by org.opensourcephysics.drawing2d.ElementSpring
All Implemented Interfaces:
Drawable, Interactive, LogMeasurable, Measurable

public class ElementSpring
extends ElementSegment

Title: ElementSpring

Description: A spring.

Version:
June 2008
Author:
Francisco Esquembre

Field Summary
static int DEF_LOOPS
           
static int DEF_PPL
           
static double DEF_RADIUS
           
 
Fields inherited from class org.opensourcephysics.drawing2d.Element
TARGET_POSITION, TARGET_SIZE
 
Constructor Summary
ElementSpring()
           
 
Method Summary
 void draw(DrawingPanel _panel, java.awt.Graphics _g)
          Draws the element on a given Graphics2D.
 int getLoops()
          Returns the number of loops of the spring
 int getPointsPerLoop()
          Returns the number of points per loop
 double getRadius()
          Gets the radius of the spring.
 double getSolenoid()
          Returns the double factor used to make the spring look like a solenoid.
 boolean isThinExtremes()
          Whether the extremes of the spring should be thin.
 void setRadius(double radius)
          Sets the radius of the spring.
 void setResolution(int _loops, int _ppl)
          Configures the number of points used to display the spring
 void setSolenoid(double _sol)
          A double factor that makes the spring look like a solenoid.
 void setThinExtremes(boolean _thin)
          Whether the extremes of the spring should be thin.
 
Methods inherited from class org.opensourcephysics.drawing2d.ElementSegment
findInteractive
 
Methods inherited from class org.opensourcephysics.drawing2d.Element
addInteractionListener, getCanBeMeasured, getDataObject, getInteractionTarget, getName, getPanel, getPosition, getSize, getSizeX, getSizeY, getStyle, getTransformation, getX, getXMax, getXMaxLogscale, getXMin, getXMinLogscale, getY, getYMax, getYMaxLogscale, getYMin, getYMinLogscale, hasChanged, invokeActions, isEnabled, isMeasured, isVisible, removeInteractionListener, setCanBeMeasured, setDataObject, setElementChanged, setEnabled, setName, setNeedToProject, setPanel, setPosition, setSize, setSizeX, setSizeXY, setSizeY, setTransformation, setVisible, setX, setXY, setY, toBodyFrame, toSpaceFrame, updateHotSpot
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEF_RADIUS

public static final double DEF_RADIUS
See Also:
Constant Field Values

DEF_LOOPS

public static final int DEF_LOOPS
See Also:
Constant Field Values

DEF_PPL

public static final int DEF_PPL
See Also:
Constant Field Values
Constructor Detail

ElementSpring

public ElementSpring()
Method Detail

setRadius

public void setRadius(double radius)
Sets the radius of the spring.

Parameters:
radius - the radius of the spring (normal to its direction)

getRadius

public double getRadius()
Gets the radius of the spring.


setSolenoid

public void setSolenoid(double _sol)
A double factor that makes the spring look like a solenoid.

Parameters:
_sol -

getSolenoid

public double getSolenoid()
Returns the double factor used to make the spring look like a solenoid.

Returns:

setThinExtremes

public void setThinExtremes(boolean _thin)
Whether the extremes of the spring should be thin. True by default

Parameters:
_thin -

isThinExtremes

public boolean isThinExtremes()
Whether the extremes of the spring should be thin.

Returns:

setResolution

public void setResolution(int _loops,
                          int _ppl)
Configures the number of points used to display the spring

Parameters:
loops - the number of total loops
pointsPerLoop - the number of points per loop

getLoops

public int getLoops()
Returns the number of loops of the spring

Returns:

getPointsPerLoop

public int getPointsPerLoop()
Returns the number of points per loop

Returns:

draw

public void draw(DrawingPanel _panel,
                 java.awt.Graphics _g)
Description copied from class: Element
Draws the element on a given Graphics2D. Required by Drawable (in Interactive)

Specified by:
draw in interface Drawable
Overrides:
draw in class ElementSegment