forked from guptalab/3dna
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVisualizationResetButtonActionListener.java
More file actions
50 lines (39 loc) · 2.48 KB
/
Copy pathVisualizationResetButtonActionListener.java
File metadata and controls
50 lines (39 loc) · 2.48 KB
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
46
47
48
49
50
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;
/**
* Created by lenovo on 9/15/2014.
*/
public class VisualizationResetButtonActionListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
//set the ViewingPlatform by setting the canvasx, canvasy, canvasz values as 0.0,0.0,2.0
VisualizeActionListener.canvasX=0.0f;
VisualizeActionListener.canvasY=0.0f;
VisualizeActionListener.canvasZ=20.0f;
ImportActionListener.canvasx=0.0f;
ImportActionListener.canvasy=0.0f;
ImportActionListener.canvasz=2.0f;
if(MainFrame.isImported){
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)); // set 3d to x=0, y=-1, z= 5
View_TransformGroup.setTransform(View_Transform3D); // assign Transform3D to ViewPlatform
}
else{
ViewingPlatform vp = VisualizeActionListener.visualizationSimpleUniverse.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(VisualizeActionListener.canvasX,
VisualizeActionListener.canvasY,VisualizeActionListener.canvasZ)); // set 3d to x=0, y=-1, z= 5
View_TransformGroup.setTransform(View_Transform3D); // assign Transform3D to ViewPlatform
}
}
}