|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectLine2D
Axis2D
public class Axis2D
An axis as a graduated line. Axis2D objets are really Line2D objects with a
Graduation. Because axis are Line2D, they can be located anywhere in a widget
with any orientation. Lines are drawn from starting point
(x1,y1)
to end point
(x2,y2),
using a graduation from minimal value Graduation.getMinimum() to maximal
value Graduation.getMaximum().
Note the line's coordinates (x1,y1) and
(x2,y2) are completely independent of graduation
minimal and maximal values. Line's coordinates should be expressed in some units convenient
for rendering, as pixels or point (1/72 of inch). On the opposite, graduation can have any
arbitrary units, which is given by Graduation.getUnit(). The
createAffineTransform static method can be used for mapping
logical coordinates to pixels coordinates for an arbitrary pair of Axis2D objects,
which doesn't need to be perpendicular.
DefaultCoordinateSystemAxis,
AxisDirection,
Graduation,
Serialized Form
| display/geotk-display (download) | View source code for this class |
| Nested Class Summary | |
|---|---|
class |
Axis2D.TickIterator
Iterates along the graduation ticks and provides access to the graduation values. |
| Nested classes/interfaces inherited from class Line2D |
|---|
Line2D.Double, Line2D.Float |
| Constructor Summary | |
|---|---|
Axis2D()
Constructs an axis with a default NumberGraduation. |
|
Axis2D(Graduation graduation)
Constructs an axis with the specified graduation. |
|
| Method Summary | |
|---|---|
static AffineTransform |
createAffineTransform(Axis2D xAxis,
Axis2D yAxis)
Creates an affine transform mapping logical to pixels coordinates for a pair of axes. |
Rectangle2D |
getBounds2D()
Returns a bounding box for this axis. |
Graduation |
getGraduation()
Returns the axis's graduation. |
double |
getLength()
Returns the axis length. |
Point2D |
getP1()
Returns the (x,y) coordinates of the start point. |
Point2D |
getP2()
Returns the (x,y) coordinates of the end point. |
PathIterator |
getPathIterator(AffineTransform transform)
Returns an iterator object that iterates along the Axis2D boundary
and provides access to the geometry of the shape outline. |
PathIterator |
getPathIterator(AffineTransform transform,
double flatness)
Returns an iterator object that iterates along the Axis2D boundary
and provides access to the geometry of the shape outline. |
Object |
getRenderingHint(RenderingHints.Key key)
Returns the value of a single preference for the rendering algorithms. |
double |
getX1()
Returns the x coordinate of the start point. |
double |
getX2()
Returns the x coordinate of the end point. |
double |
getY1()
Returns the y coordinate of the start point. |
double |
getY2()
Returns the y coordinate of the end point. |
boolean |
isLabelClockwise()
Returns true if the axis would have to rotate clockwise in order to
overlaps its graduation. |
void |
paint(Graphics2D graphics)
Draw this axis in the specified graphics context. |
void |
setLabelClockwise(boolean c)
Sets the label's locations relative to this axis. |
void |
setLine(double x1,
double y1,
double x2,
double y2)
Sets the location of the endpoints of this Axis2D to the specified
coordinates. |
void |
setRenderingHint(RenderingHints.Key key,
Object value)
Sets the value of a single preference for the rendering algorithms. |
DefaultCoordinateSystemAxis |
toCoordinateSystemAxis()
Returns this axis name and direction. |
String |
toString()
Returns a string representation of this axis. |
| Methods inherited from class Line2D |
|---|
clone, contains, contains, contains, contains, getBounds, intersects, intersects, intersectsLine, intersectsLine, linesIntersect, ptLineDist, ptLineDist, ptLineDist, ptLineDistSq, ptLineDistSq, ptLineDistSq, ptSegDist, ptSegDist, ptSegDist, ptSegDistSq, ptSegDistSq, ptSegDistSq, relativeCCW, relativeCCW, relativeCCW, setLine, setLine |
| Methods inherited from class Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface Cloneable |
|---|
clone |
| Constructor Detail |
|---|
public Axis2D()
NumberGraduation.
public Axis2D(Graduation graduation)
graduation - The graduation to be given to this axis.| Method Detail |
|---|
public Graduation getGraduation()
public double getX1()
getX1 in class Line2DgetY1(),
getX2(),
setLine(double, double, double, double)public double getX2()
getX2 in class Line2DgetY2(),
getX1(),
setLine(double, double, double, double)public double getY1()
getY1 in class Line2DgetX1(),
getY2(),
setLine(double, double, double, double)public double getY2()
getY2 in class Line2DgetX2(),
getY1(),
setLine(double, double, double, double)public Point2D getP1()
getP1 in class Line2Dpublic Point2D getP2()
getP2 in class Line2Dpublic double getLength()
P2). This length is usually measured in pixels or points
(1/72 of inch).
public Rectangle2D getBounds2D()
P1) to (P2), the axis's ticks and all labels.
getBounds2D in interface ShapegetX1(),
getY1(),
getX2(),
getY2()
public void setLine(double x1,
double y1,
double x2,
double y2)
throws IllegalArgumentException
Axis2D to the specified
coordinates. Coordinates should be in pixels (for screen rendering) or points
(for paper rendering). Using points units make it easy to render labels with
a reasonable font size, no matter the screen resolution or the axis graduation.
setLine in class Line2Dx1 - Coordinate x of starting point.y1 - Coordinate y of starting pointx2 - Coordinate x of end point.y2 - Coordinate y of end point.
IllegalArgumentException - If a coordinate is NaN or infinite.getX1(),
getY1(),
getX2(),
getY2()public boolean isLabelClockwise()
true if the axis would have to rotate clockwise in order to
overlaps its graduation.
true if the axis would have to rotate clockwise in order to
overlaps its graduation.public void setLabelClockwise(boolean c)
true means
that the axis would have to rotate clockwise in order to overlaps its graduation.
Value false means that the axis would have to rotate counter-clockwise
in order to overlaps its graduation.
c - true if the axis would have to rotate clockwise in order to
overlaps its graduation.public PathIterator getPathIterator(AffineTransform transform)
Axis2D boundary
and provides access to the geometry of the shape outline. The shape includes
the axis line, graduation and labels. If an optional AffineTransform
is specified, the coordinates returned in the iteration are transformed accordingly.
getPathIterator in interface ShapegetPathIterator in class Line2Dtransform - The transform to apply on the coordinates to be iterated.
public PathIterator getPathIterator(AffineTransform transform,
double flatness)
Axis2D boundary
and provides access to the geometry of the shape outline. The shape includes
the axis line, graduation and labels. If an optional AffineTransform
is specified, the coordinates returned in the iteration are transformed accordingly.
getPathIterator in interface ShapegetPathIterator in class Line2Dtransform - The transform to apply on the coordinates to be iterated.flatness - Control the subdivisions of curves by straight lines.public void paint(Graphics2D graphics)
Graphics2D.draw(this). However, this method may be slightly
faster and produce better quality output.
graphics - The graphics context to use for drawing.public Object getRenderingHint(RenderingHints.Key key)
Graduation interface.
key - The key corresponding to the hint to get.
null
if no value is associated to the specified key.Graduation.TICK_LABEL_FONT,
Graduation.AXIS_TITLE_FONT
public void setRenderingHint(RenderingHints.Key key,
Object value)
Graduation interface.
key - The key of the hint to be set.value - The value indicating preferences for the specified hint category.
A null value removes any hint for the specified key.Graduation.TICK_LABEL_FONT,
Graduation.AXIS_TITLE_FONTpublic String toString()
toString in class Objectpublic DefaultCoordinateSystemAxis toCoordinateSystemAxis()
public static AffineTransform createAffineTransform(Axis2D xAxis,
Axis2D yAxis)
xAxis
and yAxis graduations, respectively.xAxis, which may or may not be horizontal. Changing the y
value move the pixel location in parallel with the yAxis, which may or
may not be vertical.
xAxis - The x axis. This axis doesn't have to be horizontal;
it can have any orientation, including vertical.yAxis - The y axis. This axis doesn't have to be vertical;
it can have any orientation, including horizontal.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||