|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.approximatrix.charting.render.AbstractRenderer
com.approximatrix.charting.CoordSystem
public class CoordSystem
This class defines a coordinate system. The CoordSystem 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 CoordSystem, 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 int |
bottommargin
The bottom margin. |
protected CoordSystemUtilities |
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.text.DecimalFormat |
dfX
DecimalFormat used throught on the Xaxis of the CoordSystem |
protected java.text.DecimalFormat |
dfY
DecimalFormat used throught on the Yaxis of the CoordSystem |
static int |
FIRST_YAXIS
the axis binding constant for the first y-axis |
protected java.awt.Font |
font
The Font used in the CoordSystem. |
protected java.awt.font.FontRenderContext |
frc
FontRenderContext used througout the CoordSystem |
protected int |
leftmargin
The left margin |
int |
MINIMALMARGIN
The minimal margin constant. |
protected ChartDataModel |
model
The DataModel class. |
protected int |
rightmargin
The right margin. |
static int |
SECOND_YAXIS
the axis binding constant for the second y-axis |
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 |
protected boolean |
shouldPaintAxes
If true, axes will be drawn, but nothing is drawn if false |
protected boolean |
shouldPaintGrid
If true, a grid is painted along with the tick marks. |
protected boolean |
shouldPaintLabels
If true, the labels will be painted. |
protected boolean |
shouldPaintOnlyTick
if true only the tick will be painted on the yaxis. |
protected int |
topmargin
The top margin. |
protected Axis |
xaxis
The xaxis. |
protected java.lang.String |
xaxis_unit
The x-axis caption string. |
protected java.awt.geom.AffineTransform |
y1transform
The multiplication matrix for the first y-axis and the x-axis. |
protected java.awt.geom.AffineTransform |
y2transform
The multiplication matrix for the second y-axis and the x-axis. |
protected Axis |
yaxis
The first y-axis. |
protected java.lang.String |
yaxis_unit
The y-axis caption string. |
protected Axis |
yaxis2
The second y-axis. |
| Fields inherited from class com.approximatrix.charting.render.AbstractRenderer |
|---|
listener |
| Constructor Summary | |
|---|---|
CoordSystem(ChartDataModel cdm)
Creates a new CoordSystem using the given model constraints. |
|
CoordSystem(ChartDataModel c,
java.text.DecimalFormat yAxisFormat,
boolean drawArrows,
boolean paintAltYTick,
boolean paintOnlyYTick)
Create a new CoordSystem with alternate painting parameters. |
|
CoordSystem(ChartDataModel c,
java.lang.String xunit,
java.lang.String yunit)
Creates a new CoordSystem using the given model constraints. |
|
| Method Summary | |
|---|---|
void |
chartDataChanged(ChartDataModelEvent evt)
Listener to force the recomputation of all transforms on data changes |
protected int |
getBottomMargin()
Returns the bottom margin. |
ChartDataModelConstraints |
getChartDataModelConstraints(int axis)
Returns the used ChartDataModelConstraints. |
java.awt.geom.AffineTransform |
getDefaultTransform(int axis)
This method computes the default transform which transforms the user space coordinates of this coordinate system to the pixel space coordinates used in the Graphics object. |
Axis |
getFirstYAxis()
Returns the first y-axis. |
java.awt.Font |
getFont()
Returns the font used for the axis labels. |
java.awt.font.FontRenderContext |
getFontRenderContext()
Returns the FontRenderContext used througout the CoordSystem |
java.awt.Rectangle |
getInnerBounds()
Returns the inner margin, ie the bounds minus the margins. |
protected int |
getLeftMargin()
Returns the left margin. |
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 |
boolean |
getPaintGrid()
Returns whether a grid is painted. |
java.awt.Dimension |
getPreferredSize()
Returns the preferred size needed for the renderer. |
protected int |
getRightMargin()
Returns the right margin. |
Axis |
getSecondYAxis()
Returns the second y-axis. |
protected int |
getTopMargin()
Returns the top margin. |
java.awt.geom.AffineTransform |
getTransform(int axis)
Returns the currently defined AffineTransform for any y-axis. |
Axis |
getXAxis()
Returns the x axis. |
java.lang.String |
getXAxisUnit()
Gets the x-axis unit string. |
java.text.DecimalFormat |
getXDecimalFormat()
Returns the DecimalFormat used throught on the Xaxis of the CoordSystem |
java.lang.String |
getYAxisUnit()
Gets the y-axis label. |
java.text.DecimalFormat |
getYDecimalFormat()
Returns the DecimalFormat used throught on the Yaxis of the CoordSystem |
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 |
boolean |
isPaintAxes()
Returns whether axes will be painted. |
boolean |
isPaintLabels()
if true, labels will be painted for each axis |
boolean |
isPaintOnlyTick()
if true only the tick will be painted on the yaxis. |
void |
paintDefault(java.awt.Graphics2D g)
This method is called by the paint method to do the actual painting. |
void |
render(java.awt.Graphics2D g)
Overrides the method to just call paintDefault. |
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 |
setBottomMargin(int margin)
Sets the bottom margin. |
void |
setBounds(java.awt.Rectangle bounds)
Computes all margins, initializes the length of the Axis and calls super.setBounds. |
void |
setFirstYAxis(Axis a)
Sets the left y-axis and computes the matrix transformation. |
void |
setFont(java.awt.Font f)
Sets the font for the axis labels. |
protected void |
setLeftMargin(int margin)
Sets the left margin. |
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. |
void |
setPaintAxes(boolean axes)
Sets whether the axes will be painted. |
void |
setPaintGrid(boolean value)
Sets whether a grid is painted. |
void |
setPaintLabels(boolean label)
Sets whether labels should be painted for the axes |
protected void |
setRightMargin(int margin)
Sets the right margin. |
void |
setSecondYAxis(Axis a)
Sets the second y-axis and computes the matrix transformation. |
protected void |
setTopMargin(int margin)
Sets the top margin. |
void |
setTransform(java.awt.geom.AffineTransform at,
int axis)
Sets the coordinate transformation for any y-coordinate. |
private void |
setTransforms()
Sets axes transforms for this coordinate system |
void |
setXAxis(Axis a)
Sets the x-axis. |
void |
setXAxisUnit(java.lang.String xunit)
Sets the x-axis unit string. |
void |
setYAxisUnit(java.lang.String yunit)
Sets the y-axis unit string. |
| Methods inherited from class com.approximatrix.charting.render.AbstractRenderer |
|---|
addRenderChangeListener, clearRenderChangeListeners, fireRenderChangeEvent, getBounds, getDirectRender, isDifferentBounds, removeRenderChangeListener, setDirectRender |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String xaxis_unit
protected java.lang.String yaxis_unit
protected java.awt.Font font
protected final java.awt.font.FontRenderContext frc
protected java.text.DecimalFormat dfY
protected java.text.DecimalFormat dfX
protected boolean shouldDrawArrows
protected boolean shouldPaintAltTick
protected boolean shouldPaintOnlyTick
protected boolean shouldPaintLabels
protected boolean shouldPaintGrid
protected boolean shouldPaintAxes
protected int leftmargin
protected int topmargin
protected int rightmargin
protected int bottommargin
public final int MINIMALMARGIN
public final int ARROWLENGTH
protected ChartDataModelConstraints constraints
protected ChartDataModelConstraints constraints2
protected ChartDataModel model
protected CoordSystemUtilities c
protected Axis xaxis
protected Axis yaxis
protected Axis yaxis2
protected java.awt.geom.AffineTransform y1transform
protected java.awt.geom.AffineTransform y2transform
public static final int FIRST_YAXIS
public static final int SECOND_YAXIS
| Constructor Detail |
|---|
public CoordSystem(ChartDataModel cdm)
c - the ChartDataModel needed to compute the DataConstraints.
public CoordSystem(ChartDataModel c,
java.lang.String xunit,
java.lang.String yunit)
c - the ChartDataModel needed to compute the DataConstraints.xtext - the x-axis unitytext - the y-axis unit
public CoordSystem(ChartDataModel c,
java.text.DecimalFormat yAxisFormat,
boolean drawArrows,
boolean paintAltYTick,
boolean paintOnlyYTick)
c - the ChartDataModel needed to compute the DataConstraints.drawArrows - if true the arrows will be drawn at the end of the axispaintAltYTick - 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 |
|---|
public void setTransform(java.awt.geom.AffineTransform at,
int axis)
at - the AffineTransform that transforms the coordinates into pixel
spacepublic java.awt.geom.AffineTransform getTransform(int axis)
axis - the y-axis to be used.public java.awt.geom.AffineTransform getDefaultTransform(int axis)
axis - defines which y-axis to use.public void setPaintGrid(boolean value)
value - whether the grid should be paintedpublic boolean getPaintGrid()
public void setXAxis(Axis a)
a - the x-axispublic Axis getXAxis()
public void setXAxisUnit(java.lang.String xunit)
xtext - the unit stringpublic java.lang.String getXAxisUnit()
public void setYAxisUnit(java.lang.String yunit)
ytext - the unit stringpublic java.lang.String getYAxisUnit()
public void setFont(java.awt.Font f)
f - the Font to be usedpublic java.awt.Font getFont()
public void setFirstYAxis(Axis a)
a - the left y-axispublic Axis getFirstYAxis()
public void setSecondYAxis(Axis a)
a - the right y-axispublic Axis getSecondYAxis()
public java.awt.Rectangle getInnerBounds()
public void setBounds(java.awt.Rectangle bounds)
super.setBounds. Additionally, it sets the
default AffineTransforms for every y-axis.
setBounds in interface RenderersetBounds in class AbstractRendererbounds - Rectangle object defining the boundsprivate void setTransforms()
public java.awt.Dimension getPreferredSize()
getPreferredSize in interface Rendererpublic void render(java.awt.Graphics2D g)
paintDefault.
render in interface Rendererrender in class AbstractRendererg - the Graphics2D object to paint inpublic void paintDefault(java.awt.Graphics2D g)
paintDefault in class AbstractRendererg - the Graphics2D object to paint inprotected int getLeftMargin()
protected int getRightMargin()
protected int getTopMargin()
protected int getBottomMargin()
protected void setLeftMargin(int margin)
margin - the new margin valueprotected void setRightMargin(int margin)
margin - the new margin valueprotected void setTopMargin(int margin)
margin - the new margin valuepublic void setBottomMargin(int margin)
margin - the new margin valuepublic java.awt.font.FontRenderContext getFontRenderContext()
public java.text.DecimalFormat getYDecimalFormat()
public java.text.DecimalFormat getXDecimalFormat()
public boolean isDrawArrows()
public boolean isPaintAltTick()
public boolean isPaintOnlyTick()
public boolean isPaintLabels()
public void setPaintLabels(boolean label)
label - true to paint labels, false otherwisepublic boolean isPaintAxes()
public void setPaintAxes(boolean axes)
axes - true to paint axes, false otherwisepublic ChartDataModelConstraints getChartDataModelConstraints(int axis)
public void setMaximumXTicks(int value)
value - the maximum number of X ticks, or -1 to reset to defaultpublic void setMaximumYTicks(int value)
value - the maximum number of Y ticks, or -1 to reset to defaultpublic int getMaximumXTicks()
public int getMaximumYTicks()
public void resetMaximumXTicks()
public void resetMaximumYTicks()
public void chartDataChanged(ChartDataModelEvent evt)
chartDataChanged in interface ChartDataModelListenerevt - the event that caused the data changeChartDataModelListener.chartDataChanged(com.approximatrix.charting.event.ChartDataModelEvent)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||