Package org.opensourcephysics.display
Class Spring
java.lang.Object
org.opensourcephysics.display.Spring
- All Implemented Interfaces:
Drawable
,Measurable
Draws a coil spring in a drawing panel.
- Version:
- 1.0
- Author:
- F. Esquembre, W. Christian
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Color
protected Stroke
protected boolean
protected int
protected int
protected float
The radius of the spring (normal to its direction)protected float
protected float
protected float
protected boolean
protected boolean
protected float
protected float
protected boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
draw
(DrawingPanel panel, Graphics g) Implementation of Drawable.int
getLoops()
int
double
Get the radius of the spring.double
getSizeX()
Gets the X size of the springdouble
getSizeY()
Gets the Y size of the springdouble
getX()
Gets the X position of the origin of the springdouble
getXMax()
Gets the maximum x needed to draw this object.double
getXMin()
Gets the minimum x needed to draw this object.double
getY()
Gets the Y position of the origin of the springdouble
getYMax()
Gets the maximum y needed to draw this object.double
getYMin()
Gets the minimum y needed to draw this object.boolean
Determines if information is available to set min/max values.boolean
void
setEdgeColor
(Color color) void
setEdgeStroke
(Stroke stroke) void
setRadius
(double radius) Set the radius of the spring.void
setResolution
(int nLoops, int nPointsPerLoop) Sets the number of spires and points per spire used to draw the springvoid
setSizeX
(double sizeX) Sets the X size of the springvoid
setSizeXY
(double sizeX, double sizeY) Sets the size of the springvoid
setSizeY
(double sizeY) Sets the Y size of the springvoid
setSolenoid
(double factor) Sets a double factor that makes the spring look like a solenoid by causing the spires to go back and forth Default is 0, which makes a standard springvoid
setThinExtremes
(boolean thin) Whether the spring should show thin extremes.void
setVisible
(boolean visible) Sets the visibiliby of the springvoid
setX
(double x) Sets the X position of the origin of the springvoid
setXY
(double x, double y) Sets the position of the origin of the springvoid
setY
(double y) Sets the Y position of the origin of the springMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.opensourcephysics.display.Drawable
isInteractive
-
Field Details
-
thinExtremes
protected boolean thinExtremes -
visible
protected boolean visible -
loops
protected int loops -
pointsPerLoop
protected int pointsPerLoop -
x
protected float x -
y
protected float y -
sizex
protected float sizex -
sizey
protected float sizey -
radius
protected float radiusThe radius of the spring (normal to its direction) -
solenoid
protected float solenoid -
edgeColor
-
edgeStroke
-
hasChanged
protected boolean hasChanged -
zeroLength
protected boolean zeroLength
-
-
Constructor Details
-
Spring
public Spring()Constructs a 0.1 radius Spring. -
Spring
public Spring(double _radius) Special constructor that allows to specify the radius of the spring- Parameters:
_radius
- the radius of the spring (normal to its direction)
-
-
Method Details
-
setX
public void setX(double x) Sets the X position of the origin of the spring- Parameters:
x
- double
-
getX
public double getX()Gets the X position of the origin of the spring- Returns:
- double
-
setY
public void setY(double y) Sets the Y position of the origin of the spring- Parameters:
y
- double
-
getY
public double getY()Gets the Y position of the origin of the spring- Returns:
- double
-
setXY
public void setXY(double x, double y) Sets the position of the origin of the spring- Parameters:
x
- doubley
- double
-
setSizeX
public void setSizeX(double sizeX) Sets the X size of the spring- Parameters:
sizeX
- double
-
getSizeX
public double getSizeX()Gets the X size of the spring- Returns:
- double
-
setSizeY
public void setSizeY(double sizeY) Sets the Y size of the spring- Parameters:
sizeY
- double
-
getSizeY
public double getSizeY()Gets the Y size of the spring- Returns:
- double
-
setSizeXY
public void setSizeXY(double sizeX, double sizeY) Sets the size of the spring- Parameters:
sizeX
- doublesizeY
- double
-
setRadius
public void setRadius(double radius) Set the radius of the spring.- Parameters:
_radius
- the radius of the spring (normal to its direction)
-
getRadius
public double getRadius()Get the radius of the spring. -
setVisible
public void setVisible(boolean visible) Sets the visibiliby of the spring- Parameters:
_visible
- boolean
-
isVisible
public boolean isVisible() -
setEdgeColor
-
getEdgeColor
-
setEdgeStroke
-
getEdgeStroke
-
setResolution
public void setResolution(int nLoops, int nPointsPerLoop) Sets the number of spires and points per spire used to draw the spring- Parameters:
nLoops
- intnPointsPerLoop
- int
-
getLoops
public int getLoops() -
getPointsPerLoop
public int getPointsPerLoop() -
setSolenoid
public void setSolenoid(double factor) Sets a double factor that makes the spring look like a solenoid by causing the spires to go back and forth Default is 0, which makes a standard spring- Parameters:
factor
- double
-
setThinExtremes
public void setThinExtremes(boolean thin) Whether the spring should show thin extremes. Default is true- Parameters:
thin
- boolean
-
draw
Implementation of Drawable. -
isMeasured
public boolean isMeasured()Description copied from interface:Measurable
Determines if information is available to set min/max values. Objects that store data should return false if data is null.- Specified by:
isMeasured
in interfaceMeasurable
- Returns:
- true if min/max values are valid
-
getXMin
public double getXMin()Description copied from interface:Measurable
Gets the minimum x needed to draw this object.- Specified by:
getXMin
in interfaceMeasurable
- Returns:
- minimum
-
getXMax
public double getXMax()Description copied from interface:Measurable
Gets the maximum x needed to draw this object.- Specified by:
getXMax
in interfaceMeasurable
- Returns:
- maximum
-
getYMin
public double getYMin()Description copied from interface:Measurable
Gets the minimum y needed to draw this object.- Specified by:
getYMin
in interfaceMeasurable
- Returns:
- minimum
-
getYMax
public double getYMax()Description copied from interface:Measurable
Gets the maximum y needed to draw this object.- Specified by:
getYMax
in interfaceMeasurable
- Returns:
- minimum
-