.. | .. |
---|
41 | 41 | JFrame frame; |
---|
42 | 42 | |
---|
43 | 43 | static ObjEditor theFrame; |
---|
| 44 | + |
---|
| 45 | + public cGridBag GetSeparator() |
---|
| 46 | + { |
---|
| 47 | + cGridBag separator = new cGridBag(); |
---|
| 48 | + separator.add(new JSeparator()); |
---|
| 49 | + separator.preferredHeight = 5; |
---|
| 50 | + return separator; |
---|
| 51 | + } |
---|
44 | 52 | |
---|
45 | 53 | cButton GetButton(String name, boolean border) |
---|
46 | 54 | { |
---|
47 | | - try |
---|
48 | | - { |
---|
49 | | - ImageIcon icon = GetIcon(name); |
---|
50 | | - return new cButton(icon, border); |
---|
51 | | - } |
---|
52 | | - catch (Exception e) |
---|
53 | | - { |
---|
54 | | - return new cButton(name, border); |
---|
55 | | - } |
---|
| 55 | + ImageIcon icon = GetIcon(name); |
---|
| 56 | + return new cButton(icon, border); |
---|
| 57 | + } |
---|
| 58 | + |
---|
| 59 | + cLabel GetLabel(String name, boolean border) |
---|
| 60 | + { |
---|
| 61 | + //ImageIcon icon = GetIcon(name); |
---|
| 62 | + return new cLabel(GetImage(name), border); |
---|
56 | 63 | } |
---|
57 | 64 | |
---|
58 | 65 | cToggleButton GetToggleButton(String name, boolean border) |
---|
59 | 66 | { |
---|
60 | | - try |
---|
61 | | - { |
---|
62 | | - ImageIcon icon = GetIcon(name); |
---|
63 | | - return new cToggleButton(icon, border); |
---|
64 | | - } |
---|
65 | | - catch (Exception e) |
---|
66 | | - { |
---|
67 | | - return new cToggleButton(name, border); |
---|
68 | | - } |
---|
| 67 | + ImageIcon icon = GetIcon(name); |
---|
| 68 | + return new cToggleButton(icon, border); |
---|
69 | 69 | } |
---|
70 | 70 | |
---|
71 | 71 | cCheckBox GetCheckBox(String name, boolean border) |
---|
72 | 72 | { |
---|
| 73 | + ImageIcon icon = GetIcon(name); |
---|
| 74 | + return new cCheckBox(icon, border); |
---|
| 75 | + } |
---|
| 76 | + |
---|
| 77 | + ImageIcon GetIcon(String name) |
---|
| 78 | + { |
---|
73 | 79 | try |
---|
74 | 80 | { |
---|
75 | | - ImageIcon icon = GetIcon(name); |
---|
76 | | - return new cCheckBox(icon, border); |
---|
| 81 | + BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); |
---|
| 82 | + |
---|
| 83 | +// if (image.getWidth() > 48 && image.getHeight() > 48) |
---|
| 84 | +// { |
---|
| 85 | +// BufferedImage resized = new BufferedImage(48, 48, image.getType()); |
---|
| 86 | +// Graphics2D g = resized.createGraphics(); |
---|
| 87 | +// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); |
---|
| 88 | +// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
---|
| 89 | +// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null); |
---|
| 90 | +// g.dispose(); |
---|
| 91 | +// |
---|
| 92 | +// image = resized; |
---|
| 93 | +// } |
---|
| 94 | + |
---|
| 95 | + javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image); |
---|
| 96 | + return icon; |
---|
77 | 97 | } |
---|
78 | 98 | catch (Exception e) |
---|
79 | 99 | { |
---|
80 | | - return new cCheckBox(name, border); |
---|
| 100 | + return null; |
---|
81 | 101 | } |
---|
82 | 102 | } |
---|
83 | | - |
---|
84 | | - private ImageIcon GetIcon(String name) throws IOException |
---|
| 103 | + |
---|
| 104 | + BufferedImage GetImage(String name) |
---|
85 | 105 | { |
---|
86 | | - BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); |
---|
87 | | - |
---|
88 | | - if (image.getWidth() != 24 && image.getHeight() != 24) |
---|
| 106 | + try |
---|
89 | 107 | { |
---|
90 | | - BufferedImage resized = new BufferedImage(24, 24, image.getType()); |
---|
91 | | - Graphics2D g = resized.createGraphics(); |
---|
92 | | - g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); |
---|
93 | | - //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
---|
94 | | - g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null); |
---|
95 | | - g.dispose(); |
---|
96 | | - |
---|
97 | | - image = resized; |
---|
| 108 | + BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); |
---|
| 109 | + |
---|
| 110 | + return image; |
---|
98 | 111 | } |
---|
99 | | - |
---|
100 | | - javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image); |
---|
101 | | - return icon; |
---|
| 112 | + catch (Exception e) |
---|
| 113 | + { |
---|
| 114 | + return null; |
---|
| 115 | + } |
---|
102 | 116 | } |
---|
103 | 117 | |
---|
104 | 118 | // SCRIPT |
---|
.. | .. |
---|
282 | 296 | client = inClient; |
---|
283 | 297 | copy = client; |
---|
284 | 298 | |
---|
| 299 | + if (copy.versions == null) |
---|
| 300 | + { |
---|
| 301 | + copy.versions = new Object3D[100]; |
---|
| 302 | + copy.versionindex = -1; |
---|
| 303 | + } |
---|
| 304 | + |
---|
285 | 305 | // "this" is not called: SetupUI2(objEditor); |
---|
286 | 306 | } |
---|
287 | 307 | |
---|
.. | .. |
---|
295 | 315 | client = inClient; |
---|
296 | 316 | copy = client; |
---|
297 | 317 | |
---|
| 318 | + if (copy.versions == null) |
---|
| 319 | + { |
---|
| 320 | + copy.versions = new Object3D[100]; |
---|
| 321 | + copy.versionindex = -1; |
---|
| 322 | + } |
---|
| 323 | + |
---|
298 | 324 | SetupUI2(callee.GetEditor()); |
---|
299 | 325 | } |
---|
300 | 326 | |
---|
.. | .. |
---|
327 | 353 | copy = localCopy; |
---|
328 | 354 | copy.editWindow = this; |
---|
329 | 355 | |
---|
| 356 | + if (copy.versions == null) |
---|
| 357 | + { |
---|
| 358 | +// copy.versions = new byte[100][]; |
---|
| 359 | +// copy.versionindex = -1; |
---|
| 360 | + } |
---|
| 361 | + |
---|
330 | 362 | SetupMenu(); |
---|
331 | 363 | |
---|
332 | 364 | //SetupName(objEditor); // new |
---|
.. | .. |
---|
419 | 451 | |
---|
420 | 452 | toolbarPanel = new JPanel(); |
---|
421 | 453 | toolbarPanel.setName("Toolbar"); |
---|
| 454 | + |
---|
422 | 455 | treePanel = new cGridBag(); |
---|
423 | 456 | treePanel.setName("Tree"); |
---|
424 | 457 | |
---|
425 | 458 | editPanel = new cGridBag().setVertical(true); |
---|
426 | | - editPanel.setName("Edit"); |
---|
| 459 | + //editPanel.setName("Edit"); |
---|
427 | 460 | |
---|
428 | 461 | ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout()); |
---|
429 | 462 | |
---|
.. | .. |
---|
431 | 464 | editPanel.add(editCommandsPanel); |
---|
432 | 465 | editPanel.add(ctrlPanel); |
---|
433 | 466 | |
---|
434 | | - toolboxPanel = new cGridBag().setVertical(false); |
---|
435 | | - toolboxPanel.setName("Toolbox"); |
---|
| 467 | + toolboxPanel = new cGridBag().setVertical(true); |
---|
| 468 | + //toolboxPanel.setName("Toolbox"); |
---|
436 | 469 | |
---|
437 | 470 | materialPanel = new cGridBag().setVertical(true); |
---|
438 | | - materialPanel.setName("Material"); |
---|
| 471 | + //materialPanel.setName("Material"); |
---|
439 | 472 | |
---|
440 | 473 | /*JTextPane*/ |
---|
441 | 474 | infoarea = createTextPane(); |
---|
.. | .. |
---|
443 | 476 | |
---|
444 | 477 | infoarea.setEditable(true); |
---|
445 | 478 | SetText(); |
---|
| 479 | + |
---|
446 | 480 | // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f)); |
---|
447 | 481 | // infoarea.setOpaque(false); |
---|
448 | 482 | // //infoarea.setForeground(textcolor); |
---|
.. | .. |
---|
450 | 484 | // TEXTAREA infoarea.setWrapStyleWord(true); |
---|
451 | 485 | infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED); |
---|
452 | 486 | infoPanel.setPreferredSize(new Dimension(1, 1)); |
---|
453 | | - infoPanel.setName("Info"); |
---|
| 487 | + //infoPanel.setName("Info"); |
---|
454 | 488 | //infoPanel.setLayout(new BorderLayout()); |
---|
455 | 489 | //infoPanel.add(createTextPane()); |
---|
456 | 490 | |
---|
.. | .. |
---|
816 | 850 | frame.validate(); |
---|
817 | 851 | } |
---|
818 | 852 | |
---|
819 | | - private byte[] CompressCopy() |
---|
| 853 | + private Object3D CompressCopy() |
---|
820 | 854 | { |
---|
821 | 855 | boolean temp = CameraPane.SWITCH; |
---|
822 | 856 | CameraPane.SWITCH = false; |
---|
.. | .. |
---|
824 | 858 | copy.ExtractBigData(versiontable); |
---|
825 | 859 | // if (copy == client) |
---|
826 | 860 | |
---|
827 | | - byte[] versions[] = copy.versions; |
---|
| 861 | + Object3D versions[] = copy.versions; |
---|
828 | 862 | copy.versions = null; |
---|
829 | 863 | |
---|
830 | | - byte[] compress = Compress(copy); |
---|
| 864 | + //byte[] compress = Compress(copy); |
---|
| 865 | + Object3D compress = (Object3D)Grafreed.clone(copy); |
---|
831 | 866 | |
---|
832 | 867 | copy.versions = versions; |
---|
833 | 868 | |
---|
.. | .. |
---|
968 | 1003 | // NumberSlider vDivsField; |
---|
969 | 1004 | // JCheckBox endcaps; |
---|
970 | 1005 | JCheckBox liveCB; |
---|
971 | | - JCheckBox selectCB; |
---|
| 1006 | + JCheckBox selectableCB; |
---|
972 | 1007 | JCheckBox hideCB; |
---|
973 | 1008 | JCheckBox link2masterCB; |
---|
974 | 1009 | JCheckBox markCB; |
---|
.. | .. |
---|
1180 | 1215 | |
---|
1181 | 1216 | liveCB = AddCheckBox(setupPanel, "Live", copy.live); |
---|
1182 | 1217 | liveCB.setToolTipText("Animate object"); |
---|
1183 | | - selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect); |
---|
1184 | | - selectCB.setToolTipText("Make object selectable"); |
---|
| 1218 | + selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect); |
---|
| 1219 | + selectableCB.setToolTipText("Make object selectable"); |
---|
1185 | 1220 | // Return(); |
---|
| 1221 | + |
---|
1186 | 1222 | hideCB = AddCheckBox(setupPanel, "Hide", copy.hide); |
---|
1187 | 1223 | hideCB.setToolTipText("Hide object"); |
---|
1188 | 1224 | markCB = AddCheckBox(setupPanel, "Mark", copy.marked); |
---|
1189 | 1225 | markCB.setToolTipText("As animation target transform"); |
---|
| 1226 | + |
---|
| 1227 | + ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); |
---|
1190 | 1228 | |
---|
1191 | 1229 | setupPanel2 = new cGridBag().setVertical(false); |
---|
1192 | 1230 | |
---|
.. | .. |
---|
1474 | 1512 | XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll); |
---|
1475 | 1513 | XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll); |
---|
1476 | 1514 | XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll); |
---|
| 1515 | + //XYZPanel.setName("XYZ"); |
---|
1477 | 1516 | |
---|
1478 | 1517 | /* |
---|
1479 | 1518 | gridPanel = new JPanel(); //new BorderLayout()); |
---|
.. | .. |
---|
1511 | 1550 | //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); |
---|
1512 | 1551 | //tmp.setName("Edit"); |
---|
1513 | 1552 | objectPanel.add(materialPanel); |
---|
| 1553 | + objectPanel.setIconAt(0, GetIcon("icons/material.png")); |
---|
| 1554 | + objectPanel.setToolTipTextAt(0, "Material panel"); |
---|
| 1555 | + |
---|
1514 | 1556 | // JPanel north = new JPanel(new BorderLayout()); |
---|
1515 | 1557 | // north.setName("Edit"); |
---|
1516 | 1558 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1517 | 1559 | // objectPanel.add(north); |
---|
1518 | 1560 | objectPanel.add(editPanel); |
---|
| 1561 | + objectPanel.setIconAt(1, GetIcon("icons/write.png")); |
---|
| 1562 | + objectPanel.setToolTipTextAt(1, "Edit panel"); |
---|
1519 | 1563 | |
---|
1520 | 1564 | //if (Globals.ADVANCED) |
---|
1521 | 1565 | objectPanel.add(infoPanel); |
---|
| 1566 | + objectPanel.setIconAt(2, GetIcon("icons/info.png")); |
---|
| 1567 | + objectPanel.setToolTipTextAt(2, "Info panel"); |
---|
| 1568 | + |
---|
| 1569 | + objectPanel.add(XYZPanel); |
---|
| 1570 | + objectPanel.setIconAt(3, GetIcon("icons/XYZ.png")); |
---|
| 1571 | + objectPanel.setToolTipTextAt(3, "XYZ/RGB panel"); |
---|
1522 | 1572 | |
---|
1523 | 1573 | objectPanel.add(toolboxPanel); |
---|
| 1574 | + objectPanel.setIconAt(4, GetIcon("icons/primitives.png")); |
---|
| 1575 | + objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel"); |
---|
1524 | 1576 | |
---|
1525 | 1577 | /* |
---|
1526 | 1578 | aConstraints.gridx = 0; |
---|
.. | .. |
---|
1541 | 1593 | scrollpane.addMouseWheelListener(this); // Default not fast enough |
---|
1542 | 1594 | |
---|
1543 | 1595 | /*JTabbedPane*/ scenePanel = new cGridBag(); |
---|
1544 | | - scenePanel.preferredWidth = 6; |
---|
| 1596 | + scenePanel.preferredWidth = 5; |
---|
1545 | 1597 | |
---|
1546 | 1598 | JTabbedPane tabbedPane = new JTabbedPane(); |
---|
1547 | 1599 | tabbedPane.add(scrollpane); |
---|
.. | .. |
---|
1619 | 1671 | bigThree = new cGridBag(); |
---|
1620 | 1672 | bigThree.addComponent(scenePanel); |
---|
1621 | 1673 | bigThree.addComponent(centralPanel); |
---|
1622 | | - bigThree.addComponent(XYZPanel); |
---|
| 1674 | + //bigThree.addComponent(XYZPanel); |
---|
1623 | 1675 | |
---|
1624 | 1676 | // // SIDE EFFECT!!! |
---|
1625 | 1677 | // aConstraints.gridx = 0; |
---|
.. | .. |
---|
1660 | 1712 | frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
---|
1661 | 1713 | frame.addWindowListener(new WindowAdapter() |
---|
1662 | 1714 | { |
---|
1663 | | - |
---|
1664 | 1715 | public void windowClosing(WindowEvent e) |
---|
1665 | 1716 | { |
---|
1666 | 1717 | Close(); |
---|
.. | .. |
---|
1722 | 1773 | //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints); |
---|
1723 | 1774 | |
---|
1724 | 1775 | cGridBag colorSection = new cGridBag().setVertical(true); |
---|
| 1776 | + |
---|
| 1777 | + cGridBag huepanel = new cGridBag(); |
---|
| 1778 | + cGridBag huelabel = new cGridBag(); |
---|
| 1779 | + huelabel.add(GetLabel("icons/hue.png", false)); |
---|
| 1780 | + huelabel.preferredWidth = 20; |
---|
| 1781 | + huepanel.add(new cGridBag()); // Label |
---|
| 1782 | + huepanel.add(huelabel); // Field/slider |
---|
| 1783 | + |
---|
| 1784 | + huepanel.preferredHeight = 7; |
---|
| 1785 | + |
---|
| 1786 | + colorSection.add(huepanel); |
---|
1725 | 1787 | |
---|
1726 | 1788 | cGridBag color = new cGridBag(); |
---|
1727 | | - color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints); |
---|
1728 | | - colorLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1729 | | - color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
| 1789 | + |
---|
| 1790 | + color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints); |
---|
| 1791 | + colorLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1792 | + color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints); |
---|
| 1793 | + |
---|
1730 | 1794 | //colorField.preferredWidth = 200; |
---|
1731 | 1795 | colorSection.add(color); |
---|
1732 | 1796 | |
---|
1733 | 1797 | cGridBag modulation = new cGridBag(); |
---|
1734 | 1798 | modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints); |
---|
1735 | 1799 | modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1736 | | - modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
| 1800 | + modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints); |
---|
1737 | 1801 | colorSection.add(modulation); |
---|
1738 | 1802 | |
---|
| 1803 | + cGridBag opacity = new cGridBag(); |
---|
| 1804 | + opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints); |
---|
| 1805 | + opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
| 1806 | + opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints); |
---|
| 1807 | + colorSection.add(opacity); |
---|
| 1808 | + |
---|
| 1809 | + colorSection.add(GetSeparator()); |
---|
| 1810 | + |
---|
1739 | 1811 | cGridBag texture = new cGridBag(); |
---|
1740 | 1812 | texture.add(textureLabel = new JLabel("Texture")); // , aConstraints); |
---|
1741 | 1813 | textureLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1742 | 1814 | texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1743 | 1815 | colorSection.add(texture); |
---|
1744 | 1816 | |
---|
1745 | | - panel.add(new JSeparator()); |
---|
| 1817 | + panel.add(GetSeparator()); |
---|
1746 | 1818 | |
---|
1747 | 1819 | panel.add(colorSection); |
---|
1748 | 1820 | |
---|
.. | .. |
---|
1798 | 1870 | shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1799 | 1871 | diffuseSection.add(shadowbias); |
---|
1800 | 1872 | |
---|
1801 | | - panel.add(new JSeparator()); |
---|
| 1873 | + panel.add(GetSeparator()); |
---|
1802 | 1874 | |
---|
1803 | 1875 | panel.add(diffuseSection); |
---|
1804 | 1876 | |
---|
.. | .. |
---|
1861 | 1933 | specularSection.add(anisoV); |
---|
1862 | 1934 | |
---|
1863 | 1935 | |
---|
1864 | | - panel.add(new JSeparator()); |
---|
| 1936 | + panel.add(GetSeparator()); |
---|
1865 | 1937 | |
---|
1866 | 1938 | panel.add(specularSection); |
---|
1867 | 1939 | |
---|
.. | .. |
---|
1886 | 1958 | backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1887 | 1959 | backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints); |
---|
1888 | 1960 | colorSection.add(backlit); |
---|
1889 | | - |
---|
1890 | | - cGridBag opacity = new cGridBag(); |
---|
1891 | | - opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints); |
---|
1892 | | - opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING); |
---|
1893 | | - opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints); |
---|
1894 | | - colorSection.add(opacity); |
---|
1895 | 1961 | |
---|
1896 | 1962 | //panel.add(new JSeparator()); |
---|
1897 | 1963 | |
---|
.. | .. |
---|
1937 | 2003 | opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints); |
---|
1938 | 2004 | textureSection.add(opacityPower); |
---|
1939 | 2005 | |
---|
1940 | | - panel.add(new JSeparator()); |
---|
| 2006 | + panel.add(GetSeparator()); |
---|
1941 | 2007 | |
---|
1942 | 2008 | panel.add(textureSection); |
---|
1943 | 2009 | |
---|
.. | .. |
---|
3236 | 3302 | { |
---|
3237 | 3303 | copy.live ^= true; |
---|
3238 | 3304 | return; |
---|
3239 | | - } else if (event.getSource() == selectCB) |
---|
| 3305 | + } else if (event.getSource() == selectableCB) |
---|
3240 | 3306 | { |
---|
3241 | 3307 | copy.dontselect ^= true; |
---|
3242 | 3308 | return; |
---|
.. | .. |
---|
3500 | 3566 | |
---|
3501 | 3567 | static public byte[] Compress(Object3D o) |
---|
3502 | 3568 | { |
---|
| 3569 | + // Slower to actually compress. |
---|
3503 | 3570 | try |
---|
3504 | 3571 | { |
---|
3505 | 3572 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
.. | .. |
---|
3627 | 3694 | |
---|
3628 | 3695 | cRadio tab = GetCurrentTab(); |
---|
3629 | 3696 | |
---|
3630 | | - byte[] compress = CompressCopy(); |
---|
| 3697 | + Object3D compress = CompressCopy(); // Saved version. No need for "Replace". |
---|
3631 | 3698 | |
---|
3632 | 3699 | boolean thesame = false; |
---|
3633 | 3700 | |
---|
3634 | | - // Quick heuristic using length. Works only when stream is compressed. |
---|
3635 | | - if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1])) |
---|
3636 | | - { |
---|
3637 | | - thesame = true; |
---|
3638 | | - } |
---|
| 3701 | +// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1])) |
---|
| 3702 | +// { |
---|
| 3703 | +// thesame = true; |
---|
| 3704 | +// } |
---|
3639 | 3705 | |
---|
3640 | 3706 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3641 | 3707 | if (!thesame) |
---|
.. | .. |
---|
3694 | 3760 | |
---|
3695 | 3761 | copy.clear(); |
---|
3696 | 3762 | |
---|
| 3763 | + copy.skyboxname = obj.skyboxname; |
---|
| 3764 | + copy.skyboxext = obj.skyboxext; |
---|
| 3765 | + |
---|
3697 | 3766 | for (int i=0; i<obj.Size(); i++) |
---|
3698 | 3767 | { |
---|
3699 | 3768 | copy.add(obj.get(i)); |
---|
.. | .. |
---|
3731 | 3800 | cButton replaceButton; |
---|
3732 | 3801 | cButton redoButton; |
---|
3733 | 3802 | |
---|
| 3803 | + boolean muteSlider; |
---|
| 3804 | + |
---|
| 3805 | + int VersionCount() |
---|
| 3806 | + { |
---|
| 3807 | + int count = 0; |
---|
| 3808 | + |
---|
| 3809 | + for (int i = copy.versions.length; --i >= 0;) |
---|
| 3810 | + { |
---|
| 3811 | + if (copy.versions[i] != null) |
---|
| 3812 | + count++; |
---|
| 3813 | + } |
---|
| 3814 | + |
---|
| 3815 | + return count; |
---|
| 3816 | + } |
---|
| 3817 | + |
---|
3734 | 3818 | void SetUndoStates() |
---|
3735 | 3819 | { |
---|
3736 | 3820 | cRadio tab = GetCurrentTab(); |
---|
3737 | 3821 | |
---|
3738 | 3822 | restoreButton.setEnabled(copy.versionindex != -1); |
---|
3739 | 3823 | replaceButton.setEnabled(copy.versionindex != -1); |
---|
| 3824 | + |
---|
3740 | 3825 | undoButton.setEnabled(copy.versionindex > 0); |
---|
3741 | 3826 | redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null); |
---|
| 3827 | + |
---|
| 3828 | + muteSlider = true; |
---|
| 3829 | + versionSlider.setMaximum(VersionCount() - 1); |
---|
| 3830 | + versionSlider.setInteger(copy.versionindex); |
---|
| 3831 | + muteSlider = false; |
---|
3742 | 3832 | } |
---|
3743 | 3833 | |
---|
3744 | 3834 | public boolean Undo() |
---|
3745 | 3835 | { |
---|
| 3836 | + // Option? |
---|
| 3837 | + Replace(); |
---|
| 3838 | + |
---|
3746 | 3839 | System.err.println("Undo"); |
---|
3747 | 3840 | |
---|
3748 | 3841 | cRadio tab = GetCurrentTab(); |
---|
.. | .. |
---|
3768 | 3861 | |
---|
3769 | 3862 | copy.versionindex -= 1; |
---|
3770 | 3863 | |
---|
3771 | | - CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3864 | + CopyChanged((Object3D)copy.versions[copy.versionindex]); |
---|
3772 | 3865 | |
---|
3773 | 3866 | return true; |
---|
3774 | 3867 | } |
---|
.. | .. |
---|
3785 | 3878 | return false; |
---|
3786 | 3879 | } |
---|
3787 | 3880 | |
---|
3788 | | - CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3881 | + //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3882 | + CopyChanged(copy.versions[copy.versionindex]); |
---|
3789 | 3883 | |
---|
3790 | 3884 | return true; |
---|
3791 | 3885 | } |
---|
.. | .. |
---|
3809 | 3903 | |
---|
3810 | 3904 | public void Redo() |
---|
3811 | 3905 | { |
---|
| 3906 | + // Option? |
---|
| 3907 | + Replace(); |
---|
| 3908 | + |
---|
3812 | 3909 | cRadio tab = GetCurrentTab(); |
---|
3813 | 3910 | |
---|
3814 | 3911 | if (copy.versions[copy.versionindex + 1] == null) |
---|
.. | .. |
---|
3819 | 3916 | |
---|
3820 | 3917 | copy.versionindex += 1; |
---|
3821 | 3918 | |
---|
3822 | | - CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3919 | + CopyChanged(copy.versions[copy.versionindex]); |
---|
3823 | 3920 | |
---|
3824 | 3921 | //if (!tab.user[tab.versionindex]) |
---|
3825 | 3922 | // tab.graphs[tab.versionindex] = null; |
---|
.. | .. |
---|
4118 | 4215 | //copy.Touch(); |
---|
4119 | 4216 | } |
---|
4120 | 4217 | |
---|
4121 | | - cNumberSlider versionField; |
---|
| 4218 | + cNumberSlider versionSlider; |
---|
4122 | 4219 | |
---|
4123 | 4220 | public void stateChanged(ChangeEvent e) |
---|
4124 | 4221 | { |
---|
4125 | 4222 | // assert(false); |
---|
4126 | | - if (e.getSource() == versionField) |
---|
| 4223 | + if (e.getSource() == versionSlider) |
---|
4127 | 4224 | { |
---|
4128 | | - int version = versionField.getInteger(); |
---|
| 4225 | + if (muteSlider) |
---|
| 4226 | + return; |
---|
| 4227 | + |
---|
| 4228 | + int version = versionSlider.getInteger(); |
---|
4129 | 4229 | |
---|
4130 | 4230 | if (copy.versions[version] != null) |
---|
4131 | 4231 | { |
---|
4132 | | - CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version])); |
---|
| 4232 | + CopyChanged(copy.versions[copy.versionindex = version]); |
---|
4133 | 4233 | } |
---|
4134 | 4234 | |
---|
4135 | 4235 | return; |
---|
.. | .. |
---|
4724 | 4824 | readobj.ResetDisplayList(); |
---|
4725 | 4825 | } catch (Exception e) |
---|
4726 | 4826 | { |
---|
4727 | | - //e.printStackTrace(); |
---|
| 4827 | + if (!e.toString().contains("GZIP")) |
---|
| 4828 | + e.printStackTrace(); |
---|
| 4829 | + |
---|
4728 | 4830 | try |
---|
4729 | 4831 | { |
---|
4730 | 4832 | java.io.FileInputStream istream = new java.io.FileInputStream(fullname); |
---|
.. | .. |
---|
4804 | 4906 | { |
---|
4805 | 4907 | //readobj.deepCopySelf(copy); |
---|
4806 | 4908 | copy.clear(); // june 2014 |
---|
| 4909 | + copy.skyboxname = readobj.skyboxname; |
---|
| 4910 | + copy.skyboxext = readobj.skyboxext; |
---|
4807 | 4911 | for (int i = 0; i < readobj.size(); i++) |
---|
4808 | 4912 | { |
---|
4809 | 4913 | Object3D child = readobj.get(i); // reserve(i); |
---|
.. | .. |
---|
4844 | 4948 | } |
---|
4845 | 4949 | } catch (ClassCastException e) |
---|
4846 | 4950 | { |
---|
| 4951 | + e.printStackTrace(); |
---|
4847 | 4952 | assert (false); |
---|
4848 | 4953 | Composite c = (Composite) copy; |
---|
4849 | 4954 | c.children.clear(); |
---|
.. | .. |
---|
4857 | 4962 | copy.versions = readobj.versions; |
---|
4858 | 4963 | copy.versionindex = readobj.versionindex; |
---|
4859 | 4964 | |
---|
4860 | | - SetUndoStates(); |
---|
| 4965 | + if (copy.versions == null) |
---|
| 4966 | + { |
---|
| 4967 | + copy.versions = new Object3D[100]; |
---|
| 4968 | + copy.versionindex = -1; |
---|
| 4969 | + } |
---|
| 4970 | + |
---|
| 4971 | + //? SetUndoStates(); |
---|
4861 | 4972 | |
---|
4862 | 4973 | ResetModel(); |
---|
4863 | 4974 | copy.HardTouch(); // recompile? |
---|
.. | .. |
---|
4968 | 5079 | //ps.print(buffer.toString()); |
---|
4969 | 5080 | } catch (IOException e) |
---|
4970 | 5081 | { |
---|
| 5082 | + e.printStackTrace(); |
---|
4971 | 5083 | } |
---|
4972 | 5084 | } |
---|
4973 | 5085 | |
---|