|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.approximatrix.charting.coordsystem.ClassicCoordSystemUtilities
public class ClassicCoordSystemUtilities
This class provides some utility functions for a ClassicCoordSystem. They were externalized to make the ClassicCoordSystem class clearer.
| Field Summary | |
|---|---|
protected ClassicCoordSystem |
c
The coordinate system associated with these utilities |
protected ChartDataModelConstraints |
constraints
The primary axis constraints |
protected ChartDataModelConstraints |
constraints2
The secondary axis contraints |
private static int |
DEFAULT_MAX_ACTUAL_TICKS
The default maximum number of ticks to allow the tick position calculator to generate on a single axis. |
private static float[] |
DOT1
Constant array of floats used to create the default grid line style. |
private int |
estimated_x_ticks
Estimate of the number of x ticks to draw. |
private int |
estimated_y_ticks
Estimates of the number of y ticks to draw. |
private static java.awt.Color |
GRID_COLOR
Color used for drawing gridlines |
private static java.awt.BasicStroke |
GRID_LINE_STYLE
Default and fixed grid line style to use |
protected int |
leftUnitBuffer
Buffer to move the y axis label off the absolute bounds |
protected int |
marginOffset
used for the offset on the y axis for the size of a "tick" |
private static int |
MAX
Internal constant refering to the max value index of a 2-element constraint array |
private int |
maximum_x_ticks
The maximum number of x ticks to allow in the x direction |
private int |
maximum_y_ticks
The maximum number of y ticks to allow in the x direction |
private static int |
MIN
Internal constant refering to the min value index of a 2-element constraint array |
protected ChartDataModel |
model
The model associated with these utilities |
private static int |
SIMPLE_TICK_THRESHOLD
The threshhold of specified tic mark counts at which the routines default to simple tick mark calculator |
private static int |
STOP_TICK_RECURSIONS
Count of recursions into the tick mark auto-placement routine at which to give up calculating placement |
private int |
tick_recursions
Used to limit the number of recursions into the tick mark auto-placement routine |
| Constructor Summary | |
|---|---|
ClassicCoordSystemUtilities(ClassicCoordSystem coord,
ChartDataModelConstraints constraints,
ChartDataModelConstraints constraints2,
ChartDataModel model)
Creates a new instance of ClassicCoordSystemUtilities |
|
| Method Summary | |
|---|---|
private void |
checkMaxTickConsistency()
Makes sure that the estimated tic mark count is always limited by the maximum tic mark count limit. |
int |
computeBottomMargin()
Computes the bottom margin. |
int |
computeLeftMargin()
Computes the left margin. |
int |
computeRightMargin()
Computes the right margin. |
private double[] |
computeTicMarkLocations(double max,
double min,
int numTicsDesired,
int maxTics)
Deprecated. Deprecated in version 1.4 - should use Tick Locator classes |
private double[] |
computeTicMarkLocations(double max,
double min,
int numTicsDesired,
int maxTics,
boolean force_simple)
Deprecated. Deprecated in version 1.4 - should use Tick Locator classes |
int |
computeTopMargin()
Computes the top margin. |
int |
computeXAxisLabelHeight()
Computes the maximum height of all x-axis labels. |
int |
computeYAxisLabelWidth()
Computes the maximum width of all y-axis labels. |
void |
drawNumericalXAxisGrid(java.awt.Graphics2D g)
Draws a grid based on values in the x-axis |
void |
drawNumericalXAxisTicks(java.awt.Graphics2D g)
This method is called by paintDefault to paint the ticks on the x-axis for numerical x-axis values. |
void |
drawXAxisTicks(java.awt.Graphics2D g)
This method is called by paintDefault to paint the ticks on the x-axis for non-numerical x-axis values.. |
void |
drawYAxisGrid(java.awt.Graphics2D g)
Draws a grid based on values in the y-axis |
void |
drawYAxisTicks(java.awt.Graphics2D g)
This method is called by paintDefault to paint the ticks on the y-axis. |
int |
getEstimatedXTicks()
Returns the number of estimated X ticks to draw on the graph (not the actual) |
int |
getEstimatedYTicks()
Returns the number of estimated Y ticks to draw on the graph (not the actual) |
int |
getMaximumXTicks()
Returns the maximum number of X ticks to draw on the X axis |
int |
getMaximumYTicks()
Returns the maximum number of Y ticks to draw on the Y axis |
java.awt.geom.Line2D |
getSecondYAxisLine2D()
Computes the Line2D object of the second y-axis using the DataConstraints. |
java.awt.geom.Line2D |
getXAxisLine2D()
Computes the Line2D object of the x-axis using the DataConstraints. |
private java.awt.geom.Point2D[] |
getXTickLocations()
Returns the location of tick marks on the x-axis without any transform for plotting |
java.awt.geom.Line2D |
getYAxisLine2D()
Computes the Line2D object of the y-axis using the DataConstraints. |
private java.awt.geom.Point2D[] |
getYTickLocations()
Returns the location of tick marks on the y-axis without any transform for plotting |
private double[] |
performAutoScale(double max,
double min,
int numTicsDesired,
int maxTics)
Computes the tick mark locations on an axis |
private double[] |
safeMaxMin(double max,
double min)
Returns a safe estimate of min and max drawing values for an axis. |
private double[] |
safeMaxMin(java.lang.Number max,
java.lang.Number min)
Returns a safe estimate of min and max drawing values for an axis. |
void |
setEstimatedXTicks(int number)
Sets the estimated number of X ticks (not the actual - handled by autoscaler) |
void |
setEstimatedYTicks(int number)
Sets the estimated number of Y ticks (not the actual - handled by autoscaler) |
void |
setMaximumXTicks(int value)
|
void |
setMaximumYTicks(int value)
Sets the maximum number of ticks along the Y axis that will be allowed. |
private double[] |
simpleTics(double max,
double min,
int numTicsDesired)
Foolproof and simple method for determining Tic placement in cases where the tic count is low theoretically. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final int MAX
private static final int MIN
private static final java.awt.Color GRID_COLOR
private static final float[] DOT1
private static final java.awt.BasicStroke GRID_LINE_STYLE
protected final int marginOffset
protected final int leftUnitBuffer
protected ClassicCoordSystem c
protected ChartDataModelConstraints constraints
protected ChartDataModelConstraints constraints2
protected ChartDataModel model
private int estimated_x_ticks
private int estimated_y_ticks
private static final int DEFAULT_MAX_ACTUAL_TICKS
private int maximum_x_ticks
private int maximum_y_ticks
private static final int SIMPLE_TICK_THRESHOLD
private int tick_recursions
private static final int STOP_TICK_RECURSIONS
| Constructor Detail |
|---|
public ClassicCoordSystemUtilities(ClassicCoordSystem coord,
ChartDataModelConstraints constraints,
ChartDataModelConstraints constraints2,
ChartDataModel model)
| Method Detail |
|---|
public int computeLeftMargin()
public int computeRightMargin()
public int computeTopMargin()
public int computeBottomMargin()
public int computeXAxisLabelHeight()
public int computeYAxisLabelWidth()
public void drawNumericalXAxisTicks(java.awt.Graphics2D g)
g - the Graphics2D context to paint inpublic void drawXAxisTicks(java.awt.Graphics2D g)
g - the Graphics2D context to paint inpublic void drawYAxisTicks(java.awt.Graphics2D g)
g - the Graphics2D context in which to drawpublic void drawYAxisGrid(java.awt.Graphics2D g)
public void drawNumericalXAxisGrid(java.awt.Graphics2D g)
private java.awt.geom.Point2D[] getYTickLocations()
private java.awt.geom.Point2D[] getXTickLocations()
public java.awt.geom.Line2D getXAxisLine2D()
public java.awt.geom.Line2D getYAxisLine2D()
public java.awt.geom.Line2D getSecondYAxisLine2D()
private double[] computeTicMarkLocations(double max,
double min,
int numTicsDesired,
int maxTics)
max - the largest value to be plottedmin - the smallest value to be plottednumTicsDesired - the approximate desired number of tics (the result may not be this number of tics)maxTics - the absolute maximum number of tics to draw
private double[] computeTicMarkLocations(double max,
double min,
int numTicsDesired,
int maxTics,
boolean force_simple)
max - the largest value to be plottedmin - the smallest value to be plottednumTicsDesired - the approximate desired number of tics (the result may not be this number of tics)maxTics - the absolute maximum number of tics to drawforce_simple - force the use of the simple algorithm for drawing tic marks
private double[] simpleTics(double max,
double min,
int numTicsDesired)
max - the largest value to be plottedmin - the smallest value to be plottednumTicsDesired - the exact number of tics desired
private double[] performAutoScale(double max,
double min,
int numTicsDesired,
int maxTics)
max - the largest value in a data setmin - the smallest value in a data setnumTicsDesired - the first guess at the number of desired tick marks
public void setEstimatedXTicks(int number)
number - the number of xticks to draw (estimated)public void setEstimatedYTicks(int number)
number - the number of yticks to draw (estimated)public int getEstimatedXTicks()
public int getEstimatedYTicks()
public void setMaximumXTicks(int value)
value - public void setMaximumYTicks(int value)
value - the maximum number of Y ticks, or -1 to reset to defaultpublic int getMaximumXTicks()
public int getMaximumYTicks()
private void checkMaxTickConsistency()
private double[] safeMaxMin(java.lang.Number max,
java.lang.Number min)
max - the original max valuemin - the originial min value
private double[] safeMaxMin(double max,
double min)
max - the original max valuemin - the originial min value
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||