Class AbstractInteractive

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

public abstract class AbstractInteractive extends Object implements Interactive
AbstractInteractive implements common Interactive methods.
Version:
1.0
Author:
Wolfgang Christian
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
    protected double
     
    protected double
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    Draws the object.
    findInteractive(DrawingPanel panel, int xpix, int ypix)
    Finds the interactive object that will respond to mouse actions.
    double
    Gets the x coordinate.
    double
    Gets the maximum x needed to draw this object.
    double
    Gets the minimum x needed to draw this object.
    double
    Gets the y coordinate.
    double
    Gets the maximum y needed to draw this object.
    double
    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

      public Color color
    • x

      protected double x
    • y

      protected double y
  • Constructor Details

    • AbstractInteractive

      public AbstractInteractive()
  • Method Details

    • draw

      public abstract void draw(DrawingPanel panel, 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 -