.. | .. |
---|
4 | 4 | |
---|
5 | 5 | import java.awt.*; |
---|
6 | 6 | import java.awt.event.*; |
---|
| 7 | +import java.awt.image.BufferedImage; |
---|
7 | 8 | import javax.swing.*; |
---|
8 | 9 | import javax.swing.event.*; |
---|
9 | 10 | import javax.swing.text.*; |
---|
.. | .. |
---|
35 | 36 | |
---|
36 | 37 | GroupEditor callee; |
---|
37 | 38 | JFrame frame; |
---|
| 39 | + |
---|
| 40 | + static ObjEditor theFrame; |
---|
| 41 | + |
---|
| 42 | + cButton GetButton(String name, boolean border) |
---|
| 43 | + { |
---|
| 44 | + try |
---|
| 45 | + { |
---|
| 46 | + ImageIcon icon = GetIcon(name); |
---|
| 47 | + return new cButton(icon, border); |
---|
| 48 | + } |
---|
| 49 | + catch (Exception e) |
---|
| 50 | + { |
---|
| 51 | + return new cButton(name, border); |
---|
| 52 | + } |
---|
| 53 | + } |
---|
| 54 | + |
---|
| 55 | + cToggleButton GetToggleButton(String name, boolean border) |
---|
| 56 | + { |
---|
| 57 | + try |
---|
| 58 | + { |
---|
| 59 | + ImageIcon icon = GetIcon(name); |
---|
| 60 | + return new cToggleButton(icon, border); |
---|
| 61 | + } |
---|
| 62 | + catch (Exception e) |
---|
| 63 | + { |
---|
| 64 | + return new cToggleButton(name, border); |
---|
| 65 | + } |
---|
| 66 | + } |
---|
| 67 | + |
---|
| 68 | + cCheckBox GetCheckBox(String name, boolean border) |
---|
| 69 | + { |
---|
| 70 | + try |
---|
| 71 | + { |
---|
| 72 | + ImageIcon icon = GetIcon(name); |
---|
| 73 | + return new cCheckBox(icon, border); |
---|
| 74 | + } |
---|
| 75 | + catch (Exception e) |
---|
| 76 | + { |
---|
| 77 | + return new cCheckBox(name, border); |
---|
| 78 | + } |
---|
| 79 | + } |
---|
| 80 | + |
---|
| 81 | + private ImageIcon GetIcon(String name) throws IOException |
---|
| 82 | + { |
---|
| 83 | + BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); |
---|
| 84 | + |
---|
| 85 | + if (image.getWidth() != 24 && image.getHeight() != 24) |
---|
| 86 | + { |
---|
| 87 | + BufferedImage resized = new BufferedImage(24, 24, image.getType()); |
---|
| 88 | + Graphics2D g = resized.createGraphics(); |
---|
| 89 | + g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); |
---|
| 90 | + //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
---|
| 91 | + g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null); |
---|
| 92 | + g.dispose(); |
---|
| 93 | + |
---|
| 94 | + image = resized; |
---|
| 95 | + } |
---|
| 96 | + |
---|
| 97 | + javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image); |
---|
| 98 | + return icon; |
---|
| 99 | + } |
---|
38 | 100 | |
---|
39 | 101 | // SCRIPT |
---|
40 | 102 | |
---|
.. | .. |
---|
145 | 207 | |
---|
146 | 208 | objEditor.ctrlPanel.remove(namePanel); |
---|
147 | 209 | |
---|
148 | | - if (!GroupEditor.allparams) |
---|
| 210 | + if (!allparams) |
---|
149 | 211 | return; |
---|
150 | 212 | |
---|
151 | 213 | // objEditor.ctrlPanel.remove(liveCB); |
---|
.. | .. |
---|
168 | 230 | // objEditor.ctrlPanel.remove(remarkButton); |
---|
169 | 231 | |
---|
170 | 232 | objEditor.ctrlPanel.remove(setupPanel); |
---|
171 | | - objEditor.ctrlPanel.remove(commandsPanel); |
---|
| 233 | + objEditor.ctrlPanel.remove(setupPanel2); |
---|
| 234 | + objEditor.ctrlPanel.remove(objectCommandsPanel); |
---|
172 | 235 | objEditor.ctrlPanel.remove(pushPanel); |
---|
173 | 236 | //objEditor.ctrlPanel.remove(fillPanel); |
---|
174 | 237 | |
---|
.. | .. |
---|
243 | 306 | //localCopy.parent = null; |
---|
244 | 307 | |
---|
245 | 308 | frame = new JFrame(); |
---|
| 309 | + frame.setUndecorated(true); |
---|
246 | 310 | objEditor = this; |
---|
247 | 311 | this.callee = callee; |
---|
248 | 312 | |
---|
.. | .. |
---|
273 | 337 | return frame.action(event, obj); |
---|
274 | 338 | } |
---|
275 | 339 | |
---|
| 340 | + // Cannot work without static |
---|
| 341 | + static boolean allparams = true; |
---|
| 342 | + |
---|
| 343 | + static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>(); |
---|
| 344 | + |
---|
276 | 345 | void SetupMenu() |
---|
277 | 346 | { |
---|
278 | 347 | frame.setMenuBar(menuBar = new MenuBar()); |
---|
279 | 348 | menuBar.add(fileMenu = new Menu("File")); |
---|
280 | 349 | fileMenu.add(newItem = new MenuItem("New")); |
---|
281 | | - fileMenu.add(loadItem = new MenuItem("Load...")); |
---|
| 350 | + fileMenu.add(loadItem = new MenuItem("Open...")); |
---|
282 | 351 | |
---|
283 | 352 | //oe.menuBar.add(menu = new Menu("Include")); |
---|
284 | 353 | Menu menu = new Menu("Import"); |
---|
.. | .. |
---|
319 | 388 | closeItem.addActionListener(this); |
---|
320 | 389 | |
---|
321 | 390 | objectPanel = new JTabbedPane(); |
---|
| 391 | + |
---|
| 392 | + ChangeListener changeListener = new ChangeListener() |
---|
| 393 | + { |
---|
| 394 | + public void stateChanged(ChangeEvent changeEvent) |
---|
| 395 | + { |
---|
| 396 | +// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed) |
---|
| 397 | +// { |
---|
| 398 | +// if (latestObject != null) |
---|
| 399 | +// { |
---|
| 400 | +// refreshContents(true); |
---|
| 401 | +// SetMaterial(latestObject); |
---|
| 402 | +// } |
---|
| 403 | +// |
---|
| 404 | +// materialFlushed = true; |
---|
| 405 | +// } |
---|
| 406 | +// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit")) |
---|
| 407 | +// { |
---|
| 408 | +// if (listUI.size() == 0) |
---|
| 409 | +// EditSelection(false); |
---|
| 410 | +// } |
---|
| 411 | + |
---|
| 412 | + refreshContents(false); // To refresh Info tab |
---|
| 413 | + } |
---|
| 414 | + }; |
---|
| 415 | + objectPanel.addChangeListener(changeListener); |
---|
| 416 | + |
---|
322 | 417 | toolbarPanel = new JPanel(); |
---|
323 | 418 | toolbarPanel.setName("Toolbar"); |
---|
324 | 419 | treePanel = new cGridBag(); |
---|
325 | 420 | treePanel.setName("Tree"); |
---|
| 421 | + |
---|
| 422 | + editPanel = new cGridBag().setVertical(true); |
---|
| 423 | + editPanel.setName("Edit"); |
---|
| 424 | + |
---|
326 | 425 | ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout()); |
---|
327 | | - ctrlPanel.setName("Edit"); |
---|
| 426 | + |
---|
| 427 | + editCommandsPanel = new cGridBag(); |
---|
| 428 | + editPanel.add(editCommandsPanel); |
---|
| 429 | + editPanel.add(ctrlPanel); |
---|
| 430 | + |
---|
| 431 | + toolboxPanel = new cGridBag().setVertical(false); |
---|
| 432 | + toolboxPanel.setName("Toolbox"); |
---|
| 433 | + |
---|
328 | 434 | materialPanel = new cGridBag().setVertical(true); |
---|
329 | 435 | materialPanel.setName("Material"); |
---|
| 436 | + |
---|
330 | 437 | /*JTextPane*/ |
---|
331 | 438 | infoarea = createTextPane(); |
---|
332 | 439 | doc = infoarea.getStyledDocument(); |
---|
.. | .. |
---|
419 | 526 | e.printStackTrace(); |
---|
420 | 527 | } |
---|
421 | 528 | |
---|
422 | | - String selection = infoarea.getText(); |
---|
423 | | - java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection); |
---|
424 | | - java.awt.datatransfer.Clipboard clipboard = |
---|
425 | | - Toolkit.getDefaultToolkit().getSystemClipboard(); |
---|
| 529 | +// String selection = infoarea.getText(); |
---|
| 530 | +// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection); |
---|
| 531 | +// java.awt.datatransfer.Clipboard clipboard = |
---|
| 532 | +// Toolkit.getDefaultToolkit().getSystemClipboard(); |
---|
426 | 533 | //clipboard.setContents(data, data); |
---|
427 | 534 | } |
---|
428 | 535 | |
---|
.. | .. |
---|
582 | 689 | } |
---|
583 | 690 | } |
---|
584 | 691 | |
---|
| 692 | +static GraphicsDevice device = GraphicsEnvironment |
---|
| 693 | + .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
| 694 | + |
---|
| 695 | + Rectangle keeprect; |
---|
| 696 | + cRadio radio; |
---|
| 697 | + |
---|
| 698 | +cButton keepButton; |
---|
| 699 | + cButton twoButton; // Full 3D |
---|
| 700 | + cButton sixButton; |
---|
| 701 | + cButton threeButton; |
---|
| 702 | + cButton sevenButton; |
---|
| 703 | + cButton fourButton; // full panel |
---|
| 704 | + cButton oneButton; // full XYZ |
---|
| 705 | + //cButton currentLayout; |
---|
| 706 | + |
---|
| 707 | + boolean maximized; |
---|
| 708 | + |
---|
| 709 | + cButton fullscreenLayout; |
---|
| 710 | + |
---|
| 711 | + void Minimize() |
---|
| 712 | + { |
---|
| 713 | + frame.setState(Frame.ICONIFIED); |
---|
| 714 | + } |
---|
| 715 | + |
---|
| 716 | + void Maximize() |
---|
| 717 | + { |
---|
| 718 | + if (maximized) |
---|
| 719 | + { |
---|
| 720 | + frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); |
---|
| 721 | + } |
---|
| 722 | + else |
---|
| 723 | + { |
---|
| 724 | + keeprect = frame.getBounds(); |
---|
| 725 | + Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); |
---|
| 726 | + Dimension rect2 = frame.getToolkit().getScreenSize(); |
---|
| 727 | + frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height); |
---|
| 728 | +// frame.setState(Frame.MAXIMIZED_BOTH); |
---|
| 729 | + } |
---|
| 730 | + |
---|
| 731 | + maximized ^= true; |
---|
| 732 | + } |
---|
| 733 | + |
---|
585 | 734 | void ToggleFullScreen() |
---|
586 | 735 | { |
---|
587 | | - if (CameraPane.FULLSCREEN) |
---|
| 736 | + cameraView.ToggleFullScreen(); |
---|
| 737 | + |
---|
| 738 | + if (!CameraPane.FULLSCREEN) |
---|
588 | 739 | { |
---|
589 | | - frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
590 | | - framePanel.add(bigThree); |
---|
591 | | - frame.getContentPane().add(/*"Center",*/framePanel); |
---|
| 740 | + device.setFullScreenWindow(null); |
---|
| 741 | + //frame.setVisible(false); |
---|
| 742 | +// frame.removeNotify(); |
---|
| 743 | +// frame.setUndecorated(false); |
---|
| 744 | +// frame.addNotify(); |
---|
| 745 | + //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); |
---|
| 746 | + |
---|
| 747 | +// X frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
| 748 | +// X framePanel.add(bigThree); |
---|
| 749 | +// X frame.getContentPane().add(/*"Center",*/framePanel); |
---|
| 750 | + framePanel.setDividerLocation(1); |
---|
| 751 | + |
---|
| 752 | + //frame.setVisible(true); |
---|
| 753 | + radio.layout = keepButton; |
---|
| 754 | + //theFrame = null; |
---|
| 755 | + keepButton = null; |
---|
| 756 | + radio.layout.doClick(); |
---|
| 757 | + |
---|
592 | 758 | } else |
---|
593 | 759 | { |
---|
594 | | - frame.getContentPane().remove(/*"Center",*/framePanel); |
---|
595 | | - framePanel.remove(bigThree); |
---|
596 | | - frame.getContentPane().add(/*"Center",*/bigThree); |
---|
| 760 | + keepButton = radio.layout; |
---|
| 761 | + //keeprect = frame.getBounds(); |
---|
| 762 | +// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width, |
---|
| 763 | +// frame.getToolkit().getScreenSize().height); |
---|
| 764 | + //frame.setVisible(false); |
---|
| 765 | + device.setFullScreenWindow(frame); |
---|
| 766 | +// frame.removeNotify(); |
---|
| 767 | +// frame.setUndecorated(true); |
---|
| 768 | +// frame.addNotify(); |
---|
| 769 | +// X frame.getContentPane().remove(/*"Center",*/framePanel); |
---|
| 770 | +// X framePanel.remove(bigThree); |
---|
| 771 | +// X frame.getContentPane().add(/*"Center",*/bigThree); |
---|
| 772 | + framePanel.setDividerLocation(0); |
---|
| 773 | + |
---|
| 774 | + radio.layout = fullscreenLayout; |
---|
| 775 | + radio.layout.doClick(); |
---|
| 776 | + //frame.setVisible(true); |
---|
597 | 777 | } |
---|
598 | | - cameraView.ToggleFullScreen(); |
---|
599 | 778 | } |
---|
600 | 779 | |
---|
601 | 780 | private JTextPane createTextPane() |
---|
.. | .. |
---|
736 | 915 | JCheckBox speedupCB; |
---|
737 | 916 | JCheckBox rewindCB; |
---|
738 | 917 | JCheckBox flipVCB; |
---|
| 918 | + |
---|
| 919 | + cCheckBox toggleTextureCB; |
---|
| 920 | + cCheckBox toggleSwitchCB; |
---|
| 921 | + |
---|
739 | 922 | JComboBox texresMenu; |
---|
| 923 | + |
---|
740 | 924 | JButton resetButton; |
---|
741 | 925 | JButton stepButton; |
---|
742 | 926 | JButton stepAllButton; |
---|
.. | .. |
---|
745 | 929 | JButton fasterButton; |
---|
746 | 930 | JButton remarkButton; |
---|
747 | 931 | |
---|
| 932 | + cGridBag editPanel; |
---|
| 933 | + cGridBag editCommandsPanel; |
---|
| 934 | + |
---|
748 | 935 | cGridBag namePanel; |
---|
749 | 936 | cGridBag setupPanel; |
---|
750 | | - cGridBag commandsPanel; |
---|
| 937 | + cGridBag setupPanel2; |
---|
| 938 | + cGridBag objectCommandsPanel; |
---|
751 | 939 | cGridBag pushPanel; |
---|
752 | 940 | cGridBag fillPanel; |
---|
753 | 941 | |
---|
.. | .. |
---|
924 | 1112 | |
---|
925 | 1113 | oe.ctrlPanel.Return(); |
---|
926 | 1114 | |
---|
927 | | - if (!GroupEditor.allparams) |
---|
| 1115 | + if (!allparams) |
---|
928 | 1116 | return; |
---|
929 | 1117 | |
---|
930 | 1118 | setupPanel = new cGridBag().setVertical(false); |
---|
.. | .. |
---|
939 | 1127 | markCB = AddCheckBox(setupPanel, "Mark", copy.marked); |
---|
940 | 1128 | markCB.setToolTipText("Set the animation target transform"); |
---|
941 | 1129 | |
---|
942 | | - rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind); |
---|
| 1130 | + setupPanel2 = new cGridBag().setVertical(false); |
---|
| 1131 | + |
---|
| 1132 | + rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind); |
---|
943 | 1133 | rewindCB.setToolTipText("Rewind animation"); |
---|
944 | 1134 | |
---|
945 | | - randomCB = AddCheckBox(setupPanel, "Random", copy.random); |
---|
946 | | - randomCB.setToolTipText("Option for switch node"); |
---|
| 1135 | + randomCB = AddCheckBox(setupPanel2, "Rand", copy.random); |
---|
| 1136 | + randomCB.setToolTipText("Randomly Rewind or Go back and forth"); |
---|
947 | 1137 | |
---|
948 | 1138 | if (Globals.ADVANCED) |
---|
949 | 1139 | { |
---|
950 | | - link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master); |
---|
| 1140 | + link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); |
---|
951 | 1141 | link2masterCB.setToolTipText("Attach to support"); |
---|
952 | | - speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup); |
---|
| 1142 | + speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
953 | 1143 | speedupCB.setToolTipText("Option motion capture"); |
---|
954 | 1144 | } |
---|
955 | 1145 | |
---|
956 | 1146 | oe.ctrlPanel.add(setupPanel); |
---|
957 | 1147 | oe.ctrlPanel.Return(); |
---|
| 1148 | + oe.ctrlPanel.add(setupPanel2); |
---|
| 1149 | + oe.ctrlPanel.Return(); |
---|
958 | 1150 | |
---|
959 | | - commandsPanel = new cGridBag().setVertical(false); |
---|
| 1151 | + objectCommandsPanel = new cGridBag().setVertical(false); |
---|
960 | 1152 | |
---|
961 | | - resetButton = AddButton(commandsPanel, "Reset"); |
---|
| 1153 | + resetButton = AddButton(objectCommandsPanel, "Reset"); |
---|
962 | 1154 | resetButton.setToolTipText("Jump to frame zero"); |
---|
963 | | - stepButton = AddButton(commandsPanel, "Step"); |
---|
| 1155 | + stepButton = AddButton(objectCommandsPanel, "Step"); |
---|
964 | 1156 | stepButton.setToolTipText("Step one frame"); |
---|
965 | 1157 | // resetAllButton = AddButton(oe, "Reset All"); |
---|
966 | 1158 | // stepAllButton = AddButton(oe, "Step All"); |
---|
967 | 1159 | // Return(); |
---|
968 | | - slowerButton = AddButton(commandsPanel, "Slow"); |
---|
| 1160 | + slowerButton = AddButton(objectCommandsPanel, "Slow"); |
---|
969 | 1161 | slowerButton.setToolTipText("Decrease animation speed"); |
---|
970 | | - fasterButton = AddButton(commandsPanel, "Fast"); |
---|
| 1162 | + fasterButton = AddButton(objectCommandsPanel, "Fast"); |
---|
971 | 1163 | fasterButton.setToolTipText("Increase animation speed"); |
---|
972 | | - remarkButton = AddButton(commandsPanel, "Remark"); |
---|
| 1164 | + remarkButton = AddButton(objectCommandsPanel, "Remark"); |
---|
973 | 1165 | remarkButton.setToolTipText("Set the current transform as the target"); |
---|
974 | 1166 | |
---|
975 | | - oe.ctrlPanel.add(commandsPanel); |
---|
| 1167 | + oe.ctrlPanel.add(objectCommandsPanel); |
---|
976 | 1168 | oe.ctrlPanel.Return(); |
---|
977 | 1169 | |
---|
978 | 1170 | pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons |
---|
.. | .. |
---|
1178 | 1370 | //worldPanel.setName("World"); |
---|
1179 | 1371 | centralPanel = new cGridBag(); |
---|
1180 | 1372 | centralPanel.preferredWidth = 20; |
---|
1181 | | - timelinePanel = new JPanel(new BorderLayout()); |
---|
1182 | | - timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel); |
---|
| 1373 | + |
---|
| 1374 | + if (Globals.ADVANCED) |
---|
| 1375 | + { |
---|
| 1376 | + timelinePanel = new JPanel(new BorderLayout()); |
---|
| 1377 | + timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel); |
---|
1183 | 1378 | |
---|
1184 | 1379 | cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel); |
---|
1185 | 1380 | cameraPanel.setContinuousLayout(true); |
---|
.. | .. |
---|
1188 | 1383 | // cameraPanel.setDividerSize(9); |
---|
1189 | 1384 | cameraPanel.setResizeWeight(1.0); |
---|
1190 | 1385 | |
---|
| 1386 | + } |
---|
| 1387 | + |
---|
1191 | 1388 | centralPanel.add(cameraView); |
---|
| 1389 | + centralPanel.setFocusable(true); |
---|
1192 | 1390 | //frame.setJMenuBar(timelineMenubar); |
---|
1193 | 1391 | //centralPanel.add(timelinePanel); |
---|
1194 | 1392 | |
---|
.. | .. |
---|
1255 | 1453 | // north.setName("Edit"); |
---|
1256 | 1454 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1257 | 1455 | // objectPanel.add(north); |
---|
1258 | | - objectPanel.add(ctrlPanel); |
---|
| 1456 | + objectPanel.add(editPanel); |
---|
1259 | 1457 | objectPanel.add(infoPanel); |
---|
| 1458 | + objectPanel.add(toolboxPanel); |
---|
1260 | 1459 | |
---|
1261 | 1460 | /* |
---|
1262 | 1461 | aConstraints.gridx = 0; |
---|
.. | .. |
---|
1265 | 1464 | aConstraints.gridy += 1; |
---|
1266 | 1465 | aConstraints.gridwidth = 1; |
---|
1267 | 1466 | mainPanel.add(objectPanel, aConstraints); |
---|
1268 | | - */ |
---|
| 1467 | + */ |
---|
1269 | 1468 | |
---|
1270 | 1469 | scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS, |
---|
1271 | 1470 | VERTICAL_SCROLLBAR_AS_NEEDED, |
---|
.. | .. |
---|
1282 | 1481 | JTabbedPane tabbedPane = new JTabbedPane(); |
---|
1283 | 1482 | tabbedPane.add(scrollpane); |
---|
1284 | 1483 | |
---|
1285 | | - tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
1286 | | - |
---|
1287 | | - optionsPanel = new cGridBag().setVertical(true); |
---|
| 1484 | + optionsPanel = new cGridBag().setVertical(false); |
---|
1288 | 1485 | |
---|
1289 | 1486 | optionsPanel.setName("Options"); |
---|
1290 | 1487 | |
---|
.. | .. |
---|
1292 | 1489 | |
---|
1293 | 1490 | tabbedPane.add(optionsPanel); |
---|
1294 | 1491 | |
---|
| 1492 | + tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
| 1493 | + |
---|
1295 | 1494 | scenePanel.add(tabbedPane); |
---|
1296 | 1495 | |
---|
1297 | 1496 | /* |
---|
.. | .. |
---|
1384 | 1583 | // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc); |
---|
1385 | 1584 | |
---|
1386 | 1585 | frame.setSize(1280, 860); |
---|
| 1586 | + |
---|
| 1587 | + frame.validate(); |
---|
1387 | 1588 | frame.setVisible(true); |
---|
1388 | 1589 | |
---|
| 1590 | + cameraView.requestFocusInWindow(); |
---|
| 1591 | + |
---|
1389 | 1592 | gridPanel.setDividerLocation(1.0); |
---|
1390 | 1593 | |
---|
1391 | 1594 | frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
---|
.. | .. |
---|
2072 | 2275 | |
---|
2073 | 2276 | void LoadObjFile(String fullname) |
---|
2074 | 2277 | { |
---|
2075 | | - /* |
---|
| 2278 | + System.out.println("Loading " + fullname); |
---|
| 2279 | + /**/ |
---|
2076 | 2280 | //lastFilename = fullname; |
---|
2077 | 2281 | if(loadObjThread == null) |
---|
2078 | 2282 | { |
---|
2079 | | - loadObjThread = new LoadOBJThread(); |
---|
2080 | | - loadObjThread.start(); |
---|
| 2283 | + loadObjThread = new LoadOBJThread(); |
---|
| 2284 | + loadObjThread.start(); |
---|
2081 | 2285 | } |
---|
2082 | 2286 | |
---|
2083 | 2287 | loadObjThread.add(fullname); |
---|
2084 | | - */ |
---|
| 2288 | + /**/ |
---|
2085 | 2289 | |
---|
2086 | | - System.out.println("Loading " + fullname); |
---|
2087 | | - makeSomething(new FileObject(fullname, true), true); |
---|
| 2290 | + //makeSomething(new FileObject(fullname, true), true); |
---|
2088 | 2291 | } |
---|
2089 | 2292 | |
---|
2090 | 2293 | void LoadGFDFile(String fullname) |
---|
.. | .. |
---|
2701 | 2904 | |
---|
2702 | 2905 | void SetMaterial(Object3D object) |
---|
2703 | 2906 | { |
---|
| 2907 | + latestObject = object; |
---|
| 2908 | + |
---|
2704 | 2909 | cMaterial mat = object.material; |
---|
2705 | 2910 | |
---|
2706 | 2911 | if (mat == null) |
---|
.. | .. |
---|
2886 | 3091 | cameraView.ToggleDL(); |
---|
2887 | 3092 | cameraView.repaint(); |
---|
2888 | 3093 | return; |
---|
2889 | | - } else if (event.getSource() == toggleTextureItem) |
---|
| 3094 | + } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB) |
---|
2890 | 3095 | { |
---|
2891 | 3096 | cameraView.ToggleTexture(); |
---|
2892 | 3097 | // june 2013 copy.HardTouch(); |
---|
.. | .. |
---|
2925 | 3130 | frame.validate(); |
---|
2926 | 3131 | |
---|
2927 | 3132 | return; |
---|
2928 | | - } else if (event.getSource() == toggleSwitchItem) |
---|
| 3133 | + } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB) |
---|
2929 | 3134 | { |
---|
2930 | | - cameraView.ToggleRandom(); |
---|
| 3135 | + cameraView.ToggleSwitch(); |
---|
2931 | 3136 | cameraView.repaint(); |
---|
2932 | 3137 | return; |
---|
2933 | 3138 | } else if (event.getSource() == toggleHandleItem) |
---|
.. | .. |
---|
3214 | 3419 | objEditor.refreshContents(); |
---|
3215 | 3420 | } |
---|
3216 | 3421 | |
---|
| 3422 | + static public byte[] Compress(Object3D o) |
---|
| 3423 | + { |
---|
| 3424 | + try |
---|
| 3425 | + { |
---|
| 3426 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 3427 | + java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3428 | + ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
| 3429 | + |
---|
| 3430 | + Object3D parent = o.parent; |
---|
| 3431 | + o.parent = null; |
---|
| 3432 | + |
---|
| 3433 | + out.writeObject(o); |
---|
| 3434 | + |
---|
| 3435 | + o.parent = parent; |
---|
| 3436 | + |
---|
| 3437 | + out.flush(); |
---|
| 3438 | + |
---|
| 3439 | + zstream.close(); |
---|
| 3440 | + out.close(); |
---|
| 3441 | + |
---|
| 3442 | + return baos.toByteArray(); |
---|
| 3443 | + } catch (Exception e) |
---|
| 3444 | + { |
---|
| 3445 | + System.err.println(e); |
---|
| 3446 | + return null; |
---|
| 3447 | + } |
---|
| 3448 | + } |
---|
| 3449 | + |
---|
| 3450 | + static public Object Uncompress(byte[] bytes) |
---|
| 3451 | + { |
---|
| 3452 | + System.out.println("#bytes = " + bytes.length); |
---|
| 3453 | + try |
---|
| 3454 | + { |
---|
| 3455 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
| 3456 | + java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3457 | + ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3458 | + Object obj = in.readObject(); |
---|
| 3459 | + in.close(); |
---|
| 3460 | + |
---|
| 3461 | + return obj; |
---|
| 3462 | + } catch (Exception e) |
---|
| 3463 | + { |
---|
| 3464 | + System.err.println(e); |
---|
| 3465 | + return null; |
---|
| 3466 | + } |
---|
| 3467 | + } |
---|
| 3468 | + |
---|
3217 | 3469 | static public Object clone(Object o) |
---|
3218 | 3470 | { |
---|
3219 | 3471 | try |
---|
.. | .. |
---|
3222 | 3474 | ObjectOutputStream out = new ObjectOutputStream(baos); |
---|
3223 | 3475 | |
---|
3224 | 3476 | out.writeObject(o); |
---|
| 3477 | + |
---|
| 3478 | + out.flush(); |
---|
| 3479 | + out.close(); |
---|
| 3480 | + |
---|
| 3481 | + byte[] bytes = baos.toByteArray(); |
---|
| 3482 | + |
---|
| 3483 | + System.out.println("clone = " + bytes.length); |
---|
3225 | 3484 | |
---|
3226 | | - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); |
---|
| 3485 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
3227 | 3486 | ObjectInputStream in = new ObjectInputStream(bais); |
---|
3228 | 3487 | Object obj = in.readObject(); |
---|
3229 | 3488 | in.close(); |
---|
3230 | | - out.close(); |
---|
| 3489 | + |
---|
3231 | 3490 | return obj; |
---|
3232 | 3491 | } catch (Exception e) |
---|
3233 | 3492 | { |
---|
.. | .. |
---|
3242 | 3501 | for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) |
---|
3243 | 3502 | { |
---|
3244 | 3503 | ab = (cRadio)e.nextElement(); |
---|
3245 | | - if(ab.GetObject() == client) |
---|
| 3504 | + if(ab.GetObject() == copy) |
---|
3246 | 3505 | { |
---|
3247 | 3506 | return ab; |
---|
3248 | 3507 | } |
---|
.. | .. |
---|
3251 | 3510 | return null; |
---|
3252 | 3511 | } |
---|
3253 | 3512 | |
---|
| 3513 | + java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3514 | + |
---|
3254 | 3515 | public void Save() |
---|
3255 | 3516 | { |
---|
| 3517 | + System.err.println("Save"); |
---|
| 3518 | + |
---|
3256 | 3519 | cRadio tab = GetCurrentTab(); |
---|
3257 | 3520 | |
---|
| 3521 | + boolean temp = CameraPane.SWITCH; |
---|
| 3522 | + CameraPane.SWITCH = false; |
---|
| 3523 | + |
---|
| 3524 | + copy.ExtractBigData(hashtable); |
---|
| 3525 | + |
---|
3258 | 3526 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3259 | | - tab.graphs[tab.undoindex++] = (Object3D)clone(copy); |
---|
| 3527 | + tab.graphs[tab.undoindex++] = Compress(copy); |
---|
3260 | 3528 | |
---|
| 3529 | + copy.RestoreBigData(hashtable); |
---|
| 3530 | + |
---|
| 3531 | + CameraPane.SWITCH = temp; |
---|
| 3532 | + |
---|
| 3533 | + //assert(hashtable.isEmpty()); |
---|
| 3534 | + |
---|
3261 | 3535 | for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
3262 | 3536 | { |
---|
3263 | 3537 | tab.graphs[i] = null; |
---|
3264 | 3538 | } |
---|
3265 | 3539 | |
---|
| 3540 | + SetUndoStates(); |
---|
| 3541 | + |
---|
3266 | 3542 | // test save |
---|
3267 | 3543 | if (false) |
---|
3268 | 3544 | { |
---|
.. | .. |
---|
3285 | 3561 | |
---|
3286 | 3562 | void CopyChanged(Object3D obj) |
---|
3287 | 3563 | { |
---|
| 3564 | + SetUndoStates(); |
---|
| 3565 | + |
---|
| 3566 | + boolean temp = CameraPane.SWITCH; |
---|
| 3567 | + CameraPane.SWITCH = false; |
---|
| 3568 | + |
---|
| 3569 | + copy.ExtractBigData(hashtable); |
---|
| 3570 | + |
---|
3288 | 3571 | copy.clear(); |
---|
3289 | 3572 | |
---|
3290 | 3573 | for (int i=0; i<obj.Size(); i++) |
---|
3291 | 3574 | { |
---|
3292 | 3575 | copy.add(obj.get(i)); |
---|
3293 | 3576 | } |
---|
| 3577 | + |
---|
| 3578 | + copy.RestoreBigData(hashtable); |
---|
| 3579 | + |
---|
| 3580 | + CameraPane.SWITCH = temp; |
---|
| 3581 | + |
---|
| 3582 | + //assert(hashtable.isEmpty()); |
---|
3294 | 3583 | |
---|
3295 | 3584 | copy.Touch(); |
---|
3296 | 3585 | |
---|
.. | .. |
---|
3313 | 3602 | refreshContents(); |
---|
3314 | 3603 | } |
---|
3315 | 3604 | |
---|
| 3605 | + cButton undoButton; |
---|
| 3606 | + cButton redoButton; |
---|
| 3607 | + |
---|
| 3608 | + void SetUndoStates() |
---|
| 3609 | + { |
---|
| 3610 | + cRadio tab = GetCurrentTab(); |
---|
| 3611 | + |
---|
| 3612 | + undoButton.setEnabled(tab.undoindex > 0); |
---|
| 3613 | + redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null); |
---|
| 3614 | + } |
---|
| 3615 | + |
---|
3316 | 3616 | public void Undo() |
---|
3317 | 3617 | { |
---|
| 3618 | + System.err.println("Undo"); |
---|
| 3619 | + |
---|
3318 | 3620 | cRadio tab = GetCurrentTab(); |
---|
3319 | 3621 | |
---|
3320 | 3622 | if (tab.undoindex == 0) |
---|
.. | .. |
---|
3331 | 3633 | |
---|
3332 | 3634 | tab.undoindex -= 1; |
---|
3333 | 3635 | |
---|
3334 | | - CopyChanged(tab.graphs[tab.undoindex]); |
---|
| 3636 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
3335 | 3637 | } |
---|
3336 | 3638 | |
---|
3337 | 3639 | public void Redo() |
---|
.. | .. |
---|
3346 | 3648 | |
---|
3347 | 3649 | tab.undoindex += 1; |
---|
3348 | 3650 | |
---|
3349 | | - CopyChanged(tab.graphs[tab.undoindex]); |
---|
| 3651 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
3350 | 3652 | } |
---|
3351 | 3653 | |
---|
3352 | 3654 | void ImportGFD() |
---|
.. | .. |
---|
3498 | 3800 | assert false; |
---|
3499 | 3801 | } |
---|
3500 | 3802 | |
---|
3501 | | - void EditSelection() |
---|
| 3803 | + void EditSelection(boolean newWindow) |
---|
3502 | 3804 | { |
---|
3503 | 3805 | } |
---|
3504 | 3806 | |
---|
.. | .. |
---|
3993 | 4295 | |
---|
3994 | 4296 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
3995 | 4297 | { |
---|
3996 | | - Save(); |
---|
| 4298 | + if (Globals.SAVEONMAKE) // && resetmodel) |
---|
| 4299 | + Save(); |
---|
3997 | 4300 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
3998 | 4301 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
3999 | 4302 | // if (thing instanceof GenericJointDemo) |
---|
.. | .. |
---|
4080 | 4383 | { |
---|
4081 | 4384 | ResetModel(); |
---|
4082 | 4385 | Select(thing.GetTreePath(), true, false); // unselect... false); |
---|
| 4386 | + |
---|
| 4387 | + if (thing.Size() == 0) |
---|
| 4388 | + { |
---|
| 4389 | + //EditSelection(false); |
---|
| 4390 | + } |
---|
| 4391 | + |
---|
4083 | 4392 | refreshContents(); |
---|
4084 | 4393 | } |
---|
4085 | 4394 | |
---|
.. | .. |
---|
4217 | 4526 | |
---|
4218 | 4527 | try |
---|
4219 | 4528 | { |
---|
| 4529 | + // Try compressed version first. |
---|
4220 | 4530 | java.io.FileInputStream istream = new java.io.FileInputStream(fullname); |
---|
4221 | 4531 | java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream); |
---|
4222 | 4532 | java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream); |
---|
.. | .. |
---|
4286 | 4596 | |
---|
4287 | 4597 | void LoadIt(Object obj) |
---|
4288 | 4598 | { |
---|
| 4599 | + if (obj == null) |
---|
| 4600 | + { |
---|
| 4601 | + // Invalid file |
---|
| 4602 | + return; |
---|
| 4603 | + } |
---|
| 4604 | + |
---|
4289 | 4605 | System.out.println("Loaded " + obj); |
---|
4290 | 4606 | //new Exception().printStackTrace(); |
---|
4291 | 4607 | Object3D readobj = (Object3D) obj; |
---|
.. | .. |
---|
4295 | 4611 | |
---|
4296 | 4612 | if (readobj != null) |
---|
4297 | 4613 | { |
---|
| 4614 | + if (Globals.SAVEONMAKE) |
---|
| 4615 | + Save(); |
---|
4298 | 4616 | try |
---|
4299 | 4617 | { |
---|
4300 | 4618 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
4472 | 4790 | String filename = browser.getFile(); |
---|
4473 | 4791 | if (filename != null && filename.length() > 0) |
---|
4474 | 4792 | { |
---|
| 4793 | + if (!filename.endsWith(".gfd")) |
---|
| 4794 | + filename += ".gfd"; |
---|
4475 | 4795 | lastname = browser.getDirectory() + filename; |
---|
4476 | 4796 | save(); |
---|
4477 | 4797 | } |
---|
.. | .. |
---|
4665 | 4985 | CheckboxMenuItem togglePaintItem; |
---|
4666 | 4986 | JSplitPane mainPanel; |
---|
4667 | 4987 | JScrollPane scrollpane; |
---|
| 4988 | + |
---|
4668 | 4989 | JPanel toolbarPanel; |
---|
| 4990 | + |
---|
4669 | 4991 | cGridBag treePanel; |
---|
| 4992 | + |
---|
4670 | 4993 | JPanel radioPanel; |
---|
4671 | 4994 | ButtonGroup buttonGroup; |
---|
4672 | | - cGridBag ctrlPanel; |
---|
| 4995 | + |
---|
| 4996 | + cGridBag toolboxPanel; |
---|
4673 | 4997 | cGridBag materialPanel; |
---|
| 4998 | + cGridBag ctrlPanel; |
---|
| 4999 | + |
---|
4674 | 5000 | JScrollPane infoPanel; |
---|
| 5001 | + |
---|
4675 | 5002 | cGridBag optionsPanel; |
---|
| 5003 | + |
---|
4676 | 5004 | JTabbedPane objectPanel; |
---|
| 5005 | + boolean materialFlushed; |
---|
| 5006 | + Object3D latestObject; |
---|
| 5007 | + |
---|
4677 | 5008 | cGridBag XYZPanel; |
---|
| 5009 | + |
---|
4678 | 5010 | JSplitPane gridPanel; |
---|
4679 | 5011 | JSplitPane bigPanel; |
---|
| 5012 | + |
---|
4680 | 5013 | cGridBag bigThree; |
---|
4681 | 5014 | cGridBag scenePanel; |
---|
4682 | 5015 | cGridBag centralPanel; |
---|
.. | .. |
---|
4791 | 5124 | cNumberSlider fogField; |
---|
4792 | 5125 | JLabel opacityPowerLabel; |
---|
4793 | 5126 | cNumberSlider opacityPowerField; |
---|
4794 | | - JTree jTree; |
---|
| 5127 | + cTree jTree; |
---|
4795 | 5128 | //ObjectUI parent; |
---|
4796 | 5129 | |
---|
4797 | 5130 | cNumberSlider normalpushField; |
---|