|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.opensourcephysics.display.axes.AbstractAxes
org.opensourcephysics.display.axes.CartesianType1
public class CartesianType1
A modified version of the ptolemy.plot.PlotBox class designed to work with the OSP drawing framework. See Ptolemy Group Java at UC Berkeley for more information. This class provides a labeled box within which to place a data plot. A title, X and Y axis labels, and tick marks are all supported. The tick marks for the axes are usually computed automatically from the ranges. Every attempt is made to choose reasonable positions for the tick marks regardless of the data ranges (powers of ten multiplied by 1, 2, or 5 are used). However, they can also be specified explicitly using the methods addXTick and addYTick. A label is a string that must be surrounded by quotation marks if it contains any spaces. A position is a number giving the location of the tick mark along the axis. For example, a horizontal axis for a frequency domain plot might have tick marks as follows:
XTicks: -PI -3.14159, -PI/2 -1.570795, 0 0, PI/2 1.570795, PI 3.14159Tick marks could also denote years, months, days of the week, etc. Exponents are not drawn if min and max values are between 0 and 1000 and a linear scale is used.
The X and Y axes can also use a logarithmic scale. The grid labels represent powers of 10. Note that if a logarithmic scale is used, then the values (before the log of the value is taken) must be positive. Non-positive values will be silently dropped. By default, tick marks are connected by a light grey background grid.
| Field Summary | |
|---|---|
protected DrawableTextLine |
xLine
The title and label strings. |
protected DrawableTextLine |
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 | |
|---|---|
CartesianType1(PlottingPanel panel)
Constructor for the AxesType1 object |
|
| Method Summary | |
|---|---|
void |
addXTick(java.lang.String label,
double position)
Specify a tick mark for the X axis. |
void |
addYTick(java.lang.String label,
double position)
Specify a tick mark for the Y axis. |
void |
draw(DrawingPanel panel,
java.awt.Graphics g)
Draws the plot by implementing the drawable interface. |
protected void |
drawPlot(DrawingPanel panel,
java.awt.Graphics graphics)
Draws the axes onto the specified panel |
java.awt.Dimension |
getInterior(DrawingPanel panel)
Implements the Dimensioned interface. |
java.lang.String |
getTitle()
Get the title of the graph, or an empty string if there is none. |
double |
getX()
Gets the drawing location. |
java.lang.String |
getXLabel()
Get the label for the X (horizontal) axis, or null if none has been set. |
double |
getY()
Gets the drawing location. |
java.lang.String |
getYLabel()
Get the label for the Y (vertical) axis, or null if none has been set. |
boolean |
isXLog()
Return whether the X axis is drawn with a logarithmic scale. |
boolean |
isYLog()
Return whether the Y axis is drawn with a logarithmic scale. |
void |
resizeFonts(double factor,
DrawingPanel panel)
Resizes fonts by the specified factor. |
void |
setLabelFont(java.lang.String name)
Set the label font, which is used for axis labels and legend labels. |
void |
setShowMajorXGrid(boolean showGrid)
Shows a grid line for every x axis major tickmark. |
void |
setShowMajorYGrid(boolean showGrid)
Shows a grid line for every y axis major tickmark. |
void |
setShowMinorXGrid(boolean showGrid)
Shows a grid line for every x axis minor tickmark. |
void |
setShowMinorYGrid(boolean showGrid)
Shows a grid line for every y axis minor tickmark. |
void |
setTitle(java.lang.String title,
java.lang.String font_name)
Set the title of the graph. |
void |
setTitleFont(java.lang.String name)
Set the title font. |
void |
setX(double x)
Sets the drawing location. |
void |
setXLabel(java.lang.String label,
java.lang.String font_name)
Set the label for the X (horizontal) axis. |
void |
setXLog(boolean xlog)
Specify whether the X axis is drawn with a logarithmic scale. |
void |
setY(double y)
Sets the drawing location. |
void |
setYLabel(java.lang.String label,
java.lang.String font_name)
Set the label for the Y (vertical) axis. |
void |
setYLog(boolean ylog)
Specify whether the Y axis is drawn with a logarithmic scale. |
| 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.axes.DrawableAxes |
|---|
getInteriorBackground, setInteriorBackground, setVisible |
| Field Detail |
|---|
protected DrawableTextLine xLine
protected DrawableTextLine yLine
| Constructor Detail |
|---|
public CartesianType1(PlottingPanel panel)
panel - the panel on which this axes is drawn| Method Detail |
|---|
public void draw(DrawingPanel panel,
java.awt.Graphics g)
draw in interface Drawablepanel - g -
public void addXTick(java.lang.String label,
double position)
label - The label for the tick mark.position - The position on the X axis.
public void addYTick(java.lang.String label,
double position)
label - The label for the tick mark.position - The position on the Y axis.public void setLabelFont(java.lang.String name)
name - A font name.
public void setTitle(java.lang.String title,
java.lang.String font_name)
setTitle in interface DrawableAxessetTitle in class AbstractAxestitle - the titlefont_name - an optional font namepublic void setTitleFont(java.lang.String name)
name - A font name.
public void setXLabel(java.lang.String label,
java.lang.String font_name)
setXLabel in interface DrawableAxeslabel - the labelfont_name - an optional font namepublic void setXLog(boolean xlog)
setXLog in interface CartesianAxesxlog - If true, logarithmic axis is used.
public void setYLabel(java.lang.String label,
java.lang.String font_name)
setYLabel in interface DrawableAxeslabel - the labelfont_name - an optional font namepublic void setYLog(boolean ylog)
setYLog in interface CartesianAxesylog - If true, logarithmic axis is used.public java.lang.String getTitle()
getTitle in interface DrawableAxesgetTitle in class AbstractAxespublic java.lang.String getXLabel()
getXLabel in interface DrawableAxespublic boolean isXLog()
isXLog in interface CartesianAxespublic java.lang.String getYLabel()
getYLabel in interface DrawableAxespublic boolean isYLog()
isYLog in interface CartesianAxes
public void resizeFonts(double factor,
DrawingPanel panel)
resizeFonts in interface DrawableAxesresizeFonts in class AbstractAxesfactor - the factorpanel - the drawing panel on which these axes are drawn
protected void drawPlot(DrawingPanel panel,
java.awt.Graphics graphics)
panel - graphics - public void setShowMajorXGrid(boolean showGrid)
setShowMajorXGrid in interface DrawableAxesshowGrid - The new drawMajorXGrid valuepublic void setShowMinorXGrid(boolean showGrid)
setShowMinorXGrid in interface DrawableAxesshowGrid - The new drawMinorXGrid valuepublic void setShowMajorYGrid(boolean showGrid)
setShowMajorYGrid in interface DrawableAxesshowGrid - The new drawMajorYGrid valuepublic void setShowMinorYGrid(boolean showGrid)
setShowMinorYGrid in interface DrawableAxesshowGrid - The new drawMinorYGrid valuepublic void setX(double x)
CartesianAxes
setX in interface CartesianAxespublic void setY(double y)
CartesianAxes
setY in interface CartesianAxespublic double getX()
CartesianAxes
getX in interface CartesianAxespublic double getY()
CartesianAxes
getY in interface CartesianAxespublic java.awt.Dimension getInterior(DrawingPanel panel)
getInterior in interface Dimensionedpanel - DrawingPanel
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||