.. | .. |
---|
309 | 309 | //localCopy.parent = null; |
---|
310 | 310 | |
---|
311 | 311 | frame = new JFrame(); |
---|
312 | | - frame.setUndecorated(true); |
---|
| 312 | + frame.setUndecorated(false); |
---|
313 | 313 | objEditor = this; |
---|
314 | 314 | this.callee = callee; |
---|
315 | 315 | |
---|
.. | .. |
---|
350 | 350 | frame.setMenuBar(menuBar = new MenuBar()); |
---|
351 | 351 | menuBar.add(fileMenu = new Menu("File")); |
---|
352 | 352 | fileMenu.add(newItem = new MenuItem("New")); |
---|
353 | | - fileMenu.add(loadItem = new MenuItem("Open...")); |
---|
| 353 | + fileMenu.add(openItem = new MenuItem("Open...")); |
---|
354 | 354 | |
---|
355 | 355 | //oe.menuBar.add(menu = new Menu("Include")); |
---|
356 | 356 | Menu menu = new Menu("Import"); |
---|
.. | .. |
---|
382 | 382 | } |
---|
383 | 383 | |
---|
384 | 384 | newItem.addActionListener(this); |
---|
385 | | - loadItem.addActionListener(this); |
---|
| 385 | + openItem.addActionListener(this); |
---|
386 | 386 | saveItem.addActionListener(this); |
---|
387 | 387 | saveAsItem.addActionListener(this); |
---|
388 | 388 | exportAsItem.addActionListener(this); |
---|
.. | .. |
---|
449 | 449 | // TEXTAREA infoarea.setLineWrap(true); |
---|
450 | 450 | // TEXTAREA infoarea.setWrapStyleWord(true); |
---|
451 | 451 | infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED); |
---|
452 | | - infoPanel.setPreferredSize(new Dimension(50, 200)); |
---|
| 452 | + infoPanel.setPreferredSize(new Dimension(1, 1)); |
---|
453 | 453 | infoPanel.setName("Info"); |
---|
454 | 454 | //infoPanel.setLayout(new BorderLayout()); |
---|
455 | 455 | //infoPanel.add(createTextPane()); |
---|
.. | .. |
---|
699 | 699 | } |
---|
700 | 700 | } |
---|
701 | 701 | |
---|
702 | | -static GraphicsDevice device = GraphicsEnvironment |
---|
703 | | - .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
| 702 | +//static GraphicsDevice device = GraphicsEnvironment |
---|
| 703 | +// .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
704 | 704 | |
---|
705 | 705 | Rectangle keeprect; |
---|
706 | 706 | cRadio radio; |
---|
.. | .. |
---|
721 | 721 | void Minimize() |
---|
722 | 722 | { |
---|
723 | 723 | frame.setState(Frame.ICONIFIED); |
---|
| 724 | + frame.validate(); |
---|
724 | 725 | } |
---|
725 | 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={} |
---|
726 | 730 | void Maximize() |
---|
727 | 731 | { |
---|
| 732 | + if (CameraPane.FULLSCREEN) |
---|
| 733 | + { |
---|
| 734 | + ToggleFullScreen(); |
---|
| 735 | + } |
---|
| 736 | + |
---|
728 | 737 | if (maximized) |
---|
729 | 738 | { |
---|
730 | 739 | frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); |
---|
.. | .. |
---|
732 | 741 | else |
---|
733 | 742 | { |
---|
734 | 743 | keeprect = frame.getBounds(); |
---|
735 | | - Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); |
---|
736 | | - Dimension rect2 = frame.getToolkit().getScreenSize(); |
---|
737 | | - 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); |
---|
738 | 747 | // frame.setState(Frame.MAXIMIZED_BOTH); |
---|
| 748 | + frame.setBounds(frame.getGraphicsConfiguration().getBounds()); |
---|
739 | 749 | } |
---|
740 | 750 | |
---|
741 | 751 | maximized ^= true; |
---|
| 752 | + |
---|
| 753 | + frame.validate(); |
---|
742 | 754 | } |
---|
| 755 | + |
---|
| 756 | + cButton minButton; |
---|
| 757 | + cButton maxButton; |
---|
| 758 | + cButton fullButton; |
---|
743 | 759 | |
---|
744 | 760 | void ToggleFullScreen() |
---|
745 | 761 | { |
---|
| 762 | +GraphicsDevice device = frame.getGraphicsConfiguration().getDevice(); |
---|
| 763 | + |
---|
746 | 764 | cameraView.ToggleFullScreen(); |
---|
747 | 765 | |
---|
748 | 766 | if (!CameraPane.FULLSCREEN) |
---|
749 | 767 | { |
---|
750 | 768 | device.setFullScreenWindow(null); |
---|
| 769 | + frame.dispose(); |
---|
| 770 | + frame.setUndecorated(false); |
---|
| 771 | + frame.validate(); |
---|
| 772 | + frame.setVisible(true); |
---|
| 773 | + |
---|
751 | 774 | //frame.setVisible(false); |
---|
752 | 775 | // frame.removeNotify(); |
---|
753 | 776 | // frame.setUndecorated(false); |
---|
.. | .. |
---|
757 | 780 | // X frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
758 | 781 | // X framePanel.add(bigThree); |
---|
759 | 782 | // X frame.getContentPane().add(/*"Center",*/framePanel); |
---|
760 | | - framePanel.setDividerLocation(1); |
---|
| 783 | + framePanel.setDividerLocation(46); |
---|
761 | 784 | |
---|
762 | 785 | //frame.setVisible(true); |
---|
763 | 786 | radio.layout = keepButton; |
---|
.. | .. |
---|
772 | 795 | // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width, |
---|
773 | 796 | // frame.getToolkit().getScreenSize().height); |
---|
774 | 797 | //frame.setVisible(false); |
---|
| 798 | + |
---|
| 799 | + frame.dispose(); |
---|
| 800 | + frame.setUndecorated(true); |
---|
775 | 801 | device.setFullScreenWindow(frame); |
---|
| 802 | + frame.validate(); |
---|
| 803 | + frame.setVisible(true); |
---|
776 | 804 | // frame.removeNotify(); |
---|
777 | 805 | // frame.setUndecorated(true); |
---|
778 | 806 | // frame.addNotify(); |
---|
.. | .. |
---|
785 | 813 | radio.layout.doClick(); |
---|
786 | 814 | //frame.setVisible(true); |
---|
787 | 815 | } |
---|
| 816 | + frame.validate(); |
---|
788 | 817 | } |
---|
789 | 818 | |
---|
790 | 819 | private JTextPane createTextPane() |
---|
.. | .. |
---|
1117 | 1146 | namePanel = new cGridBag(); |
---|
1118 | 1147 | |
---|
1119 | 1148 | nameField = AddText(namePanel, copy.GetName()); |
---|
1120 | | - namePanel.add(nameField); |
---|
| 1149 | + namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)); |
---|
1121 | 1150 | oe.ctrlPanel.add(namePanel); |
---|
1122 | 1151 | |
---|
1123 | 1152 | oe.ctrlPanel.Return(); |
---|
.. | .. |
---|
1142 | 1171 | rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind); |
---|
1143 | 1172 | rewindCB.setToolTipText("Rewind animation"); |
---|
1144 | 1173 | |
---|
1145 | | - randomCB = AddCheckBox(setupPanel2, "Rand", copy.random); |
---|
| 1174 | + randomCB = AddCheckBox(setupPanel2, "Random", copy.random); |
---|
1146 | 1175 | randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); |
---|
1147 | 1176 | |
---|
| 1177 | + link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); |
---|
| 1178 | + link2masterCB.setToolTipText("Attach to support"); |
---|
| 1179 | + |
---|
1148 | 1180 | if (Globals.ADVANCED) |
---|
1149 | 1181 | { |
---|
1150 | | - link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); |
---|
1151 | | - link2masterCB.setToolTipText("Attach to support"); |
---|
1152 | 1182 | speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
1153 | 1183 | speedupCB.setToolTipText("Option motion capture"); |
---|
1154 | 1184 | } |
---|
.. | .. |
---|
1464 | 1494 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1465 | 1495 | // objectPanel.add(north); |
---|
1466 | 1496 | objectPanel.add(editPanel); |
---|
1467 | | - objectPanel.add(infoPanel); |
---|
| 1497 | + |
---|
| 1498 | + //if (Globals.ADVANCED) |
---|
| 1499 | + objectPanel.add(infoPanel); |
---|
| 1500 | + |
---|
1468 | 1501 | objectPanel.add(toolboxPanel); |
---|
1469 | 1502 | |
---|
1470 | 1503 | /* |
---|
.. | .. |
---|
1573 | 1606 | // aConstraints.gridheight = 1; |
---|
1574 | 1607 | |
---|
1575 | 1608 | framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree); |
---|
1576 | | - framePanel.setContinuousLayout(true); |
---|
1577 | | - framePanel.setOneTouchExpandable(true); |
---|
1578 | | - framePanel.setDividerLocation(0.8); |
---|
| 1609 | + framePanel.setContinuousLayout(false); |
---|
| 1610 | + framePanel.setOneTouchExpandable(false); |
---|
| 1611 | + //.setDividerLocation(0.8); |
---|
1579 | 1612 | //framePanel.setDividerSize(15); |
---|
1580 | 1613 | //framePanel.setResizeWeight(0.15); |
---|
1581 | 1614 | framePanel.setName("Frame"); |
---|
.. | .. |
---|
1594 | 1627 | |
---|
1595 | 1628 | frame.setSize(1280, 860); |
---|
1596 | 1629 | |
---|
1597 | | - frame.validate(); |
---|
1598 | | - frame.setVisible(true); |
---|
1599 | | - |
---|
1600 | 1630 | cameraView.requestFocusInWindow(); |
---|
1601 | 1631 | |
---|
1602 | 1632 | gridPanel.setDividerLocation(1.0); |
---|
| 1633 | + |
---|
| 1634 | + frame.validate(); |
---|
| 1635 | + |
---|
| 1636 | + frame.setVisible(true); |
---|
1603 | 1637 | |
---|
1604 | 1638 | frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
---|
1605 | 1639 | frame.addWindowListener(new WindowAdapter() |
---|
.. | .. |
---|
1686 | 1720 | texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1687 | 1721 | colorSection.add(texture); |
---|
1688 | 1722 | |
---|
1689 | | - cGridBag anisoU = new cGridBag(); |
---|
1690 | | - anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints); |
---|
1691 | | - anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1692 | | - anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1693 | | - colorSection.add(anisoU); |
---|
1694 | | - |
---|
1695 | | - cGridBag anisoV = new cGridBag(); |
---|
1696 | | - anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints); |
---|
1697 | | - anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1698 | | - anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1699 | | - colorSection.add(anisoV); |
---|
1700 | | - |
---|
1701 | | - cGridBag shadowbias = new cGridBag(); |
---|
1702 | | - shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints); |
---|
1703 | | - shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1704 | | - shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1705 | | - colorSection.add(shadowbias); |
---|
1706 | | - |
---|
1707 | 1723 | panel.add(new JSeparator()); |
---|
1708 | 1724 | |
---|
1709 | 1725 | panel.add(colorSection); |
---|
.. | .. |
---|
1753 | 1769 | fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1754 | 1770 | fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1755 | 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); |
---|
1756 | 1778 | |
---|
1757 | 1779 | panel.add(new JSeparator()); |
---|
1758 | 1780 | |
---|
.. | .. |
---|
1804 | 1826 | // aConstraints.gridy += 1; |
---|
1805 | 1827 | // aConstraints.gridwidth = 1; |
---|
1806 | 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 | + |
---|
1807 | 1841 | |
---|
1808 | 1842 | panel.add(new JSeparator()); |
---|
1809 | 1843 | |
---|
.. | .. |
---|
1811 | 1845 | |
---|
1812 | 1846 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1813 | 1847 | |
---|
1814 | | - cGridBag globalSection = new cGridBag().setVertical(true); |
---|
| 1848 | + //cGridBag globalSection = new cGridBag().setVertical(true); |
---|
1815 | 1849 | |
---|
1816 | 1850 | cGridBag camera = new cGridBag(); |
---|
1817 | 1851 | camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints); |
---|
1818 | 1852 | cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1819 | 1853 | camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1820 | | - globalSection.add(camera); |
---|
| 1854 | + colorSection.add(camera); |
---|
1821 | 1855 | |
---|
1822 | 1856 | cGridBag ambient = new cGridBag(); |
---|
1823 | 1857 | ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints); |
---|
1824 | 1858 | ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1825 | 1859 | ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1826 | | - globalSection.add(ambient); |
---|
| 1860 | + colorSection.add(ambient); |
---|
1827 | 1861 | |
---|
1828 | 1862 | cGridBag backlit = new cGridBag(); |
---|
1829 | 1863 | backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints); |
---|
1830 | 1864 | backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1831 | 1865 | backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1832 | | - globalSection.add(backlit); |
---|
| 1866 | + colorSection.add(backlit); |
---|
1833 | 1867 | |
---|
1834 | 1868 | cGridBag opacity = new cGridBag(); |
---|
1835 | 1869 | opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints); |
---|
1836 | 1870 | opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1837 | 1871 | opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1838 | | - globalSection.add(opacity); |
---|
| 1872 | + colorSection.add(opacity); |
---|
1839 | 1873 | |
---|
1840 | | - panel.add(new JSeparator()); |
---|
| 1874 | + //panel.add(new JSeparator()); |
---|
1841 | 1875 | |
---|
1842 | | - panel.add(globalSection); |
---|
| 1876 | + //panel.add(globalSection); |
---|
1843 | 1877 | |
---|
1844 | 1878 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1845 | 1879 | |
---|
.. | .. |
---|
1946 | 1980 | // 3D models |
---|
1947 | 1981 | if (filename.endsWith(".3ds") || filename.endsWith(".3DS")) |
---|
1948 | 1982 | { |
---|
1949 | | - lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
1950 | | - LoadFile(filename, lastConverter); |
---|
| 1983 | + //lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
| 1984 | + //LoadFile(filename, lastConverter); |
---|
| 1985 | + LoadObjFile(filename); // New 3ds loader |
---|
1951 | 1986 | continue; |
---|
1952 | 1987 | } |
---|
1953 | 1988 | if (filename.endsWith(".dae") || filename.endsWith(".DAE")) |
---|
.. | .. |
---|
2673 | 2708 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2); |
---|
2674 | 2709 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2); |
---|
2675 | 2710 | } |
---|
| 2711 | + |
---|
2676 | 2712 | //cJME.count++; |
---|
2677 | 2713 | //cJME.count %= 12; |
---|
2678 | 2714 | if (gc) |
---|
.. | .. |
---|
2856 | 2892 | } |
---|
2857 | 2893 | } |
---|
2858 | 2894 | } |
---|
| 2895 | + |
---|
2859 | 2896 | cFileSystemPane FSPane; |
---|
2860 | 2897 | |
---|
2861 | 2898 | void SetMaterial(cMaterial mat, Object3D.cVector2[] others) |
---|
.. | .. |
---|
2909 | 2946 | } |
---|
2910 | 2947 | } |
---|
2911 | 2948 | } |
---|
| 2949 | + |
---|
2912 | 2950 | freezematerial = false; |
---|
2913 | 2951 | } |
---|
2914 | 2952 | |
---|
.. | .. |
---|
3361 | 3399 | { |
---|
3362 | 3400 | Close(); |
---|
3363 | 3401 | //return true; |
---|
3364 | | - } else if (source == loadItem) |
---|
| 3402 | + } else if (source == openItem) |
---|
3365 | 3403 | { |
---|
3366 | | - load(); |
---|
| 3404 | + Open(); |
---|
3367 | 3405 | //return true; |
---|
3368 | 3406 | } else if (source == newItem) |
---|
3369 | 3407 | { |
---|
.. | .. |
---|
3388 | 3426 | { |
---|
3389 | 3427 | generatePOV(); |
---|
3390 | 3428 | //return true; |
---|
| 3429 | + } else if (event.getSource() == archiveItem) |
---|
| 3430 | + { |
---|
| 3431 | + cTools.Archive(frame); |
---|
| 3432 | + return; |
---|
3391 | 3433 | } else if (source == zBufferItem) |
---|
3392 | 3434 | { |
---|
3393 | 3435 | try |
---|
.. | .. |
---|
3439 | 3481 | try |
---|
3440 | 3482 | { |
---|
3441 | 3483 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3442 | | - java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
3443 | | - ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
| 3484 | +// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3485 | + ObjectOutputStream out = new ObjectOutputStream(baos); //zstream); |
---|
3444 | 3486 | |
---|
3445 | 3487 | Object3D parent = o.parent; |
---|
3446 | 3488 | o.parent = null; |
---|
.. | .. |
---|
3451 | 3493 | |
---|
3452 | 3494 | out.flush(); |
---|
3453 | 3495 | |
---|
3454 | | - zstream.close(); |
---|
| 3496 | + baos //zstream |
---|
| 3497 | + .close(); |
---|
3455 | 3498 | out.close(); |
---|
3456 | 3499 | |
---|
3457 | | - return baos.toByteArray(); |
---|
| 3500 | + byte[] bytes = baos.toByteArray(); |
---|
| 3501 | + |
---|
| 3502 | + System.out.println("save #bytes = " + bytes.length); |
---|
| 3503 | + return bytes; |
---|
3458 | 3504 | } catch (Exception e) |
---|
3459 | 3505 | { |
---|
3460 | 3506 | System.err.println(e); |
---|
.. | .. |
---|
3464 | 3510 | |
---|
3465 | 3511 | static public Object Uncompress(byte[] bytes) |
---|
3466 | 3512 | { |
---|
3467 | | - System.out.println("#bytes = " + bytes.length); |
---|
| 3513 | + System.out.println("restore #bytes = " + bytes.length); |
---|
3468 | 3514 | try |
---|
3469 | 3515 | { |
---|
3470 | 3516 | ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
3471 | | - java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
3472 | | - ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3517 | + //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3518 | + ObjectInputStream in = new ObjectInputStream(bais); // istream); |
---|
3473 | 3519 | Object obj = in.readObject(); |
---|
| 3520 | + |
---|
| 3521 | + bais //istream |
---|
| 3522 | + .close(); |
---|
3474 | 3523 | in.close(); |
---|
3475 | 3524 | |
---|
3476 | 3525 | return obj; |
---|
.. | .. |
---|
3529 | 3578 | |
---|
3530 | 3579 | public void Save() |
---|
3531 | 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 | + { |
---|
3532 | 3602 | System.err.println("Save"); |
---|
3533 | 3603 | |
---|
3534 | 3604 | cRadio tab = GetCurrentTab(); |
---|
.. | .. |
---|
3538 | 3608 | |
---|
3539 | 3609 | copy.ExtractBigData(hashtable); |
---|
3540 | 3610 | |
---|
3541 | | - //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3542 | | - tab.graphs[tab.undoindex++] = Compress(copy); |
---|
3543 | | - |
---|
3544 | | - copy.RestoreBigData(hashtable); |
---|
| 3611 | + byte[] compress = Compress(copy); |
---|
3545 | 3612 | |
---|
3546 | 3613 | CameraPane.SWITCH = temp; |
---|
3547 | 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 | + |
---|
3548 | 3637 | //assert(hashtable.isEmpty()); |
---|
3549 | 3638 | |
---|
3550 | 3639 | for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
3551 | 3640 | { |
---|
3552 | | - tab.graphs[i] = null; |
---|
| 3641 | + //tab.user[i] = false; |
---|
| 3642 | + // tab.graphs[i] = null; |
---|
3553 | 3643 | } |
---|
3554 | 3644 | |
---|
3555 | 3645 | SetUndoStates(); |
---|
.. | .. |
---|
3572 | 3662 | e.printStackTrace(); |
---|
3573 | 3663 | } |
---|
3574 | 3664 | } |
---|
| 3665 | + |
---|
| 3666 | + return !thesame; |
---|
3575 | 3667 | } |
---|
3576 | 3668 | |
---|
3577 | 3669 | void CopyChanged(Object3D obj) |
---|
.. | .. |
---|
3628 | 3720 | redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null); |
---|
3629 | 3721 | } |
---|
3630 | 3722 | |
---|
3631 | | - public void Undo() |
---|
| 3723 | + public boolean Undo() |
---|
3632 | 3724 | { |
---|
3633 | 3725 | System.err.println("Undo"); |
---|
3634 | 3726 | |
---|
.. | .. |
---|
3637 | 3729 | if (tab.undoindex == 0) |
---|
3638 | 3730 | { |
---|
3639 | 3731 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3640 | | - return; |
---|
| 3732 | + return false; |
---|
3641 | 3733 | } |
---|
3642 | 3734 | |
---|
3643 | | - if (tab.graphs[tab.undoindex] == null) |
---|
| 3735 | + if (tab.graphs[tab.undoindex] == null) // || !tab.user[tab.undoindex]) |
---|
3644 | 3736 | { |
---|
3645 | | - Save(); |
---|
3646 | | - 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 | + } |
---|
3647 | 3746 | } |
---|
3648 | 3747 | |
---|
3649 | 3748 | tab.undoindex -= 1; |
---|
3650 | 3749 | |
---|
3651 | 3750 | CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3751 | + |
---|
| 3752 | + return true; |
---|
3652 | 3753 | } |
---|
3653 | 3754 | |
---|
3654 | 3755 | public void Redo() |
---|
.. | .. |
---|
3664 | 3765 | tab.undoindex += 1; |
---|
3665 | 3766 | |
---|
3666 | 3767 | CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3768 | + |
---|
| 3769 | + //if (!tab.user[tab.undoindex]) |
---|
| 3770 | + // tab.graphs[tab.undoindex] = null; |
---|
3667 | 3771 | } |
---|
3668 | 3772 | |
---|
3669 | 3773 | void ImportGFD() |
---|
.. | .. |
---|
4626 | 4730 | |
---|
4627 | 4731 | if (readobj != null) |
---|
4628 | 4732 | { |
---|
4629 | | - if (Globals.SAVEONMAKE) |
---|
4630 | | - Save(); |
---|
| 4733 | + //if (Globals.SAVEONMAKE) // A new object cannot share meshes |
---|
| 4734 | + // Save(); |
---|
4631 | 4735 | try |
---|
4632 | 4736 | { |
---|
4633 | 4737 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
4688 | 4792 | } |
---|
4689 | 4793 | } |
---|
4690 | 4794 | |
---|
4691 | | - void load() // throws ClassNotFoundException |
---|
| 4795 | + void Open() // throws ClassNotFoundException |
---|
4692 | 4796 | { |
---|
4693 | 4797 | if (Grafreed.standAlone) |
---|
4694 | 4798 | { |
---|
.. | .. |
---|
4973 | 5077 | MenuBar menuBar; |
---|
4974 | 5078 | Menu fileMenu; |
---|
4975 | 5079 | MenuItem newItem; |
---|
4976 | | - MenuItem loadItem; |
---|
| 5080 | + MenuItem openItem; |
---|
4977 | 5081 | MenuItem saveItem; |
---|
4978 | 5082 | MenuItem saveAsItem; |
---|
4979 | 5083 | MenuItem exportAsItem; |
---|
.. | .. |
---|
4996 | 5100 | CheckboxMenuItem toggleSwitchItem; |
---|
4997 | 5101 | CheckboxMenuItem toggleRootItem; |
---|
4998 | 5102 | CheckboxMenuItem animationItem; |
---|
| 5103 | + MenuItem archiveItem; |
---|
4999 | 5104 | CheckboxMenuItem toggleHandleItem; |
---|
5000 | 5105 | CheckboxMenuItem togglePaintItem; |
---|
5001 | 5106 | JSplitPane mainPanel; |
---|