com.approximatrix.charting.coordsystem
Class ClassicCoordSystem

java.lang.Object
  extended by com.approximatrix.charting.render.AbstractRenderer
      extended by com.approximatrix.charting.coordsystem.AbstractCoordSystem
          extended by com.approximatrix.charting.coordsystem.ClassicCoordSystem
All Implemented Interfaces:
CoordSystem, ChartDataModelListener, Renderer, java.util.EventListener
Direct Known Subclasses:
CoordSystem, InvisibleCoordSystem

public class ClassicCoordSystem
extends AbstractCoordSystem
implements ChartDataModelListener

This class defines a coordinate system. The ClassicCoordSystem class computes an AffineTransform for each y-axis, which translates the user space coordinates (ie. the data value coordinates) into pixel space coordinates. These AffineTransform classes make the PixelToPointTranslator obsolete, since it provides more flexibility. getDefaultTransform always computes the default transformation, whereas you can set another transformation via setTransform. This will be used to implement zooming and panning in the Swing classes.

All classes incl. this one, which render data will use the transformations to translate the coordinates. The transformations are not set up on instantiation of a ClassicCoordSystem, instead they're computed when setBounds is called, because they need this information of course. Afterwards you can set your own transformation or even better you can manipulate the existing ones by pre- or postconcatenating another AffineTransform.


Field Summary
 int ARROWLENGTH
          The arrow length constant.
protected  ClassicCoordSystemUtilities c
          The utilities class, which contains all the rendering methods etc.
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.
protected  java.awt.font.FontRenderContext frc
          FontRenderContext used througout the ClassicCoordSystem
 int MINIMALMARGIN
          The minimal margin constant.
protected  ChartDataModel model
          The DataModel class.
protected  boolean shouldDrawArrows
          if true, the arrows will be drawn at the end of the axi
protected  boolean shouldPaintAltTick
          if true, the increment will be painted at each tick mark
 
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
ClassicCoordSystem(ChartDataModel cdm)
          Creates a new ClassicCoordSystem using the given model constraints.
ClassicCoordSystem(ChartDataModel c, java.text.DecimalFormat yAxisFormat, boolean drawArrows, boolean paintAltYTick, boolean paintOnlyYTick)
          Create a new ClassicCoordSystem with alternate painting parameters.
ClassicCoordSystem(ChartDataModel c, java.lang.String xunit, java.lang.String yunit)
          Creates a new ClassicCoordSystem using the given model constraints.
 
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.
 ChartDataModelConstraints getChartDataModelConstraints(int axis)
          Returns the used ChartDataModelConstraints.
 java.awt.font.FontRenderContext getFontRenderContext()
          Returns the FontRenderContext used througout the ClassicCoordSystem
 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.text.DecimalFormat getXDecimalFormat()
          Returns the DecimalFormat used on the Xaxis
 java.text.DecimalFormat getYDecimalFormat()
          Returns the DecimalFormat used on the Yaxis
 boolean isDrawArrows()
          if true, the arrows will be drawn at the end of the axis
 boolean isPaintAltTick()
          if true, the increment will be painted at each tick mark
 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 setCenterLabelsBetweenTicks(boolean value)
          Forces the coordinate system to place the label centered between tick marks (for bar charts for example).
 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, getYAxisUnit, isCenterLabelsBetweenTicks, isPaintAxes, isPaintGrid, isPaintLabels, isPaintOnlyTick, removeRenderChangeListener, render, setBottomMargin, setBounds, 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

frc

protected final java.awt.font.FontRenderContext frc
FontRenderContext used througout the ClassicCoordSystem


shouldDrawArrows

protected boolean shouldDrawArrows
if true, the arrows will be drawn at the end of the axi


shouldPaintAltTick

protected boolean shouldPaintAltTick
if true, the increment will be painted at each tick mark


MINIMALMARGIN

public final int MINIMALMARGIN
The minimal margin constant.

See Also:
Constant Field Values

ARROWLENGTH

public final int ARROWLENGTH
The arrow length constant.

See Also:
Constant Field Values

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 class.


c

protected ClassicCoordSystemUtilities c
The utilities class, which contains all the rendering methods etc.

Constructor Detail

ClassicCoordSystem

public ClassicCoordSystem(ChartDataModel cdm)
Creates a new ClassicCoordSystem using the given model constraints. Also creates default linear x and y-axis. Note that the length of the axis are set on the first call to setBounds().

Parameters:
c - the ChartDataModel needed to compute the DataConstraints.

ClassicCoordSystem

public ClassicCoordSystem(ChartDataModel c,
                          java.lang.String xunit,
                          java.lang.String yunit)
Creates a new ClassicCoordSystem using the given model constraints. Also creates default linear x and y-axis. Note that the length of the axis are set on the first call to setBounds().

Parameters:
c - the ChartDataModel needed to compute the DataConstraints.
xtext - the x-axis unit
ytext - the y-axis unit

ClassicCoordSystem

public ClassicCoordSystem(ChartDataModel c,
                          java.text.DecimalFormat yAxisFormat,
                          boolean drawArrows,
                          boolean paintAltYTick,
                          boolean paintOnlyYTick)
Create a new ClassicCoordSystem with alternate painting parameters.

Parameters:
c - the ChartDataModel needed to compute the DataConstraints.
drawArrows - if true the arrows will be drawn at the end of the axis
paintAltYTick - if true the caption will paint on alternate ticks of the yaxis instead of on every one.
paintOnlyYTick - if true the horizontal lightgray line will not appear behind the chart at each yaxis tick mark.
Method Detail

isPaintAltTick

public boolean isPaintAltTick()
if true, the increment will be painted at each tick mark


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.

getFontRenderContext

public java.awt.font.FontRenderContext getFontRenderContext()
Returns the FontRenderContext used througout the ClassicCoordSystem


getYDecimalFormat

public java.text.DecimalFormat getYDecimalFormat()
Description copied from interface: CoordSystem
Returns the DecimalFormat used on the Yaxis

Specified by:
getYDecimalFormat in interface CoordSystem
Overrides:
getYDecimalFormat in class AbstractCoordSystem

getXDecimalFormat

public java.text.DecimalFormat getXDecimalFormat()
Description copied from interface: CoordSystem
Returns the DecimalFormat used on the Xaxis

Specified by:
getXDecimalFormat in interface CoordSystem
Overrides:
getXDecimalFormat in class AbstractCoordSystem

isDrawArrows

public boolean isDrawArrows()
if true, the arrows will be drawn at the end of the axis


getChartDataModelConstraints

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

Specified by:
getChartDataModelConstraints 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

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

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)

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

setCenterLabelsBetweenTicks

public void setCenterLabelsBetweenTicks(boolean value)
Description copied from interface: CoordSystem
Forces the coordinate system to place the label centered between tick marks (for bar charts for example).

Specified by:
setCenterLabelsBetweenTicks in interface CoordSystem
Overrides:
setCenterLabelsBetweenTicks in class AbstractCoordSystem
Parameters:
value - true to center, false otherwise