.. | .. |
---|
15 | 15 | //import javax.swing.plaf.ColorUIResource; |
---|
16 | 16 | //import javax.swing.plaf.metal.DefaultMetalTheme; |
---|
17 | 17 | |
---|
| 18 | +import javax.swing.plaf.basic.BasicSplitPaneDivider; |
---|
| 19 | +import javax.swing.plaf.basic.BasicSplitPaneUI; |
---|
| 20 | + |
---|
18 | 21 | //import javax.media.opengl.GLCanvas; |
---|
19 | 22 | |
---|
20 | 23 | import //weka.core. |
---|
.. | .. |
---|
306 | 309 | //localCopy.parent = null; |
---|
307 | 310 | |
---|
308 | 311 | frame = new JFrame(); |
---|
309 | | - frame.setUndecorated(true); |
---|
| 312 | + frame.setUndecorated(false); |
---|
310 | 313 | objEditor = this; |
---|
311 | 314 | this.callee = callee; |
---|
312 | 315 | |
---|
.. | .. |
---|
347 | 350 | frame.setMenuBar(menuBar = new MenuBar()); |
---|
348 | 351 | menuBar.add(fileMenu = new Menu("File")); |
---|
349 | 352 | fileMenu.add(newItem = new MenuItem("New")); |
---|
350 | | - fileMenu.add(loadItem = new MenuItem("Open...")); |
---|
| 353 | + fileMenu.add(openItem = new MenuItem("Open...")); |
---|
351 | 354 | |
---|
352 | 355 | //oe.menuBar.add(menu = new Menu("Include")); |
---|
353 | 356 | Menu menu = new Menu("Import"); |
---|
.. | .. |
---|
379 | 382 | } |
---|
380 | 383 | |
---|
381 | 384 | newItem.addActionListener(this); |
---|
382 | | - loadItem.addActionListener(this); |
---|
| 385 | + openItem.addActionListener(this); |
---|
383 | 386 | saveItem.addActionListener(this); |
---|
384 | 387 | saveAsItem.addActionListener(this); |
---|
385 | 388 | exportAsItem.addActionListener(this); |
---|
.. | .. |
---|
446 | 449 | // TEXTAREA infoarea.setLineWrap(true); |
---|
447 | 450 | // TEXTAREA infoarea.setWrapStyleWord(true); |
---|
448 | 451 | infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED); |
---|
449 | | - infoPanel.setPreferredSize(new Dimension(50, 200)); |
---|
| 452 | + infoPanel.setPreferredSize(new Dimension(1, 1)); |
---|
450 | 453 | infoPanel.setName("Info"); |
---|
451 | 454 | //infoPanel.setLayout(new BorderLayout()); |
---|
452 | 455 | //infoPanel.add(createTextPane()); |
---|
.. | .. |
---|
458 | 461 | mainPanel.setDividerSize(9); |
---|
459 | 462 | mainPanel.setDividerLocation(0.5); //1.0); |
---|
460 | 463 | mainPanel.setResizeWeight(0.5); |
---|
461 | | - |
---|
| 464 | + |
---|
| 465 | +//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5)); |
---|
| 466 | + BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider(); |
---|
| 467 | + divider.setDividerSize(15); |
---|
| 468 | + divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!")); |
---|
| 469 | + |
---|
| 470 | + mainPanel.setUI(new BasicSplitPaneUI()); |
---|
| 471 | + |
---|
462 | 472 | //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5)); |
---|
463 | 473 | //mainPanel.setLayout(new GridBagLayout()); |
---|
464 | 474 | toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); |
---|
.. | .. |
---|
689 | 699 | } |
---|
690 | 700 | } |
---|
691 | 701 | |
---|
692 | | -static GraphicsDevice device = GraphicsEnvironment |
---|
693 | | - .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
| 702 | +//static GraphicsDevice device = GraphicsEnvironment |
---|
| 703 | +// .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
694 | 704 | |
---|
695 | 705 | Rectangle keeprect; |
---|
696 | 706 | cRadio radio; |
---|
.. | .. |
---|
711 | 721 | void Minimize() |
---|
712 | 722 | { |
---|
713 | 723 | frame.setState(Frame.ICONIFIED); |
---|
| 724 | + frame.validate(); |
---|
714 | 725 | } |
---|
715 | 726 | |
---|
| 727 | +// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={} |
---|
| 728 | +// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={} |
---|
| 729 | +// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={} |
---|
716 | 730 | void Maximize() |
---|
717 | 731 | { |
---|
| 732 | + if (CameraPane.FULLSCREEN) |
---|
| 733 | + { |
---|
| 734 | + ToggleFullScreen(); |
---|
| 735 | + } |
---|
| 736 | + |
---|
718 | 737 | if (maximized) |
---|
719 | 738 | { |
---|
720 | 739 | frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); |
---|
.. | .. |
---|
722 | 741 | else |
---|
723 | 742 | { |
---|
724 | 743 | 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); |
---|
| 744 | +// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); |
---|
| 745 | +// Dimension rect2 = frame.getToolkit().getScreenSize(); |
---|
| 746 | +// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height); |
---|
728 | 747 | // frame.setState(Frame.MAXIMIZED_BOTH); |
---|
| 748 | + frame.setBounds(frame.getGraphicsConfiguration().getBounds()); |
---|
729 | 749 | } |
---|
730 | 750 | |
---|
731 | 751 | maximized ^= true; |
---|
| 752 | + |
---|
| 753 | + frame.validate(); |
---|
732 | 754 | } |
---|
| 755 | + |
---|
| 756 | + cButton minButton; |
---|
| 757 | + cButton maxButton; |
---|
| 758 | + cButton fullButton; |
---|
733 | 759 | |
---|
734 | 760 | void ToggleFullScreen() |
---|
735 | 761 | { |
---|
| 762 | +GraphicsDevice device = frame.getGraphicsConfiguration().getDevice(); |
---|
| 763 | + |
---|
736 | 764 | cameraView.ToggleFullScreen(); |
---|
737 | 765 | |
---|
738 | 766 | if (!CameraPane.FULLSCREEN) |
---|
739 | 767 | { |
---|
740 | 768 | device.setFullScreenWindow(null); |
---|
| 769 | + frame.dispose(); |
---|
| 770 | + frame.setUndecorated(false); |
---|
| 771 | + frame.validate(); |
---|
| 772 | + frame.setVisible(true); |
---|
| 773 | + |
---|
741 | 774 | //frame.setVisible(false); |
---|
742 | 775 | // frame.removeNotify(); |
---|
743 | 776 | // frame.setUndecorated(false); |
---|
.. | .. |
---|
747 | 780 | // X frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
748 | 781 | // X framePanel.add(bigThree); |
---|
749 | 782 | // X frame.getContentPane().add(/*"Center",*/framePanel); |
---|
750 | | - framePanel.setDividerLocation(1); |
---|
| 783 | + framePanel.setDividerLocation(46); |
---|
751 | 784 | |
---|
752 | 785 | //frame.setVisible(true); |
---|
753 | 786 | radio.layout = keepButton; |
---|
.. | .. |
---|
762 | 795 | // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width, |
---|
763 | 796 | // frame.getToolkit().getScreenSize().height); |
---|
764 | 797 | //frame.setVisible(false); |
---|
| 798 | + |
---|
| 799 | + frame.dispose(); |
---|
| 800 | + frame.setUndecorated(true); |
---|
765 | 801 | device.setFullScreenWindow(frame); |
---|
| 802 | + frame.validate(); |
---|
| 803 | + frame.setVisible(true); |
---|
766 | 804 | // frame.removeNotify(); |
---|
767 | 805 | // frame.setUndecorated(true); |
---|
768 | 806 | // frame.addNotify(); |
---|
.. | .. |
---|
775 | 813 | radio.layout.doClick(); |
---|
776 | 814 | //frame.setVisible(true); |
---|
777 | 815 | } |
---|
| 816 | + frame.validate(); |
---|
778 | 817 | } |
---|
779 | 818 | |
---|
780 | 819 | private JTextPane createTextPane() |
---|
.. | .. |
---|
1107 | 1146 | namePanel = new cGridBag(); |
---|
1108 | 1147 | |
---|
1109 | 1148 | nameField = AddText(namePanel, copy.GetName()); |
---|
1110 | | - namePanel.add(nameField); |
---|
| 1149 | + namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)); |
---|
1111 | 1150 | oe.ctrlPanel.add(namePanel); |
---|
1112 | 1151 | |
---|
1113 | 1152 | oe.ctrlPanel.Return(); |
---|
.. | .. |
---|
1125 | 1164 | hideCB = AddCheckBox(setupPanel, "Hide", copy.hide); |
---|
1126 | 1165 | hideCB.setToolTipText("Hide object"); |
---|
1127 | 1166 | markCB = AddCheckBox(setupPanel, "Mark", copy.marked); |
---|
1128 | | - markCB.setToolTipText("Set the animation target transform"); |
---|
| 1167 | + markCB.setToolTipText("As animation target transform"); |
---|
1129 | 1168 | |
---|
1130 | 1169 | setupPanel2 = new cGridBag().setVertical(false); |
---|
1131 | 1170 | |
---|
1132 | 1171 | rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind); |
---|
1133 | 1172 | rewindCB.setToolTipText("Rewind animation"); |
---|
1134 | 1173 | |
---|
1135 | | - randomCB = AddCheckBox(setupPanel2, "Rand", copy.random); |
---|
1136 | | - randomCB.setToolTipText("Randomly Rewind or Go back and forth"); |
---|
| 1174 | + randomCB = AddCheckBox(setupPanel2, "Random", copy.random); |
---|
| 1175 | + randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); |
---|
1137 | 1176 | |
---|
| 1177 | + link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); |
---|
| 1178 | + link2masterCB.setToolTipText("Attach to support"); |
---|
| 1179 | + |
---|
1138 | 1180 | if (Globals.ADVANCED) |
---|
1139 | 1181 | { |
---|
1140 | | - link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); |
---|
1141 | | - link2masterCB.setToolTipText("Attach to support"); |
---|
1142 | 1182 | speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
1143 | 1183 | speedupCB.setToolTipText("Option motion capture"); |
---|
1144 | 1184 | } |
---|
.. | .. |
---|
1454 | 1494 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1455 | 1495 | // objectPanel.add(north); |
---|
1456 | 1496 | objectPanel.add(editPanel); |
---|
1457 | | - objectPanel.add(infoPanel); |
---|
| 1497 | + |
---|
| 1498 | + //if (Globals.ADVANCED) |
---|
| 1499 | + objectPanel.add(infoPanel); |
---|
| 1500 | + |
---|
1458 | 1501 | objectPanel.add(toolboxPanel); |
---|
1459 | 1502 | |
---|
1460 | 1503 | /* |
---|
.. | .. |
---|
1563 | 1606 | // aConstraints.gridheight = 1; |
---|
1564 | 1607 | |
---|
1565 | 1608 | framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree); |
---|
1566 | | - framePanel.setContinuousLayout(true); |
---|
1567 | | - framePanel.setOneTouchExpandable(true); |
---|
1568 | | - framePanel.setDividerLocation(0.8); |
---|
| 1609 | + framePanel.setContinuousLayout(false); |
---|
| 1610 | + framePanel.setOneTouchExpandable(false); |
---|
| 1611 | + //.setDividerLocation(0.8); |
---|
1569 | 1612 | //framePanel.setDividerSize(15); |
---|
1570 | 1613 | //framePanel.setResizeWeight(0.15); |
---|
1571 | 1614 | framePanel.setName("Frame"); |
---|
.. | .. |
---|
1584 | 1627 | |
---|
1585 | 1628 | frame.setSize(1280, 860); |
---|
1586 | 1629 | |
---|
1587 | | - frame.validate(); |
---|
1588 | | - frame.setVisible(true); |
---|
1589 | | - |
---|
1590 | 1630 | cameraView.requestFocusInWindow(); |
---|
1591 | 1631 | |
---|
1592 | 1632 | gridPanel.setDividerLocation(1.0); |
---|
| 1633 | + |
---|
| 1634 | + frame.validate(); |
---|
| 1635 | + |
---|
| 1636 | + frame.setVisible(true); |
---|
1593 | 1637 | |
---|
1594 | 1638 | frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
---|
1595 | 1639 | frame.addWindowListener(new WindowAdapter() |
---|
.. | .. |
---|
1676 | 1720 | texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1677 | 1721 | colorSection.add(texture); |
---|
1678 | 1722 | |
---|
1679 | | - cGridBag anisoU = new cGridBag(); |
---|
1680 | | - anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints); |
---|
1681 | | - anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1682 | | - anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1683 | | - colorSection.add(anisoU); |
---|
1684 | | - |
---|
1685 | | - cGridBag anisoV = new cGridBag(); |
---|
1686 | | - anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints); |
---|
1687 | | - anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1688 | | - anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1689 | | - colorSection.add(anisoV); |
---|
1690 | | - |
---|
1691 | | - cGridBag shadowbias = new cGridBag(); |
---|
1692 | | - shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints); |
---|
1693 | | - shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1694 | | - shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1695 | | - colorSection.add(shadowbias); |
---|
1696 | | - |
---|
1697 | 1723 | panel.add(new JSeparator()); |
---|
1698 | 1724 | |
---|
1699 | 1725 | panel.add(colorSection); |
---|
.. | .. |
---|
1743 | 1769 | fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1744 | 1770 | fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1745 | 1771 | diffuseSection.add(fakedepth); |
---|
| 1772 | + |
---|
| 1773 | + cGridBag shadowbias = new cGridBag(); |
---|
| 1774 | + shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints); |
---|
| 1775 | + shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1776 | + shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
| 1777 | + diffuseSection.add(shadowbias); |
---|
1746 | 1778 | |
---|
1747 | 1779 | panel.add(new JSeparator()); |
---|
1748 | 1780 | |
---|
.. | .. |
---|
1794 | 1826 | // aConstraints.gridy += 1; |
---|
1795 | 1827 | // aConstraints.gridwidth = 1; |
---|
1796 | 1828 | |
---|
| 1829 | + cGridBag anisoU = new cGridBag(); |
---|
| 1830 | + anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints); |
---|
| 1831 | + anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1832 | + anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
| 1833 | + specularSection.add(anisoU); |
---|
| 1834 | + |
---|
| 1835 | + cGridBag anisoV = new cGridBag(); |
---|
| 1836 | + anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints); |
---|
| 1837 | + anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1838 | + anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
| 1839 | + specularSection.add(anisoV); |
---|
| 1840 | + |
---|
1797 | 1841 | |
---|
1798 | 1842 | panel.add(new JSeparator()); |
---|
1799 | 1843 | |
---|
.. | .. |
---|
1801 | 1845 | |
---|
1802 | 1846 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1803 | 1847 | |
---|
1804 | | - cGridBag globalSection = new cGridBag().setVertical(true); |
---|
| 1848 | + //cGridBag globalSection = new cGridBag().setVertical(true); |
---|
1805 | 1849 | |
---|
1806 | 1850 | cGridBag camera = new cGridBag(); |
---|
1807 | 1851 | camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints); |
---|
1808 | 1852 | cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1809 | 1853 | camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1810 | | - globalSection.add(camera); |
---|
| 1854 | + colorSection.add(camera); |
---|
1811 | 1855 | |
---|
1812 | 1856 | cGridBag ambient = new cGridBag(); |
---|
1813 | 1857 | ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints); |
---|
1814 | 1858 | ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1815 | 1859 | ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1816 | | - globalSection.add(ambient); |
---|
| 1860 | + colorSection.add(ambient); |
---|
1817 | 1861 | |
---|
1818 | 1862 | cGridBag backlit = new cGridBag(); |
---|
1819 | 1863 | backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints); |
---|
1820 | 1864 | backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1821 | 1865 | backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1822 | | - globalSection.add(backlit); |
---|
| 1866 | + colorSection.add(backlit); |
---|
1823 | 1867 | |
---|
1824 | 1868 | cGridBag opacity = new cGridBag(); |
---|
1825 | 1869 | opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints); |
---|
1826 | 1870 | opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1827 | 1871 | opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1828 | | - globalSection.add(opacity); |
---|
| 1872 | + colorSection.add(opacity); |
---|
1829 | 1873 | |
---|
1830 | | - panel.add(new JSeparator()); |
---|
| 1874 | + //panel.add(new JSeparator()); |
---|
1831 | 1875 | |
---|
1832 | | - panel.add(globalSection); |
---|
| 1876 | + //panel.add(globalSection); |
---|
1833 | 1877 | |
---|
1834 | 1878 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1835 | 1879 | |
---|
.. | .. |
---|
1936 | 1980 | // 3D models |
---|
1937 | 1981 | if (filename.endsWith(".3ds") || filename.endsWith(".3DS")) |
---|
1938 | 1982 | { |
---|
1939 | | - lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
1940 | | - LoadFile(filename, lastConverter); |
---|
| 1983 | + //lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
| 1984 | + //LoadFile(filename, lastConverter); |
---|
| 1985 | + LoadObjFile(filename); // New 3ds loader |
---|
1941 | 1986 | continue; |
---|
1942 | 1987 | } |
---|
1943 | 1988 | if (filename.endsWith(".dae") || filename.endsWith(".DAE")) |
---|
.. | .. |
---|
2663 | 2708 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2); |
---|
2664 | 2709 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2); |
---|
2665 | 2710 | } |
---|
| 2711 | + |
---|
2666 | 2712 | //cJME.count++; |
---|
2667 | 2713 | //cJME.count %= 12; |
---|
2668 | 2714 | if (gc) |
---|
.. | .. |
---|
2846 | 2892 | } |
---|
2847 | 2893 | } |
---|
2848 | 2894 | } |
---|
| 2895 | + |
---|
2849 | 2896 | cFileSystemPane FSPane; |
---|
2850 | 2897 | |
---|
2851 | 2898 | void SetMaterial(cMaterial mat, Object3D.cVector2[] others) |
---|
.. | .. |
---|
2899 | 2946 | } |
---|
2900 | 2947 | } |
---|
2901 | 2948 | } |
---|
| 2949 | + |
---|
2902 | 2950 | freezematerial = false; |
---|
2903 | 2951 | } |
---|
2904 | 2952 | |
---|
.. | .. |
---|
3017 | 3065 | // } |
---|
3018 | 3066 | |
---|
3019 | 3067 | /**/ |
---|
3020 | | - if (deselect) |
---|
| 3068 | + if (deselect || child == null) |
---|
3021 | 3069 | { |
---|
3022 | 3070 | //group.deselectAll(); |
---|
3023 | 3071 | //freeze = true; |
---|
3024 | 3072 | GetTree().clearSelection(); |
---|
3025 | 3073 | //freeze = false; |
---|
| 3074 | + |
---|
| 3075 | + if (child == null) |
---|
| 3076 | + { |
---|
| 3077 | + return; |
---|
| 3078 | + } |
---|
3026 | 3079 | } |
---|
3027 | 3080 | |
---|
3028 | 3081 | //group.addSelectee(child); |
---|
.. | .. |
---|
3346 | 3399 | { |
---|
3347 | 3400 | Close(); |
---|
3348 | 3401 | //return true; |
---|
3349 | | - } else if (source == loadItem) |
---|
| 3402 | + } else if (source == openItem) |
---|
3350 | 3403 | { |
---|
3351 | | - load(); |
---|
| 3404 | + Open(); |
---|
3352 | 3405 | //return true; |
---|
3353 | 3406 | } else if (source == newItem) |
---|
3354 | 3407 | { |
---|
.. | .. |
---|
3373 | 3426 | { |
---|
3374 | 3427 | generatePOV(); |
---|
3375 | 3428 | //return true; |
---|
| 3429 | + } else if (event.getSource() == archiveItem) |
---|
| 3430 | + { |
---|
| 3431 | + cTools.Archive(frame); |
---|
| 3432 | + return; |
---|
3376 | 3433 | } else if (source == zBufferItem) |
---|
3377 | 3434 | { |
---|
3378 | 3435 | try |
---|
.. | .. |
---|
3424 | 3481 | try |
---|
3425 | 3482 | { |
---|
3426 | 3483 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3427 | | - java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
3428 | | - ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
| 3484 | +// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3485 | + ObjectOutputStream out = new ObjectOutputStream(baos); //zstream); |
---|
3429 | 3486 | |
---|
3430 | 3487 | Object3D parent = o.parent; |
---|
3431 | 3488 | o.parent = null; |
---|
.. | .. |
---|
3436 | 3493 | |
---|
3437 | 3494 | out.flush(); |
---|
3438 | 3495 | |
---|
3439 | | - zstream.close(); |
---|
| 3496 | + baos //zstream |
---|
| 3497 | + .close(); |
---|
3440 | 3498 | out.close(); |
---|
3441 | 3499 | |
---|
3442 | | - return baos.toByteArray(); |
---|
| 3500 | + byte[] bytes = baos.toByteArray(); |
---|
| 3501 | + |
---|
| 3502 | + System.out.println("save #bytes = " + bytes.length); |
---|
| 3503 | + return bytes; |
---|
3443 | 3504 | } catch (Exception e) |
---|
3444 | 3505 | { |
---|
3445 | 3506 | System.err.println(e); |
---|
.. | .. |
---|
3449 | 3510 | |
---|
3450 | 3511 | static public Object Uncompress(byte[] bytes) |
---|
3451 | 3512 | { |
---|
3452 | | - System.out.println("#bytes = " + bytes.length); |
---|
| 3513 | + System.out.println("restore #bytes = " + bytes.length); |
---|
3453 | 3514 | try |
---|
3454 | 3515 | { |
---|
3455 | 3516 | ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
3456 | | - java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
3457 | | - ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3517 | + //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3518 | + ObjectInputStream in = new ObjectInputStream(bais); // istream); |
---|
3458 | 3519 | Object obj = in.readObject(); |
---|
| 3520 | + |
---|
| 3521 | + bais //istream |
---|
| 3522 | + .close(); |
---|
3459 | 3523 | in.close(); |
---|
3460 | 3524 | |
---|
3461 | 3525 | return obj; |
---|
.. | .. |
---|
3514 | 3578 | |
---|
3515 | 3579 | public void Save() |
---|
3516 | 3580 | { |
---|
| 3581 | + Save(true); |
---|
| 3582 | + } |
---|
| 3583 | + |
---|
| 3584 | + private boolean Equal(byte[] compress, byte[] name) |
---|
| 3585 | + { |
---|
| 3586 | + if (compress.length != name.length) |
---|
| 3587 | + { |
---|
| 3588 | + return false; |
---|
| 3589 | + } |
---|
| 3590 | + |
---|
| 3591 | + for (int i=compress.length; --i>=0;) |
---|
| 3592 | + { |
---|
| 3593 | + if (compress[i] != name[i]) |
---|
| 3594 | + return false; |
---|
| 3595 | + } |
---|
| 3596 | + |
---|
| 3597 | + return true; |
---|
| 3598 | + } |
---|
| 3599 | + |
---|
| 3600 | + public boolean Save(boolean user) |
---|
| 3601 | + { |
---|
3517 | 3602 | System.err.println("Save"); |
---|
3518 | 3603 | |
---|
3519 | 3604 | cRadio tab = GetCurrentTab(); |
---|
.. | .. |
---|
3523 | 3608 | |
---|
3524 | 3609 | copy.ExtractBigData(hashtable); |
---|
3525 | 3610 | |
---|
3526 | | - //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3527 | | - tab.graphs[tab.undoindex++] = Compress(copy); |
---|
3528 | | - |
---|
3529 | | - copy.RestoreBigData(hashtable); |
---|
| 3611 | + byte[] compress = Compress(copy); |
---|
3530 | 3612 | |
---|
3531 | 3613 | CameraPane.SWITCH = temp; |
---|
3532 | 3614 | |
---|
| 3615 | + boolean thesame = false; |
---|
| 3616 | + |
---|
| 3617 | + // Quick heuristic using length. Works only when stream is compressed. |
---|
| 3618 | + if (tab.undoindex > 0 && tab.graphs[tab.undoindex-1] != null && Equal(compress, tab.graphs[tab.undoindex-1])) |
---|
| 3619 | + { |
---|
| 3620 | + thesame = true; |
---|
| 3621 | + } |
---|
| 3622 | + |
---|
| 3623 | + //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
| 3624 | + if (!thesame) |
---|
| 3625 | + { |
---|
| 3626 | + //tab.user[tab.undoindex] = user; |
---|
| 3627 | + boolean increment = tab.graphs[tab.undoindex] == null; |
---|
| 3628 | + |
---|
| 3629 | + tab.graphs[tab.undoindex] = compress; |
---|
| 3630 | + |
---|
| 3631 | + if (increment) |
---|
| 3632 | + tab.undoindex++; |
---|
| 3633 | + } |
---|
| 3634 | + |
---|
| 3635 | + copy.RestoreBigData(hashtable); |
---|
| 3636 | + |
---|
3533 | 3637 | //assert(hashtable.isEmpty()); |
---|
3534 | 3638 | |
---|
3535 | 3639 | for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
3536 | 3640 | { |
---|
3537 | | - tab.graphs[i] = null; |
---|
| 3641 | + //tab.user[i] = false; |
---|
| 3642 | + // tab.graphs[i] = null; |
---|
3538 | 3643 | } |
---|
3539 | 3644 | |
---|
3540 | 3645 | SetUndoStates(); |
---|
.. | .. |
---|
3557 | 3662 | e.printStackTrace(); |
---|
3558 | 3663 | } |
---|
3559 | 3664 | } |
---|
| 3665 | + |
---|
| 3666 | + return !thesame; |
---|
3560 | 3667 | } |
---|
3561 | 3668 | |
---|
3562 | 3669 | void CopyChanged(Object3D obj) |
---|
.. | .. |
---|
3613 | 3720 | redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null); |
---|
3614 | 3721 | } |
---|
3615 | 3722 | |
---|
3616 | | - public void Undo() |
---|
| 3723 | + public boolean Undo() |
---|
3617 | 3724 | { |
---|
3618 | 3725 | System.err.println("Undo"); |
---|
3619 | 3726 | |
---|
.. | .. |
---|
3622 | 3729 | if (tab.undoindex == 0) |
---|
3623 | 3730 | { |
---|
3624 | 3731 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3625 | | - return; |
---|
| 3732 | + return false; |
---|
3626 | 3733 | } |
---|
3627 | 3734 | |
---|
3628 | | - if (tab.graphs[tab.undoindex] == null) |
---|
| 3735 | + if (tab.graphs[tab.undoindex] == null) // || !tab.user[tab.undoindex]) |
---|
3629 | 3736 | { |
---|
3630 | | - Save(); |
---|
3631 | | - tab.undoindex -= 1; |
---|
| 3737 | + if (Save(false)) |
---|
| 3738 | + tab.undoindex -= 1; |
---|
| 3739 | + else |
---|
| 3740 | + { |
---|
| 3741 | + if (tab.undoindex <= 0) |
---|
| 3742 | + return false; |
---|
| 3743 | + else |
---|
| 3744 | + tab.undoindex -= 1; |
---|
| 3745 | + } |
---|
3632 | 3746 | } |
---|
3633 | 3747 | |
---|
3634 | 3748 | tab.undoindex -= 1; |
---|
3635 | 3749 | |
---|
3636 | 3750 | CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3751 | + |
---|
| 3752 | + return true; |
---|
3637 | 3753 | } |
---|
3638 | 3754 | |
---|
3639 | 3755 | public void Redo() |
---|
.. | .. |
---|
3649 | 3765 | tab.undoindex += 1; |
---|
3650 | 3766 | |
---|
3651 | 3767 | CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3768 | + |
---|
| 3769 | + //if (!tab.user[tab.undoindex]) |
---|
| 3770 | + // tab.graphs[tab.undoindex] = null; |
---|
3652 | 3771 | } |
---|
3653 | 3772 | |
---|
3654 | 3773 | void ImportGFD() |
---|
.. | .. |
---|
4611 | 4730 | |
---|
4612 | 4731 | if (readobj != null) |
---|
4613 | 4732 | { |
---|
4614 | | - if (Globals.SAVEONMAKE) |
---|
4615 | | - Save(); |
---|
| 4733 | + //if (Globals.SAVEONMAKE) // A new object cannot share meshes |
---|
| 4734 | + // Save(); |
---|
4616 | 4735 | try |
---|
4617 | 4736 | { |
---|
4618 | 4737 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
4673 | 4792 | } |
---|
4674 | 4793 | } |
---|
4675 | 4794 | |
---|
4676 | | - void load() // throws ClassNotFoundException |
---|
| 4795 | + void Open() // throws ClassNotFoundException |
---|
4677 | 4796 | { |
---|
4678 | 4797 | if (Grafreed.standAlone) |
---|
4679 | 4798 | { |
---|
.. | .. |
---|
4958 | 5077 | MenuBar menuBar; |
---|
4959 | 5078 | Menu fileMenu; |
---|
4960 | 5079 | MenuItem newItem; |
---|
4961 | | - MenuItem loadItem; |
---|
| 5080 | + MenuItem openItem; |
---|
4962 | 5081 | MenuItem saveItem; |
---|
4963 | 5082 | MenuItem saveAsItem; |
---|
4964 | 5083 | MenuItem exportAsItem; |
---|
.. | .. |
---|
4981 | 5100 | CheckboxMenuItem toggleSwitchItem; |
---|
4982 | 5101 | CheckboxMenuItem toggleRootItem; |
---|
4983 | 5102 | CheckboxMenuItem animationItem; |
---|
| 5103 | + MenuItem archiveItem; |
---|
4984 | 5104 | CheckboxMenuItem toggleHandleItem; |
---|
4985 | 5105 | CheckboxMenuItem togglePaintItem; |
---|
4986 | 5106 | JSplitPane mainPanel; |
---|