Allows the user to modify the coordinate system of a ShapeView
(or
a ShapeScreen
).
You cannot create instances of this class. Instead, you should call
getCoordinateSystem()
or
getCoordinateSystem()
to retrieve the current coordinate
system and then chain method calls to it to apply modifications to the
system. For example,
getCoordinateSystem().origin(Anchor.BOTTOM_LEFT).flipY().width(400);
will set the origin (0, 0) at the bottom-left corner of the view, flip the y-axis so that it grows upward in the positive direction, and fixes the width of the view to be 400 units, scaling it to fit the actual pixel size of the view.
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
CoordinateSystem(ShapeView owner)
Creates a new
CoordinateSystem for the specified
ShapeView . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
PointF
|
deviceToLocal(PointF pt)
Transforms a point from device coordinates (pixels on the view/screen)
to local coordinates.
| ||||||||||
PointF
|
deviceToLocal(float x, float y)
Transforms a point from device coordinates (pixels on the view/screen)
to local coordinates.
| ||||||||||
CoordinateSystem
|
flipX()
Flips the x-axis of the coordinate system so that it higher values on
the x-axis are to the left of lower values.
| ||||||||||
CoordinateSystem
|
flipY()
Flips the y-axis of the coordinate system so that it higher values on
the y-axis are above lower values.
| ||||||||||
CoordinateSystem
|
height(float units)
Sets the number of vertical units that the view should occupy.
| ||||||||||
boolean
|
isFlippedX()
Gets a value indicating whether the x-axis of this coordinate system is
flipped (that is, higher values of x are to the left lower values).
| ||||||||||
boolean
|
isFlippedY()
Gets a value indicating whether the y-axis of this coordinate system is
flipped (that is, higher values of y are above lower values).
| ||||||||||
CoordinateSystem
|
origin(Anchor anchor)
Sets the location on the view where the origin (0, 0) is located.
| ||||||||||
void
|
reset()
Resets the coordinate system so that the origin is in the top-left
corner of the view, the x-axis goes right in the positive direction,
the y-axis goes down in the positive direction, and one unit is equal
to one pixel.
| ||||||||||
CoordinateSystem
|
width(float units)
Sets the number of horizontal units that the view should occupy.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void
|
applyTransform(Canvas canvas)
Applies the transformation represented by this coordinate system to the
specified
Graphics2D object. | ||||||||||
void
|
updateTransform()
Called internally to update the
AffineTransform that will be
used to transform this view. |
Methods inherited from
class
java.lang.Object
| |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Object
|
clone()
| ||||||||||
boolean
|
equals(Object arg0)
| ||||||||||
void
|
finalize()
| ||||||||||
final
Class<?>
|
getClass()
| ||||||||||
int
|
hashCode()
| ||||||||||
final
void
|
notify()
| ||||||||||
final
void
|
notifyAll()
| ||||||||||
String
|
toString()
| ||||||||||
final
void
|
wait()
| ||||||||||
final
void
|
wait(long arg0, int arg1)
| ||||||||||
final
void
|
wait(long arg0)
|
Creates a new CoordinateSystem
for the specified
ShapeView
.
ShapeView
that owns this coordinate system
Transforms a point from device coordinates (pixels on the view/screen) to local coordinates.
the local coordinates in this coordinate system corresponding to the specified device coordinates
Transforms a point from device coordinates (pixels on the view/screen) to local coordinates.
the local coordinates in this coordinate system corresponding to the specified device coordinates
Flips the x-axis of the coordinate system so that it higher values on the x-axis are to the left of lower values.
this coordinate system, for chaining method calls
Flips the y-axis of the coordinate system so that it higher values on the y-axis are above lower values.
this coordinate system, for chaining method calls
Sets the number of vertical units that the view should occupy. The view will be scaled so that it always occupies this many units; that is, if the height of the coordinate system is 400 units and the view is 800 pixels tall, each unit will be 2 pixels tall. Likewise, if the view is 200 pixels tall, each unit will be 0.5 pixels tall.
this coordinate system, for chaining method calls
Gets a value indicating whether the x-axis of this coordinate system is flipped (that is, higher values of x are to the left lower values).
true if the coordinate system's x-axis is flipped, otherwise false
Gets a value indicating whether the y-axis of this coordinate system is flipped (that is, higher values of y are above lower values).
true if the coordinate system's y-axis is flipped, otherwise false
Sets the location on the view where the origin (0, 0) is located. Note
that if you set the origin to be the right and/or bottom edges of the
view, you should make sure to call flipX()
and/or
flipY()
to ensure that the coordinate system has the correct
orientation.
Anchor
representing the origin of the
coordinate system with respect to the viewthis coordinate system, for chaining method calls
Resets the coordinate system so that the origin is in the top-left corner of the view, the x-axis goes right in the positive direction, the y-axis goes down in the positive direction, and one unit is equal to one pixel.
Sets the number of horizontal units that the view should occupy. The view will be scaled so that it always occupies this many units; that is, if the width of the coordinate system is 400 units and the view is 800 pixels wide, each unit will be 2 pixels wide. Likewise, if the view is 200 pixels wide, each unit will be 0.5 pixels wide.
this coordinate system, for chaining method calls
Applies the transformation represented by this coordinate system to the
specified Graphics2D
object.
Called internally to update the AffineTransform
that will be
used to transform this view.