.. | .. |
---|
4 | 4 | |
---|
5 | 5 | import java.awt.*; |
---|
6 | 6 | import java.awt.event.*; |
---|
| 7 | +import java.awt.image.BufferedImage; |
---|
7 | 8 | import javax.swing.*; |
---|
8 | 9 | import javax.swing.event.*; |
---|
9 | 10 | import javax.swing.text.*; |
---|
.. | .. |
---|
35 | 36 | |
---|
36 | 37 | GroupEditor callee; |
---|
37 | 38 | JFrame frame; |
---|
| 39 | + |
---|
| 40 | + static ObjEditor theFrame; |
---|
| 41 | + |
---|
| 42 | + cButton GetButton(String name, boolean border) |
---|
| 43 | + { |
---|
| 44 | + try |
---|
| 45 | + { |
---|
| 46 | + ImageIcon icon = GetIcon(name); |
---|
| 47 | + return new cButton(icon, border); |
---|
| 48 | + } |
---|
| 49 | + catch (Exception e) |
---|
| 50 | + { |
---|
| 51 | + return new cButton(name, border); |
---|
| 52 | + } |
---|
| 53 | + } |
---|
| 54 | + |
---|
| 55 | + cToggleButton GetToggleButton(String name, boolean border) |
---|
| 56 | + { |
---|
| 57 | + try |
---|
| 58 | + { |
---|
| 59 | + ImageIcon icon = GetIcon(name); |
---|
| 60 | + return new cToggleButton(icon, border); |
---|
| 61 | + } |
---|
| 62 | + catch (Exception e) |
---|
| 63 | + { |
---|
| 64 | + return new cToggleButton(name, border); |
---|
| 65 | + } |
---|
| 66 | + } |
---|
| 67 | + |
---|
| 68 | + cCheckBox GetCheckBox(String name, boolean border) |
---|
| 69 | + { |
---|
| 70 | + try |
---|
| 71 | + { |
---|
| 72 | + ImageIcon icon = GetIcon(name); |
---|
| 73 | + return new cCheckBox(icon, border); |
---|
| 74 | + } |
---|
| 75 | + catch (Exception e) |
---|
| 76 | + { |
---|
| 77 | + return new cCheckBox(name, border); |
---|
| 78 | + } |
---|
| 79 | + } |
---|
| 80 | + |
---|
| 81 | + private ImageIcon GetIcon(String name) throws IOException |
---|
| 82 | + { |
---|
| 83 | + BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); |
---|
| 84 | + |
---|
| 85 | + if (image.getWidth() != 24 && image.getHeight() != 24) |
---|
| 86 | + { |
---|
| 87 | + BufferedImage resized = new BufferedImage(24, 24, image.getType()); |
---|
| 88 | + Graphics2D g = resized.createGraphics(); |
---|
| 89 | + g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); |
---|
| 90 | + //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
---|
| 91 | + g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null); |
---|
| 92 | + g.dispose(); |
---|
| 93 | + |
---|
| 94 | + image = resized; |
---|
| 95 | + } |
---|
| 96 | + |
---|
| 97 | + javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image); |
---|
| 98 | + return icon; |
---|
| 99 | + } |
---|
38 | 100 | |
---|
39 | 101 | // SCRIPT |
---|
40 | 102 | |
---|
.. | .. |
---|
168 | 230 | // objEditor.ctrlPanel.remove(remarkButton); |
---|
169 | 231 | |
---|
170 | 232 | objEditor.ctrlPanel.remove(setupPanel); |
---|
171 | | - objEditor.ctrlPanel.remove(commandsPanel); |
---|
| 233 | + objEditor.ctrlPanel.remove(setupPanel2); |
---|
| 234 | + objEditor.ctrlPanel.remove(objectCommandsPanel); |
---|
172 | 235 | objEditor.ctrlPanel.remove(pushPanel); |
---|
173 | 236 | //objEditor.ctrlPanel.remove(fillPanel); |
---|
174 | 237 | |
---|
.. | .. |
---|
243 | 306 | //localCopy.parent = null; |
---|
244 | 307 | |
---|
245 | 308 | frame = new JFrame(); |
---|
| 309 | + frame.setUndecorated(true); |
---|
246 | 310 | objEditor = this; |
---|
247 | 311 | this.callee = callee; |
---|
248 | 312 | |
---|
.. | .. |
---|
278 | 342 | frame.setMenuBar(menuBar = new MenuBar()); |
---|
279 | 343 | menuBar.add(fileMenu = new Menu("File")); |
---|
280 | 344 | fileMenu.add(newItem = new MenuItem("New")); |
---|
281 | | - fileMenu.add(loadItem = new MenuItem("Load...")); |
---|
| 345 | + fileMenu.add(loadItem = new MenuItem("Open...")); |
---|
282 | 346 | |
---|
283 | 347 | //oe.menuBar.add(menu = new Menu("Include")); |
---|
284 | 348 | Menu menu = new Menu("Import"); |
---|
.. | .. |
---|
323 | 387 | toolbarPanel.setName("Toolbar"); |
---|
324 | 388 | treePanel = new cGridBag(); |
---|
325 | 389 | treePanel.setName("Tree"); |
---|
| 390 | + |
---|
| 391 | + editPanel = new cGridBag().setVertical(true); |
---|
| 392 | + editPanel.setName("Edit"); |
---|
| 393 | + |
---|
326 | 394 | ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout()); |
---|
327 | | - ctrlPanel.setName("Edit"); |
---|
| 395 | + |
---|
| 396 | + editCommandsPanel = new cGridBag(); |
---|
| 397 | + editPanel.add(editCommandsPanel); |
---|
| 398 | + editPanel.add(ctrlPanel); |
---|
| 399 | + |
---|
| 400 | + toolboxPanel = new cGridBag().setVertical(false); |
---|
| 401 | + toolboxPanel.setName("Toolbox"); |
---|
| 402 | + |
---|
328 | 403 | materialPanel = new cGridBag().setVertical(true); |
---|
329 | 404 | materialPanel.setName("Material"); |
---|
| 405 | + |
---|
330 | 406 | /*JTextPane*/ |
---|
331 | 407 | infoarea = createTextPane(); |
---|
332 | 408 | doc = infoarea.getStyledDocument(); |
---|
.. | .. |
---|
419 | 495 | e.printStackTrace(); |
---|
420 | 496 | } |
---|
421 | 497 | |
---|
422 | | - String selection = infoarea.getText(); |
---|
423 | | - java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection); |
---|
424 | | - java.awt.datatransfer.Clipboard clipboard = |
---|
425 | | - Toolkit.getDefaultToolkit().getSystemClipboard(); |
---|
| 498 | +// String selection = infoarea.getText(); |
---|
| 499 | +// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection); |
---|
| 500 | +// java.awt.datatransfer.Clipboard clipboard = |
---|
| 501 | +// Toolkit.getDefaultToolkit().getSystemClipboard(); |
---|
426 | 502 | //clipboard.setContents(data, data); |
---|
427 | 503 | } |
---|
428 | 504 | |
---|
.. | .. |
---|
582 | 658 | } |
---|
583 | 659 | } |
---|
584 | 660 | |
---|
| 661 | +static GraphicsDevice device = GraphicsEnvironment |
---|
| 662 | + .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
| 663 | + |
---|
| 664 | + Rectangle keeprect; |
---|
| 665 | + cRadio radio; |
---|
| 666 | + |
---|
| 667 | +cButton keepButton; |
---|
| 668 | + cButton twoButton; // Full 3D |
---|
| 669 | + cButton sixButton; |
---|
| 670 | + cButton threeButton; |
---|
| 671 | + cButton sevenButton; |
---|
| 672 | + cButton fourButton; // full panel |
---|
| 673 | + cButton oneButton; // full XYZ |
---|
| 674 | + //cButton currentLayout; |
---|
| 675 | + |
---|
| 676 | + boolean maximized; |
---|
| 677 | + |
---|
| 678 | + cButton fullscreenLayout; |
---|
| 679 | + |
---|
| 680 | + void Minimize() |
---|
| 681 | + { |
---|
| 682 | + frame.setState(Frame.ICONIFIED); |
---|
| 683 | + } |
---|
| 684 | + |
---|
| 685 | + void Maximize() |
---|
| 686 | + { |
---|
| 687 | + if (maximized) |
---|
| 688 | + { |
---|
| 689 | + frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); |
---|
| 690 | + } |
---|
| 691 | + else |
---|
| 692 | + { |
---|
| 693 | + keeprect = frame.getBounds(); |
---|
| 694 | + Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); |
---|
| 695 | + Dimension rect2 = frame.getToolkit().getScreenSize(); |
---|
| 696 | + frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height); |
---|
| 697 | +// frame.setState(Frame.MAXIMIZED_BOTH); |
---|
| 698 | + } |
---|
| 699 | + |
---|
| 700 | + maximized ^= true; |
---|
| 701 | + } |
---|
| 702 | + |
---|
585 | 703 | void ToggleFullScreen() |
---|
586 | 704 | { |
---|
587 | 705 | if (CameraPane.FULLSCREEN) |
---|
588 | 706 | { |
---|
589 | | - frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
590 | | - framePanel.add(bigThree); |
---|
591 | | - frame.getContentPane().add(/*"Center",*/framePanel); |
---|
| 707 | + device.setFullScreenWindow(null); |
---|
| 708 | + //frame.setVisible(false); |
---|
| 709 | +// frame.removeNotify(); |
---|
| 710 | +// frame.setUndecorated(false); |
---|
| 711 | +// frame.addNotify(); |
---|
| 712 | + //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); |
---|
| 713 | + |
---|
| 714 | +// X frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
| 715 | +// X framePanel.add(bigThree); |
---|
| 716 | +// X frame.getContentPane().add(/*"Center",*/framePanel); |
---|
| 717 | + framePanel.setDividerLocation(1); |
---|
| 718 | + |
---|
| 719 | + //frame.setVisible(true); |
---|
| 720 | + radio.layout = keepButton; |
---|
| 721 | + //theFrame = null; |
---|
| 722 | + keepButton = null; |
---|
| 723 | + radio.layout.doClick(); |
---|
| 724 | + |
---|
592 | 725 | } else |
---|
593 | 726 | { |
---|
594 | | - frame.getContentPane().remove(/*"Center",*/framePanel); |
---|
595 | | - framePanel.remove(bigThree); |
---|
596 | | - frame.getContentPane().add(/*"Center",*/bigThree); |
---|
| 727 | + keepButton = radio.layout; |
---|
| 728 | + //keeprect = frame.getBounds(); |
---|
| 729 | +// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width, |
---|
| 730 | +// frame.getToolkit().getScreenSize().height); |
---|
| 731 | + //frame.setVisible(false); |
---|
| 732 | + device.setFullScreenWindow(frame); |
---|
| 733 | +// frame.removeNotify(); |
---|
| 734 | +// frame.setUndecorated(true); |
---|
| 735 | +// frame.addNotify(); |
---|
| 736 | +// X frame.getContentPane().remove(/*"Center",*/framePanel); |
---|
| 737 | +// X framePanel.remove(bigThree); |
---|
| 738 | +// X frame.getContentPane().add(/*"Center",*/bigThree); |
---|
| 739 | + framePanel.setDividerLocation(0); |
---|
| 740 | + |
---|
| 741 | + radio.layout = fullscreenLayout; |
---|
| 742 | + radio.layout.doClick(); |
---|
| 743 | + //frame.setVisible(true); |
---|
597 | 744 | } |
---|
| 745 | + |
---|
598 | 746 | cameraView.ToggleFullScreen(); |
---|
599 | 747 | } |
---|
600 | 748 | |
---|
.. | .. |
---|
745 | 893 | JButton fasterButton; |
---|
746 | 894 | JButton remarkButton; |
---|
747 | 895 | |
---|
| 896 | + cGridBag editPanel; |
---|
| 897 | + cGridBag editCommandsPanel; |
---|
| 898 | + |
---|
748 | 899 | cGridBag namePanel; |
---|
749 | 900 | cGridBag setupPanel; |
---|
750 | | - cGridBag commandsPanel; |
---|
| 901 | + cGridBag setupPanel2; |
---|
| 902 | + cGridBag objectCommandsPanel; |
---|
751 | 903 | cGridBag pushPanel; |
---|
752 | 904 | cGridBag fillPanel; |
---|
753 | 905 | |
---|
.. | .. |
---|
939 | 1091 | markCB = AddCheckBox(setupPanel, "Mark", copy.marked); |
---|
940 | 1092 | markCB.setToolTipText("Set the animation target transform"); |
---|
941 | 1093 | |
---|
942 | | - rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind); |
---|
| 1094 | + setupPanel2 = new cGridBag().setVertical(false); |
---|
| 1095 | + |
---|
| 1096 | + rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind); |
---|
943 | 1097 | rewindCB.setToolTipText("Rewind animation"); |
---|
944 | 1098 | |
---|
945 | | - randomCB = AddCheckBox(setupPanel, "Random", copy.random); |
---|
946 | | - randomCB.setToolTipText("Option for switch node"); |
---|
| 1099 | + randomCB = AddCheckBox(setupPanel2, "Rand", copy.random); |
---|
| 1100 | + randomCB.setToolTipText("Randomly Rewind or Go back and forth"); |
---|
947 | 1101 | |
---|
948 | 1102 | if (Globals.ADVANCED) |
---|
949 | 1103 | { |
---|
950 | | - link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master); |
---|
| 1104 | + link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); |
---|
951 | 1105 | link2masterCB.setToolTipText("Attach to support"); |
---|
952 | | - speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup); |
---|
| 1106 | + speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
953 | 1107 | speedupCB.setToolTipText("Option motion capture"); |
---|
954 | 1108 | } |
---|
955 | 1109 | |
---|
956 | 1110 | oe.ctrlPanel.add(setupPanel); |
---|
957 | 1111 | oe.ctrlPanel.Return(); |
---|
| 1112 | + oe.ctrlPanel.add(setupPanel2); |
---|
| 1113 | + oe.ctrlPanel.Return(); |
---|
958 | 1114 | |
---|
959 | | - commandsPanel = new cGridBag().setVertical(false); |
---|
| 1115 | + objectCommandsPanel = new cGridBag().setVertical(false); |
---|
960 | 1116 | |
---|
961 | | - resetButton = AddButton(commandsPanel, "Reset"); |
---|
| 1117 | + resetButton = AddButton(objectCommandsPanel, "Reset"); |
---|
962 | 1118 | resetButton.setToolTipText("Jump to frame zero"); |
---|
963 | | - stepButton = AddButton(commandsPanel, "Step"); |
---|
| 1119 | + stepButton = AddButton(objectCommandsPanel, "Step"); |
---|
964 | 1120 | stepButton.setToolTipText("Step one frame"); |
---|
965 | 1121 | // resetAllButton = AddButton(oe, "Reset All"); |
---|
966 | 1122 | // stepAllButton = AddButton(oe, "Step All"); |
---|
967 | 1123 | // Return(); |
---|
968 | | - slowerButton = AddButton(commandsPanel, "Slow"); |
---|
| 1124 | + slowerButton = AddButton(objectCommandsPanel, "Slow"); |
---|
969 | 1125 | slowerButton.setToolTipText("Decrease animation speed"); |
---|
970 | | - fasterButton = AddButton(commandsPanel, "Fast"); |
---|
| 1126 | + fasterButton = AddButton(objectCommandsPanel, "Fast"); |
---|
971 | 1127 | fasterButton.setToolTipText("Increase animation speed"); |
---|
972 | | - remarkButton = AddButton(commandsPanel, "Remark"); |
---|
| 1128 | + remarkButton = AddButton(objectCommandsPanel, "Remark"); |
---|
973 | 1129 | remarkButton.setToolTipText("Set the current transform as the target"); |
---|
974 | 1130 | |
---|
975 | | - oe.ctrlPanel.add(commandsPanel); |
---|
| 1131 | + oe.ctrlPanel.add(objectCommandsPanel); |
---|
976 | 1132 | oe.ctrlPanel.Return(); |
---|
977 | 1133 | |
---|
978 | 1134 | pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons |
---|
.. | .. |
---|
1178 | 1334 | //worldPanel.setName("World"); |
---|
1179 | 1335 | centralPanel = new cGridBag(); |
---|
1180 | 1336 | centralPanel.preferredWidth = 20; |
---|
1181 | | - timelinePanel = new JPanel(new BorderLayout()); |
---|
1182 | | - timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel); |
---|
| 1337 | + |
---|
| 1338 | + if (Globals.ADVANCED) |
---|
| 1339 | + { |
---|
| 1340 | + timelinePanel = new JPanel(new BorderLayout()); |
---|
| 1341 | + timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel); |
---|
1183 | 1342 | |
---|
1184 | 1343 | cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel); |
---|
1185 | 1344 | cameraPanel.setContinuousLayout(true); |
---|
.. | .. |
---|
1188 | 1347 | // cameraPanel.setDividerSize(9); |
---|
1189 | 1348 | cameraPanel.setResizeWeight(1.0); |
---|
1190 | 1349 | |
---|
| 1350 | + } |
---|
| 1351 | + |
---|
1191 | 1352 | centralPanel.add(cameraView); |
---|
| 1353 | + centralPanel.setFocusable(true); |
---|
1192 | 1354 | //frame.setJMenuBar(timelineMenubar); |
---|
1193 | 1355 | //centralPanel.add(timelinePanel); |
---|
1194 | 1356 | |
---|
.. | .. |
---|
1250 | 1412 | |
---|
1251 | 1413 | //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); |
---|
1252 | 1414 | //tmp.setName("Edit"); |
---|
| 1415 | + objectPanel.add(toolboxPanel); |
---|
1253 | 1416 | objectPanel.add(materialPanel); |
---|
1254 | 1417 | // JPanel north = new JPanel(new BorderLayout()); |
---|
1255 | 1418 | // north.setName("Edit"); |
---|
1256 | 1419 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1257 | 1420 | // objectPanel.add(north); |
---|
1258 | | - objectPanel.add(ctrlPanel); |
---|
| 1421 | + objectPanel.add(editPanel); |
---|
1259 | 1422 | objectPanel.add(infoPanel); |
---|
1260 | 1423 | |
---|
1261 | 1424 | /* |
---|
.. | .. |
---|
1386 | 1549 | frame.setSize(1280, 860); |
---|
1387 | 1550 | frame.setVisible(true); |
---|
1388 | 1551 | |
---|
| 1552 | + cameraView.requestFocusInWindow(); |
---|
| 1553 | + |
---|
1389 | 1554 | gridPanel.setDividerLocation(1.0); |
---|
1390 | 1555 | |
---|
1391 | 1556 | frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
---|
.. | .. |
---|
1935 | 2100 | e2.printStackTrace(); |
---|
1936 | 2101 | } |
---|
1937 | 2102 | } |
---|
| 2103 | + |
---|
1938 | 2104 | LoadJMEThread loadThread; |
---|
1939 | 2105 | |
---|
1940 | 2106 | class LoadJMEThread extends Thread |
---|
.. | .. |
---|
1992 | 2158 | //LoadFile0(filename, converter); |
---|
1993 | 2159 | } |
---|
1994 | 2160 | } |
---|
| 2161 | + |
---|
1995 | 2162 | LoadOBJThread loadObjThread; |
---|
1996 | 2163 | |
---|
1997 | 2164 | class LoadOBJThread extends Thread |
---|
.. | .. |
---|
2070 | 2237 | |
---|
2071 | 2238 | void LoadObjFile(String fullname) |
---|
2072 | 2239 | { |
---|
2073 | | - /* |
---|
| 2240 | + System.out.println("Loading " + fullname); |
---|
| 2241 | + /**/ |
---|
2074 | 2242 | //lastFilename = fullname; |
---|
2075 | 2243 | if(loadObjThread == null) |
---|
2076 | 2244 | { |
---|
2077 | | - loadObjThread = new LoadOBJThread(); |
---|
2078 | | - loadObjThread.start(); |
---|
| 2245 | + loadObjThread = new LoadOBJThread(); |
---|
| 2246 | + loadObjThread.start(); |
---|
2079 | 2247 | } |
---|
2080 | 2248 | |
---|
2081 | 2249 | loadObjThread.add(fullname); |
---|
2082 | | - */ |
---|
| 2250 | + /**/ |
---|
2083 | 2251 | |
---|
2084 | | - System.out.println("Loading " + fullname); |
---|
2085 | | - makeSomething(new FileObject(fullname, true), true); |
---|
| 2252 | + //makeSomething(new FileObject(fullname, true), true); |
---|
2086 | 2253 | } |
---|
2087 | 2254 | |
---|
2088 | 2255 | void LoadGFDFile(String fullname) |
---|
.. | .. |
---|
2925 | 3092 | return; |
---|
2926 | 3093 | } else if (event.getSource() == toggleSwitchItem) |
---|
2927 | 3094 | { |
---|
2928 | | - cameraView.ToggleRandom(); |
---|
| 3095 | + cameraView.ToggleSwitch(); |
---|
2929 | 3096 | cameraView.repaint(); |
---|
2930 | 3097 | return; |
---|
2931 | 3098 | } else if (event.getSource() == toggleHandleItem) |
---|
.. | .. |
---|
3212 | 3379 | objEditor.refreshContents(); |
---|
3213 | 3380 | } |
---|
3214 | 3381 | |
---|
3215 | | - Object3D graphs[] = new Object3D[10000]; |
---|
3216 | | - int undoindex = 0; |
---|
3217 | | - |
---|
3218 | | - static public Object clone(Object o) |
---|
| 3382 | + static public byte[] Compress(Object3D o) |
---|
3219 | 3383 | { |
---|
3220 | 3384 | try |
---|
3221 | 3385 | { |
---|
3222 | 3386 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3223 | | - ObjectOutputStream out = new ObjectOutputStream(baos); |
---|
| 3387 | + java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3388 | + ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
3224 | 3389 | |
---|
| 3390 | + Object3D parent = o.parent; |
---|
| 3391 | + o.parent = null; |
---|
| 3392 | + |
---|
3225 | 3393 | out.writeObject(o); |
---|
| 3394 | + |
---|
| 3395 | + o.parent = parent; |
---|
| 3396 | + |
---|
| 3397 | + out.flush(); |
---|
3226 | 3398 | |
---|
3227 | | - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); |
---|
3228 | | - ObjectInputStream in = new ObjectInputStream(bais); |
---|
| 3399 | + zstream.close(); |
---|
| 3400 | + out.close(); |
---|
| 3401 | + |
---|
| 3402 | + return baos.toByteArray(); |
---|
| 3403 | + } catch (Exception e) |
---|
| 3404 | + { |
---|
| 3405 | + System.err.println(e); |
---|
| 3406 | + return null; |
---|
| 3407 | + } |
---|
| 3408 | + } |
---|
| 3409 | + |
---|
| 3410 | + static public Object Uncompress(byte[] bytes) |
---|
| 3411 | + { |
---|
| 3412 | + System.out.println("#bytes = " + bytes.length); |
---|
| 3413 | + try |
---|
| 3414 | + { |
---|
| 3415 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
| 3416 | + java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3417 | + ObjectInputStream in = new ObjectInputStream(istream); |
---|
3229 | 3418 | Object obj = in.readObject(); |
---|
3230 | 3419 | in.close(); |
---|
3231 | | - out.close(); |
---|
| 3420 | + |
---|
3232 | 3421 | return obj; |
---|
3233 | 3422 | } catch (Exception e) |
---|
3234 | 3423 | { |
---|
.. | .. |
---|
3237 | 3426 | } |
---|
3238 | 3427 | } |
---|
3239 | 3428 | |
---|
| 3429 | + static public Object clone(Object o) |
---|
| 3430 | + { |
---|
| 3431 | + try |
---|
| 3432 | + { |
---|
| 3433 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 3434 | + ObjectOutputStream out = new ObjectOutputStream(baos); |
---|
| 3435 | + |
---|
| 3436 | + out.writeObject(o); |
---|
| 3437 | + |
---|
| 3438 | + out.flush(); |
---|
| 3439 | + out.close(); |
---|
| 3440 | + |
---|
| 3441 | + byte[] bytes = baos.toByteArray(); |
---|
| 3442 | + |
---|
| 3443 | + System.out.println("clone = " + bytes.length); |
---|
| 3444 | + |
---|
| 3445 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
| 3446 | + ObjectInputStream in = new ObjectInputStream(bais); |
---|
| 3447 | + Object obj = in.readObject(); |
---|
| 3448 | + in.close(); |
---|
| 3449 | + |
---|
| 3450 | + return obj; |
---|
| 3451 | + } catch (Exception e) |
---|
| 3452 | + { |
---|
| 3453 | + System.err.println(e); |
---|
| 3454 | + return null; |
---|
| 3455 | + } |
---|
| 3456 | + } |
---|
| 3457 | + |
---|
| 3458 | + cRadio GetCurrentTab() |
---|
| 3459 | + { |
---|
| 3460 | + cRadio ab; |
---|
| 3461 | + for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) |
---|
| 3462 | + { |
---|
| 3463 | + ab = (cRadio)e.nextElement(); |
---|
| 3464 | + if(ab.GetObject() == copy) |
---|
| 3465 | + { |
---|
| 3466 | + return ab; |
---|
| 3467 | + } |
---|
| 3468 | + } |
---|
| 3469 | + |
---|
| 3470 | + return null; |
---|
| 3471 | + } |
---|
| 3472 | + |
---|
| 3473 | + java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3474 | + |
---|
3240 | 3475 | public void Save() |
---|
3241 | 3476 | { |
---|
3242 | | - if (true) return; |
---|
| 3477 | + System.err.println("Save"); |
---|
| 3478 | + |
---|
| 3479 | + cRadio tab = GetCurrentTab(); |
---|
| 3480 | + |
---|
| 3481 | + boolean temp = CameraPane.SWITCH; |
---|
| 3482 | + CameraPane.SWITCH = false; |
---|
| 3483 | + |
---|
| 3484 | + copy.ExtractBigData(hashtable); |
---|
3243 | 3485 | |
---|
3244 | 3486 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3245 | | - graphs[undoindex++] = (Object3D)clone(copy); |
---|
| 3487 | + tab.graphs[tab.undoindex++] = Compress(copy); |
---|
3246 | 3488 | |
---|
3247 | | - for (int i = undoindex; i < graphs.length; i++) |
---|
| 3489 | + copy.RestoreBigData(hashtable); |
---|
| 3490 | + |
---|
| 3491 | + CameraPane.SWITCH = temp; |
---|
| 3492 | + |
---|
| 3493 | + //assert(hashtable.isEmpty()); |
---|
| 3494 | + |
---|
| 3495 | + for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
3248 | 3496 | { |
---|
3249 | | - graphs[i] = null; |
---|
| 3497 | + tab.graphs[i] = null; |
---|
3250 | 3498 | } |
---|
3251 | 3499 | |
---|
3252 | 3500 | // test save |
---|
.. | .. |
---|
3254 | 3502 | { |
---|
3255 | 3503 | try |
---|
3256 | 3504 | { |
---|
3257 | | - FileOutputStream ostream = new FileOutputStream("save" + undoindex); |
---|
| 3505 | + FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
3258 | 3506 | ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
3259 | 3507 | |
---|
3260 | 3508 | p.writeObject(copy); |
---|
.. | .. |
---|
3269 | 3517 | } |
---|
3270 | 3518 | } |
---|
3271 | 3519 | |
---|
| 3520 | + void CopyChanged(Object3D obj) |
---|
| 3521 | + { |
---|
| 3522 | + boolean temp = CameraPane.SWITCH; |
---|
| 3523 | + CameraPane.SWITCH = false; |
---|
| 3524 | + |
---|
| 3525 | + copy.ExtractBigData(hashtable); |
---|
| 3526 | + |
---|
| 3527 | + copy.clear(); |
---|
| 3528 | + |
---|
| 3529 | + for (int i=0; i<obj.Size(); i++) |
---|
| 3530 | + { |
---|
| 3531 | + copy.add(obj.get(i)); |
---|
| 3532 | + } |
---|
| 3533 | + |
---|
| 3534 | + copy.RestoreBigData(hashtable); |
---|
| 3535 | + |
---|
| 3536 | + CameraPane.SWITCH = temp; |
---|
| 3537 | + |
---|
| 3538 | + //assert(hashtable.isEmpty()); |
---|
| 3539 | + |
---|
| 3540 | + copy.Touch(); |
---|
| 3541 | + |
---|
| 3542 | + ResetModel(); |
---|
| 3543 | + copy.HardTouch(); // recompile? |
---|
| 3544 | + |
---|
| 3545 | + cRadio ab; |
---|
| 3546 | + for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) |
---|
| 3547 | + { |
---|
| 3548 | + ab = (cRadio)e.nextElement(); |
---|
| 3549 | + Object3D test = copy.GetObject(ab.object.GetUUID()); |
---|
| 3550 | + //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID()); |
---|
| 3551 | + if (test != null) |
---|
| 3552 | + { |
---|
| 3553 | + test.editWindow = ab.object.editWindow; |
---|
| 3554 | + ab.object = test; |
---|
| 3555 | + } |
---|
| 3556 | + } |
---|
| 3557 | + |
---|
| 3558 | + refreshContents(); |
---|
| 3559 | + } |
---|
| 3560 | + |
---|
3272 | 3561 | public void Undo() |
---|
3273 | 3562 | { |
---|
3274 | | - if (undoindex == 0) |
---|
| 3563 | + System.err.println("Undo"); |
---|
| 3564 | + |
---|
| 3565 | + cRadio tab = GetCurrentTab(); |
---|
| 3566 | + |
---|
| 3567 | + if (tab.undoindex == 0) |
---|
3275 | 3568 | { |
---|
3276 | 3569 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3277 | 3570 | return; |
---|
3278 | 3571 | } |
---|
3279 | 3572 | |
---|
3280 | | - if (graphs[undoindex] == null) |
---|
| 3573 | + if (tab.graphs[tab.undoindex] == null) |
---|
3281 | 3574 | { |
---|
3282 | 3575 | Save(); |
---|
3283 | | - undoindex -= 1; |
---|
| 3576 | + tab.undoindex -= 1; |
---|
3284 | 3577 | } |
---|
3285 | 3578 | |
---|
3286 | | - undoindex -= 1; |
---|
| 3579 | + tab.undoindex -= 1; |
---|
3287 | 3580 | |
---|
3288 | | - copy = graphs[undoindex]; |
---|
3289 | | - |
---|
3290 | | - cameraView.object = copy; |
---|
3291 | | - copy.Touch(); |
---|
3292 | | - |
---|
3293 | | - ResetModel(); |
---|
3294 | | - refreshContents(); |
---|
| 3581 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
3295 | 3582 | } |
---|
3296 | 3583 | |
---|
3297 | 3584 | public void Redo() |
---|
3298 | 3585 | { |
---|
3299 | | - if (graphs[undoindex + 1] == null) |
---|
| 3586 | + cRadio tab = GetCurrentTab(); |
---|
| 3587 | + |
---|
| 3588 | + if (tab.graphs[tab.undoindex + 1] == null) |
---|
3300 | 3589 | { |
---|
3301 | 3590 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3302 | 3591 | return; |
---|
3303 | 3592 | } |
---|
3304 | 3593 | |
---|
3305 | | - undoindex += 1; |
---|
| 3594 | + tab.undoindex += 1; |
---|
3306 | 3595 | |
---|
3307 | | - copy = graphs[undoindex]; |
---|
3308 | | - |
---|
3309 | | - cameraView.object = copy; |
---|
3310 | | - copy.Touch(); |
---|
3311 | | - |
---|
3312 | | - ResetModel(); |
---|
3313 | | - refreshContents(); |
---|
| 3596 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
3314 | 3597 | } |
---|
3315 | 3598 | |
---|
3316 | 3599 | void ImportGFD() |
---|
.. | .. |
---|
3462 | 3745 | assert false; |
---|
3463 | 3746 | } |
---|
3464 | 3747 | |
---|
3465 | | - void EditSelection() |
---|
| 3748 | + void EditSelection(boolean newWindow) |
---|
3466 | 3749 | { |
---|
3467 | 3750 | } |
---|
3468 | 3751 | |
---|
.. | .. |
---|
3957 | 4240 | |
---|
3958 | 4241 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
3959 | 4242 | { |
---|
3960 | | - Save(); |
---|
| 4243 | + if (Globals.SAVEONMAKE) // && resetmodel) |
---|
| 4244 | + Save(); |
---|
3961 | 4245 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
3962 | 4246 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
3963 | 4247 | // if (thing instanceof GenericJointDemo) |
---|
.. | .. |
---|
4044 | 4328 | { |
---|
4045 | 4329 | ResetModel(); |
---|
4046 | 4330 | Select(thing.GetTreePath(), true, false); // unselect... false); |
---|
| 4331 | + |
---|
| 4332 | + if (thing.Size() == 0) |
---|
| 4333 | + { |
---|
| 4334 | + //EditSelection(false); |
---|
| 4335 | + } |
---|
| 4336 | + |
---|
4047 | 4337 | refreshContents(); |
---|
4048 | 4338 | } |
---|
4049 | 4339 | |
---|
.. | .. |
---|
4181 | 4471 | |
---|
4182 | 4472 | try |
---|
4183 | 4473 | { |
---|
| 4474 | + // Try compressed version first. |
---|
4184 | 4475 | java.io.FileInputStream istream = new java.io.FileInputStream(fullname); |
---|
4185 | 4476 | java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream); |
---|
4186 | 4477 | java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream); |
---|
.. | .. |
---|
4250 | 4541 | |
---|
4251 | 4542 | void LoadIt(Object obj) |
---|
4252 | 4543 | { |
---|
| 4544 | + if (obj == null) |
---|
| 4545 | + { |
---|
| 4546 | + // Invalid file |
---|
| 4547 | + return; |
---|
| 4548 | + } |
---|
| 4549 | + |
---|
4253 | 4550 | System.out.println("Loaded " + obj); |
---|
4254 | 4551 | //new Exception().printStackTrace(); |
---|
4255 | 4552 | Object3D readobj = (Object3D) obj; |
---|
.. | .. |
---|
4259 | 4556 | |
---|
4260 | 4557 | if (readobj != null) |
---|
4261 | 4558 | { |
---|
| 4559 | + if (Globals.SAVEONMAKE) |
---|
| 4560 | + Save(); |
---|
4262 | 4561 | try |
---|
4263 | 4562 | { |
---|
4264 | 4563 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
4629 | 4928 | CheckboxMenuItem togglePaintItem; |
---|
4630 | 4929 | JSplitPane mainPanel; |
---|
4631 | 4930 | JScrollPane scrollpane; |
---|
| 4931 | + |
---|
4632 | 4932 | JPanel toolbarPanel; |
---|
| 4933 | + |
---|
4633 | 4934 | cGridBag treePanel; |
---|
| 4935 | + |
---|
4634 | 4936 | JPanel radioPanel; |
---|
4635 | 4937 | ButtonGroup buttonGroup; |
---|
4636 | | - cGridBag ctrlPanel; |
---|
| 4938 | + |
---|
| 4939 | + cGridBag toolboxPanel; |
---|
4637 | 4940 | cGridBag materialPanel; |
---|
| 4941 | + cGridBag ctrlPanel; |
---|
| 4942 | + |
---|
4638 | 4943 | JScrollPane infoPanel; |
---|
| 4944 | + |
---|
4639 | 4945 | cGridBag optionsPanel; |
---|
| 4946 | + |
---|
4640 | 4947 | JTabbedPane objectPanel; |
---|
| 4948 | + |
---|
4641 | 4949 | cGridBag XYZPanel; |
---|
| 4950 | + |
---|
4642 | 4951 | JSplitPane gridPanel; |
---|
4643 | 4952 | JSplitPane bigPanel; |
---|
| 4953 | + |
---|
4644 | 4954 | cGridBag bigThree; |
---|
4645 | 4955 | cGridBag scenePanel; |
---|
4646 | 4956 | cGridBag centralPanel; |
---|
.. | .. |
---|
4755 | 5065 | cNumberSlider fogField; |
---|
4756 | 5066 | JLabel opacityPowerLabel; |
---|
4757 | 5067 | cNumberSlider opacityPowerField; |
---|
4758 | | - JTree jTree; |
---|
| 5068 | + cTree jTree; |
---|
4759 | 5069 | //ObjectUI parent; |
---|
4760 | 5070 | |
---|
4761 | 5071 | cNumberSlider normalpushField; |
---|