info.monitorenter.gui.chart
Interface IAxis

All Superinterfaces:
Serializable
All Known Implementing Classes:
AAxis, AAxisTransformation, AxisInverse, AxisLinear, AxisLog10, AxisLogE

public interface IAxis
extends Serializable

Interface for an axis of the Chart2D.

Version:
$Revision: 1.26 $
Author:
Achim Westermann

Field Summary
static String PROPERTY_LABELFORMATTER
          Constant for a PropertyChangeEvent of the label formatter.
static String PROPERTY_PAINTGRID
          Constant for a PropertyChangeEvent of the paint grid flag.
static String PROPERTY_RANGEPOLICY
          Constant for a PropertyChangeEvent of the range policy.
static String PROPERTY_TITLE
          Constant for a PropertyChangeEvent of the title String.
static String PROPERTY_TITLEFONT
          Constant for a PropertyChangeEvent of the title font.
static String PROPERTY_TITLEPAINTER
          Constant for a PropertyChangeEvent of the IAxisTitlePainter.
 
Method Summary
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Add a listener for the given property.
 boolean addTrace(ITrace2D trace)
          Adds a trace that belongs to this axis.
 AAxis.AChart2DDataAccessor getAccessor()
          Returns the accessor to the chart.
 int getDimension()
          Returns the constant for the dimension this axis stands for in the chart.
 IAxisLabelFormatter getFormatter()
          Returns the formatter for labels.
 int getHeight(Graphics2D g2d)
          Returns the height in pixel this axis needs to paint itself.
 double getMajorTickSpacing()
          Get the major tick spacing for label generation.
 double getMinorTickSpacing()
          Get the minor tick spacing for label generation.
 PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
          Returns an array of all the listeners that were added to the this instance with addPropertyChangeListener(String, PropertyChangeListener).
 Range getRange()
          This method is used by the Chart2D to scale it's values during painting.
 IRangePolicy getRangePolicy()
          Returns the range policy used by this axis.
 double getScaledValue(double absolute)
          Scales the given absolute value into a value between 0 and 1.0 (if it is in the range of the data).
 String getTitle()
          Returns the title or null if there was no title configured before.
 IAxisTitlePainter getTitlePainter()
          Returns the instance that will paint the title of this axis.
 int getWidth(Graphics2D g2d)
          Returns the width in pixel this axis needs to paint itself.
 boolean isPaintGrid()
          Returns wether the x grid is painted or not.
 boolean isPaintScale()
          Returns whether the scale for this axis should be painted or not.
 boolean isStartMajorTick()
          Check wether scale values are started from major ticks.
 void removePropertyChangeListener(String property, PropertyChangeListener listener)
          Remove a PropertyChangeListener for a specific property.
 boolean removeTrace(ITrace2D trace)
          Removes the given trace from this axis.
 void replace(IAxis axis)
          Copies the complete state (flat, references are overtaken) of the given axis to this instance and overtakes any property change listeners.
 void scale()
          Scales all ITrace2D instances in the dimension represented by this axis.
 void scaleTrace(ITrace2D trace)
          Scales the given ITrace2D in the dimension represented by this axis.
 void setFormatter(IAxisLabelFormatter formatter)
          Sets the formatter to use for labels.
 void setMajorTickSpacing(double majorTickSpacing)
          This method sets the major tick spacing for label generation.
 void setMinorTickSpacing(double minorTickSpacing)
          This method sets the minor tick spacing for label generation.
 void setPaintGrid(boolean grid)
          Set wether the grid in this dimension should be painted or not.
 void setPaintScale(boolean show)
          Set if the scale for this axis should be shown.
 void setRange(Range range)
          Sets a Range to use for filtering the view to the the connected Axis.
 void setRangePolicy(IRangePolicy rangePolicy)
          Sets the RangePolicy.
 void setStartMajorTick(boolean majorTick)
          Set wether scale values are started from major ticks.
 String setTitle(String title)
          Sets the title of this axis will be painted by the {IAxisTitlePainter} of this instance.
 IAxisTitlePainter setTitlePainter(IAxisTitlePainter painter)
          Sets the title painter that will paint the title of this axis.
 double translatePxToValue(int pixel)
          Transforms the given pixel value (which has to be a awt value like MouseEvent.getY() into the chart value.
 int translateValueToPx(double value)
          Transforms the given chart data value into the corresponding awt pixel value for the chart.
 

Field Detail

PROPERTY_PAINTGRID

static final String PROPERTY_PAINTGRID
Constant for a PropertyChangeEvent of the paint grid flag.

See Also:
Constant Field Values

PROPERTY_RANGEPOLICY

static final String PROPERTY_RANGEPOLICY
Constant for a PropertyChangeEvent of the range policy.

See Also:
Constant Field Values

PROPERTY_TITLE

static final String PROPERTY_TITLE
Constant for a PropertyChangeEvent of the title String.

See Also:
Constant Field Values

PROPERTY_TITLEPAINTER

static final String PROPERTY_TITLEPAINTER
Constant for a PropertyChangeEvent of the IAxisTitlePainter.

See Also:
Constant Field Values

PROPERTY_TITLEFONT

static final String PROPERTY_TITLEFONT
Constant for a PropertyChangeEvent of the title font.

See Also:
Constant Field Values

PROPERTY_LABELFORMATTER

static final String PROPERTY_LABELFORMATTER
Constant for a PropertyChangeEvent of the label formatter.

See Also:
Constant Field Values
Method Detail

addTrace

boolean addTrace(ITrace2D trace)
Adds a trace that belongs to this axis.

Parameters:
trace - the trace to add.
Returns:
true if the trace was added, false else.

removeTrace

boolean removeTrace(ITrace2D trace)
Removes the given trace from this axis.

Parameters:
trace - the trace to remove from this axis.
Returns:
true if the given trace could be removed from this axis, false else.

translatePxToValue

double translatePxToValue(int pixel)
Transforms the given pixel value (which has to be a awt value like MouseEvent.getY() into the chart value.

Internal use only, the interface does not guarantee that the pixel corresponds to any valid awt pixel value within the chart component.

Parameters:
pixel - a pixel value of the chart component as used by awt.
Returns:
the awt pixel value transformed to the chart value.

translateValueToPx

int translateValueToPx(double value)
Transforms the given chart data value into the corresponding awt pixel value for the chart.

Parameters:
value - a chart data value.
Returns:
the awt pixel value corresponding to the chart data value.

scale

void scale()
Scales all ITrace2D instances in the dimension represented by this axis.

This method is not deadlock - safe and should be called by the Chart2D only!


scaleTrace

void scaleTrace(ITrace2D trace)
Scales the given ITrace2D in the dimension represented by this axis.

This method is not deadlock - safe and should be called by the Chart2D only!

Parameters:
trace - the trace to scale.

setTitle

String setTitle(String title)
Sets the title of this axis will be painted by the {IAxisTitlePainter} of this instance.

Parameters:
title - the title to set.
Returns:
the previous Title or null if there was no title configured before.
See Also:
setTitlePainter(IAxisTitlePainter)

getTitle

String getTitle()
Returns the title or null if there was no title configured before.

Returns:
the title or null if there was no title configured before.
See Also:
getTitlePainter()

setTitlePainter

IAxisTitlePainter setTitlePainter(IAxisTitlePainter painter)
Sets the title painter that will paint the title of this axis.

Parameters:
painter - the instance that will paint the title of this axis.
Returns:
the previous title painter of this axis or null if there was none configured before.

getTitlePainter

IAxisTitlePainter getTitlePainter()
Returns the instance that will paint the title of this axis.

Returns:
the instance that will paint the title of this axis.

addPropertyChangeListener

void addPropertyChangeListener(String propertyName,
                               PropertyChangeListener listener)
Add a listener for the given property.

The following PropertyChangeEvent types should be fired to listeners:

getPropertyName() getSource() getOldValue() getNewValue()
PROPERTY_RANGEPOLICY IAxis that changed IRangePolicy, the old value. IRangePolicy, the new value.
PROPERTY_PAINTGRID IAxis that changed Boolean, the old value. Boolean, the new value.
PROPERTY_LABELFORMATTER IAxis that changed IAxisLabelFormatter, the old value or null if there was no formatter before. IAxisLabelFormatter, the new value.
PROPERTY_TITLE IAxis that changed String, the old value or null if there was no title before. String, the new value.
PROPERTY_TITLEPAINTER IAxis that changed IAxisTitlePainter, the old value or null if there was no title painter before. IAxisTitlePainter, the new value.
PROPERTY_TITLEFONT IAxis that changed Font, the old value or null if there was no title font before. Font, the new value.

Parameters:
propertyName - the property to be informed about changes.
listener - the listener that will be informed.

getAccessor

AAxis.AChart2DDataAccessor getAccessor()
Returns the accessor to the chart.

Returns:
the accessor to the chart.

getDimension

int getDimension()
Returns the constant for the dimension this axis stands for in the chart.

Returns:
Chart2D.X, Chart2D.Y or -1 if this axis is not assigned to a chart.

getFormatter

IAxisLabelFormatter getFormatter()
Returns the formatter for labels.

Returns:
the formatter for labels.

getMajorTickSpacing

double getMajorTickSpacing()
Get the major tick spacing for label generation.

Returns:
the major tick spacing for label generation.
See Also:
setMajorTickSpacing(double)

getMinorTickSpacing

double getMinorTickSpacing()
Get the minor tick spacing for label generation.

Returns:
the minor tick spacing for label generation.
See Also:
setMinorTickSpacing(double)

getWidth

int getWidth(Graphics2D g2d)
Returns the width in pixel this axis needs to paint itself.

This includes the axis line, it's ticks and labels and it's title.

Note:
For an x axis the width only includes the overhang it needs on the right edge for painting a complete lable, not the complete space it needs for the complete line.

Parameters:
g2d - needed for font metric information.
Returns:
the width in pixel this axis needs to paint itself.

getHeight

int getHeight(Graphics2D g2d)
Returns the height in pixel this axis needs to paint itself.

This includes the axis line, it's ticks and labels and it's title.

Note:
For an y axis the hight only includes the overhang it needs on the upper edge for painting a complete lable, not the complete space it needs for the complete line.

Parameters:
g2d - needed for font metric information.
Returns:
the height in pixel this axis needs to paint itself.

getPropertyChangeListeners

PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
Returns an array of all the listeners that were added to the this instance with addPropertyChangeListener(String, PropertyChangeListener).

Parameters:
propertyName - The name of the property being listened to.
Returns:
an array of all the listeners that were added to the this instance with addPropertyChangeListener(String, PropertyChangeListener).
See Also:
PropertyChangeSupport.getPropertyChangeListeners(java.lang.String)

getRange

Range getRange()
This method is used by the Chart2D to scale it's values during painting.

Caution: This method does not necessarily return the Range configured with setRange(Range). The internal IRangePolicy is taken into account.

Returns:
the range corresponding to the upper and lower bound of the values that will be displayable on this Axis of the Chart2D.
See Also:
setRangePolicy(IRangePolicy)

getRangePolicy

IRangePolicy getRangePolicy()
Returns the range policy used by this axis.

Returns:
the range policy used by this axis
See Also:
AAxis.AChart2DDataAccessor.getRangePolicy()

getScaledValue

double getScaledValue(double absolute)
Scales the given absolute value into a value between 0 and 1.0 (if it is in the range of the data).

If the given absolute value is not in the display- range of the Chart2D, negative values or values greater than 1.0 may result.

Parameters:
absolute - a value in the real value range of the corresponding chart.
Returns:
a value between 0.0 and 1.0 that is mapped to a position within the chart.

isPaintGrid

boolean isPaintGrid()
Returns wether the x grid is painted or not.

Returns:
wether the x grid is painted or not.

isPaintScale

boolean isPaintScale()
Returns whether the scale for this axis should be painted or not.

Returns:
whether the scale for this axis should be painted or not.

isStartMajorTick

boolean isStartMajorTick()
Check wether scale values are started from major ticks.

Returns:
true if scale values start from major ticks.
See Also:
AAxis.setMajorTickSpacing(double)

removePropertyChangeListener

void removePropertyChangeListener(String property,
                                  PropertyChangeListener listener)
Remove a PropertyChangeListener for a specific property. If listener was added more than once to the same event source for the specified property, it will be notified one less time after being removed. If propertyName is null, no exception is thrown and no action is taken. If listener is null, or was never added for the specified property, no exception is thrown and no action is taken.

Parameters:
property - The name of the property that was listened on.
listener - The PropertyChangeListener to be removed.
See Also:
PropertyChangeSupport.removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)

replace

void replace(IAxis axis)
Copies the complete state (flat, references are overtaken) of the given axis to this instance and overtakes any property change listeners.

This is used when a new axis is set to a chart.

Parameters:
axis - the axis to replace by this instance.
See Also:
Chart2D.setAxisX(info.monitorenter.gui.chart.axis.AAxis), Chart2D.setAxisY(info.monitorenter.gui.chart.axis.AAxis)

setFormatter

void setFormatter(IAxisLabelFormatter formatter)
Sets the formatter to use for labels.

Parameters:
formatter - The formatter to set.

setMajorTickSpacing

void setMajorTickSpacing(double majorTickSpacing)
This method sets the major tick spacing for label generation.

Only values between 0.0 and 100.0 are allowed.

The number that is passed in represents the distance, measured in values, between each major tick mark. If you have a trace with a range from 0 to 50 and the major tick spacing is set to 10, you will get major ticks next to the following values: 0, 10, 20, 30, 40, 50.

Note:
Ticks are free of any multiples of 1000. If the chart contains values between 0 an 1000 and configured a tick of 2 the values 0, 200, 400, 600, 800 and 1000 will highly probable to be displayed. This depends on the size (in pixels) of the Chart2D<. Of course there is a difference: ticks are used in divisions and multiplications: If the internal values are very low and the ticks are very high, huge rounding errors might occur (division by ticks results in very low values a double cannot hit exactly. So prefer setting ticks between 0 an 10 or - if you know your values are very small (e.g. in nano range [10 -9 ]) use a small value (e.g. 2*10 -9 ).

Parameters:
majorTickSpacing - the major tick spacing for label generation.

setMinorTickSpacing

void setMinorTickSpacing(double minorTickSpacing)
This method sets the minor tick spacing for label generation.

The number that is passed-in represents the distance, measured in values, between each minor tick mark. If you have a trace with a range from 0 to 10 and the minor tick spacing is set to 2, you will get major ticks next to the following values: 0, 2, 4, 6, 8, 10. If a major tick hits the same values the tick will be a major ticks. For this example: if a major tick spacing is set to 5 you will only get minor ticks for: 2, 4, 6, 8.

Note:
Ticks are free of any powers of 10. There is no difference between setting a tick to 2, 200 or 20000 because ticks cannot break the rule that every scale label has to be visible. If the chart contains values between 0 an 1000 and configured a tick of 2 the values 0, 200, 400, 600, 800 and 1000 will highly probable to be displayed. This depends on the size (in pixels) of the Chart2D<. Of course there is a difference: ticks are used in divisions and multiplications: If the internal values are very low and the ticks are very high, huge rounding errors might occur (division by ticks results in very low values a double cannot hit exactly. So prefer setting ticks between 0 an 10 or - if you know your values are very small (e.g. in nano range [10 -9 ]) use a small value (e.g. 2*10 -9 ).

Parameters:
minorTickSpacing - the minor tick spacing to set.

setPaintGrid

void setPaintGrid(boolean grid)
Set wether the grid in this dimension should be painted or not.

A repaint operation for the chart is triggered.

Parameters:
grid - true if the grid should be painted or false if not.

setPaintScale

void setPaintScale(boolean show)
Set if the scale for this axis should be shown.

Parameters:
show - true if the scale on this axis should be shown, false else.

setRange

void setRange(Range range)
Sets a Range to use for filtering the view to the the connected Axis. Note that it's effect will be affected by the internal IRangePolicy.

To get full control use:
setRangePolicy(new <AnARangePolicy>(range);

Parameters:
range - Range to use for filtering the view to the the connected Axis.
See Also:
getRangePolicy(), IRangePolicy.setRange(Range)

setRangePolicy

void setRangePolicy(IRangePolicy rangePolicy)
Sets the RangePolicy.

If the given RangePolicy has an unconfigured internal Range ( Range.RANGE_UNBOUNDED) the old internal RangePolicy is taken into account:
If the old RangePolicy has a configured Range this is transferred to the new RangePolicy.

Parameters:
rangePolicy - The rangePolicy to set.

setStartMajorTick

void setStartMajorTick(boolean majorTick)
Set wether scale values are started from major ticks.

Parameters:
majorTick - true if scale values shall start with a major tick.
See Also:
AAxis.setMajorTickSpacing(double)


Copyright © 2001 - 2007 LGPL, All Rights Footloose.