info.monitorenter.gui.chart.axis
Class AAxis.XDataAccessor

java.lang.Object
  extended by info.monitorenter.gui.chart.axis.AAxis.AChart2DDataAccessor
      extended by info.monitorenter.gui.chart.axis.AAxis.XDataAccessor
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AAxisTransformation.XDataAccessor, AxisInverse.XDataInverseAccessor
Enclosing class:
AAxis<T extends IAxisScalePolicy>

public class AAxis.XDataAccessor
extends AAxis.AChart2DDataAccessor

An accessor for the x axis of a chart.

Author:
Chart2D.getAxisX(), Serialized Form

Field Summary
 
Fields inherited from class info.monitorenter.gui.chart.axis.AAxis.AChart2DDataAccessor
m_chart
 
Constructor Summary
AAxis.XDataAccessor(Chart2D chart)
          Creates an instance that accesses the given chart's x axis.
 
Method Summary
 int getDimension()
          Returns the constant for the dimension that is accessed on the chart.
 int getHeight(java.awt.Graphics g2d)
          Returns the height in pixel the corresponding axis needs to paint itself.
protected  double getMaximumPixelForLabel(java.awt.Graphics g2d)
          Returns the maximum pixels that will be needed to paint a label.
protected  double getMaxValue(ITrace2D trace)
          Returns the max value of the given trace according to the dimension the outer axis belongs to.
 double getMinimumValueDistanceForLabels(java.awt.Graphics g2d)
          Returns the minimum amount of increase in the value that will be needed to display all labels without overwriting each others.
protected  double getMinValue(ITrace2D trace)
          Returns the min value of the given trace according to the dimension the outer axis belongs to.
protected  int getPixelRange()
          Returns the amount of pixel available for displaying the values on the chart in the dimension this accessor stands for.
protected  double getValue(ITracePoint2D point)
          Returns the value of the given point according to the dimension the outer axis belongs to.
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 AAxis.
 int getWidth(java.awt.Graphics g2d)
          Returns the width in pixel the corresponding axis needs to paint itself.
protected  void scaleTrace(ITrace2D trace, Range range)
          Scales the given trace in the dimension represented by this axis.
 java.lang.String toString()
          Returns "X".
 double translateMousePosition(java.awt.event.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.getX() 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 info.monitorenter.gui.chart.axis.AAxis.AChart2DDataAccessor
getChart
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AAxis.XDataAccessor

public AAxis.XDataAccessor(Chart2D chart)
Creates an instance that accesses the given chart's x axis.

Parameters:
chart - the chart to access.
Method Detail

getDimension

public int getDimension()
Description copied from class: AAxis.AChart2DDataAccessor
Returns the constant for the dimension that is accessed on the chart.

Specified by:
getDimension in class AAxis.AChart2DDataAccessor
Returns:
Chart2D.X, Chart2D.Y or -1 if this axis is not assigned to a chart.
See Also:
AAxis.AChart2DDataAccessor.getDimension()

getHeight

public int getHeight(java.awt.Graphics g2d)
Description copied from class: AAxis.AChart2DDataAccessor
Returns the height in pixel the corresponding axis needs to paint itself.

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

Specified by:
getHeight in class AAxis.AChart2DDataAccessor
Parameters:
g2d - needed for font metric information.
Returns:
the height in pixel the corresponding axis needs to paint itself.
See Also:
AAxis.AChart2DDataAccessor.getHeight(java.awt.Graphics)

getMaximumPixelForLabel

protected final double getMaximumPixelForLabel(java.awt.Graphics g2d)
Description copied from class: AAxis.AChart2DDataAccessor
Returns the maximum pixels that will be needed to paint a label.

Specified by:
getMaximumPixelForLabel in class AAxis.AChart2DDataAccessor
Parameters:
g2d - provides information about the graphics context to paint on (e.g. font size).
Returns:
the maximum pixels that will be needed to paint a label.
See Also:
AAxis.AChart2DDataAccessor.getMaximumPixelForLabel(Graphics)

getMaxValue

protected double getMaxValue(ITrace2D trace)
Description copied from class: AAxis.AChart2DDataAccessor
Returns the max value of the given trace according to the dimension the outer axis belongs to.

This is either an x or an y value depending on the dimension the outer axis is working in.

Specified by:
getMaxValue in class AAxis.AChart2DDataAccessor
Parameters:
trace - the trace to read the maximum of.
Returns:
the max value of the given trace according to the dimension the outer axis belongs to.
See Also:
AAxis.AChart2DDataAccessor.getMaxValue(info.monitorenter.gui.chart.ITrace2D)

getMinimumValueDistanceForLabels

public final double getMinimumValueDistanceForLabels(java.awt.Graphics g2d)
Description copied from class: AAxis.AChart2DDataAccessor
Returns the minimum amount of increase in the value that will be needed to display all labels without overwriting each others.

This procedure needs the amount of pixels needed by the largest possible label and relies on the implementation of AAxis.AChart2DDataAccessor.getMaximumPixelForLabel(Graphics), whose result is multiplied with the "value per pixel" quantifier.

Specified by:
getMinimumValueDistanceForLabels in class AAxis.AChart2DDataAccessor
Parameters:
g2d - the current graphic context to use in case further information is required.
Returns:
the minimum amount of increase in the value that will be needed to display all labels without overwriting each others.
See Also:
AAxis.AChart2DDataAccessor.getMinimumValueDistanceForLabels(java.awt.Graphics)

getMinValue

protected double getMinValue(ITrace2D trace)
Description copied from class: AAxis.AChart2DDataAccessor
Returns the min value of the given trace according to the dimension the outer axis belongs to.

This is either an x or an y value depending on the dimension the outer axis is working in.

Specified by:
getMinValue in class AAxis.AChart2DDataAccessor
Parameters:
trace - the trace to read the maximum of.
Returns:
the min value of the given trace according to the dimension the outer axis belongs to.
See Also:
AAxis.AChart2DDataAccessor.getMinValue(info.monitorenter.gui.chart.ITrace2D)

getPixelRange

protected int getPixelRange()
Description copied from class: AAxis.AChart2DDataAccessor
Returns the amount of pixel available for displaying the values on the chart in the dimension this accessor stands for.

This method must not be called within the first lines of a paint cycle (necessary underlying values then are computed new).

Specified by:
getPixelRange in class AAxis.AChart2DDataAccessor
Returns:
the amount of pixel available for displaying the values on the chart in the dimension this accessor stands for.
See Also:
AAxis.AChart2DDataAccessor.getPixelRange()

getValue

protected double getValue(ITracePoint2D point)
Description copied from class: AAxis.AChart2DDataAccessor
Returns the value of the given point according to the dimension the outer axis belongs to.

This is either ITracePoint2D.getX() or ITracePoint2D.getY().

Specified by:
getValue in class AAxis.AChart2DDataAccessor
Parameters:
point - the point to read ITracePoint2D.getX() or ITracePoint2D.getY() from.
Returns:
the value of the given point according to the dimension the outer axis belongs to.
See Also:
AAxis.AChart2DDataAccessor.getValue(info.monitorenter.gui.chart.ITracePoint2D)

getValueDistanceForPixel

protected final double getValueDistanceForPixel(int pixel)
Description copied from class: AAxis.AChart2DDataAccessor
Returns the value distance on the current chart that exists for the given amount of pixel distance in the given direction of this AAxis.

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 added ITrace2D instances changes.

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.

Specified by:
getValueDistanceForPixel in class AAxis.AChart2DDataAccessor
Parameters:
pixel - The desired distance between to scale points of the x- axis in pixel.
Returns:
a scaled (from pixel to internal value-range) and normed (to the factor of the current unit of the axis) value usable to calculate the coordinates for the scale points of the axis.
See Also:
AAxis.AChart2DDataAccessor.getValueDistanceForPixel(int)

getWidth

public int getWidth(java.awt.Graphics g2d)
Description copied from class: AAxis.AChart2DDataAccessor
Returns the width in pixel the corresponding axis needs to paint itself.

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

Specified by:
getWidth in class AAxis.AChart2DDataAccessor
Parameters:
g2d - needed for font metric information.
Returns:
the width in pixel the corresponding axis needs to paint itself.
See Also:
AAxis.AChart2DDataAccessor.getWidth(java.awt.Graphics)

scaleTrace

protected void scaleTrace(ITrace2D trace,
                          Range range)
Description copied from class: AAxis.AChart2DDataAccessor
Scales the given trace in the dimension represented by this axis.

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

Specified by:
scaleTrace in class AAxis.AChart2DDataAccessor
Parameters:
trace - the trace to scale.
range - the range to use as scaler.
See Also:
AAxis.AChart2DDataAccessor.scaleTrace(info.monitorenter.gui.chart.ITrace2D, info.monitorenter.util.Range)

toString

public java.lang.String toString()
Returns "X".

Overrides:
toString in class java.lang.Object
Returns:
"X"

translateMousePosition

public final double translateMousePosition(java.awt.event.MouseEvent mouseEvent)
Description copied from class: AAxis.AChart2DDataAccessor
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.

Note that the mouse event has to be an event fired on this component!

Specified by:
translateMousePosition in class AAxis.AChart2DDataAccessor
Parameters:
mouseEvent - a mouse event that has been fired on this component.
Returns:
the translation of the mouse event coordinates of the given mouse event to the value within the chart for the dimension covered by this axis (x or y) or null if no calculations could be performed as the chart was not painted before.
See Also:
AAxis.AChart2DDataAccessor.translateMousePosition(java.awt.event.MouseEvent)

translatePxToValue

public double translatePxToValue(int pixel)
Description copied from class: AAxis.AChart2DDataAccessor
Transforms the given pixel value (which has to be a awt value like MouseEvent.getX() 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.

Warning: A value transformed to a pixel by AAxis.AChart2DDataAccessor.translateValueToPx(double) and then retransformed by AAxis.AChart2DDataAccessor.translatePxToValue(int) will most often have changed, as the transformation from value to px a) has to hit an exact int b) most often will map from a bigger domain (value range) to a smaller one (range of chart on the screen).

Specified by:
translatePxToValue in class AAxis.AChart2DDataAccessor
Parameters:
pixel - a pixel value of the chart component as used by awt.
Returns:
the awt pixel value transformed to the chart value.
See Also:
AAxis.AChart2DDataAccessor.translatePxToValue(int)

translateValueToPx

public int translateValueToPx(double value)
Description copied from class: AAxis.AChart2DDataAccessor
Transforms the given chart data value into the corresponding awt pixel value for the chart.

The inverse transformation to AAxis.AChart2DDataAccessor.translatePxToValue(int).

Specified by:
translateValueToPx in class AAxis.AChart2DDataAccessor
Parameters:
value - a chart data value.
Returns:
the awt pixel value corresponding to the chart data value.
See Also:
AAxis.AChart2DDataAccessor.translateValueToPx(double)


Copyright © 2001 - 2010 LGPL, All Rights Footloose.