|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectLayout.PamAxis
public class PamAxis
Draws an axis on a Java Component.
PamAxis contains all the information needed to draw an axis, the actual drawing is generally called from the paintComponent function in the containing window.
for a good example, see PamAxisPanel which will automaticall draw four axis around a central plot.
PamLabel,
PamAxisPanel| Field Summary | |
|---|---|
static int |
ABOVE_LEFT
|
private boolean |
allowScaleMultiples
|
(package private) double |
axisAngle
|
(package private) double |
axisScale
|
(package private) double |
axisValue
|
private java.util.ArrayList<java.lang.Double> |
axisValues
|
static int |
BELOW_RIGHT
|
static int |
BOTH_SIDES
|
private static double[] |
defaultIntervals
|
private static double[] |
defaultScaleEnds
|
private boolean |
drawLine
|
(package private) java.awt.FontMetrics |
fontMetrics
|
private double |
forcedFirstVal
|
private boolean |
forceFirstVal
|
private java.lang.String |
format
|
private boolean |
fractionalScale
Always set the scale interval to be 1/2, 1/4, 1/8, etc of the maximum |
private boolean |
integerFormat
|
private double |
interval
|
static int |
INTERVAL_AUTO
|
private double[] |
intervals
|
private boolean |
intervalStart
|
private java.lang.String |
label
|
static int |
LABEL_NEAR_CENTRE
|
static int |
LABEL_NEAR_MAX
|
static int |
LABEL_NEAR_MIN
|
(package private) double |
labelOffsetX
|
(package private) double |
labelOffsetY
|
private int |
labelPos
|
private boolean |
logScale
|
private boolean |
logTenthsScale
|
(package private) int |
maxLabelHeight
|
(package private) int |
maxLabelWidth
|
private double |
maxVal
|
(package private) static int |
minPixels
|
private double |
minVal
|
private double[] |
scaleEnds
|
(package private) double |
theInterval
|
(package private) double |
tickAngle
|
private int |
tickLength
|
(package private) int[] |
tickLengthX
|
(package private) int[] |
tickLengthY
|
private int |
tickPosition
|
(package private) static int |
TICKS_AUTO
|
(package private) static int |
TICKS_ENDSONLY
|
(package private) double |
tickStepX
|
(package private) double |
tickStepY
|
(package private) double |
totalPixs
|
private int |
x1
|
private int |
x2
|
private int |
y1
|
private int |
y2
|
| Constructor Summary | |
|---|---|
PamAxis(int x1,
int y1,
int x2,
int y2,
double minVal,
double maxVal,
boolean aboveLeft,
java.lang.String label,
java.lang.String format)
|
|
PamAxis(int x1,
int y1,
int x2,
int y2,
double minVal,
double maxVal,
int tickPosition,
java.lang.String label,
int labelPos,
java.lang.String format)
|
|
| Method Summary | |
|---|---|
void |
drawAxis(java.awt.Graphics g)
Draw the axis in the Graphics Context g |
void |
drawAxis(java.awt.Graphics g,
int x1,
int y1,
int x2,
int y2)
Draw the axis in the graphics context g at the given position |
private void |
drawAxisTitle(java.awt.Graphics2D g2d)
|
void |
drawGrid(java.awt.Graphics g,
java.awt.Dimension plotSize,
java.awt.Insets insets,
int minorGrid)
|
void |
drawGrid(java.awt.Graphics g,
java.awt.Dimension plotSize,
int minorGrid)
Draw a grid to go with the axis. |
protected void |
drawLinearAxis(java.awt.Graphics2D g2d)
Draw a linear axis on the graphics context |
private void |
drawLinearMinorGrid(java.awt.Graphics g,
java.util.ArrayList<java.awt.Point> axisPoints,
int xExtent,
int yExtent,
int minorGrid)
|
protected void |
drawLogAxis(java.awt.Graphics2D g2d)
Draw a logarithmic axis on the graphics context |
private void |
drawLogMinorGrid(java.awt.Graphics g,
java.util.ArrayList<java.awt.Point> axisPoints,
int xExtent,
int yExtent,
int minorGrid)
|
private void |
drawTickAndLabel(java.awt.Graphics2D g2d,
double x,
double y,
double value)
Draw a tick and a label at the given point |
protected void |
drawTickAndLabel(java.awt.Graphics2D g2d,
java.awt.Point xy,
double value)
Draw a tick and a label at the given point. |
protected java.lang.String |
formatValue(double val)
Format the text for the label. |
java.util.ArrayList<java.awt.Point> |
getAxisPoints(boolean extraOne)
Work out the coordinates of all tick marks. |
java.util.ArrayList<java.lang.Double> |
getAxisValues()
|
double |
getDataValue(double position)
Converts a position on the plot into a data value based on the axis max, min and scale. |
static double |
getDefaultScaleEnd(double val,
double minVal)
|
int |
getExtent(java.awt.Graphics g)
Gets the dimension of the axis parallel to the direction of the tickmark - i.e. |
int |
getExtent(java.awt.Graphics g,
java.lang.String typicalString)
Gets the dimension of the axis parallel to the direction of the tickmark - i.e. |
int |
getExtent2(java.awt.Graphics g)
Gets the dimension of the axis perpendicular to the direction of the tickmark - i.e. |
int |
getExtent2(java.awt.Graphics g,
java.lang.String typicalString)
Gets the dimension of the axis perpendicular to the direction of the tickmark - i.e. |
java.lang.String |
getFormat()
|
private double |
getInterval(double range,
int totalPixs,
int minPixs)
|
java.lang.String |
getLabel()
|
int |
getLabelPos()
|
private java.util.ArrayList<java.awt.Point> |
getLinearPoints(boolean extraOne)
work out the coordinates of all tick marks using a linear scale |
protected java.util.ArrayList<java.awt.Point> |
getLogPoints(boolean extraOne)
Get the coordinates of tick points for a logarithmic axis |
double |
getMaxVal()
|
double |
getMinVal()
|
double |
getPosition(double dataValue)
The axis knows all about scale and can tell us the pixel value for any given data value. |
int |
getTickPosition()
|
int |
getX1()
|
int |
getX2()
|
int |
getY1()
|
int |
getY2()
|
boolean |
isAllowScaleMultiples()
|
boolean |
isDrawLine()
|
boolean |
isFractionalScale()
|
boolean |
isIntegerFormat()
|
boolean |
isLogScale()
|
boolean |
isLogTenthsScale()
|
void |
setAllowScaleMultiples(boolean allowScaleMultiples)
|
void |
setAngleScales(boolean angleScales)
Easy way to make scales end at 45, 90, 180, etc and step in sensible 45, 90, etc. |
void |
setDrawLine(boolean drawLine)
|
void |
setForceFirstVal(boolean forceFirstVal,
double forcedFirstVal)
|
void |
setFormat(java.lang.String format)
Set the format string for writing out numbers on the axis. |
void |
setFractionalScale(boolean fractionalScale)
|
void |
setInterval(double interval)
Set the interval between ticks. |
void |
setLabel(java.lang.String label)
|
void |
setLabelPos(int labelPos)
|
void |
setLogScale(boolean logScale)
|
void |
setLogTenthsScale(boolean logTenthsScale)
|
void |
setMaxVal(double maxVal)
|
void |
setMinVal(double minVal)
|
void |
setPosition(int x1,
int y1,
int x2,
int y2)
Set the axis default coordinates |
void |
setRange(double minVal,
double maxVal)
Set the minimum and maximum values for the axis. |
void |
setTickPosition(int tickPosition)
|
void |
setX1(int x1)
|
void |
setX2(int x2)
|
void |
setY1(int y1)
|
void |
setY2(int y2)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static final int TICKS_ENDSONLY
static final int TICKS_AUTO
private static final double[] defaultIntervals
private double[] intervals
private static final double[] defaultScaleEnds
private double[] scaleEnds
private boolean allowScaleMultiples
static final int minPixels
public static final int INTERVAL_AUTO
public static final int ABOVE_LEFT
public static final int BELOW_RIGHT
public static final int BOTH_SIDES
public static final int LABEL_NEAR_MAX
public static final int LABEL_NEAR_MIN
public static final int LABEL_NEAR_CENTRE
private int x1
private int x2
private int y1
private int y2
private double minVal
private double maxVal
private boolean forceFirstVal
private double forcedFirstVal
private int tickPosition
private double interval
private boolean logTenthsScale
private boolean drawLine
private boolean intervalStart
private int tickLength
private java.lang.String label
private java.lang.String format
private boolean integerFormat
private boolean logScale
private int labelPos
private boolean fractionalScale
java.awt.FontMetrics fontMetrics
double axisValue
double axisScale
int[] tickLengthX
int[] tickLengthY
double labelOffsetX
double labelOffsetY
double tickStepX
double tickStepY
double axisAngle
double theInterval
int maxLabelWidth
int maxLabelHeight
double totalPixs
double tickAngle
private java.util.ArrayList<java.lang.Double> axisValues
| Constructor Detail |
|---|
public PamAxis(int x1,
int y1,
int x2,
int y2,
double minVal,
double maxVal,
int tickPosition,
java.lang.String label,
int labelPos,
java.lang.String format)
x1 - first x coordinate of axisy1 - first y coordinate of axisx2 - second x coordinate of axisy2 - second coordinate of axisminVal - minimum axis valuemaxVal - maximum axis valuetickPosition - tick position (ABOVE_LEFT or BELOW_RIGHT)label - text for label (or null if no label)labelPos - Position of axis label (LABEL_NEAR_MAX, LABEL_NEAR_MIN
or LABEL_NEAR_CENTRE)format - format for numbers printed on the display. This must be a standard
format String such as "%d", "%f", "%3.1f", "%.2 seconds", etc.
public PamAxis(int x1,
int y1,
int x2,
int y2,
double minVal,
double maxVal,
boolean aboveLeft,
java.lang.String label,
java.lang.String format)
x1 - x1y1 - y1x2 - x2y2 - y2minVal - min axis valuemaxVal - max axis valueaboveLeft - above and / or to the leftlabel - axis labelformat - format of numbers| Method Detail |
|---|
public void setPosition(int x1,
int y1,
int x2,
int y2)
x1 - y1 - x2 - y2 - public void setInterval(double interval)
interval - the interval or INTERVAL_AUTO
public void setRange(double minVal,
double maxVal)
minVal - maxVal -
public void drawAxis(java.awt.Graphics g,
int x1,
int y1,
int x2,
int y2)
g - x1 - y1 - x2 - y2 - public void drawAxis(java.awt.Graphics g)
g - graphics context to draw onpublic java.util.ArrayList<java.awt.Point> getAxisPoints(boolean extraOne)
extraOne -
private java.util.ArrayList<java.awt.Point> getLinearPoints(boolean extraOne)
extraOne -
protected void drawLinearAxis(java.awt.Graphics2D g2d)
g2d - graphics context to draw onprotected void drawLogAxis(java.awt.Graphics2D g2d)
g2d - graphics context to draw onprotected java.util.ArrayList<java.awt.Point> getLogPoints(boolean extraOne)
extraOne -
protected void drawTickAndLabel(java.awt.Graphics2D g2d,
java.awt.Point xy,
double value)
g2d - xy - value -
private void drawTickAndLabel(java.awt.Graphics2D g2d,
double x,
double y,
double value)
g2d - x - y - value - protected java.lang.String formatValue(double val)
val - value
public void drawGrid(java.awt.Graphics g,
java.awt.Dimension plotSize,
int minorGrid)
g - Graphics context to draw onplotSize - size of the graphicminorGrid - draw a minor grid as well as lines at the main tick marks.
public void drawGrid(java.awt.Graphics g,
java.awt.Dimension plotSize,
java.awt.Insets insets,
int minorGrid)
private void drawLinearMinorGrid(java.awt.Graphics g,
java.util.ArrayList<java.awt.Point> axisPoints,
int xExtent,
int yExtent,
int minorGrid)
private void drawLogMinorGrid(java.awt.Graphics g,
java.util.ArrayList<java.awt.Point> axisPoints,
int xExtent,
int yExtent,
int minorGrid)
private void drawAxisTitle(java.awt.Graphics2D g2d)
public int getExtent2(java.awt.Graphics g)
g - graphics handle for component the axis is to be draw on
public int getExtent2(java.awt.Graphics g,
java.lang.String typicalString)
g - graphics handle for component the axis is to be draw ontypicalString - typical text string.
public int getExtent(java.awt.Graphics g)
g - graphics handle for component the axis is to be draw on
public int getExtent(java.awt.Graphics g,
java.lang.String typicalString)
g - graphics handle the axis is being draw ontypicalString - typical label string for a tick
private double getInterval(double range,
int totalPixs,
int minPixs)
public boolean isLogScale()
public void setLogScale(boolean logScale)
public boolean isDrawLine()
public void setDrawLine(boolean drawLine)
public java.lang.String getFormat()
public void setFormat(java.lang.String format)
format - format stringpublic boolean isIntegerFormat()
public java.lang.String getLabel()
public void setLabel(java.lang.String label)
public int getLabelPos()
public void setLabelPos(int labelPos)
public int getTickPosition()
public void setTickPosition(int tickPosition)
public double getMaxVal()
public void setMaxVal(double maxVal)
public double getMinVal()
public void setMinVal(double minVal)
public static double getDefaultScaleEnd(double val,
double minVal)
public void setForceFirstVal(boolean forceFirstVal,
double forcedFirstVal)
public boolean isLogTenthsScale()
public void setLogTenthsScale(boolean logTenthsScale)
public java.util.ArrayList<java.lang.Double> getAxisValues()
public int getX1()
public void setX1(int x1)
public int getX2()
public void setX2(int x2)
public int getY1()
public void setY1(int y1)
public int getY2()
public void setY2(int y2)
public double getPosition(double dataValue)
dataValue -
public double getDataValue(double position)
This is the exact compliment of getPosition()
position - position along the axis in pixels.
public boolean isAllowScaleMultiples()
public void setAllowScaleMultiples(boolean allowScaleMultiples)
public void setAngleScales(boolean angleScales)
angleScales - public boolean isFractionalScale()
public void setFractionalScale(boolean fractionalScale)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||