.. | .. |
---|
44 | 44 | |
---|
45 | 45 | cButton GetButton(String name, boolean border) |
---|
46 | 46 | { |
---|
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 | | - } |
---|
| 47 | + ImageIcon icon = GetIcon(name); |
---|
| 48 | + return new cButton(icon, border); |
---|
56 | 49 | } |
---|
57 | 50 | |
---|
58 | 51 | cToggleButton GetToggleButton(String name, boolean border) |
---|
59 | 52 | { |
---|
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 | | - } |
---|
| 53 | + ImageIcon icon = GetIcon(name); |
---|
| 54 | + return new cToggleButton(icon, border); |
---|
69 | 55 | } |
---|
70 | 56 | |
---|
71 | 57 | cCheckBox GetCheckBox(String name, boolean border) |
---|
72 | 58 | { |
---|
| 59 | + ImageIcon icon = GetIcon(name); |
---|
| 60 | + return new cCheckBox(icon, border); |
---|
| 61 | + } |
---|
| 62 | + |
---|
| 63 | + private ImageIcon GetIcon(String name) |
---|
| 64 | + { |
---|
73 | 65 | try |
---|
74 | 66 | { |
---|
75 | | - ImageIcon icon = GetIcon(name); |
---|
76 | | - return new cCheckBox(icon, border); |
---|
| 67 | + BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); |
---|
| 68 | + |
---|
| 69 | + if (image.getWidth() != 24 && image.getHeight() != 24) |
---|
| 70 | + { |
---|
| 71 | + BufferedImage resized = new BufferedImage(24, 24, image.getType()); |
---|
| 72 | + Graphics2D g = resized.createGraphics(); |
---|
| 73 | + g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); |
---|
| 74 | + //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
---|
| 75 | + g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null); |
---|
| 76 | + g.dispose(); |
---|
| 77 | + |
---|
| 78 | + image = resized; |
---|
| 79 | + } |
---|
| 80 | + |
---|
| 81 | + javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image); |
---|
| 82 | + return icon; |
---|
77 | 83 | } |
---|
78 | 84 | catch (Exception e) |
---|
79 | 85 | { |
---|
80 | | - return new cCheckBox(name, border); |
---|
| 86 | + return null; |
---|
81 | 87 | } |
---|
82 | | - } |
---|
83 | | - |
---|
84 | | - private ImageIcon GetIcon(String name) throws IOException |
---|
85 | | - { |
---|
86 | | - BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); |
---|
87 | | - |
---|
88 | | - if (image.getWidth() != 24 && image.getHeight() != 24) |
---|
89 | | - { |
---|
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; |
---|
98 | | - } |
---|
99 | | - |
---|
100 | | - javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image); |
---|
101 | | - return icon; |
---|
102 | 88 | } |
---|
103 | 89 | |
---|
104 | 90 | // SCRIPT |
---|
.. | .. |
---|
282 | 268 | client = inClient; |
---|
283 | 269 | copy = client; |
---|
284 | 270 | |
---|
| 271 | + if (copy.versions == null) |
---|
| 272 | + { |
---|
| 273 | + copy.versions = new byte[100][]; |
---|
| 274 | + copy.versionindex = -1; |
---|
| 275 | + } |
---|
| 276 | + |
---|
285 | 277 | // "this" is not called: SetupUI2(objEditor); |
---|
286 | 278 | } |
---|
287 | 279 | |
---|
.. | .. |
---|
295 | 287 | client = inClient; |
---|
296 | 288 | copy = client; |
---|
297 | 289 | |
---|
| 290 | + if (copy.versions == null) |
---|
| 291 | + { |
---|
| 292 | + copy.versions = new byte[100][]; |
---|
| 293 | + copy.versionindex = -1; |
---|
| 294 | + } |
---|
| 295 | + |
---|
298 | 296 | SetupUI2(callee.GetEditor()); |
---|
299 | 297 | } |
---|
300 | 298 | |
---|
.. | .. |
---|
327 | 325 | copy = localCopy; |
---|
328 | 326 | copy.editWindow = this; |
---|
329 | 327 | |
---|
| 328 | + if (copy.versions == null) |
---|
| 329 | + { |
---|
| 330 | +// copy.versions = new byte[100][]; |
---|
| 331 | +// copy.versionindex = -1; |
---|
| 332 | + } |
---|
| 333 | + |
---|
330 | 334 | SetupMenu(); |
---|
331 | 335 | |
---|
332 | 336 | //SetupName(objEditor); // new |
---|
.. | .. |
---|
419 | 423 | |
---|
420 | 424 | toolbarPanel = new JPanel(); |
---|
421 | 425 | toolbarPanel.setName("Toolbar"); |
---|
| 426 | + |
---|
422 | 427 | treePanel = new cGridBag(); |
---|
423 | 428 | treePanel.setName("Tree"); |
---|
424 | 429 | |
---|
425 | 430 | editPanel = new cGridBag().setVertical(true); |
---|
426 | | - editPanel.setName("Edit"); |
---|
| 431 | + //editPanel.setName("Edit"); |
---|
427 | 432 | |
---|
428 | 433 | ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout()); |
---|
429 | 434 | |
---|
.. | .. |
---|
432 | 437 | editPanel.add(ctrlPanel); |
---|
433 | 438 | |
---|
434 | 439 | toolboxPanel = new cGridBag().setVertical(false); |
---|
435 | | - toolboxPanel.setName("Toolbox"); |
---|
| 440 | + //toolboxPanel.setName("Toolbox"); |
---|
436 | 441 | |
---|
437 | 442 | materialPanel = new cGridBag().setVertical(true); |
---|
438 | | - materialPanel.setName("Material"); |
---|
| 443 | + //materialPanel.setName("Material"); |
---|
439 | 444 | |
---|
440 | 445 | /*JTextPane*/ |
---|
441 | 446 | infoarea = createTextPane(); |
---|
.. | .. |
---|
443 | 448 | |
---|
444 | 449 | infoarea.setEditable(true); |
---|
445 | 450 | SetText(); |
---|
| 451 | + |
---|
446 | 452 | // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f)); |
---|
447 | 453 | // infoarea.setOpaque(false); |
---|
448 | 454 | // //infoarea.setForeground(textcolor); |
---|
.. | .. |
---|
450 | 456 | // TEXTAREA infoarea.setWrapStyleWord(true); |
---|
451 | 457 | infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED); |
---|
452 | 458 | infoPanel.setPreferredSize(new Dimension(1, 1)); |
---|
453 | | - infoPanel.setName("Info"); |
---|
| 459 | + //infoPanel.setName("Info"); |
---|
454 | 460 | //infoPanel.setLayout(new BorderLayout()); |
---|
455 | 461 | //infoPanel.add(createTextPane()); |
---|
456 | 462 | |
---|
.. | .. |
---|
968 | 974 | // NumberSlider vDivsField; |
---|
969 | 975 | // JCheckBox endcaps; |
---|
970 | 976 | JCheckBox liveCB; |
---|
971 | | - JCheckBox selectCB; |
---|
| 977 | + JCheckBox selectableCB; |
---|
972 | 978 | JCheckBox hideCB; |
---|
973 | 979 | JCheckBox link2masterCB; |
---|
974 | 980 | JCheckBox markCB; |
---|
.. | .. |
---|
1180 | 1186 | |
---|
1181 | 1187 | liveCB = AddCheckBox(setupPanel, "Live", copy.live); |
---|
1182 | 1188 | liveCB.setToolTipText("Animate object"); |
---|
1183 | | - selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect); |
---|
1184 | | - selectCB.setToolTipText("Make object selectable"); |
---|
| 1189 | + selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect); |
---|
| 1190 | + selectableCB.setToolTipText("Make object selectable"); |
---|
1185 | 1191 | // Return(); |
---|
| 1192 | + |
---|
1186 | 1193 | hideCB = AddCheckBox(setupPanel, "Hide", copy.hide); |
---|
1187 | 1194 | hideCB.setToolTipText("Hide object"); |
---|
1188 | 1195 | markCB = AddCheckBox(setupPanel, "Mark", copy.marked); |
---|
.. | .. |
---|
1474 | 1481 | XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll); |
---|
1475 | 1482 | XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll); |
---|
1476 | 1483 | XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll); |
---|
| 1484 | + //XYZPanel.setName("XYZ"); |
---|
1477 | 1485 | |
---|
1478 | 1486 | /* |
---|
1479 | 1487 | gridPanel = new JPanel(); //new BorderLayout()); |
---|
.. | .. |
---|
1511 | 1519 | //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); |
---|
1512 | 1520 | //tmp.setName("Edit"); |
---|
1513 | 1521 | objectPanel.add(materialPanel); |
---|
| 1522 | + objectPanel.setIconAt(0, GetIcon("icons/material.png")); |
---|
1514 | 1523 | // JPanel north = new JPanel(new BorderLayout()); |
---|
1515 | 1524 | // north.setName("Edit"); |
---|
1516 | 1525 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1517 | 1526 | // objectPanel.add(north); |
---|
1518 | 1527 | objectPanel.add(editPanel); |
---|
| 1528 | + objectPanel.setIconAt(1, GetIcon("icons/write.png")); |
---|
1519 | 1529 | |
---|
1520 | 1530 | //if (Globals.ADVANCED) |
---|
1521 | 1531 | objectPanel.add(infoPanel); |
---|
| 1532 | + objectPanel.setIconAt(2, GetIcon("icons/info.png")); |
---|
| 1533 | + |
---|
| 1534 | + objectPanel.add(XYZPanel); |
---|
| 1535 | + objectPanel.setIconAt(3, GetIcon("icons/XYZ.png")); |
---|
1522 | 1536 | |
---|
1523 | 1537 | objectPanel.add(toolboxPanel); |
---|
| 1538 | + objectPanel.setIconAt(4, GetIcon("icons/primitives.png")); |
---|
1524 | 1539 | |
---|
1525 | 1540 | /* |
---|
1526 | 1541 | aConstraints.gridx = 0; |
---|
.. | .. |
---|
1541 | 1556 | scrollpane.addMouseWheelListener(this); // Default not fast enough |
---|
1542 | 1557 | |
---|
1543 | 1558 | /*JTabbedPane*/ scenePanel = new cGridBag(); |
---|
1544 | | - scenePanel.preferredWidth = 6; |
---|
| 1559 | + scenePanel.preferredWidth = 5; |
---|
1545 | 1560 | |
---|
1546 | 1561 | JTabbedPane tabbedPane = new JTabbedPane(); |
---|
1547 | 1562 | tabbedPane.add(scrollpane); |
---|
.. | .. |
---|
1617 | 1632 | /**/ |
---|
1618 | 1633 | |
---|
1619 | 1634 | bigThree = new cGridBag(); |
---|
1620 | | - bigThree.addComponent(scenePanel); |
---|
1621 | 1635 | bigThree.addComponent(centralPanel); |
---|
1622 | | - bigThree.addComponent(XYZPanel); |
---|
| 1636 | + bigThree.addComponent(scenePanel); |
---|
| 1637 | + //bigThree.addComponent(XYZPanel); |
---|
1623 | 1638 | |
---|
1624 | 1639 | // // SIDE EFFECT!!! |
---|
1625 | 1640 | // aConstraints.gridx = 0; |
---|
.. | .. |
---|
3236 | 3251 | { |
---|
3237 | 3252 | copy.live ^= true; |
---|
3238 | 3253 | return; |
---|
3239 | | - } else if (event.getSource() == selectCB) |
---|
| 3254 | + } else if (event.getSource() == selectableCB) |
---|
3240 | 3255 | { |
---|
3241 | 3256 | copy.dontselect ^= true; |
---|
3242 | 3257 | return; |
---|
.. | .. |
---|
3731 | 3746 | cButton replaceButton; |
---|
3732 | 3747 | cButton redoButton; |
---|
3733 | 3748 | |
---|
| 3749 | + boolean muteSlider; |
---|
| 3750 | + |
---|
| 3751 | + int VersionCount() |
---|
| 3752 | + { |
---|
| 3753 | + int count = 0; |
---|
| 3754 | + |
---|
| 3755 | + for (int i = copy.versions.length; --i >= 0;) |
---|
| 3756 | + { |
---|
| 3757 | + if (copy.versions[i] != null) |
---|
| 3758 | + count++; |
---|
| 3759 | + } |
---|
| 3760 | + |
---|
| 3761 | + return count; |
---|
| 3762 | + } |
---|
| 3763 | + |
---|
3734 | 3764 | void SetUndoStates() |
---|
3735 | 3765 | { |
---|
3736 | 3766 | cRadio tab = GetCurrentTab(); |
---|
3737 | 3767 | |
---|
3738 | 3768 | restoreButton.setEnabled(copy.versionindex != -1); |
---|
3739 | 3769 | replaceButton.setEnabled(copy.versionindex != -1); |
---|
| 3770 | + |
---|
3740 | 3771 | undoButton.setEnabled(copy.versionindex > 0); |
---|
3741 | 3772 | redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null); |
---|
| 3773 | + |
---|
| 3774 | + muteSlider = true; |
---|
| 3775 | + versionSlider.setMaximum(VersionCount() - 1); |
---|
| 3776 | + versionSlider.setInteger(copy.versionindex); |
---|
| 3777 | + muteSlider = false; |
---|
3742 | 3778 | } |
---|
3743 | 3779 | |
---|
3744 | 3780 | public boolean Undo() |
---|
3745 | 3781 | { |
---|
| 3782 | + // Option? |
---|
| 3783 | + Replace(); |
---|
| 3784 | + |
---|
3746 | 3785 | System.err.println("Undo"); |
---|
3747 | 3786 | |
---|
3748 | 3787 | cRadio tab = GetCurrentTab(); |
---|
.. | .. |
---|
3809 | 3848 | |
---|
3810 | 3849 | public void Redo() |
---|
3811 | 3850 | { |
---|
| 3851 | + // Option? |
---|
| 3852 | + Replace(); |
---|
| 3853 | + |
---|
3812 | 3854 | cRadio tab = GetCurrentTab(); |
---|
3813 | 3855 | |
---|
3814 | 3856 | if (copy.versions[copy.versionindex + 1] == null) |
---|
.. | .. |
---|
4118 | 4160 | //copy.Touch(); |
---|
4119 | 4161 | } |
---|
4120 | 4162 | |
---|
4121 | | - cNumberSlider versionField; |
---|
| 4163 | + cNumberSlider versionSlider; |
---|
4122 | 4164 | |
---|
4123 | 4165 | public void stateChanged(ChangeEvent e) |
---|
4124 | 4166 | { |
---|
4125 | 4167 | // assert(false); |
---|
4126 | | - if (e.getSource() == versionField) |
---|
| 4168 | + if (e.getSource() == versionSlider) |
---|
4127 | 4169 | { |
---|
4128 | | - int version = versionField.getInteger(); |
---|
| 4170 | + if (muteSlider) |
---|
| 4171 | + return; |
---|
| 4172 | + |
---|
| 4173 | + int version = versionSlider.getInteger(); |
---|
4129 | 4174 | |
---|
4130 | 4175 | if (copy.versions[version] != null) |
---|
4131 | 4176 | { |
---|
.. | .. |
---|
4724 | 4769 | readobj.ResetDisplayList(); |
---|
4725 | 4770 | } catch (Exception e) |
---|
4726 | 4771 | { |
---|
4727 | | - //e.printStackTrace(); |
---|
| 4772 | + if (!e.toString().contains("GZIP")) |
---|
| 4773 | + e.printStackTrace(); |
---|
| 4774 | + |
---|
4728 | 4775 | try |
---|
4729 | 4776 | { |
---|
4730 | 4777 | java.io.FileInputStream istream = new java.io.FileInputStream(fullname); |
---|
.. | .. |
---|
4844 | 4891 | } |
---|
4845 | 4892 | } catch (ClassCastException e) |
---|
4846 | 4893 | { |
---|
| 4894 | + e.printStackTrace(); |
---|
4847 | 4895 | assert (false); |
---|
4848 | 4896 | Composite c = (Composite) copy; |
---|
4849 | 4897 | c.children.clear(); |
---|
.. | .. |
---|
4857 | 4905 | copy.versions = readobj.versions; |
---|
4858 | 4906 | copy.versionindex = readobj.versionindex; |
---|
4859 | 4907 | |
---|
4860 | | - SetUndoStates(); |
---|
| 4908 | + if (copy.versions == null) |
---|
| 4909 | + { |
---|
| 4910 | + copy.versions = new byte[100][]; |
---|
| 4911 | + copy.versionindex = -1; |
---|
| 4912 | + } |
---|
| 4913 | + |
---|
| 4914 | + //? SetUndoStates(); |
---|
4861 | 4915 | |
---|
4862 | 4916 | ResetModel(); |
---|
4863 | 4917 | copy.HardTouch(); // recompile? |
---|
.. | .. |
---|
4968 | 5022 | //ps.print(buffer.toString()); |
---|
4969 | 5023 | } catch (IOException e) |
---|
4970 | 5024 | { |
---|
| 5025 | + e.printStackTrace(); |
---|
4971 | 5026 | } |
---|
4972 | 5027 | } |
---|
4973 | 5028 | |
---|