.. | .. |
---|
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.*; |
---|
.. | .. |
---|
37 | 38 | JFrame frame; |
---|
38 | 39 | |
---|
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 | + } |
---|
40 | 100 | |
---|
41 | 101 | // SCRIPT |
---|
42 | 102 | |
---|
.. | .. |
---|
171 | 231 | |
---|
172 | 232 | objEditor.ctrlPanel.remove(setupPanel); |
---|
173 | 233 | objEditor.ctrlPanel.remove(setupPanel2); |
---|
174 | | - objEditor.ctrlPanel.remove(commandsPanel); |
---|
| 234 | + objEditor.ctrlPanel.remove(objectCommandsPanel); |
---|
175 | 235 | objEditor.ctrlPanel.remove(pushPanel); |
---|
176 | 236 | //objEditor.ctrlPanel.remove(fillPanel); |
---|
177 | 237 | |
---|
.. | .. |
---|
323 | 383 | closeItem.addActionListener(this); |
---|
324 | 384 | |
---|
325 | 385 | objectPanel = new JTabbedPane(); |
---|
| 386 | + |
---|
| 387 | + ChangeListener changeListener = new ChangeListener() |
---|
| 388 | + { |
---|
| 389 | + public void stateChanged(ChangeEvent changeEvent) |
---|
| 390 | + { |
---|
| 391 | +// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed) |
---|
| 392 | +// { |
---|
| 393 | +// if (latestObject != null) |
---|
| 394 | +// { |
---|
| 395 | +// refreshContents(true); |
---|
| 396 | +// SetMaterial(latestObject); |
---|
| 397 | +// } |
---|
| 398 | +// |
---|
| 399 | +// materialFlushed = true; |
---|
| 400 | +// } |
---|
| 401 | + |
---|
| 402 | + refreshContents(false); // To refresh Info tab |
---|
| 403 | + } |
---|
| 404 | + }; |
---|
| 405 | + objectPanel.addChangeListener(changeListener); |
---|
| 406 | + |
---|
326 | 407 | toolbarPanel = new JPanel(); |
---|
327 | 408 | toolbarPanel.setName("Toolbar"); |
---|
328 | 409 | treePanel = new cGridBag(); |
---|
329 | 410 | treePanel.setName("Tree"); |
---|
| 411 | + |
---|
| 412 | + editPanel = new cGridBag().setVertical(true); |
---|
| 413 | + editPanel.setName("Edit"); |
---|
| 414 | + |
---|
330 | 415 | ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout()); |
---|
331 | | - ctrlPanel.setName("Edit"); |
---|
| 416 | + |
---|
| 417 | + editCommandsPanel = new cGridBag(); |
---|
| 418 | + editPanel.add(editCommandsPanel); |
---|
| 419 | + editPanel.add(ctrlPanel); |
---|
| 420 | + |
---|
| 421 | + toolboxPanel = new cGridBag().setVertical(false); |
---|
| 422 | + toolboxPanel.setName("Toolbox"); |
---|
| 423 | + |
---|
332 | 424 | materialPanel = new cGridBag().setVertical(true); |
---|
333 | 425 | materialPanel.setName("Material"); |
---|
| 426 | + |
---|
334 | 427 | /*JTextPane*/ |
---|
335 | 428 | infoarea = createTextPane(); |
---|
336 | 429 | doc = infoarea.getStyledDocument(); |
---|
.. | .. |
---|
603 | 696 | |
---|
604 | 697 | boolean maximized; |
---|
605 | 698 | |
---|
| 699 | + cButton fullscreenLayout; |
---|
| 700 | + |
---|
606 | 701 | void Minimize() |
---|
607 | 702 | { |
---|
608 | 703 | frame.setState(Frame.ICONIFIED); |
---|
.. | .. |
---|
664 | 759 | // X frame.getContentPane().add(/*"Center",*/bigThree); |
---|
665 | 760 | framePanel.setDividerLocation(0); |
---|
666 | 761 | |
---|
667 | | - radio.layout = twoButton; |
---|
| 762 | + radio.layout = fullscreenLayout; |
---|
668 | 763 | radio.layout.doClick(); |
---|
669 | 764 | //frame.setVisible(true); |
---|
670 | 765 | } |
---|
.. | .. |
---|
810 | 905 | JCheckBox speedupCB; |
---|
811 | 906 | JCheckBox rewindCB; |
---|
812 | 907 | JCheckBox flipVCB; |
---|
| 908 | + |
---|
| 909 | + cCheckBox toggleTextureCB; |
---|
| 910 | + cCheckBox toggleSwitchCB; |
---|
| 911 | + |
---|
813 | 912 | JComboBox texresMenu; |
---|
| 913 | + |
---|
814 | 914 | JButton resetButton; |
---|
815 | 915 | JButton stepButton; |
---|
816 | 916 | JButton stepAllButton; |
---|
.. | .. |
---|
819 | 919 | JButton fasterButton; |
---|
820 | 920 | JButton remarkButton; |
---|
821 | 921 | |
---|
| 922 | + cGridBag editPanel; |
---|
| 923 | + cGridBag editCommandsPanel; |
---|
| 924 | + |
---|
822 | 925 | cGridBag namePanel; |
---|
823 | 926 | cGridBag setupPanel; |
---|
824 | 927 | cGridBag setupPanel2; |
---|
825 | | - cGridBag commandsPanel; |
---|
| 928 | + cGridBag objectCommandsPanel; |
---|
826 | 929 | cGridBag pushPanel; |
---|
827 | 930 | cGridBag fillPanel; |
---|
828 | 931 | |
---|
.. | .. |
---|
1035 | 1138 | oe.ctrlPanel.add(setupPanel2); |
---|
1036 | 1139 | oe.ctrlPanel.Return(); |
---|
1037 | 1140 | |
---|
1038 | | - commandsPanel = new cGridBag().setVertical(false); |
---|
| 1141 | + objectCommandsPanel = new cGridBag().setVertical(false); |
---|
1039 | 1142 | |
---|
1040 | | - resetButton = AddButton(commandsPanel, "Reset"); |
---|
| 1143 | + resetButton = AddButton(objectCommandsPanel, "Reset"); |
---|
1041 | 1144 | resetButton.setToolTipText("Jump to frame zero"); |
---|
1042 | | - stepButton = AddButton(commandsPanel, "Step"); |
---|
| 1145 | + stepButton = AddButton(objectCommandsPanel, "Step"); |
---|
1043 | 1146 | stepButton.setToolTipText("Step one frame"); |
---|
1044 | 1147 | // resetAllButton = AddButton(oe, "Reset All"); |
---|
1045 | 1148 | // stepAllButton = AddButton(oe, "Step All"); |
---|
1046 | 1149 | // Return(); |
---|
1047 | | - slowerButton = AddButton(commandsPanel, "Slow"); |
---|
| 1150 | + slowerButton = AddButton(objectCommandsPanel, "Slow"); |
---|
1048 | 1151 | slowerButton.setToolTipText("Decrease animation speed"); |
---|
1049 | | - fasterButton = AddButton(commandsPanel, "Fast"); |
---|
| 1152 | + fasterButton = AddButton(objectCommandsPanel, "Fast"); |
---|
1050 | 1153 | fasterButton.setToolTipText("Increase animation speed"); |
---|
1051 | | - remarkButton = AddButton(commandsPanel, "Remark"); |
---|
| 1154 | + remarkButton = AddButton(objectCommandsPanel, "Remark"); |
---|
1052 | 1155 | remarkButton.setToolTipText("Set the current transform as the target"); |
---|
1053 | 1156 | |
---|
1054 | | - oe.ctrlPanel.add(commandsPanel); |
---|
| 1157 | + oe.ctrlPanel.add(objectCommandsPanel); |
---|
1055 | 1158 | oe.ctrlPanel.Return(); |
---|
1056 | 1159 | |
---|
1057 | 1160 | pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons |
---|
.. | .. |
---|
1336 | 1439 | //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); |
---|
1337 | 1440 | //tmp.setName("Edit"); |
---|
1338 | 1441 | objectPanel.add(materialPanel); |
---|
| 1442 | + objectPanel.add(toolboxPanel); |
---|
1339 | 1443 | // JPanel north = new JPanel(new BorderLayout()); |
---|
1340 | 1444 | // north.setName("Edit"); |
---|
1341 | 1445 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1342 | 1446 | // objectPanel.add(north); |
---|
1343 | | - objectPanel.add(ctrlPanel); |
---|
| 1447 | + objectPanel.add(editPanel); |
---|
1344 | 1448 | objectPanel.add(infoPanel); |
---|
1345 | 1449 | |
---|
1346 | 1450 | /* |
---|
.. | .. |
---|
1367 | 1471 | JTabbedPane tabbedPane = new JTabbedPane(); |
---|
1368 | 1472 | tabbedPane.add(scrollpane); |
---|
1369 | 1473 | |
---|
1370 | | - tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
1371 | | - |
---|
1372 | | - optionsPanel = new cGridBag().setVertical(true); |
---|
| 1474 | + optionsPanel = new cGridBag().setVertical(false); |
---|
1373 | 1475 | |
---|
1374 | 1476 | optionsPanel.setName("Options"); |
---|
1375 | 1477 | |
---|
.. | .. |
---|
1377 | 1479 | |
---|
1378 | 1480 | tabbedPane.add(optionsPanel); |
---|
1379 | 1481 | |
---|
| 1482 | + tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
| 1483 | + |
---|
1380 | 1484 | scenePanel.add(tabbedPane); |
---|
1381 | 1485 | |
---|
1382 | 1486 | /* |
---|
.. | .. |
---|
1469 | 1573 | // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc); |
---|
1470 | 1574 | |
---|
1471 | 1575 | frame.setSize(1280, 860); |
---|
| 1576 | + |
---|
| 1577 | + frame.validate(); |
---|
1472 | 1578 | frame.setVisible(true); |
---|
1473 | 1579 | |
---|
1474 | 1580 | cameraView.requestFocusInWindow(); |
---|
.. | .. |
---|
2788 | 2894 | |
---|
2789 | 2895 | void SetMaterial(Object3D object) |
---|
2790 | 2896 | { |
---|
| 2897 | + latestObject = object; |
---|
| 2898 | + |
---|
2791 | 2899 | cMaterial mat = object.material; |
---|
2792 | 2900 | |
---|
2793 | 2901 | if (mat == null) |
---|
.. | .. |
---|
2973 | 3081 | cameraView.ToggleDL(); |
---|
2974 | 3082 | cameraView.repaint(); |
---|
2975 | 3083 | return; |
---|
2976 | | - } else if (event.getSource() == toggleTextureItem) |
---|
| 3084 | + } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB) |
---|
2977 | 3085 | { |
---|
2978 | 3086 | cameraView.ToggleTexture(); |
---|
2979 | 3087 | // june 2013 copy.HardTouch(); |
---|
.. | .. |
---|
3012 | 3120 | frame.validate(); |
---|
3013 | 3121 | |
---|
3014 | 3122 | return; |
---|
3015 | | - } else if (event.getSource() == toggleSwitchItem) |
---|
| 3123 | + } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB) |
---|
3016 | 3124 | { |
---|
3017 | 3125 | cameraView.ToggleSwitch(); |
---|
3018 | 3126 | cameraView.repaint(); |
---|
.. | .. |
---|
3396 | 3504 | |
---|
3397 | 3505 | public void Save() |
---|
3398 | 3506 | { |
---|
| 3507 | + System.err.println("Save"); |
---|
| 3508 | + |
---|
3399 | 3509 | cRadio tab = GetCurrentTab(); |
---|
3400 | 3510 | |
---|
3401 | 3511 | boolean temp = CameraPane.SWITCH; |
---|
.. | .. |
---|
3480 | 3590 | |
---|
3481 | 3591 | public void Undo() |
---|
3482 | 3592 | { |
---|
| 3593 | + System.err.println("Undo"); |
---|
| 3594 | + |
---|
3483 | 3595 | cRadio tab = GetCurrentTab(); |
---|
3484 | 3596 | |
---|
3485 | 3597 | if (tab.undoindex == 0) |
---|
.. | .. |
---|
3663 | 3775 | assert false; |
---|
3664 | 3776 | } |
---|
3665 | 3777 | |
---|
3666 | | - void EditSelection() |
---|
| 3778 | + void EditSelection(boolean newWindow) |
---|
3667 | 3779 | { |
---|
3668 | 3780 | } |
---|
3669 | 3781 | |
---|
.. | .. |
---|
4158 | 4270 | |
---|
4159 | 4271 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
4160 | 4272 | { |
---|
4161 | | - Save(); |
---|
| 4273 | + if (Globals.SAVEONMAKE) // && resetmodel) |
---|
| 4274 | + Save(); |
---|
4162 | 4275 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
4163 | 4276 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
4164 | 4277 | // if (thing instanceof GenericJointDemo) |
---|
.. | .. |
---|
4245 | 4358 | { |
---|
4246 | 4359 | ResetModel(); |
---|
4247 | 4360 | Select(thing.GetTreePath(), true, false); // unselect... false); |
---|
| 4361 | + |
---|
| 4362 | + if (thing.Size() == 0) |
---|
| 4363 | + { |
---|
| 4364 | + //EditSelection(false); |
---|
| 4365 | + } |
---|
| 4366 | + |
---|
4248 | 4367 | refreshContents(); |
---|
4249 | 4368 | } |
---|
4250 | 4369 | |
---|
.. | .. |
---|
4467 | 4586 | |
---|
4468 | 4587 | if (readobj != null) |
---|
4469 | 4588 | { |
---|
| 4589 | + if (Globals.SAVEONMAKE) |
---|
4470 | 4590 | Save(); |
---|
4471 | 4591 | try |
---|
4472 | 4592 | { |
---|
.. | .. |
---|
4838 | 4958 | CheckboxMenuItem togglePaintItem; |
---|
4839 | 4959 | JSplitPane mainPanel; |
---|
4840 | 4960 | JScrollPane scrollpane; |
---|
| 4961 | + |
---|
4841 | 4962 | JPanel toolbarPanel; |
---|
| 4963 | + |
---|
4842 | 4964 | cGridBag treePanel; |
---|
| 4965 | + |
---|
4843 | 4966 | JPanel radioPanel; |
---|
4844 | 4967 | ButtonGroup buttonGroup; |
---|
4845 | | - cGridBag ctrlPanel; |
---|
| 4968 | + |
---|
| 4969 | + cGridBag toolboxPanel; |
---|
4846 | 4970 | cGridBag materialPanel; |
---|
| 4971 | + cGridBag ctrlPanel; |
---|
| 4972 | + |
---|
4847 | 4973 | JScrollPane infoPanel; |
---|
| 4974 | + |
---|
4848 | 4975 | cGridBag optionsPanel; |
---|
| 4976 | + |
---|
4849 | 4977 | JTabbedPane objectPanel; |
---|
| 4978 | + boolean materialFlushed; |
---|
| 4979 | + Object3D latestObject; |
---|
| 4980 | + |
---|
4850 | 4981 | cGridBag XYZPanel; |
---|
| 4982 | + |
---|
4851 | 4983 | JSplitPane gridPanel; |
---|
4852 | 4984 | JSplitPane bigPanel; |
---|
| 4985 | + |
---|
4853 | 4986 | cGridBag bigThree; |
---|
4854 | 4987 | cGridBag scenePanel; |
---|
4855 | 4988 | cGridBag centralPanel; |
---|
.. | .. |
---|
4964 | 5097 | cNumberSlider fogField; |
---|
4965 | 5098 | JLabel opacityPowerLabel; |
---|
4966 | 5099 | cNumberSlider opacityPowerField; |
---|
4967 | | - JTree jTree; |
---|
| 5100 | + cTree jTree; |
---|
4968 | 5101 | //ObjectUI parent; |
---|
4969 | 5102 | |
---|
4970 | 5103 | cNumberSlider normalpushField; |
---|