org.opensourcephysics.display.axes
Class CartesianInteractive

java.lang.Object
  extended by org.opensourcephysics.display.axes.AbstractAxes
      extended by org.opensourcephysics.display.axes.CartesianType1
          extended by org.opensourcephysics.display.axes.CartesianInteractive
All Implemented Interfaces:
CartesianAxes, DrawableAxes, Dimensioned, Drawable, Interactive, Measurable, Selectable

public class CartesianInteractive
extends CartesianType1
implements Selectable

A cartesian axis class that provides interactive scale adjustment with a mouse.


Field Summary
static int HORZ_AXIS
           
static int HORZ_AXIS_MAX
           
static int HORZ_AXIS_MIN
           
static int HORZ_MAX
           
static int HORZ_MIN
           
static int HORZ_VAR
           
static int INSIDE
           
static int VERT_AXIS
           
static int VERT_AXIS_MAX
           
static int VERT_AXIS_MIN
           
static int VERT_MAX
           
static int VERT_MIN
           
static int VERT_VAR
           
 
Fields inherited from class org.opensourcephysics.display.axes.CartesianType1
xLine, yLine
 
Fields inherited from class org.opensourcephysics.display.axes.AbstractAxes
defaultBottomGutter, defaultLeftGutter, defaultRightGutter, defaultTopGutter, drawingPanel, gridcolor, interiorColor, labelFont, labelFormat, superscriptFont, titleFont, titleLine, visible
 
Constructor Summary
CartesianInteractive(PlottingPanel panel)
          Constructs a set of interactive axes for a plotting panel.
 
Method Summary
 void draw(DrawingPanel panel, java.awt.Graphics g)
          Draws the axes.
 Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
           
protected  int findRegion(java.awt.Point p)
          Finds the plot region containing the specified point.
protected  javax.swing.JPopupMenu getHorzVariablesPopup()
          Gets a popup menu with horizontal axis variables.
 int getMouseRegion()
          Gets the current plot region containing the mouse.
 java.awt.Cursor getPreferredCursor()
           
protected  javax.swing.JPopupMenu getVertVariablesPopup()
          Gets a popup menu with vertical axis variables.
 double getX()
          Gets the drawing location.
 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 drawing location.
 double getYMax()
          Gets the maximum y needed to draw this object.
 double getYMin()
          Gets the minimum y needed to draw this object.
protected  boolean hasHorzVariablesPopup()
          Reports whether this provides a popup menu for setting the horizontal axis variable.
protected  boolean hasVertVariablesPopup()
          Reports whether this provides a popup menu for setting the vertical axis variable.
 void hideScaleSetter()
          Hides the scale setter.
 boolean isEnabled()
           
 boolean isMeasured()
          Determines if information is available to set min/max values.
 boolean isSelected()
           
 void resizeFonts(double factor, DrawingPanel panel)
          Resizes fonts by the specified factor.
 void setEnabled(boolean enable)
           
 void setSelected(boolean selectable)
           
 void setXY(double x, double y)
           
 void toggleSelected()
           
 
Methods inherited from class org.opensourcephysics.display.axes.CartesianType1
addXTick, addYTick, drawPlot, getInterior, getTitle, getXLabel, getYLabel, isXLog, isYLog, setLabelFont, setShowMajorXGrid, setShowMajorYGrid, setShowMinorXGrid, setShowMinorYGrid, setTitle, setTitleFont, setX, setXLabel, setXLog, setY, setYLabel, setYLog
 
Methods inherited from class org.opensourcephysics.display.axes.AbstractAxes
getInteriorBackground, isVisible, resetPanelGutters, setDefaultGutters, setInteriorBackground, setVisible
 
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
setX, setY
 
Methods inherited from interface org.opensourcephysics.display.axes.DrawableAxes
getInteriorBackground, setInteriorBackground, setVisible
 

Field Detail

INSIDE

public static final int INSIDE
See Also:
Constant Field Values

HORZ_MIN

public static final int HORZ_MIN
See Also:
Constant Field Values

HORZ_MAX

