com.approximatrix.charting.coordsystem
Class BoxCoordSystem

java.lang.Object
  extended by com.approximatrix.charting.render.AbstractRenderer
      extended by com.approximatrix.charting.coordsystem.AbstractCoordSystem
          extended by com.approximatrix.charting.coordsystem.BoxCoordSystem
All Implemented Interfaces:
CoordSystem, ChartDataModelListener, Renderer, java.util.EventListener

public class BoxCoordSystem
extends AbstractCoordSystem
implements ChartDataModelListener

Coordinate system that renders as a box around the entire graph area. Tick marks are drawn on all sides of the box. Axis labels are drawn centered on the X and Y axes.

Author:
armstrong

Field Summary
protected static int BOTTOM_BUFFER
          Buffer between items on the bottom x axis
protected  ChartDataModelConstraints constraints
          The ChartDataModel constraints of the first y-axis and the x-axis.
protected  ChartDataModelConstraints constraints2
          The ChartDataModel constraints of the second y-axis and the x-axis.
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.
protected static boolean DRAW_OBJECT_X_AXIS_GRID
          Flag to draw X-axis grid when the X axis contains an Object series
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.
protected  java.awt.Color gridColor
          The color of grid lines
protected  java.awt.Stroke gridStroke
          The stroke to use for drawing grids
protected static int LEFT_BUFFER
          Buffer between items on the left y axis
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
protected  ChartDataModel model
          The DataModel object.
private  int ticSize
          The length of ticks in pixels
 
Fields inherited from class com.approximatrix.charting.coordsystem.AbstractCoordSystem
bottommargin, bounds, centerObjectLabelsBetweenTicks, dfX, dfY, leftmargin, listener, rightmargin, shouldPaintAxes, shouldPaintGrid, shouldPaintLabels, shouldPaintOnlyTick, tickFont, topmargin, unitFont, xaxis, xaxis_unit, y1transform, y2transform, yaxis, yaxis_unit, yaxis2
 
Fields inherited from interface com.approximatrix.charting.coordsystem.CoordSystem
FIRST_YAXIS, SECOND_YAXIS
 
Constructor Summary
BoxCoordSystem(ChartDataModel cdm)
          Creates a new Box Coordinate System using the passed model.
 
Method Summary
 void chartDataChanged(ChartDataModelEvent evt)
          Listener to force the recomputation of all transforms on data changes
protected  int computeBottomMargin()
          Computes the bottom margin.
protected  int computeLeftMargin()
          Computes the left margin.
protected  int computeRightMargin()
          Computes the right margin.
protected  int computeTopMargin()
          Computes the top margin.
private  void drawNumericalXAxisTicks(java.awt.Graphics2D g)
           
private  void drawObjectXAxisTicks(java.awt.Graphics2D g)
           
private  void drawSingleGridline(java.awt.Graphics2D g, int x1, int y1, int x2, int y2)
           
private  void drawXAxisTicks(java.awt.Graphics2D g)
           
private  void drawYAxisTicks(java.awt.Graphics2D g)
           
 ChartDataModelConstraints getChartDataModelConstraints(int axis)
          Returns the used ChartDataModelConstraints.
 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
 void paintDefault(java.awt.Graphics2D g)
          This method is called by the paint method to do the actual painting.
 void resetMaximumXTicks()
          Resets the maximum number of ticks along the X axis to the default value
 void resetMaximumYTicks()
          Resets the maximum number of ticks along the X axis to the default value
 void setMaximumXTicks(int value)
          Sets the maximum number of ticks along the X axis that will be allowed.
 void setMaximumYTicks(int value)
          Sets the maximum number of ticks along the Y axis that will be allowed.
 
Methods inherited from class com.approximatrix.charting.coordsystem.AbstractCoordSystem
addRenderChangeListener, clearRenderChangeListeners, fireRenderChangeEvent, getBottomMargin, getBounds, getDefaultTransform, getFirstYAxis, getFont, getInnerBounds, getLeftMargin, getPaintGrid, getPreferredSize, getRightMargin, getSecondYAxis, getTickFont, getTopMargin, getTransform, getUnitFont, getXAxis, getXAxisUnit, getXDecimalFormat, getYAxisUnit, getYDecimalFormat, isCenterLabelsBetweenTicks, isPaintAxes, isPaintGrid, isPaintLabels, isPaintOnlyTick, removeRenderChangeListener, render, setBottomMargin, setBounds, setCenterLabelsBetweenTicks, setFirstYAxis, setFont, setLeftMargin, setPaintAxes, setPaintGrid, setPaintLabels, setRightMargin, setSecondYAxis, setTickFont, setTopMargin, setTransform, setTransforms, setUnitFont, setXAxis, setXAxisUnit, setXDecimalFormat, setYAxisUnit, setYDecimalFormat
 
Methods inherited from class com.approximatrix.charting.render.AbstractRenderer
getDirectRender, isDifferentBounds, setDirectRender
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_ACTUAL_TICKS

private static final int DEFAULT_MAX_ACTUAL_TICKS
The default maximum number of ticks to allow the tick position calculator to generate on a single axis.

See Also:
Constant Field Values

BOTTOM_BUFFER

protected static final int BOTTOM_BUFFER
Buffer between items on the bottom x axis

See Also:
Constant Field Values

LEFT_BUFFER

protected static final int LEFT_BUFFER
Buffer between items on the left y axis

See Also:
Constant Field Values

DOT1

private static final float[] DOT1
Constant array of floats used to create the default grid line style.


