Package org.opensourcephysics.display
Class AbstractInteractive
java.lang.Object
org.opensourcephysics.display.AbstractInteractive
- All Implemented Interfaces:
Drawable
,Interactive
,Measurable
- Direct Known Subclasses:
InteractiveShape
AbstractInteractive implements common Interactive methods.
- Version:
- 1.0
- Author:
- Wolfgang Christian
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
draw
(DrawingPanel panel, Graphics g) Draws the object.findInteractive
(DrawingPanel panel, int xpix, int ypix) Finds the interactive object that will respond to mouse actions.double
getX()
Gets the x coordinate.double
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 coordinate.double
getYMax()
Gets the maximum y needed to draw this object.double
getYMin()
Gets the minimum y needed to draw this object.boolean
abstract boolean
isInside
(DrawingPanel panel, int xpix, int ypix) Checks to see if this object is enabled and if the pixel coordinates are inside the drawable.boolean
Determines if information is available to set min/max values.void
setEnabled
(boolean _enabled) Sets the enabled flag.void
setX
(double _x) Sets the x coordinate.void
setXY
(double _x, double _y) Sets the x and y coordinates.void
setY
(double _y) Sets the y coordinate.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.opensourcephysics.display.Interactive
isInteractive
-
Field Details
-
color
-
x
protected double x -
y
protected double y
-
-
Constructor Details
-
AbstractInteractive
public AbstractInteractive()
-
-
Method Details
-
draw
Draws the object. -
isInside
Checks to see if this object is enabled and if the pixel coordinates are inside the drawable.- Parameters:
panel
-xpix
-ypix
-- Returns:
- true if the pixel coordinates are inside; false otherwise
-
setEnabled
public void setEnabled(boolean _enabled) Sets the enabled flag.- Specified by:
setEnabled
in interfaceInteractive
- Parameters:
_enabled
-
-
isEnabled
public boolean isEnabled()- Specified by:
isEnabled
in interfaceInteractive
-
setXY
public void setXY(double _x, double _y) Sets the x and y coordinates.- Specified by:
setXY
in interfaceInteractive
- Parameters:
_x
-_y
-
-
findInteractive
Finds the interactive object that will respond to mouse actions.- Specified by:
findInteractive
in interfaceInteractive
- Parameters:
panel
- DrawingPanelxpix
- intypix
- int- Returns:
- Interactive
-
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
-
getX
public double getX()Gets the x coordinate.- Specified by:
getX
in interfaceInteractive
- Returns:
- double x
-
setX
public void setX(double _x) Sets the x coordinate.- Specified by:
setX
in interfaceInteractive
- Parameters:
_x
-
-
getY
public double getY()Gets the y coordinate.- Specified by:
getY
in interfaceInteractive
- Returns:
- double y
-
setY
public void setY(double _y) Sets the y coordinate.- Specified by:
setY
in interfaceInteractive
- Parameters:
_y
-
-