JWAVE User Guide > JWAVE Graphics > Coordinate System Transformations
  

Coordinate System Transformations
The Viewable class supports coordinate system transforms. PV‑WAVE communicates the data coordinates and 3D transform used to generate the plot, and a Viewable object uses these to do coordinate transforms.
Two methods transformToPoint and transformToData can transform between the plot’s data coordinates and a java.awt.Point object.
For example, to print the data coordinates where a user clicks on the plot, you might do the following:
double[] d = myViewable.transformToData( theClickPoint );
System.out.println( "Click at ("+ d[0] +", "+ d[1] +")" );
You can determine the boundary of the data area (usually, this boundary is the plot’s axes) using the getDataBounds method. For example, to determine if a Point object is inside the plot bounds:
 if ( myViewable.getDataBounds().contains( myPoint ) ) { ... }
Note that (due to lossy conversion) the transformToData method is only useful for plots with 2D data coordinates (that is, X vs. Y plots). To test for this condition, use the has2DCoordinates method.
For an example of using the coordinate transforms of the Viewable class, see ViewTest.java which you can find in:
(UNIX) RW_DIR/classes/jwave_demos/tests
(WIN) RW_DIR\classes\jwave_demos\tests

Version 3.6
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.