Integration of OCCT 6.5.0 from SVN
[occt.git] / samples / java / java / ShadingModelDlg.java
1
2 //Title:        Viewer3D Sample
3 //Version:      
4 //Copyright:    Copyright (c) 1999
5 //Author:       User Interface group
6 //Company:      Matra Datavision
7 //Description:  
8
9
10 import java.awt.*;
11 import java.awt.event.*;
12 import javax.swing.*;
13 import javax.swing.event.*;
14 import CASCADESamplesJni.*;
15 import SampleViewer3DJni.*;
16 import jcas.Standard_Real;
17
18
19 public class ShadingModelDlg extends JDialog
20                              implements ActionListener
21 {
22   private V3d_View myView;
23
24
25 //=======================================================================//
26 // Construction
27 //=======================================================================//
28   public ShadingModelDlg(Frame frame, V3d_View aView)
29   {
30     super(frame, "ShadingModel", false);
31     myView = aView;
32
33     try
34     {
35       jbInit();
36       pack();
37     }
38     catch(Exception ex)
39     {
40       ex.printStackTrace();
41     }
42   }
43
44   void jbInit() throws Exception
45   {
46     getContentPane().setLayout(new GridLayout(0, 1));
47     getContentPane().setBounds(10, 10, 10, 10);
48
49     JButton button;
50
51     button = new JButton("COLOR");
52     button.addActionListener(this);
53     button.setActionCommand("Color");
54     getContentPane().add(button);
55
56     button = new JButton("FLAT");
57     button.addActionListener(this);
58     button.setActionCommand("Flat");
59     getContentPane().add(button);
60
61     button = new JButton("GOURAUD");
62     button.addActionListener(this);
63     button.setActionCommand("Gouraud");
64     getContentPane().add(button);
65   }
66
67 //=======================================================================//
68 // Commands
69 //=======================================================================//
70   private void onShadingModelColor()
71   {
72     SampleViewer3DPackage.ChangeShadingModel(myView, V3d_TypeOfShadingModel.V3d_COLOR);
73   }
74
75 //=======================================================================//
76   private void onShadingModelFlat()
77   {
78     SampleViewer3DPackage.ChangeShadingModel(myView, V3d_TypeOfShadingModel.V3d_FLAT);
79   }
80
81 //=======================================================================//
82   private void onShadingModelGouraud()
83   {
84     SampleViewer3DPackage.ChangeShadingModel(myView, V3d_TypeOfShadingModel.V3d_GOURAUD);
85   }
86
87
88 //=======================================================================//
89 // Action listener interface
90 //=======================================================================//
91   public void actionPerformed(ActionEvent event)
92   {
93     String nameAction = event.getActionCommand();
94     if (nameAction.equals("Color"))
95       onShadingModelColor();
96     else if (nameAction.equals("Flat"))
97       onShadingModelFlat();
98     else if (nameAction.equals("Gouraud"))
99       onShadingModelGouraud();
100   }
101
102 }