org.opensourcephysics.display
Class AbstractInteractive

java.lang.Object
  extended by org.opensourcephysics.display.AbstractInteractive
All Implemented Interfaces:
Drawable, Interactive, Measurable
Direct Known Subclasses:
InteractiveShape

public abstract class AbstractInteractive
extends java.lang.Object
implements Interactive

AbstractInteractive implements common Interactive methods.

Version:
1.0
Author:
Wolfgang Christian

Field Summary
 java.awt.Color color
           
protected  double x
           
protected  double y
           
 
Constructor Summary
AbstractInteractive()
           
 
Method Summary
abstract  void draw(DrawingPanel panel, java.awt.Graphics g)
          Draws the object.
 Interactive 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 isEnabled()
           
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 isMeasured()
          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
 

Field Detail

color

public java.awt.Color color

x

protected double x

y

protected double y
Constructor Detail

AbstractInteractive

public AbstractInteractive()
Method Detail

draw

public abstract void draw(DrawingPanel panel,
                          java.awt.Graphics g)
Draws the object.

Specified by:
draw in interface Drawable
Parameters:
panel - the drawing panel
g - the graphics context

isInside

public 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.

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 interface Interactive
Parameters:
_enabled -

isEnabled

public boolean isEnabled()
Specified by:
isEnabled in interface Interactive

setXY

public void setXY(double _x,
                  double _y)
Sets the x and y coordinates.

Specified by:
setXY in interface Interactive
Parameters:
_x -
_y -

findInteractive

public Interactive findInteractive(DrawingPanel panel,
                                   int xpix,
                                   int ypix)
Finds the interactive object that will respond to mouse actions.

Specified by:
findInteractive in interface Interactive
Parameters:
panel - DrawingPanel
xpix - int
ypix - 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 interface Measurable
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 interface Measurable
Returns:
minimum

getXMax

public double getXMax()
Description copied from interface: Measurable
Gets the maximum x needed to draw this object.

Specified by:
getXMax in interface Measurable
Returns:
maximum

getYMin

public double getYMin()
Description copied from interface: Measurable
Gets the minimum y needed to draw this object.

Specified by:
getYMin in interface Measurable
Returns:
minimum

getYMax

public double getYMax()
Description copied from interface: Measurable
Gets the maximum y needed to draw this object.

Specified by:
getYMax in interface Measurable
Returns:
minimum

getX

public double getX()
Gets the x coordinate.

Specified by:
getX in interface Interactive
Returns:
double x

setX

public void setX(double _x)
Sets the x coordinate.

Specified by:
setX in interface Interactive
Parameters:
_x -

getY

public double getY()
Gets the y coordinate.

Specified by:
getY in interface Interactive
Returns:
double y

setY

public void setY(double _y)
Sets the y coordinate.

Specified by:
setY in interface Interactive
Parameters:
_y -