|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectinfo.monitorenter.gui.chart.axis.AAxis
public abstract class AAxis
The base class for an axis of the
.
Chart2D
Normally - as the design and interaction of an Axis
with the
is very fine-grained - it is not instantiated by users of
jchart2d: It is automatically instantiated by the constructor of Chart2D
DChart2D
. It then
may be retrieved from the Chart2D
by the methods Chart2D.getAxisX()
and
Chart2D.getAxisY()
for further configuration.
Nested Class Summary | |
---|---|
class |
AAxis.AChart2DDataAccessor
An internal connector class that will connect the axis to the a Chart2D. |
class |
AAxis.XDataAccessor
An accessor for the x axis of a chart. |
class |
AAxis.YDataAccessor
Accesses the y axis of the Chart2D . |
Field Summary | |
---|---|
protected AAxis.AChart2DDataAccessor |
m_accessor
The accessor to the Chart2D. |
protected IAxisLabelFormatter |
m_formatter
Formatting of the labels. |
protected double |
m_majorTickSpacing
The major tick spacing for label generations. |
protected double |
m_minorTickSpacing
The minor tick spacing for label generations. |
protected double |
m_power
Internally used for rouding to ticks, calculated once per paint iteration. |
Fields inherited from interface info.monitorenter.gui.chart.IAxis |
---|
PROPERTY_LABELFORMATTER, PROPERTY_PAINTGRID, PROPERTY_RANGEPOLICY, PROPERTY_TITLE, PROPERTY_TITLEFONT, PROPERTY_TITLEPAINTER |
Constructor Summary | |
---|---|
AAxis()
Default constructor that uses a LabelFormatterAutoUnits for formatting labels. |
|
AAxis(IAxisLabelFormatter formatter)
Constructor that uses the given label formatter for formatting labels. |
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. |
protected abstract AAxis.AChart2DDataAccessor |
createAccessor(Chart2D chart,
int dimension)
Template method to create the proper
implementation. |
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. |
protected LabeledValue[] |
getLabels(double resolution)
Returns the labels for this axis. |
double |
getMajorTickSpacing()
Get the major tick spacing for label generation. |
double |
getMax()
The maximum value access method for the Axis this instance is aggregated to. |
double |
getMin()
Returns the minimum value access method for the Axis this instance is aggregated to. |
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 IAxis.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 of this axis. |
LabeledValue[] |
getScaleValues(Graphics g2d)
Returns the array of labeled values that will be used by the Chart2D to paint labels. |
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. |
protected double |
getValueDistanceForPixel(int pixel)
Returns the value distance on the current chart that exists for the given amount of pixel distance in the given direction of this Axis . |
int |
getWidth(Graphics2D g2d)
Returns the width in pixel this axis needs to paint itself. |
void |
initPaintIteration()
Perfomres expensive calculations for various values that are used by many calls throughout a paint iterations. |
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. |
int |
paintTitle(Graphics2D g2d)
Routine for painting the title of this axis. |
void |
propertyChange(PropertyChangeEvent evt)
|
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. |
protected LabeledValue |
roundToTicks(double value,
boolean floor,
boolean findMajorTick)
Internal rounding routine. |
void |
scale()
Scales all instances in the dimension
represented by this axis. |
void |
scaleTrace(ITrace2D trace)
Scales the given in the dimension
represented by this axis. |
protected void |
setAccessor(AAxis.AChart2DDataAccessor accessor)
Sets the accessor to the axis of the chart. |
void |
setChart(Chart2D chart,
int dimension)
Allows the chart to register itself with the axix. |
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 of this axis which is by default . |
double |
translateMousePosition(MouseEvent mouseEvent)
Returns the translation of the mouse event coordinates of the given mouse event to the value within the chart for the dimension (x,y) covered by 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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface info.monitorenter.gui.chart.IAxis |
---|
getScaledValue |
Field Detail |
---|
protected AAxis.AChart2DDataAccessor m_accessor
It determines, which axis (x or y) this instance is representing.
protected IAxisLabelFormatter m_formatter
protected double m_majorTickSpacing
setMajorTickSpacing(double)
protected double m_minorTickSpacing
setMinorTickSpacing(double)
protected double m_power
Constructor Detail |
---|
public AAxis()
LabelFormatterAutoUnits
for formatting labels.
public AAxis(IAxisLabelFormatter formatter)
formatter
- needed for formatting labels of this axis.Method Detail |
---|
public final void propertyChange(PropertyChangeEvent evt)
propertyChange
in interface PropertyChangeListener
PropertyChangeListener.propertyChange(java.beans.PropertyChangeEvent)
public boolean addTrace(ITrace2D trace)
IAxis
addTrace
in interface IAxis
trace
- the trace to add.
IAxis.addTrace(info.monitorenter.gui.chart.ITrace2D)
public boolean removeTrace(ITrace2D trace)
IAxis
removeTrace
in interface IAxis
trace
- the trace to remove from this axis.
IAxis.removeTrace(info.monitorenter.gui.chart.ITrace2D)
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
IAxis
The following PropertyChangeEvent
types should be fired
to listeners:
getPropertyName() |
getSource() |
getOldValue() |
getNewValue() |
---|---|---|---|
|
that changed |
, the old value. |
, the new value. |
|
that changed |
, the old value. |
, the new value. |
|
that changed |
, the old value or null if
there was no formatter before. |
, the new value. |
|
that changed |
, the old value or null if there was no
title before. |
, the new value. |
|
that changed |
, the old value or null if
there was no title painter before. |
, the new value. |
|
that changed |
, the old value or null if there
was no title font before. |
, the new value. |
addPropertyChangeListener
in interface IAxis
propertyName
- the property to be informed about changes.listener
- the listener that will be informed.IAxis.addPropertyChangeListener(java.lang.String,
java.beans.PropertyChangeListener)
protected abstract AAxis.AChart2DDataAccessor createAccessor(Chart2D chart, int dimension)
AAxis.AChart2DDataAccessor
implementation.
chart
- the chart to access.dimension
- Chart2D.X
or Chart2D.Y
.
AAxis.AChart2DDataAccessor
implementation.public AAxis.AChart2DDataAccessor getAccessor()
getAccessor
in interface IAxis
public int getDimension()
IAxis
getDimension
in interface IAxis
Chart2D.X
, Chart2D.Y
or -1 if this axis is not
assigned to a chart.IAxis.getDimension()
public final IAxisLabelFormatter getFormatter()
IAxis
getFormatter
in interface IAxis
public final int getHeight(Graphics2D g2d)
IAxis
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.
getHeight
in interface IAxis
g2d
- needed for font metric information.
IAxis.getHeight(java.awt.Graphics2D)
protected LabeledValue[] getLabels(double resolution)
The labels will have at least the given argument resolution
as distance in the
value domain of the chart.
resolution
- the distance in the value domain of the chart that has to be at least between to
labels.
public double getMajorTickSpacing()
IAxis
getMajorTickSpacing
in interface IAxis
IAxis.getMajorTickSpacing()
public double getMax()
It supports the retrieval of data from the corrcet dimension of the connected Chart2 (X or Y)
as well as the respect to the configured IRangePolicy
.
public double getMin()
It supports the retrieval of data from the corrcet dimension of the connected Chart2 (X or Y)
as well as the respect to the configured IRangePolicy
.
public double getMinorTickSpacing()
getMinorTickSpacing
in interface IAxis
setMinorTickSpacing(double)
public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
IAxis
IAxis.addPropertyChangeListener(String, PropertyChangeListener)
.
getPropertyChangeListeners
in interface IAxis
propertyName
- The name of the property being listened to.
IAxis.addPropertyChangeListener(String, PropertyChangeListener)
.IAxis.getPropertyChangeListeners(java.lang.String)
public final Range getRange()
Caution: This method does not necessarily return the Range configured with
setRange(Range)
. The internal IRangePolicy
is taken into account.
getRange
in interface IAxis
setRangePolicy(IRangePolicy)
public IRangePolicy getRangePolicy()
getRangePolicy
in interface IAxis
AAxis.AChart2DDataAccessor.getRangePolicy()
public LabeledValue[] getScaleValues(Graphics g2d)
Chart2D
to paint labels.
g2d
- Provides information about the graphic context (e.g. font metrics).
Chart2D
to paint labels.public final String getTitle()
IAxis
null
if there was no title configured
before.
getTitle
in interface IAxis
null
if there was no title configured
before.IAxis.getTitle()
public final IAxisTitlePainter getTitlePainter()
IAxis
getTitlePainter
in interface IAxis
IAxis.getTitlePainter()
protected final double getValueDistanceForPixel(int pixel)
Axis
.
Depending on the width of the actual Chart2D and the contained values, the relation between
displayed distances (pixel) and value distances (the values of the addes
instances changes.
ITrace2D
This method calculates depending on the actual painting area of the Chart2D, the shift in value
between two points that have a screen distance of the given pixel.
This method is not used by the chart itself but a helper for outside use.
pixel
- The desired distance between to scalepoints of the x- axis in pixel.
public final int getWidth(Graphics2D g2d)
IAxis
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.
getWidth
in interface IAxis
g2d
- needed for font metric information.
IAxis.getWidth(java.awt.Graphics2D)
public void initPaintIteration()
These values are constant throughout a paint iteration by the contract that no point is added removed or changed in this period. Because these values are used from many methods it is impossible to calculate them at a "transparent" method that may perform this caching over a paint period without knowledge from outside. The first method called in a paint iteration is called several further times in the iteration. So this is the common hook to invoke before painting a chart.
public final boolean isPaintGrid()
isPaintGrid
in interface IAxis
public final boolean isPaintScale()
isPaintScale
in interface IAxis
public boolean isStartMajorTick()
isStartMajorTick
in interface IAxis
setMajorTickSpacing(double)
public int paintTitle(Graphics2D g2d)
Intended for
only!!!
Chart2D
g2d
- needed for painting.
public void removePropertyChangeListener(String property, PropertyChangeListener listener)
IAxis
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.
removePropertyChangeListener
in interface IAxis
property
- The name of the property that was listened on.listener
- The PropertyChangeListener to be removed.IAxis.removePropertyChangeListener(java.lang.String,
java.beans.PropertyChangeListener)
public void replace(IAxis axis)
IAxis
This is used when a new axis is set to a chart.
replace
in interface IAxis
axis
- the axis to replace by this instance.IAxis.replace(info.monitorenter.gui.chart.IAxis)
protected LabeledValue roundToTicks(double value, boolean floor, boolean findMajorTick)
Arguments are not chosen to be "understandable" or "usable" but optimized for performance.
The findMajorTick
argument may be used e.g. to force labels to start from a
major tick.
value
- the value to round.floor
- if true, rounding goes to floor else to ceiling.findMajorTick
- if true the returned value will be a major tick (which might be fare more away from
the given value than the next major tick).
public void scale()
IAxis
ITrace2D
instances in the dimension
represented by this axis.
This method is not deadlock - safe and should be called by the
only!
Chart2D
scale
in interface IAxis
IAxis.scale()
public void scaleTrace(ITrace2D trace)
IAxis
ITrace2D
in the dimension
represented by this axis.
This method is not deadlock - safe and should be called by the
only!
Chart2D
scaleTrace
in interface IAxis
trace
- the trace to scale.IAxis.scaleTrace(info.monitorenter.gui.chart.ITrace2D)
protected final void setAccessor(AAxis.AChart2DDataAccessor accessor)
accessor
- the accessor to the axis of the chart.public void setChart(Chart2D chart, int dimension)
This is intended for Chart2D
only!.
chart
- the chart to register itself with this axis.dimension
- Chart2D.X
or Chart2D.Y
.public void setFormatter(IAxisLabelFormatter formatter)
setFormatter
in interface IAxis
formatter
- The formatter to set.public void setMajorTickSpacing(double majorTickSpacing)
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 ).
setMajorTickSpacing
in interface IAxis
majorTickSpacing
- the major tick spacing for label generation.public void setMinorTickSpacing(double minorTickSpacing)
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 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 ).
setMinorTickSpacing
in interface IAxis
minorTickSpacing
- the minor tick spacing to set.public final void setPaintGrid(boolean grid)
If the grid is set to show (argument is true
) also the painting of the scale
labels (
is turned on. This implicit behaviour
is chosen as it seems senseless to have gridlines without knowing which value they stand for.
setPaintScale(boolean)
setPaintGrid
in interface IAxis
grid
- true if the grid should be painted or false if not.public final void setPaintScale(boolean show)
setPaintScale
in interface IAxis
show
- true if the scale on this axis should be shown, false else.public final 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);
setRange
in interface IAxis
range
- Range to use for filtering the view to the the connected Axis.getRangePolicy()
,
IRangePolicy.setRange(Range)
public 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.
IAxis.PROPERTY_RANGEPOLICY
is fired and receives listeners
if a change took place.
setRangePolicy
in interface IAxis
rangePolicy
- The rangePolicy to set.public void setStartMajorTick(boolean majorTick)
setStartMajorTick
in interface IAxis
majorTick
- true if scale values shall start with a major tick.setMajorTickSpacing(double)
public final String setTitle(String title)
IAxis
{IAxisTitlePainter}
of this instance.
setTitle
in interface IAxis
title
- the title to set.
null
if there was no title
configured before.IAxis.setTitle(String)
public final IAxisTitlePainter setTitlePainter(IAxisTitlePainter painter)
AxisTitlePainterDefault
.
setTitlePainter
in interface IAxis
painter
- the instance that will paint the title of this axis.
IAxis.setTitlePainter(info.monitorenter.gui.chart.IAxisTitlePainter)
public double translateMousePosition(MouseEvent mouseEvent) throws IllegalArgumentException
Note that the mouse event has to be an event fired on the correspondinig chart component!
mouseEvent
- a mouse event that has been fired on this component.
IllegalArgumentException
- if the given mouse event is out of the current graphics context (not a mouse event
of the chart component).public double translatePxToValue(int pixel)
IAxis
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.
translatePxToValue
in interface IAxis
pixel
- a pixel value of the chart component as used by awt.
IAxis.translatePxToValue(int)
public int translateValueToPx(double value)
IAxis
translateValueToPx
in interface IAxis
value
- a chart data value.
IAxis.translateValueToPx(double)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |