All Packages Class Hierarchy This Package Previous Next Index
Class GraphicPlotter.AxisScale
java.lang.Object
|
+----java.awt.Component
|
+----GraphicPlotter.MagnifiableComponent
|
+----GraphicPlotter.AxisScale
- public class AxisScale
- extends MagnifiableComponent
Component that is an X-axis or Y-axis scale. As a Component, a scale
is responsible for overriding the following methods.
- paint(Graphics) to draw the scale.
- getMinimumSize() and getPreferredSize() to tell
a layout manager of how much space it needs. For an X-axis scale,
only the height field of the size is relevant; the scale is expected
to be able to paint itself for any width. For an Y-axis scale, only
the width field of the size is revelant; the scale is expected to be
able to paint itself for any height.
The default implementation of the methods declared by this class is
sufficient for the rest of the package to work correctly when an axis
scale is not supplied. See the comments for each method on what the
default implementation does to determine if it needs to be overriden.
-
extent
- The extent of the range to be covered by the scale in terms of
user coordinates (set by the package).
-
origin
- The origin of the range to be covered by the scale in terms of
user coordinates (set by the package).
-
AxisScale()
-
-
createCoordinateAdjuster(double)
- Return the CoordinateAdjuster with a scale coordinate value that
corresponds to the user coordinate value given as an argument.
-
getAdjusterValue(CoordinateAdjuster)
- Return the user coordinate corresponding to the scale coordinate
that a coordinateAdjuster is set to.
-
getExtraInsets()
- Return the extra insets needed to show the end point values of
the scale.
-
parseScaleCoordinate(String)
- Return the user coordinate cooresponding to a scale coordinate
value.
-
scaleCoordinateOf(double)
- Return the scale coordinate form of a user coordinate value.
-
validate()
- Override validate(): unlike most types Components, validate is
invoked on this type.
origin
protected double origin
- The origin of the range to be covered by the scale in terms of
user coordinates (set by the package).
extent
protected double extent
- The extent of the range to be covered by the scale in terms of
user coordinates (set by the package).
AxisScale
public AxisScale()
getExtraInsets
public Insets getExtraInsets()
- Return the extra insets needed to show the end point values of
the scale. A return value of null indicates that there are no
extra insets. The default implementation returns null.
For an X-axis scale, only the right and left values are used by
the package; for a Y-axis scale, only the top and bottom values
are used by the package.
As an example, an X-axis scale with a range of 0 to 100 that wants
to draw itself as
|--------------------|
0 100
would return a left value of one half of the width of "0" and a
right value of one half the width of "100".
The package needs to know the extra insets being used by the
scale in order to draw each graphic element at its correct
position with respect to the scale.
createCoordinateAdjuster
public CoordinateAdjuster createCoordinateAdjuster(double uc)
- Return the CoordinateAdjuster with a scale coordinate value that
corresponds to the user coordinate value given as an argument.
Usually, the scale coordinate value will be the same as the user
coordinate value. Two cases where they differ are
- The scale coordinate is a power of 10 of the user coordinate.
For example, the scale coordinate is in terms of seconds while the
user coordinate in terms of milliseconds.
- The scale is discrete rather than continuous. For example,
the scale may used letters ('A', 'B', 'C', ...) with the mapping
between scale coordinates and user coordinates being (('A', 1.0),
('B', 2.0), ('C', 3.0), ...).
Having different scale and user coordinates allows for locations
to be changed in terms of scale coordinates while the rest of the
package deals with user coordinates.
In the default implementation, the scale and user coordinates are
the same.
getAdjusterValue
public double getAdjusterValue(CoordinateAdjuster ca) throws RuntimeException
- Return the user coordinate corresponding to the scale coordinate
that a coordinateAdjuster is set to.
exception java.lang.RuntimeException Thrown when CoordinateAdjuster value cannot be converted to a user coordinate.
The default implementation tests if the value is a
double value within the range of values covered by
the scale.
scaleCoordinateOf
public String scaleCoordinateOf(double uc)
- Return the scale coordinate form of a user coordinate value.
Because the default implementation returns the String
cooresponding to the double coordinate value, the scale
value may contain more digits after the decimal point than are
meaningful.
parseScaleCoordinate
public double parseScaleCoordinate(String sc) throws NumberFormatException
- Return the user coordinate cooresponding to a scale coordinate
value. The default implementation parses the scale coordinate
string to obtain a double value. The default
implementation throws an exception if the scale coordinate cannot
be parsed as a double value.
- Throws: NumberFormatException
- Thrown when ScaleCoordinate cannot be converted to a user coordinate.
validate
public void validate()
- Override validate(): unlike most types Components, validate is
invoked on this type. The default implementation repaints the
scale if it is invalid. This behavior is similar to that of
Components that repaint themeselves, in necessary, when the
Container that they are being laidout.
This method is invoked by the package when the graphic elements
are being laidout. Code that uses the package should invalidate
a scale rather than directly repainting it in order to coordinate
the repainting of a scale with the repainting of the graphic
elements done by the package.
- Overrides:
- validate in class Component
All Packages Class Hierarchy This Package Previous Next Index