JWaveCanvas3D and JWavePanel3D
The classes JWaveCanvas3D and JWavePanel3D provide the ability to interactively rotate a 3D chart. Pressing and dragging the mouse pointer changes the view of the chart.
Rotate
The rotation feature allows an object to be notified when the user has pressed and dragged the mouse on a chart. A wire frame object is drawn in place of the image while the user drags the mouse. When the mouse is released a notification event is sent to the listener, the listener can retrieve the new x and z degrees of rotation from the getDegX and getDegZ methods. The returned values can be used as AX and AZ keywords settings for PV-WAVE commands such as SURFACE, SHADE_SURFACE, BAR3D or SHOW3.
To use this feature with a chart object, it must first be enabled. This can be done either by calling the object’s:
setRotateEnabled(true)
method or by sending the object an action with the command string “rotate-on”. Listeners can be added to the object by calling the object’s:
addRotateListener(RotateListener listener)
method. The listener must implement the nested interface JWaveCanvas3D.RotateListener or JWavePanel3D.RotateListener. The interface requires the implementation of the method:
public void rotateUpdate(RotateEvent event)
Example
Assume that we have a chart object that extends JWaveCanvas3D and we want to allow users to change the view of the 3D chart. This could be implemented by adding the following code fragment to the class that sets up the GUI:
ShadeSurfChart chart = new ShadeSurfChart();
chart.setRotateEnabled(true);
The class ShadeSurfChart extends JWaveCanvas3D and can implement rotation by adding the following code fragment to ShadeSurfChart.
public class ShadeSurfChart extends JWaveCanvas3D
implements JWaveCanvas3D.RotateListener {
public void rotateUpdate(JWaveCanvas3D.RotateEvent event) {
int ax = event.getDegX();
int az = event.getDegZ();
jwaveWrapper.setParam(“ax”,ax);
jwaveWrapper.setParam(“az”,az)’
try {
jwaveWrapper.execute();
viewable = jwaveWrapper.getViewable();
setViewable(viewable);
} catch (JWaveException e) {
System.out.println(e);
}
}
}
The remaining ShadeSurfChart code has been left out for simplicity. For more details, see the ShadeSurfChart class in jwave_demos/canvas3d.
Version 3.6
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.