-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRightButtonActionListener.java
45 lines (37 loc) · 2.31 KB
/
RightButtonActionListener.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/** Author: Shikhar K Gupta, Foram Joshi
* Project: 3DNA
* Mentor: Prof. Manish K Gupta
*/
import com.sun.j3d.utils.universe.ViewingPlatform;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.vecmath.Vector3f;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class RightButtonActionListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
//To change body of implemented methods use File | Settings | File Templates.
float step=0.25f;
if(MainFrame.isImported){
ImportActionListener.canvasx=ImportActionListener.canvasx-step;
ViewingPlatform vp = ImportActionListener.simpleU.getViewingPlatform(); // get the ViewingPlatform of the SimpleUniverse
TransformGroup View_TransformGroup = vp.getMultiTransformGroup().getTransformGroup(0); // get the TransformGroup associated
Transform3D View_Transform3D = new Transform3D(); // create a Transform3D for the ViewingPlatform
View_TransformGroup.getTransform(View_Transform3D); // get the current 3d from the ViewingPlatform
View_Transform3D.setTranslation(new Vector3f(ImportActionListener.canvasx,
ImportActionListener.canvasy,ImportActionListener.canvasz));
View_TransformGroup.setTransform(View_Transform3D); // assign Transform3D to ViewPlatform
}
else{
CanvasActionListener.canvasx=CanvasActionListener.canvasx-step;
ViewingPlatform vp = CanvasActionListener.simpleU.getViewingPlatform(); // get the ViewingPlatform of the SimpleUniverse
TransformGroup View_TransformGroup = vp.getMultiTransformGroup().getTransformGroup(0); // get the TransformGroup associated
Transform3D View_Transform3D = new Transform3D(); // create a Transform3D for the ViewingPlatform
View_TransformGroup.getTransform(View_Transform3D); // get the current 3d from the ViewingPlatform
View_Transform3D.setTranslation(new Vector3f(CanvasActionListener.canvasx,
CanvasActionListener.canvasy,CanvasActionListener.canvasz));
View_TransformGroup.setTransform(View_Transform3D); // assign Transform3D to ViewPlatform
}
}
}