public static final int HORZ_MAX
See Also:
Constant Field Values

VERT_MIN

public static final int VERT_MIN
See Also:
Constant Field Values

VERT_MAX

public static final int VERT_MAX
See Also:
Constant Field Values

HORZ_AXIS

public static final int HORZ_AXIS
See Also:
Constant Field Values

HORZ_AXIS_MIN

public static final int HORZ_AXIS_MIN
See Also:
Constant Field Values

HORZ_AXIS_MAX

public static final int HORZ_AXIS_MAX
See Also:
Constant Field Values

VERT_AXIS

public static final int VERT_AXIS
See Also:
Constant Field Values

VERT_AXIS_MIN

public static final int VERT_AXIS_MIN
See Also:
Constant Field Values

VERT_AXIS_MAX

public static final int VERT_AXIS_MAX
See Also:
Constant Field Values

HORZ_VAR

public static final int HORZ_VAR
See Also:
Constant Field Values

VERT_VAR

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

CartesianInteractive

public CartesianInteractive(PlottingPanel panel)
Constructs a set of interactive axes for a plotting panel.

Parameters:
panel - the PlottingPanel
Method Detail

getMouseRegion

public int getMouseRegion()
Gets the current plot region containing the mouse.

Returns:
one of the static plot regions defined by CartesianInteractive, or -1

draw

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

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

getX

public double getX()
Description copied from interface: CartesianAxes
Gets the drawing location.

Specified by:
getX in interface CartesianAxes
Specified by:
getX in interface Interactive
Overrides:
getX in class CartesianType1
Returns:
the x location

getY

public double getY()
Description copied from interface: CartesianAxes
Gets the drawing location.

Specified by:
getY in interface CartesianAxes
Specified by:
getY in interface Interactive
Overrides:
getY in class CartesianType1
Returns:
the y location

setSelected

public void setSelected(boolean selectable)
Specified by:
setSelected in interface Selectable

isSelected

public boolean isSelected()
Specified by:
isSelected in interface Selectable

toggleSelected

public void toggleSelected()
Specified by:
toggleSelected in interface Selectable

getPreferredCursor

public java.awt.Cursor getPreferredCursor()
Specified by:
getPreferredCursor in interface Selectable

isEnabled

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

setEnabled

public void setEnabled(boolean enable)
Specified by:
setEnabled in interface Interactive

findInteractive

public Interactive findInteractive(DrawingPanel panel,
                                   int xpix,
                                   int ypix)
Specified by:
findInteractive in interface Interactive

setXY

public void setXY(double x,
                  double y)
Specified by:
setXY in interface 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

hideScaleSetter

public void hideScaleSetter()
Hides the scale setter.


resizeFonts

public void resizeFonts(double factor,
                        DrawingPanel panel)
Resizes fonts by the specified factor.

Specified by:
resizeFonts in interface DrawableAxes
Overrides:
resizeFonts in class CartesianType1
Parameters:
factor - the factor
panel - the drawing panel on which these axes are drawn

hasHorzVariablesPopup

protected boolean hasHorzVariablesPopup()
Reports whether this provides a popup menu for setting the horizontal axis variable.

Returns:
true if this has a popup menu with horizontal axis variables

getHorzVariablesPopup

protected javax.swing.JPopupMenu getHorzVariablesPopup()
Gets a popup menu with horizontal axis variables. This default method returns null; subclasses should override to return a popup with associated action for setting horizontal axis variable.

Returns:
the popup menu

hasVertVariablesPopup

protected boolean hasVertVariablesPopup()
Reports whether this provides a popup menu for setting the vertical axis variable.

Returns:
true if this has a popup menu with vertical axis variables

getVertVariablesPopup

protected javax.swing.JPopupMenu getVertVariablesPopup()
Gets a popup menu with vertical axis variables. This default method returns null; subclasses should override to return a popup with associated action for setting vertical axis variable.

Returns:
the popup menu

findRegion

protected int findRegion(java.awt.Point p)
Finds the plot region containing the specified point.

Parameters:
p - the point
Returns:
one of the static regions defined by CartesianInteractive