DRAW_OBJECT_X_AXIS_GRID

protected static boolean DRAW_OBJECT_X_AXIS_GRID
Flag to draw X-axis grid when the X axis contains an Object series


estimated_x_ticks

private int estimated_x_ticks
Estimate of the number of x ticks to draw. Used for evaluating the automatically-generated tick locations.


estimated_y_ticks

private int estimated_y_ticks
Estimates of the number of y ticks to draw. Used for evaluating the automatically-generated tick locations.


maximum_x_ticks

private int maximum_x_ticks
The maximum number of x ticks to allow in the x direction


maximum_y_ticks

private int maximum_y_ticks
The maximum number of y ticks to allow in the x direction


ticSize

private int ticSize
The length of ticks in pixels


constraints

protected ChartDataModelConstraints constraints
The ChartDataModel constraints of the first y-axis and the x-axis.


constraints2

protected ChartDataModelConstraints constraints2
The ChartDataModel constraints of the second y-axis and the x-axis.


model

protected ChartDataModel model
The DataModel object.


gridStroke

protected java.awt.Stroke gridStroke
The stroke to use for drawing grids


gridColor

protected java.awt.Color gridColor
The color of grid lines

Constructor Detail

BoxCoordSystem

public BoxCoordSystem(ChartDataModel cdm)
Creates a new Box Coordinate System using the passed model. Adds the coordinate system to the model as a listener.

Parameters:
cdm - the chart data model to associate the coordinate system with
Method Detail

computeBottomMargin

protected int computeBottomMargin()
Description copied from class: AbstractCoordSystem
Computes the bottom margin.

Specified by:
computeBottomMargin in class AbstractCoordSystem

computeLeftMargin

protected int computeLeftMargin()
Description copied from class: AbstractCoordSystem
Computes the left margin.

Specified by:
computeLeftMargin in class AbstractCoordSystem

computeRightMargin

protected int computeRightMargin()
Description copied from class: AbstractCoordSystem
Computes the right margin.

Specified by:
computeRightMargin in class AbstractCoordSystem

computeTopMargin

protected int computeTopMargin()
Description copied from class: AbstractCoordSystem
Computes the top margin.

Specified by:
computeTopMargin in class AbstractCoordSystem

paintDefault

public void paintDefault(java.awt.Graphics2D g)
Description copied from class: AbstractRenderer
This method is called by the paint method to do the actual painting. The painting is supposed to start at point (0,0) and the size is always the same as the preferred size. The paint method performs the possible scaling.

Specified by:
paintDefault in interface CoordSystem
Specified by:
paintDefault in class AbstractCoordSystem
Parameters:
g - the Graphics2D object to paint in.

chartDataChanged

public void chartDataChanged(ChartDataModelEvent evt)
Description copied from interface: CoordSystem
Listener to force the recomputation of all transforms on data changes

Specified by:
chartDataChanged in interface CoordSystem
Specified by:
chartDataChanged in interface ChartDataModelListener
Parameters:
evt - the event that caused the data change
See Also:
ChartDataModelListener.chartDataChanged(com.approximatrix.charting.event.ChartDataModelEvent)

getChartDataModelConstraints

public ChartDataModelConstraints getChartDataModelConstraints(int axis)
Description copied from interface: CoordSystem
Returns the used ChartDataModelConstraints.

Specified by:
getChartDataModelConstraints in interface CoordSystem

getMaximumXTicks

public int getMaximumXTicks()
Description copied from interface: CoordSystem
Returns the maximum number of X ticks to draw on the X axis

Specified by:
getMaximumXTicks in interface CoordSystem
Returns:
the maximum number of X ticks to draw

getMaximumYTicks

public int getMaximumYTicks()
Description copied from interface: CoordSystem
Returns the maximum number of Y ticks to draw on the Y axis

Specified by:
getMaximumYTicks in interface CoordSystem
Returns:
the maximum number of Y ticks to draw

resetMaximumXTicks

public void resetMaximumXTicks()
Description copied from interface: CoordSystem
Resets the maximum number of ticks along the X axis to the default value

Specified by:
resetMaximumXTicks in interface CoordSystem

resetMaximumYTicks

public void resetMaximumYTicks()
Description copied from interface: CoordSystem
Resets the maximum number of ticks along the X axis to the default value

Specified by:
resetMaximumYTicks in interface CoordSystem

setMaximumXTicks

public void setMaximumXTicks(int value)
Description copied from interface: CoordSystem
Sets the maximum number of ticks along the X axis that will be allowed.

Specified by:
setMaximumXTicks in interface CoordSystem
Parameters:
value - the maximum number of X ticks, or -1 to reset to default

setMaximumYTicks

public void setMaximumYTicks(int value)
Description copied from interface: CoordSystem
Sets the maximum number of ticks along the Y axis that will be allowed.

Specified by:
setMaximumYTicks in interface CoordSystem
Parameters:
value - the maximum number of Y ticks, or -1 to reset to default

drawYAxisTicks

private void drawYAxisTicks(java.awt.Graphics2D g)

drawXAxisTicks

private void drawXAxisTicks(java.awt.Graphics2D g)

drawNumericalXAxisTicks

private void drawNumericalXAxisTicks(java.awt.Graphics2D g)

drawObjectXAxisTicks

private void drawObjectXAxisTicks(java.awt.Graphics2D g)

drawSingleGridline

private void drawSingleGridline(java.awt.Graphics2D g,
                                int x1,
                                int y1,
                                int x2,
                                int y2)