org.opensourcephysics.display.axes
Class XYAxis

java.lang.Object
  extended by org.opensourcephysics.display.axes.XYAxis
All Implemented Interfaces:
Drawable, Interactive, Measurable
Direct Known Subclasses:
XAxis, YAxis

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

A superclass for the x axis and y axis.

Version:
1.0
Author:
Wolfgang Christian

Field Summary
static int DRAW_AT_LOCATION
          Field DRAW_AT_LOCATION
static int DRAW_IN_DISPLAY
          Field DRAW_IN_DISPLAY
static int DRAW_IN_GUTTER
          Field DRAW_IN_GUTTER
static int LINEAR
          Field LINEAR
static int LOG10
          Field LOG10
protected  double x
           
protected  double y
           
 
Constructor Summary
XYAxis()
          Constructor XYAxis
 
Method Summary
 void calculateLabels(double minimum, double maximum, int numTicks)
          Calculates the axis labels.
abstract  void draw(DrawingPanel panel, java.awt.Graphics g)
          Draws the axis in a drawing panel.
protected  void drawMultiplier(int xpix, int ypix, int exponent, java.awt.Graphics2D g2)
           
 Interactive findInteractive(DrawingPanel panel, int _xpix, int _ypix)
           
 double getX()
           
 double getXMax()
          Gets the maximum x needed to draw this object.
 double getXMin()
          Gets the minimum x needed to draw this object.
 double getY()
           
 double getYMax()
          Gets the maximum y needed to draw this object.
 double getYMin()
          Gets the minimum y needed to draw this object.
 boolean isEnabled()
           
 boolean isMeasured()
          Determines if information is available to set min/max values.
static double log10(double x)
           
 void setAxisType(int type)
          Method setAxisType
 void setEnabled(boolean _enabled)
           
 void setLabelFormat(java.text.DecimalFormat format)
          Method setLabelFormat
 void setLabelFormat(java.lang.String formatString)
          Method setLabelFormat
 void setLocation(double _location)
          Sets the location type.
 void setLocationType(int _locationType)
          Sets the location type.
 void setShowMajorGrid(boolean show)
           
 void setTitle(java.lang.String title)
          Sets the title.
 void setTitle(java.lang.String title, java.lang.String font_name)
          Sets the title.
 void setTitleFont(java.lang.String name)
          Set the title font.
 void setX(double x)
           
 void setXY(double x, double y)
           
 void setY(double y)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DRAW_IN_DISPLAY

public static final int DRAW_IN_DISPLAY
Field DRAW_IN_DISPLAY

See Also:
Constant Field Values

DRAW_IN_GUTTER

public static final int DRAW_IN_GUTTER
Field DRAW_IN_GUTTER

See Also:
Constant Field Values

DRAW_AT_LOCATION

public static final int DRAW_AT_LOCATION
Field DRAW_AT_LOCATION

See Also:
Constant Field Values

LINEAR

public static final int LINEAR
Field LINEAR

See Also:
Constant Field Values

x

protected double x

y

protected double y

LOG10

public static final int LOG10
Field LOG10

See Also:
Constant Field Values
Constructor Detail

XYAxis

public XYAxis()
Constructor XYAxis

Method Detail

draw

public abstract void draw(DrawingPanel panel,
                          java.awt.Graphics g)
Draws the axis in a drawing panel.

Specified by:
draw in interface Drawable
Parameters:
panel -
g -

setLabelFormat

public void setLabelFormat(java.text.DecimalFormat format)
Method setLabelFormat

Parameters:
format -

setLabelFormat

public void setLabelFormat(java.lang.String formatString)
Method setLabelFormat

Parameters:
formatString -

setLocationType

public void setLocationType(int _locationType)
Sets the location type.

Parameters:
_locationType -

setLocation

public void setLocation(double _location)
Sets the location type.

Parameters:
_location -

setAxisType

public void setAxisType(int type)
Method setAxisType

Parameters:
type -

setTitle

public void setTitle(java.lang.String title,
                     java.lang.String font_name)
Sets the title. The font names understood are those understood by java.awt.Font.decode(). If the font name is null, the font remains unchanged.

Parameters:
title -
font_name - an optional font name

setTitle

public void setTitle(java.lang.String title)
Sets the title.

Parameters:
title -

setTitleFont

public void setTitleFont(java.lang.String name)
Set the title font. The font names understood are those understood by java.awt.Font.decode().

Parameters:
name - A font name.

setShowMajorGrid

public void setShowMajorGrid(boolean show)

drawMultiplier

protected void drawMultiplier(int xpix,
                              int ypix,
                              int exponent,
                              java.awt.Graphics2D g2)

calculateLabels

public void calculateLabels(double minimum,
                            double maximum,
                            int numTicks)
Calculates the axis labels.

Parameters:
minimum -
maximum -
numTicks -

getXMin

public double getXMin()
Gets the minimum x needed to draw this object.

Specified by:
getXMin in interface Measurable
Returns:
minimum

getXMax

public double getXMax()
Gets the maximum x needed to draw this object.

Specified by:
getXMax in interface Measurable
Returns:
maximum

getYMin

public double getYMin()
Gets the minimum y needed to draw this object.

Specified by:
getYMin in interface Measurable
Returns:
minimum

getYMax

public double getYMax()
Gets the maximum y needed to draw this object.

Specified by:
getYMax in interface Measurable
Returns:
minimum

isMeasured

public boolean isMeasured()
Determines if information is available to set min/max values. Objects that store data, Datasets for example, usually return zero if data is null.

Specified by:
isMeasured in interface Measurable
Returns:
true if min/max values are valid

findInteractive

public Interactive findInteractive(DrawingPanel panel,
                                   int _xpix,
                                   int _ypix)
Specified by:
findInteractive in interface Interactive

setEnabled

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

isEnabled

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

setXY

public void setXY(double x,
                  double y)
Specified by:
setXY in interface Interactive

setX

public void setX(double x)
Specified by:
setX in interface Interactive

setY

public void setY(double y)
Specified by:
setY in interface Interactive

getX

public double getX()
Specified by:
getX in interface Interactive

getY

public double getY()
Specified by:
getY in interface Interactive

log10

public static double log10(double x)
                    throws java.lang.ArithmeticException
Parameters:
x - a double value
Returns:
The log10
Throws:
java.lang.ArithmeticException