tahoe/contrib/vtk/java/test.java1 // $Id: test.java,v 1.15 2002/08/15 22:56:05 recampb Exp $ 2 import java.io.*; 3 import javax.swing.*; 4 import java.awt.event.*; 5 import java.awt.*; 6 import javax.swing.tree.*; 7 import javax.swing.event.*; 8 9 public class test extends JPanel implements ActionListener, ChangeListener { 10 11 // looks like an unnamed static function 12 static { 13 System.loadLibrary("testClass"); 14 } 15 16 public native void InitCpp(); 17 public native void Print(); 18 public native void SetMinSc(int x); 19 public native int GetMinSc(); 20 public native void SetScope(String s); 21 public native void Interact(); 22 public native void CommandLine(); 23 public native void DoCommand(String command, String arguments); 24 //public native void Rotate(int x, int y , int z); 25 26 27 long cpp_obj; 28 long console; 29 long consoleObjects; 30 31 int newNodeSuffix = 1; 32 protected JButton testButton, b2, flipBookButton, nextTimeButton, prevTimeButton, selectTimeButton, addButton, removeButton, clearButton; 33 protected JTextField minScalarTF, selectTimeTF, panXTF, panYTF, rotateXTF, rotateYTF, rotateZTF, zoomTF, selectTimeTFF, panXTFF, panYTFF, rotateXTFF, rotateYTFF, rotateZTFF, zoomTFF; 34 protected JPanel leftPanel, leftRootPanel, leftFramePanel, leftBodyPanel; 35 protected JScrollPane leftRootScrollPane, leftFrameScrollPane, leftBodyScrollPane; 36 protected DynamicTree treePanel; 37 protected JTabbedPane tabbedPane; 38 protected JSlider selectTimeSlider, selectTimeSliderF; 39 private boolean tabBool; 40 protected JFrame parentFrame; 41 42 public test(JFrame parentFrame){ 43 this.parentFrame = parentFrame; 44 InitCpp(); 45 Print(); 46 tabbedPane = new JTabbedPane(); 47 tabbedPane.addChangeListener(this); 48 tabBool = false; 49 50 final JPanel rootPanel = new JPanel(); 51 final JPanel framePanel = new JPanel(); 52 final JPanel bodyPanel = new JPanel(); 53 JPanel bodyVarPanel = new JPanel(); 54 55 JMenuBar menuBar = new JMenuBar(); 56 JMenu file = new JMenu("File"); 57 JMenu help = new JMenu("Help"); 58 JMenuItem exitItem = new JMenuItem("Exit"); 59 exitItem.addActionListener(this); 60 exitItem.setActionCommand("Exit"); 61 JMenuItem addBodyItem = new JMenuItem("Add Body"); 62 JCheckBoxMenuItem frameNumsItem = new JCheckBoxMenuItem("Frame Numbers", false); 63 JMenuItem removeBodyItem = new JMenuItem("Remove Body"); 64 JMenuItem saveItem = new JMenuItem("Save"); 65 JMenuItem saveFlipItem = new JMenuItem("Save Flip Book"); 66 JMenuItem windowSizeItem= new JMenuItem("Window Size"); 67 68 GridBagConstraints gbc = new GridBagConstraints(); 69 gbc.anchor=gbc.NORTHEAST; 70 71 file.add(addBodyItem); 72 file.add(removeBodyItem); 73 file.add(frameNumsItem); 74 file.add(saveItem); 75 file.add(saveFlipItem); 76 file.add(windowSizeItem); 77 file.add(exitItem); 78 79 menuBar.add(file); 80 menuBar.add(help); 81 82 83 // setLayout(new GridBagLayout()); 84 85 // add(menuBar, new GridBagConstraints(0,0,4,1,0.0,0.05, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0),0,0)); 86 87 // add(tabbedPane,new GridBagConstraints(0,1,4,1,0.0,0.0,GridBagConstraints.NORTHWEST,GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0)); 88 setLayout(new BorderLayout()); 89 add(menuBar, BorderLayout.NORTH); 90 add(tabbedPane, BorderLayout.CENTER); 91 92 93 //bodyVarPanel.setLayout(new GridLayout(2,2,20,5)); 94 95 96 minScalarTF = new JTextField(Integer.toString(GetMinSc()), 8); 97 JLabel minScalarL = new JLabel("min_Scalar_Range"); 98 JButton bodyVarOKButton = new JButton("OK"); 99 JButton bodyVarCancelButton = new JButton("Cancel"); 100 bodyVarOKButton.addActionListener(this); 101 bodyVarOKButton.setActionCommand("BodyVarOK"); 102 103 bodyVarPanel.setLayout(new GridBagLayout()); 104 gbc.gridx=0; gbc.gridy=0; gbc.gridwidth=1; 105 bodyVarPanel.add(minScalarL, gbc); 106 gbc.gridx=1; gbc.gridy=0; gbc.gridwidth=1; 107 bodyVarPanel.add(minScalarTF, gbc); 108 109 JPanel buttonPanel=new JPanel(); 110 buttonPanel.add(bodyVarOKButton); 111 buttonPanel.add(bodyVarCancelButton); 112 gbc.gridx=0; gbc.gridy=1; gbc.gridwidth=2; gbc.anchor=gbc.NORTHEAST; 113 bodyVarPanel.add(buttonPanel,gbc); 114 115 JRadioButton ShowContoursButton = new JRadioButton("ShowContours", false); 116 JRadioButton HideContoursButton = new JRadioButton ("HideContours", true); 117 JRadioButton ShowCuttingButton = new JRadioButton ("ShowCuttingPlane", false); 118 JRadioButton HideCuttingButton = new JRadioButton ("HideCuttingPlane", true); 119 120 ShowContoursButton.addActionListener(this); 121 HideContoursButton.addActionListener(this); 122 ShowCuttingButton.addActionListener(this); 123 HideCuttingButton.addActionListener(this); 124 125 ShowContoursButton.setActionCommand("ShowContours"); 126 HideContoursButton.setActionCommand("HideContours"); 127 ShowCuttingButton.setActionCommand("ShowCutting"); 128 HideCuttingButton.setActionCommand("HideCutting"); 129 130 131 132 tabbedPane.addTab("Root Commands", rootPanel); 133 tabbedPane.addTab("Frame Commands", framePanel); 134 tabbedPane.addTab("Body Commands", bodyPanel); 135 tabbedPane.addTab("Body Variables", bodyVarPanel); 136 137 138 /** rootPanel stuff **/ 139 rootPanel.setLayout(new GridLayout(1,2)); 140 141 JPanel rootLeftPanel = new JPanel(); 142 JScrollPane rootLeftScroll = new JScrollPane(rootLeftPanel); 143 rootLeftPanel.setLayout(new GridBagLayout()); 144 JPanel rootRightPanel = new JPanel(); 145 JScrollPane rootRightScroll = new JScrollPane(rootRightPanel); 146 rootRightPanel.setLayout(new GridBagLayout()); 147 gbc.gridx=0; gbc.gridy=0; gbc.gridwidth=1; 148 rootPanel.add(rootLeftScroll); 149 150 gbc.gridx=1; gbc.gridy=0; gbc.gridwidth=1; 151 rootPanel.add(rootRightScroll); 152 153 testButton = new JButton ("Exit"); 154 testButton.addActionListener(this); 155 testButton.setActionCommand("Exit"); 156 gbc.gridx=0; gbc.gridy=6; gbc.gridwidth=1; 157 rootRightPanel.add(testButton, gbc); 158 159 JButton commandButton = new JButton("Command Line"); 160 commandButton.addActionListener(this); 161 commandButton.setActionCommand("CommandLine"); 162 gbc.gridx=0; gbc.gridy=5; 163 rootRightPanel.add(commandButton, gbc); 164 165 166 flipBookButton = new JButton("Flip Book"); 167 flipBookButton.addActionListener(this); 168 flipBookButton.setActionCommand("FlipBook"); 169 gbc.gridx=0; gbc.gridy=4; gbc.gridwidth=1; 170 rootRightPanel.add(flipBookButton, gbc); 171 172 nextTimeButton = new JButton("Next Time Step"); 173 nextTimeButton.addActionListener(this); 174 nextTimeButton.setActionCommand("NextTimeStep"); 175 gbc.gridx=1; gbc.gridy=3; gbc.gridwidth=1; 176 rootRightPanel.add(nextTimeButton, gbc); 177 178 prevTimeButton = new JButton("Previous Time Step"); 179 prevTimeButton.addActionListener(this); 180 prevTimeButton.setActionCommand("PreviousTimeStep"); 181 gbc.gridx=0; gbc.gridy=3; gbc.gridwidth=1; 182 rootRightPanel.add(prevTimeButton, gbc); 183 184 selectTimeSlider = new JSlider(0,10,0); 185 selectTimeSlider.addChangeListener(this); 186 JLabel selectTimeLabel = new JLabel("Time Step"); 187 188 gbc.gridx=0; gbc.gridy=1; gbc.gridwidth=1; 189 rootRightPanel.add(selectTimeLabel, gbc); 190 191 selectTimeTF = new JTextField("0", 5); 192 selectTimeTF.setEnabled(true); 193 gbc.gridx=0; gbc.gridy=2; gbc.gridwidth=1; gbc.anchor = gbc.CENTER; 194 rootRightPanel.add(selectTimeSlider, gbc); 195 gbc.gridx=1; gbc.gridy=2; gbc.gridwidth=1; gbc.anchor = gbc.NORTHWEST; 196 rootRightPanel.add(selectTimeTF, gbc); 197 198 199 JButton panButton = new JButton("Pan"); 200 panButton.addActionListener(this); 201 panButton.setActionCommand("Pan"); 202 203 JButton rotateButton = new JButton("Rotate"); 204 rotateButton.addActionListener(this); 205 rotateButton.setActionCommand("Rotate"); 206 207 JButton zoomButton = new JButton("Zoom"); 208 zoomButton.addActionListener(this); 209 zoomButton.setActionCommand("Zoom"); 210 211 JLabel rotXLabel = new JLabel("X"); 212 JLabel rotYLabel = new JLabel("Y"); 213 JLabel rotZLabel = new JLabel("Z"); 214 215 JLabel panXLabel = new JLabel("X"); 216 JLabel panYLabel = new JLabel("Y"); 217 JLabel zoomFactorLabel = new JLabel("Factor"); 218 219 panXTF = new JTextField("0", 5); 220 panYTF = new JTextField("0", 5); 221 rotateXTF = new JTextField("0", 5); 222 rotateYTF = new JTextField("0", 5); 223 rotateZTF = new JTextField("0", 5); 224 zoomTF = new JTextField("0", 5); 225 226 JButton resetViewButton = new JButton("Reset View"); 227 JButton interactiveButton = new JButton("Interactive"); 228 JButton updateButton = new JButton("Update"); 229 interactiveButton.addActionListener(this); 230 interactiveButton.setActionCommand("Interact"); 231 resetViewButton.addActionListener(this); 232 resetViewButton.setActionCommand("ResetView"); 233 234 235 gbc.anchor = gbc.NORTHEAST; 236 gbc.insets=new Insets(4,4,4,4); 237 gbc.gridx=1; gbc.gridy=3; gbc.gridwidth=1; 238 rootLeftPanel.add(rotateButton, gbc); 239 gbc.gridx=0; gbc.gridy=4; gbc.gridwidth=1; 240 rootLeftPanel.add(rotXLabel, gbc); 241 gbc.gridx=1; gbc.gridy=4; gbc.gridwidth=1; 242 rootLeftPanel.add(rotateXTF, gbc); 243 gbc.gridx=0; gbc.gridy=5; gbc.gridwidth=1; 244 rootLeftPanel.add(rotYLabel, gbc); 245 gbc.gridx=1; gbc.gridy=5; gbc.gridwidth=1; 246 rootLeftPanel.add(rotateYTF, gbc); 247 gbc.gridx=0; gbc.gridy=6; gbc.gridwidth=1; 248 rootLeftPanel.add(rotZLabel, gbc); 249 gbc.gridx=1; gbc.gridy=6; gbc.gridwidth=1; 250 rootLeftPanel.add(rotateZTF, gbc); 251 252 rootLeftPanel.add(new JSeparator(JSeparator.HORIZONTAL),new GridBagConstraints(0,7,2,1,0.0,0.0,GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0)); 253 gbc.gridx=1; gbc.gridy=8; gbc.gridwidth=1; 254 rootLeftPanel.add(panButton, gbc); 255 gbc.gridx=0; gbc.gridy=9; gbc.gridwidth=1; 256 rootLeftPanel.add(panXLabel, gbc); 257 gbc.gridx=1; gbc.gridy=9; gbc.gridwidth=1; 258 rootLeftPanel.add(panXTF, gbc); 259 gbc.gridx=0; gbc.gridy=10; gbc.gridwidth=1; 260 rootLeftPanel.add(panYLabel, gbc); 261 gbc.gridx=1; gbc.gridy=10; gbc.gridwidth=1; 262 rootLeftPanel.add(panYTF, gbc); 263 264 rootLeftPanel.add(new JSeparator(JSeparator.HORIZONTAL),new GridBagConstraints(0,11,2,1,0.0,0.0,GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0)); 265 266 gbc.gridx=1; gbc.gridy = 12; 267 rootLeftPanel.add(zoomButton, gbc); 268 gbc.gridx=0; gbc.gridy = 13; 269 rootLeftPanel.add(zoomFactorLabel, gbc); 270 gbc.gridx=1; gbc.gridy = 13; 271 rootLeftPanel.add(zoomTF, gbc); 272 273 rootLeftPanel.add(new JSeparator(JSeparator.HORIZONTAL),new GridBagConstraints(0,14,2,1,0.0,0.0,GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0)); 274 275 gbc.gridx=0; gbc.gridy = 15; gbc.gridwidth=2; 276 rootLeftPanel.add(resetViewButton, gbc); 277 gbc.gridx=0; gbc.gridy = 16; 278 rootLeftPanel.add(interactiveButton, gbc); 279 gbc.gridx=0; gbc.gridy = 17; 280 rootLeftPanel.add(updateButton, gbc); 281 282 /** end root panel **/ 283 284 285 286 287 288 /* frame panel stuff */ 289 framePanel.setLayout(new GridLayout(1,2)); 290 291 JPanel frameLeftPanel = new JPanel(); 292 JScrollPane frameLeftScroll = new JScrollPane(frameLeftPanel); 293 frameLeftPanel.setLayout(new GridBagLayout()); 294 JPanel frameRightPanel = new JPanel(); 295 JScrollPane frameRightScroll = new JScrollPane(frameRightPanel); 296 frameRightPanel.setLayout(new GridBagLayout()); 297 framePanel.add(frameLeftScroll); 298 299 framePanel.add(frameRightScroll); 300 301 302 303 JButton flipBookButtonF = new JButton("Flip Book"); 304 flipBookButtonF.addActionListener(this); 305 flipBookButtonF.setActionCommand("FlipBook"); 306 307 308 JButton nextTimeButtonF = new JButton("Next Time Step"); 309 nextTimeButtonF.addActionListener(this); 310 nextTimeButtonF.setActionCommand("NextTimeStep"); 311 312 313 JButton prevTimeButtonF = new JButton("Previous Time Step"); 314 prevTimeButtonF.addActionListener(this); 315 prevTimeButtonF.setActionCommand("PreviousTimeStep"); 316 317 318 selectTimeSliderF = new JSlider(0,10,0); 319 selectTimeSliderF.addChangeListener(this); 320 JLabel selectTimeLabelF = new JLabel("Time Step"); 321 JButton selectTimeButtonF = new JButton("Select Time Step"); 322 selectTimeButtonF.addActionListener(this); 323 selectTimeButtonF.setActionCommand("SelectTimeStep"); 324 325 326 selectTimeTFF = new JTextField("0", 5); 327 selectTimeTFF.setEnabled(true); 328 selectTimeTFF.addActionListener(this); 329 330 331 332 JButton panButtonF = new JButton("Pan"); 333 panButtonF.addActionListener(this); 334 panButtonF.setActionCommand("Pan"); 335 336 JButton rotateButtonF = new JButton("Rotate"); 337 rotateButtonF.addActionListener(this); 338 rotateButtonF.setActionCommand("Rotate"); 339 340 JButton zoomButtonF = new JButton("Zoom"); 341 zoomButtonF.addActionListener(this); 342 zoomButtonF.setActionCommand("Zoom"); 343 344 JLabel rotXLabelF = new JLabel("X"); 345 JLabel rotYLabelF = new JLabel("Y"); 346 JLabel rotZLabelF = new JLabel("Z"); 347 348 JLabel panXLabelF = new JLabel("X"); 349 JLabel panYLabelF = new JLabel("Y"); 350 JLabel zoomFactorLabelF = new JLabel("Factor"); 351 352 panXTFF = new JTextField("0", 5); 353 panYTFF = new JTextField("0", 5); 354 rotateXTFF = new JTextField("0", 5); 355 rotateYTFF = new JTextField("0", 5); 356 rotateZTFF = new JTextField("0", 5); 357 zoomTFF = new JTextField("0", 5); 358 359 JButton resetViewButtonF = new JButton("Reset View"); 360 JButton interactiveButtonF = new JButton("Interactive"); 361 JButton updateButtonF = new JButton("Update"); 362 363 JLabel bgLabel = new JLabel("Background Color"); 364 JRadioButton bgBlackButton = new JRadioButton("Black"); 365 bgBlackButton.addActionListener(this); 366 bgBlackButton.setActionCommand("Black BG"); 367 bgBlackButton.setSelected(true); 368 JRadioButton bgWhiteButton = new JRadioButton("White"); 369 bgWhiteButton.addActionListener(this); 370 bgWhiteButton.setActionCommand("White BG"); 371 ButtonGroup bgButtonGroup = new ButtonGroup(); 372 bgButtonGroup.add(bgBlackButton); 373 bgButtonGroup.add(bgWhiteButton); 374 375 JLabel repLabel = new JLabel("Representation"); 376 JRadioButton repSurfButton = new JRadioButton("Surface"); 377 repSurfButton.setSelected(true); 378 repSurfButton.addActionListener(this); 379 repSurfButton.setActionCommand("Surf"); 380 JRadioButton repWireButton = new JRadioButton("Wire"); 381 repWireButton.addActionListener(this); 382 repWireButton.setActionCommand("Wire"); 383 JRadioButton repPointButton = new JRadioButton("Points"); 384 repPointButton.addActionListener(this); 385 repPointButton.setActionCommand("Points"); 386 ButtonGroup repButtons = new ButtonGroup(); 387 repButtons.add(repSurfButton); 388 repButtons.add(repWireButton); 389 repButtons.add(repPointButton); 390 391 JLabel axesLabel = new JLabel("Axes"); 392 JLabel colorBarLabel = new JLabel ("Color Bar"); 393 JLabel nodeNumsLabel = new JLabel ("Node Numbers"); 394 JLabel elemNumsLabel = new JLabel ("Element Numbers"); 395 JRadioButton axesShowButton = new JRadioButton("Show"); 396 JRadioButton axesHideButton = new JRadioButton("Hide"); 397 ButtonGroup axesButtons = new ButtonGroup(); 398 JRadioButton colorBarShowButton = new JRadioButton("Show"); 399 JRadioButton colorBarHideButton = new JRadioButton("Hide"); 400 ButtonGroup colorBarButtons = new ButtonGroup(); 401 JRadioButton nodeNumsShowButton = new JRadioButton("Show"); 402 JRadioButton nodeNumsHideButton = new JRadioButton("Hide"); 403 ButtonGroup nodeNumsButtons = new ButtonGroup(); 404 JRadioButton elemNumsShowButton = new JRadioButton("Show"); 405 JRadioButton elemNumsHideButton = new JRadioButton("Hide"); 406 ButtonGroup elemNumsButtons = new ButtonGroup(); 407 axesButtons.add(axesShowButton); 408 axesButtons.add(axesHideButton); 409 colorBarButtons.add(colorBarShowButton); 410 colorBarButtons.add(colorBarHideButton); 411 nodeNumsButtons.add(nodeNumsShowButton); 412 nodeNumsButtons.add(nodeNumsHideButton); 413 elemNumsButtons.add(elemNumsShowButton); 414 elemNumsButtons.add(elemNumsHideButton); 415 axesHideButton.setSelected(true); 416 colorBarHideButton.setSelected(true); 417 nodeNumsHideButton.setSelected(true); 418 elemNumsHideButton.setSelected(true); 419 420 axesShowButton.addActionListener(this); 421 axesHideButton.addActionListener(this); 422 axesShowButton.setActionCommand("ShowAxes"); 423 axesHideButton.setActionCommand("HideAxes"); 424 colorBarShowButton.addActionListener(this); 425 colorBarHideButton.addActionListener(this); 426 colorBarShowButton.setActionCommand("ShowColorBar"); 427 colorBarHideButton.setActionCommand("HideColorBar"); 428 nodeNumsShowButton.addActionListener(this); 429 nodeNumsHideButton.addActionListener(this); 430 nodeNumsShowButton.setActionCommand("ShowNodeNums"); 431 nodeNumsHideButton.setActionCommand("HideNodeNums"); 432 elemNumsShowButton.addActionListener(this); 433 elemNumsHideButton.addActionListener(this); 434 elemNumsShowButton.setActionCommand("ShowElemNums"); 435 elemNumsHideButton.setActionCommand("HideElemNums"); 436 437 438 gbc.anchor = gbc.NORTHEAST; 439 gbc.insets=new Insets(4,4,4,4); 440 frameLeftPanel.setLayout(new GridBagLayout()); 441 gbc.gridx=1; gbc.gridy=0; gbc.gridwidth=1; 442 frameLeftPanel.add(rotateButtonF, gbc); 443 gbc.gridx=0; gbc.gridy=1; gbc.gridwidth=1; 444 frameLeftPanel.add(rotXLabelF, gbc); 445 gbc.gridx=1; gbc.gridy=1; gbc.gridwidth=1; 446 frameLeftPanel.add(rotateXTFF, gbc); 447 gbc.gridx=0; gbc.gridy=2; gbc.gridwidth=1; 448 frameLeftPanel.add(rotYLabelF, gbc); 449 gbc.gridx=1; gbc.gridy=2; gbc.gridwidth=1; 450 frameLeftPanel.add(rotateYTFF, gbc); 451 gbc.gridx=0; gbc.gridy=3; gbc.gridwidth=1; 452 frameLeftPanel.add(rotZLabelF, gbc); 453 gbc.gridx=1; gbc.gridy=3; gbc.gridwidth=1; 454 frameLeftPanel.add(rotateZTFF, gbc); 455 456 frameLeftPanel.add(new JSeparator(JSeparator.HORIZONTAL),new GridBagConstraints(0,4,2,1,0.0,0.0,GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0)); 457 gbc.gridx=1; gbc.gridy=5; gbc.gridwidth=1; 458 frameLeftPanel.add(panButtonF, gbc); 459 gbc.gridx=0; gbc.gridy=6; gbc.gridwidth=1; 460 frameLeftPanel.add(panXLabelF, gbc); 461 gbc.gridx=1; gbc.gridy=6; gbc.gridwidth=1; 462 frameLeftPanel.add(panXTFF, gbc); 463 gbc.gridx=0; gbc.gridy=7; gbc.gridwidth=1; 464 frameLeftPanel.add(panYLabelF, gbc); 465 gbc.gridx=1; gbc.gridy=7; gbc.gridwidth=1; 466 frameLeftPanel.add(panYTFF, gbc); 467 468 frameLeftPanel.add(new JSeparator(JSeparator.HORIZONTAL),new GridBagConstraints(0,8,2,1,0.0,0.0,GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0)); 469 470 gbc.gridx=1; gbc.gridy = 9; 471 frameLeftPanel.add(zoomButtonF, gbc); 472 gbc.gridx=0; gbc.gridy = 10; 473 frameLeftPanel.add(zoomFactorLabelF, gbc); 474 gbc.gridx=1; gbc.gridy = 10; 475 frameLeftPanel.add(zoomTFF, gbc); 476 477 frameLeftPanel.add(new JSeparator(JSeparator.HORIZONTAL),new GridBagConstraints(0,11,2,1,0.0,0.0,GridBagConstraints.CENTER,GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0)); 478 479 gbc.gridx=0; gbc.gridy = 12; gbc.gridwidth=2; 480 frameLeftPanel.add(resetViewButtonF, gbc); 481 gbc.gridx=0; gbc.gridy = 13; 482 483 frameLeftPanel.add(interactiveButtonF, gbc); 484 gbc.gridx=0; gbc.gridy = 14; 485 frameLeftPanel.add(updateButtonF, gbc); 486 gbc.gridx=0; gbc.gridy = 0; gbc.gridwidth=1; gbc.anchor = gbc.NORTHWEST; 487 frameRightPanel.add(bgLabel, gbc); 488 gbc.gridx=1; gbc.gridy = 0; 489 frameRightPanel.add(bgBlackButton, gbc); 490 gbc.gridx=2; gbc.gridy = 0; 491 frameRightPanel.add(bgWhiteButton, gbc); 492 gbc.gridx=0; gbc.gridy = 1; 493 frameRightPanel.add(repLabel, gbc); 494 gbc.gridx=1; gbc.gridy = 1; 495 frameRightPanel.add(repSurfButton, gbc); 496 gbc.gridx=2; gbc.gridy = 1; 497 frameRightPanel.add(repWireButton, gbc); 498 gbc.gridx=1; gbc.gridy = 2; 499 frameRightPanel.add(repPointButton, gbc); 500 gbc.gridx=0; gbc.gridy = 3; 501 frameRightPanel.add(axesLabel, gbc); 502 gbc.gridx=1; gbc.gridy = 3; 503 frameRightPanel.add(axesShowButton, gbc); 504 gbc.gridx=2; gbc.gridy = 3; 505 frameRightPanel.add(axesHideButton, gbc); 506 gbc.gridx=0; gbc.gridy = 4; 507 frameRightPanel.add(colorBarLabel, gbc); 508 gbc.gridx=1; gbc.gridy = 4; 509 frameRightPanel.add(colorBarShowButton, gbc); 510 gbc.gridx=2; gbc.gridy = 4; 511 frameRightPanel.add(colorBarHideButton, gbc); 512 gbc.gridx=0; gbc.gridy = 5; 513 frameRightPanel.add(nodeNumsLabel, gbc); 514 gbc.gridx=1; gbc.gridy = 5; 515 frameRightPanel.add(nodeNumsShowButton, gbc); 516 gbc.gridx=2; gbc.gridy = 5; 517 frameRightPanel.add(nodeNumsHideButton, gbc); 518 gbc.gridx=0; gbc.gridy = 6; 519 frameRightPanel.add(elemNumsLabel, gbc); 520 gbc.gridx=1; gbc.gridy = 6; 521 frameRightPanel.add(elemNumsShowButton, gbc); 522 gbc.gridx=2; gbc.gridy = 6; 523 frameRightPanel.add(elemNumsHideButton, gbc); 524 525 /** end frame panel stuff **/ 526 527 528 529 /** scope tree panel **/ 530 treePanel = new DynamicTree(); 531 populateTree(treePanel); 532 533 JPanel rightPanel = new JPanel(); 534 rightPanel.setLayout(new GridLayout(1,2)); 535 536 addButton = new JButton("Add"); 537 addButton.addActionListener(this); 538 addButton.setActionCommand("AddBody"); 539 540 removeButton = new JButton("Remove"); 541 removeButton.addActionListener(this); 542 removeButton.setActionCommand("RemoveBody"); 543 544 rightPanel.add(addButton); 545 rightPanel.add(removeButton); 546 547 gbc.gridx=0; gbc.gridy=3; gbc.gridheight=1; gbc.gridwidth=1; 548 treePanel.add(rightPanel, gbc); 549 add(treePanel, BorderLayout.EAST); 550 551 552 treePanel.getTree().addTreeSelectionListener(new TreeSelectionListener() { 553 public void valueChanged(TreeSelectionEvent e) { 554 DefaultMutableTreeNode node = (DefaultMutableTreeNode) 555 treePanel.getTree().getLastSelectedPathComponent(); 556 557 if (node == null) return; 558 559 Object nodeInfo = node.getUserObject(); 560 if (((String)nodeInfo).equals( "0.body")){ 561 tabbedPane.setSelectedComponent(bodyPanel); 562 SetScope((String)nodeInfo); 563 564 } 565 else if (((String)nodeInfo).equals("Console Root")){ 566 tabbedPane.setSelectedComponent(rootPanel); 567 568 SetScope((String)nodeInfo); 569 updateUI(); 570 571 } 572 else if (((String)nodeInfo).equals("0.0.frame")){ 573 tabbedPane.setSelectedComponent(framePanel); 574 SetScope((String)nodeInfo); 575 updateUI(); 576 577 } 578 579 System.out.println((String)nodeInfo); 580 581 } 582 583 584 }); 585 586 /** end scope tree panel **/ 587 588 589 590 /* body panel stuff */ 591 592 bodyPanel.setLayout(new GridLayout(1,2)); 593 594 JPanel bodyLeftPanel = new JPanel(); 595 JScrollPane bodyLeftScroll = new JScrollPane(bodyLeftPanel); 596 bodyLeftPanel.setLayout(new GridBagLayout()); 597 JPanel bodyRightPanel = new JPanel(); 598 JScrollPane bodyRightScroll = new JScrollPane(bodyRightPanel); 599 bodyRightPanel.setLayout(new GridBagLayout()); 600 bodyPanel.add(bodyLeftScroll); 601 602 bodyPanel.add(bodyRightScroll); 603 604 JButton interactiveButtonB = new JButton("Interactive"); 605 JButton updateButtonB = new JButton("Update"); 606 JButton cuttingButtonB = new JButton("Show Cutting Plane"); 607 interactiveButtonB.addActionListener(this); 608 interactiveButtonB.setActionCommand("Interactive"); 609 updateButtonB.addActionListener(this); 610 updateButtonB.setActionCommand("Update"); 611 cuttingButtonB.addActionListener(this); 612 cuttingButtonB.setActionCommand("ShowCutting"); 613 614 JLabel repLabelB = new JLabel("Representation"); 615 JRadioButton repSurfButtonB = new JRadioButton("Surface"); 616 repSurfButtonB.setSelected(true); 617 repSurfButtonB.addActionListener(this); 618 repSurfButtonB.setActionCommand("Surf"); 619 JRadioButton repWireButtonB = new JRadioButton("Wire"); 620 repWireButtonB.addActionListener(this); 621 repWireButtonB.setActionCommand("Wire"); 622 JRadioButton repPointButtonB = new JRadioButton("Points"); 623 repPointButtonB.addActionListener(this); 624 repPointButtonB.setActionCommand("Points"); 625 ButtonGroup repButtonsB = new ButtonGroup(); 626 repButtonsB.add(repSurfButton); 627 repButtonsB.add(repWireButton); 628 repButtonsB.add(repPointButton); 629 630 JLabel nodeNumsLabelB = new JLabel ("Node Numbers"); 631 JLabel elemNumsLabelB = new JLabel ("Element Numbers"); 632 633 JRadioButton nodeNumsShowButtonB = new JRadioButton("Show"); 634 JRadioButton nodeNumsHideButtonB = new JRadioButton("Hide"); 635 ButtonGroup nodeNumsButtonsB = new ButtonGroup(); 636 JRadioButton elemNumsShowButtonB = new JRadioButton("Show"); 637 JRadioButton elemNumsHideButtonB = new JRadioButton("Hide"); 638 ButtonGroup elemNumsButtonsB = new ButtonGroup(); 639 640 nodeNumsButtonsB.add(nodeNumsShowButtonB); 641 nodeNumsButtonsB.add(nodeNumsHideButtonB); 642 elemNumsButtonsB.add(elemNumsShowButtonB); 643 elemNumsButtonsB.add(elemNumsHideButtonB); 644 645 nodeNumsHideButtonB.setSelected(true); 646 elemNumsHideButtonB.setSelected(true); 647 648 nodeNumsShowButtonB.addActionListener(this); 649 nodeNumsHideButtonB.addActionListener(this); 650 nodeNumsShowButtonB.setActionCommand("ShowNodeNums"); 651 nodeNumsHideButtonB.setActionCommand("HideNodeNums"); 652 elemNumsShowButtonB.addActionListener(this); 653 elemNumsHideButtonB.addActionListener(this); 654 elemNumsShowButtonB.setActionCommand("ShowElemNums"); 655 elemNumsHideButtonB.setActionCommand("HideElemNums"); 656 657 658 JLabel contoursLabelB = new JLabel ("Contours"); 659 JLabel glyphsLabelB = new JLabel ("Glyphs"); 660 661 JRadioButton contoursShowButtonB = new JRadioButton("Show"); 662 JRadioButton contoursHideButtonB = new JRadioButton("Hide"); 663 ButtonGroup contoursButtonsB = new ButtonGroup(); 664 JRadioButton glyphsShowButtonB = new JRadioButton("Show"); 665 JRadioButton glyphsHideButtonB = new JRadioButton("Hide"); 666 ButtonGroup glyphsButtonsB = new ButtonGroup(); 667 668 contoursButtonsB.add(contoursShowButtonB); 669 contoursButtonsB.add(contoursHideButtonB); 670 glyphsButtonsB.add(glyphsShowButtonB); 671 glyphsButtonsB.add(glyphsHideButtonB); 672 673 contoursHideButtonB.setSelected(true); 674 glyphsHideButtonB.setSelected(true); 675 676 contoursShowButtonB.addActionListener(this); 677 contoursHideButtonB.addActionListener(this); 678 contoursShowButtonB.setActionCommand("Show Contours"); 679 contoursHideButtonB.setActionCommand("Hide Contours"); 680 glyphsShowButtonB.addActionListener(this); 681 glyphsHideButtonB.addActionListener(this); 682 glyphsShowButtonB.setActionCommand("Show Glyphs"); 683 glyphsHideButtonB.setActionCommand("Hide Glyphs"); 684 685 686 gbc.anchor = gbc.NORTHEAST; 687 gbc.insets=new Insets(4,4,4,4); 688 bodyLeftPanel.setLayout(new GridBagLayout()); 689 gbc.gridx=1; gbc.gridy=0; gbc.gridwidth=1; 690 bodyLeftPanel.add(interactiveButtonB, gbc); 691 gbc.gridx=1; gbc.gridy=1; gbc.gridwidth=1; 692 bodyLeftPanel.add(updateButtonB, gbc); 693 gbc.gridx=0; gbc.gridy=0; gbc.gridwidth=1;gbc.anchor = gbc.NORTHWEST; 694 bodyRightPanel.add(repLabelB, gbc); 695 gbc.gridx=1; gbc.gridy=0; gbc.gridwidth=1; 696 bodyRightPanel.add(repSurfButtonB, gbc); 697 gbc.gridx=2; gbc.gridy=0; gbc.gridwidth=1; 698 bodyRightPanel.add(repWireButtonB, gbc); 699 gbc.gridx=1; gbc.gridy=1; gbc.gridwidth=1; 700 bodyRightPanel.add(repPointButtonB, gbc); 701 gbc.gridx=0; gbc.gridy=2; gbc.gridwidth=1; 702 bodyRightPanel.add(nodeNumsLabelB, gbc); 703 704 gbc.gridx=1; gbc.gridy=2; gbc.gridwidth=1; 705 bodyRightPanel.add(nodeNumsShowButtonB, gbc); 706 gbc.gridx=2; gbc.gridy=2; gbc.gridwidth=1; 707 bodyRightPanel.add(nodeNumsHideButtonB, gbc); 708 gbc.gridx=0; gbc.gridy=3; gbc.gridwidth=1; 709 bodyRightPanel.add(elemNumsLabelB, gbc); 710 gbc.gridx=1; gbc.gridy=3; gbc.gridwidth=1; 711 bodyRightPanel.add(elemNumsShowButtonB, gbc); 712 gbc.gridx=2; gbc.gridy=3; gbc.gridwidth=1; 713 bodyRightPanel.add(elemNumsHideButtonB, gbc); 714 715 716 gbc.gridx=0; gbc.gridy = 4; 717 bodyRightPanel.add(contoursLabelB, gbc); 718 gbc.gridx=1; gbc.gridy = 4; 719 bodyRightPanel.add(contoursShowButtonB, gbc); 720 gbc.gridx=2; gbc.gridy = 4; 721 bodyRightPanel.add(contoursHideButtonB, gbc); 722 723 724 /* end body panel */ 725 726 727 728 /* for AddBody and Save commands */ 729 730 // //Create the log first, because the action listeners 731 // //need to refer to it. 732 // final JTextArea log = new JTextArea(5,20); 733 // log.setMargin(new Insets(5,5,5,5)); 734 // log.setEditable(false); 735 // JScrollPane logScrollPane = new JScrollPane(log); 736 737 // //Create a file chooser 738 // final JFileChooser fc = new JFileChooser(); 739 740 // //Create the open button 741 // ImageIcon openIcon = new ImageIcon("images/open.gif"); 742 // JButton openButton = new JButton("Open a File...", openIcon); 743 // openButton.addActionListener(new ActionListener() { 744 // public void actionPerformed(ActionEvent e) { 745 // int returnVal = fc.showOpenDialog(FileChooserDemo.this); 746 747 // if (returnVal == JFileChooser.APPROVE_OPTION) { 748 // File file = fc.getSelectedFile(); 749 // //this is where a real application would open the file. 750 // log.append("Opening: " + file.getName() + "." + newline); 751 // } else { 752 // log.append("Open command cancelled by user." + newline); 753 // } 754 // } 755 // }); 756 757 // //Create the save button 758 // ImageIcon saveIcon = new ImageIcon("images/save.gif"); 759 // JButton saveButton = new JButton("Save a File...", saveIcon); 760 // saveButton.addActionListener(new ActionListener() { 761 // public void actionPerformed(ActionEvent e) { 762 // int returnVal = fc.showSaveDialog(FileChooserDemo.this); 763 764 // if (returnVal == JFileChooser.APPROVE_OPTION) { 765 // File file = fc.getSelectedFile(); 766 // //this is where a real application would save the file. 767 // log.append("Saving: " + file.getName() + "." + newline); 768 // } else { 769 // log.append("Save command cancelled by user." + newline); 770 // } 771 // } 772 // }); 773 774 775 776 777 778 779 780 Dimension minimumSize = new Dimension(150, 250); 781 782 Dimension minimumSize2 = new Dimension(300, 250); 783 treePanel.setMinimumSize(minimumSize); 784 785 } 786 787 public void actionPerformed(ActionEvent e){ 788 if (e.getActionCommand().equals("Exit")){ 789 System.exit(0); 790 } 791 792 else if (e.getActionCommand().equals("Print value")){ 793 Print(); 794 //leftPanel.remove(addButton); 795 //updateUI(); 796 797 } 798 799 else if (e.getActionCommand().equals("Rotate")){ 800 String args; 801 args = rotateXTF.getText() + " " + rotateYTF.getText() + " " + rotateZTF.getText(); 802 System.out.println("Rotate " + args); 803 //DoCommand("Rotate", args); 804 } 805 806 else if (e.getActionCommand().equals("Pan")){ 807 String args; 808 args = panXTF.getText() + " " + panYTF.getText(); 809 System.out.println("Pan " + args); 810 //DoCommand("Pan", args); 811 } 812 813 else if (e.getActionCommand().equals("Zoom")){ 814 String args = zoomTF.getText(); 815 System.out.println("Zoom " + args); 816 //DoCommand("Rotate", args); 817 } 818 819 else if (e.getActionCommand().equals("CommandLine")){ 820 CommandLine(); 821 } 822 823 else if (e.getActionCommand().equals("BodyVarOK")){ 824 SetMinSc(Integer.parseInt(minScalarTF.getText())); 825 826 } 827 828 else if (e.getActionCommand().equals("ShowContours")){ 829 System.out.println("ShowContours"); 830 } 831 832 else if (e.getActionCommand().equals("HideContours")){ 833 System.out.println("HideContours"); 834 } 835 836 else if (e.getActionCommand().equals("ShowCutting")){ 837 System.out.println("ShowCuttingPlane"); 838 JDialog temp = new JDialog(parentFrame, true); 839 temp.setTitle("Show Cutting Plane"); 840 temp.setSize(400, 300); 841 JPanel cutPanel = new JPanel(); 842 JButton cutOKButton = new JButton("OK"); 843 JButton cutCancelButton = new JButton("Cancel"); 844 cutPanel.add(cutOKButton); 845 cutPanel.add(cutCancelButton); 846 temp.getContentPane().add(cutPanel); 847 848 temp.pack(); 849 temp.show(); 850 851 } 852 else if (e.getActionCommand().equals("HideCutting")){ 853 System.out.println("HideCuttingPlane"); 854 } 855 else if (e.getActionCommand().equals("Update")){ 856 DoCommand("Update", ""); 857 } 858 859 else if (e.getActionCommand().equals("FlipBook")){ 860 System.out.println("Flip Book"); 861 } 862 else if (e.getActionCommand().equals("NextTimeStep")){ 863 System.out.println("Next Time Step"); 864 } 865 else if (e.getActionCommand().equals("PreviousTimeStep")){ 866 System.out.println("Previous Time Step"); 867 } 868 else if (e.getActionCommand().equals("SelectTimeStep")){ 869 System.out.println("Select Time Step"); 870 } 871 else if (e.getActionCommand().equals("AddBody")){ 872 treePanel.addObject("New Node " + newNodeSuffix++); 873 //AddScope("New Node " + newNodeSuffix++); 874 } 875 else if (e.getActionCommand().equals("RemoveBody")){ 876 treePanel.removeCurrentNode(); 877 } 878 else if (e.getActionCommand().equals("Clear")){ 879 treePanel.clear(); 880 } 881 else if (e.getActionCommand().equals("Interact")){ 882 Interact(); 883 } 884 else if (e.getActionCommand().equals("Black BG")){ 885 System.out.println("Black BG"); 886 } 887 else if (e.getActionCommand().equals("White BG")){ 888 System.out.println("White BG"); 889 } 890 else if (e.getActionCommand().equals("Surf")){ 891 DoCommand("Surface", ""); 892 DoCommand("Update", ""); 893 } 894 else if (e.getActionCommand().equals("Wire")){ 895 DoCommand("Wire", ""); 896 DoCommand("Update", ""); 897 } 898 else if (e.getActionCommand().equals("Points")){ 899 DoCommand("Point", ""); 900 DoCommand("Update", ""); 901 } 902 else if (e.getActionCommand().equals("ShowAxes")){ 903 DoCommand("ShowAxes", ""); 904 } 905 else if (e.getActionCommand().equals("HideAxes")){ 906 DoCommand("HideAxes", ""); 907 } 908 else if (e.getActionCommand().equals("ShowColorBar")){ 909 System.out.println(e.getActionCommand()); 910 } 911 else if (e.getActionCommand().equals("HideColorBar")){ 912 System.out.println(e.getActionCommand()); 913 } 914 else if (e.getActionCommand().equals("ShowNodeNums")){ 915 DoCommand("ShowNodeNum", ""); 916 } 917 else if (e.getActionCommand().equals("HideNodeNums")){ 918 DoCommand("HideNodeNum", ""); 919 } 920 else if (e.getActionCommand().equals("ShowElemNums")){ 921 DoCommand("ShowElemNum", ""); 922 } 923 else if (e.getActionCommand().equals("HideElemNums")){ 924 DoCommand("HideElemNum", ""); 925 } 926 927 } 928 929 public void stateChanged(ChangeEvent e) 930 { 931 if(e.getSource()==selectTimeSlider){ 932 selectTimeTF.setText(Integer.toString((int)selectTimeSlider.getValue())); 933 String args; 934 args = selectTimeTF.getText(); 935 //System.out.println(args); 936 //DoCommand("SelectTimeStep", "args"); 937 } 938 else if(e.getSource()==selectTimeSliderF){ 939 selectTimeTFF.setText(Integer.toString((int)selectTimeSliderF.getValue())); 940 } 941 942 } 943 944 945 public void populateTree(DynamicTree treePanel) { 946 String f1Name = new String("0.0.frame"); 947 String b1Name = new String("0.body"); 948 String bd1Name = new String("0.body"); 949 950 DefaultMutableTreeNode p1, p2; 951 952 p1 = treePanel.addObject(null, f1Name); 953 p2 = treePanel.addObject(null, bd1Name); 954 treePanel.addObject(p1, b1Name); 955 956 } 957 958 959 960 } // class test This page was automatically generated by the LXR engine. Visit the LXR main site for more information. |