2 //Title: OpenCASCADE Samples
4 //Copyright: Copyright (c) 1999
5 //Author: User Interface group
6 //Company: Matra Datavision
10 import java.awt.event.*;
12 import javax.swing.event.*;
16 public class SamplesStarter extends JPanel
17 implements ChangeListener
20 public static Frame myFrame;
22 // The width and height of the frame
23 public static int WIDTH = 900;
24 public static int HEIGHT = 550;
25 public static int INITIAL_WIDTH = 400;
26 public static int INITIAL_HEIGHT = 200;
29 private static JLabel myStatusBar = null;
30 private Component myCurrentPage = null;
33 public static int totalPanels = 10;
34 public static int currentProgressValue;
35 public static JLabel progressLabel = null;
36 public static JProgressBar progressBar = null;
39 //=======================================================================//
41 //=======================================================================//
42 public SamplesStarter()
44 //-----------------------------------------------------------//
46 //-----------------------------------------------------------//
47 ResourceBundle AppRes = ResourceBundle.getBundle("properties.AppRes");
48 Locale aLocale = new Locale(AppRes.getString("language"), "");
50 Locale.setDefault(aLocale);
52 setLayout(new BorderLayout());
54 //-----------------------------------------------------------//
56 //-----------------------------------------------------------//
57 JTabbedPane tabbedPane = new JTabbedPane();
58 tabbedPane.addChangeListener(this);
59 add(tabbedPane, BorderLayout.CENTER);
63 progressLabel.setText("Loading Title page");
64 tabbedPane.addTab("Open CASCADE Technology", new AboutPanel());
69 progressBar.setValue(++currentProgressValue);
72 // The Geometry sample
74 progressLabel.setText("Loading the Geometry sample");
75 tabbedPane.addTab("Geometry", new SampleGeometryPanel());
80 progressBar.setValue(++currentProgressValue);
82 // The Topology samples
84 progressLabel.setText("Loading the Topology samples");
85 tabbedPane.addTab("Topology", new SamplesTopologyPanel());
90 progressBar.setValue(++currentProgressValue);
92 // The Viewer3D sample
94 progressLabel.setText("Loading the Viewer3D sample");
95 tabbedPane.addTab("Viewer3D", new SampleViewer3DPanel());
100 progressBar.setValue(++currentProgressValue);
102 // The AIS Basic sample
104 progressLabel.setText("Loading the AIS Basic sample");
105 tabbedPane.addTab("AIS Basic", new SampleAISBasicPanel());
107 catch (Exception e) {
110 progressBar.setValue(++currentProgressValue);
112 // The AIS DisplayMode sample
114 progressLabel.setText("Loading the AIS DisplayMode sample");
115 tabbedPane.addTab("AIS DisplayMode", new SampleAISDisplayModePanel());
117 catch (Exception e) {
120 progressBar.setValue(++currentProgressValue);
122 // The AIS Select sample
124 progressLabel.setText("Loading the AIS Select sample");
125 tabbedPane.addTab("AIS Select", new SampleAISSelectPanel());
127 catch (Exception e) {
130 progressBar.setValue(++currentProgressValue);
132 // The Display Animation sample
134 progressLabel.setText("Loading the Display Animation sample");
135 tabbedPane.addTab("DisplayAnimation", new SampleDisplayAnimationPanel());
137 catch (Exception e) {
140 progressBar.setValue(++currentProgressValue);
142 // The ImportExport sample
144 progressLabel.setText("Loading the ImportExport sample");
145 tabbedPane.addTab("Import/Export", new SampleImportExportPanel());
146 progressBar.setValue(++currentProgressValue);
148 catch (Exception e) {
154 progressLabel.setText("Loading the HLR sample");
155 tabbedPane.addTab("HLR", new SampleHLRPanel());
157 catch (Exception e) {
160 progressBar.setValue(++currentProgressValue);
162 tabbedPane.setSelectedIndex(0);
163 myCurrentPage = tabbedPane.getComponentAt(0);
165 //-----------------------------------------------------------//
166 // Create a status line
167 //-----------------------------------------------------------//
168 myStatusBar = new JLabel("");
169 myStatusBar.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
170 add(myStatusBar, BorderLayout.SOUTH);
174 //=======================================================================//
176 //=======================================================================//
177 public static void main(String[] args)
181 UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
182 // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
188 javax.swing.ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
190 WindowListener l = new WindowAdapter() {
191 public void windowClosing(WindowEvent e) {System.exit(0);}
194 ResourceBundle resIcons =
195 ResourceBundle.getBundle("properties.DesktopIcon");
196 ImageIcon imageIcon = new ImageIcon(resIcons.getString("MF_MATRALOGO"));
198 myFrame = new Frame("Open CASCADE Technology Samples");
199 myFrame.setIconImage(imageIcon.getImage());
200 myFrame.addWindowListener(l);
203 JPanel progressPanel = new JPanel() {
204 public Insets getInsets() {
205 return new Insets(40,30,20,30);
208 progressPanel.setLayout(new BoxLayout(progressPanel, BoxLayout.Y_AXIS));
209 myFrame.add(progressPanel, BorderLayout.CENTER);
211 Dimension d = new Dimension(400, 20);
212 SamplesStarter.progressLabel = new JLabel("Loading, please wait...");
213 SamplesStarter.progressLabel.setAlignmentX(CENTER_ALIGNMENT);
214 SamplesStarter.progressLabel.setMaximumSize(d);
215 SamplesStarter.progressLabel.setPreferredSize(d);
216 progressPanel.add(SamplesStarter.progressLabel);
217 progressPanel.add(Box.createRigidArea(new Dimension(1,20)));
219 SamplesStarter.progressBar = new JProgressBar(0, SamplesStarter.totalPanels);
220 SamplesStarter.progressBar.setStringPainted(true);
221 SamplesStarter.progressLabel.setLabelFor(progressBar);
222 SamplesStarter.progressBar.setAlignmentX(CENTER_ALIGNMENT);
223 progressPanel.add(SamplesStarter.progressBar);
226 myFrame.setSize(INITIAL_WIDTH, INITIAL_HEIGHT);
227 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
228 myFrame.setLocation(screenSize.width/2 - INITIAL_WIDTH/2,
229 screenSize.height/2 - INITIAL_HEIGHT/2);
232 myFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
235 SamplesStarter samplesStarter = new SamplesStarter();
238 myFrame.setLayout(new BorderLayout());
239 myFrame.add(samplesStarter, BorderLayout.CENTER);
240 myFrame.setSize(WIDTH, HEIGHT);
241 myFrame.setLocation(screenSize.width/2 - WIDTH/2,
242 screenSize.height/2 - HEIGHT/2);
244 myFrame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
247 // myFrame.repaint();
248 samplesStarter.requestDefaultFocus();
251 public static void put_info(String message)
253 if (myStatusBar != null)
254 myStatusBar.setText(". " + message);
257 public static Frame getFrame()
262 //=======================================================================//
263 // Change Listener //
264 //=======================================================================//
265 public void stateChanged(ChangeEvent event)
267 SamplesStarter.put_info("");
269 JTabbedPane tab = (JTabbedPane) event.getSource();
270 int index = tab.getSelectedIndex();
271 Component currentPage = tab.getComponentAt(index);
273 if (myCurrentPage != null)
275 myCurrentPage.setVisible(false);
276 myCurrentPage.setEnabled(false);
278 currentPage.setVisible(true);
279 currentPage.setEnabled(true);
281 myCurrentPage = currentPage;