.. | .. |
---|
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 | + cCheckBox GetCheckBox(String name, boolean border) |
---|
| 56 | + { |
---|
| 57 | + try |
---|
| 58 | + { |
---|
| 59 | + ImageIcon icon = GetIcon(name); |
---|
| 60 | + return new cCheckBox(icon, border); |
---|
| 61 | + } |
---|
| 62 | + catch (Exception e) |
---|
| 63 | + { |
---|
| 64 | + return new cCheckBox(name, border); |
---|
| 65 | + } |
---|
| 66 | + } |
---|
| 67 | + |
---|
| 68 | + private ImageIcon GetIcon(String name) throws IOException |
---|
| 69 | + { |
---|
| 70 | + BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); |
---|
| 71 | + |
---|
| 72 | + if (image.getWidth() != 24 && image.getHeight() != 24) |
---|
| 73 | + { |
---|
| 74 | + BufferedImage resized = new BufferedImage(24, 24, image.getType()); |
---|
| 75 | + Graphics2D g = resized.createGraphics(); |
---|
| 76 | + g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); |
---|
| 77 | + //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
---|
| 78 | + g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null); |
---|
| 79 | + g.dispose(); |
---|
| 80 | + |
---|
| 81 | + image = resized; |
---|
| 82 | + } |
---|
| 83 | + |
---|
| 84 | + javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image); |
---|
| 85 | + return icon; |
---|
| 86 | + } |
---|
38 | 87 | |
---|
39 | 88 | // SCRIPT |
---|
40 | 89 | |
---|
.. | .. |
---|
168 | 217 | // objEditor.ctrlPanel.remove(remarkButton); |
---|
169 | 218 | |
---|
170 | 219 | objEditor.ctrlPanel.remove(setupPanel); |
---|
171 | | - objEditor.ctrlPanel.remove(commandsPanel); |
---|
| 220 | + objEditor.ctrlPanel.remove(setupPanel2); |
---|
| 221 | + objEditor.ctrlPanel.remove(objectCommandsPanel); |
---|
172 | 222 | objEditor.ctrlPanel.remove(pushPanel); |
---|
173 | 223 | //objEditor.ctrlPanel.remove(fillPanel); |
---|
174 | 224 | |
---|
.. | .. |
---|
243 | 293 | //localCopy.parent = null; |
---|
244 | 294 | |
---|
245 | 295 | frame = new JFrame(); |
---|
| 296 | + frame.setUndecorated(true); |
---|
246 | 297 | objEditor = this; |
---|
247 | 298 | this.callee = callee; |
---|
248 | 299 | |
---|
.. | .. |
---|
278 | 329 | frame.setMenuBar(menuBar = new MenuBar()); |
---|
279 | 330 | menuBar.add(fileMenu = new Menu("File")); |
---|
280 | 331 | fileMenu.add(newItem = new MenuItem("New")); |
---|
281 | | - fileMenu.add(loadItem = new MenuItem("Load...")); |
---|
| 332 | + fileMenu.add(loadItem = new MenuItem("Open...")); |
---|
282 | 333 | |
---|
283 | 334 | //oe.menuBar.add(menu = new Menu("Include")); |
---|
284 | 335 | Menu menu = new Menu("Import"); |
---|
.. | .. |
---|
323 | 374 | toolbarPanel.setName("Toolbar"); |
---|
324 | 375 | treePanel = new cGridBag(); |
---|
325 | 376 | treePanel.setName("Tree"); |
---|
| 377 | + |
---|
| 378 | + editPanel = new cGridBag().setVertical(true); |
---|
| 379 | + editPanel.setName("Edit"); |
---|
| 380 | + |
---|
326 | 381 | ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout()); |
---|
327 | | - ctrlPanel.setName("Edit"); |
---|
| 382 | + |
---|
| 383 | + editCommandsPanel = new cGridBag(); |
---|
| 384 | + editPanel.add(editCommandsPanel); |
---|
| 385 | + editPanel.add(ctrlPanel); |
---|
| 386 | + |
---|
328 | 387 | materialPanel = new cGridBag().setVertical(true); |
---|
| 388 | + |
---|
329 | 389 | materialPanel.setName("Material"); |
---|
330 | 390 | /*JTextPane*/ |
---|
331 | 391 | infoarea = createTextPane(); |
---|
.. | .. |
---|
419 | 479 | e.printStackTrace(); |
---|
420 | 480 | } |
---|
421 | 481 | |
---|
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(); |
---|
| 482 | +// String selection = infoarea.getText(); |
---|
| 483 | +// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection); |
---|
| 484 | +// java.awt.datatransfer.Clipboard clipboard = |
---|
| 485 | +// Toolkit.getDefaultToolkit().getSystemClipboard(); |
---|
426 | 486 | //clipboard.setContents(data, data); |
---|
427 | 487 | } |
---|
428 | 488 | |
---|
.. | .. |
---|
582 | 642 | } |
---|
583 | 643 | } |
---|
584 | 644 | |
---|
| 645 | +static GraphicsDevice device = GraphicsEnvironment |
---|
| 646 | + .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
| 647 | + |
---|
| 648 | + Rectangle keeprect; |
---|
| 649 | + cRadio radio; |
---|
| 650 | + |
---|
| 651 | +cButton keepButton; |
---|
| 652 | + cButton twoButton; // Full 3D |
---|
| 653 | + cButton sixButton; |
---|
| 654 | + cButton threeButton; |
---|
| 655 | + cButton sevenButton; |
---|
| 656 | + cButton fourButton; // full panel |
---|
| 657 | + cButton oneButton; // full XYZ |
---|
| 658 | + //cButton currentLayout; |
---|
| 659 | + |
---|
| 660 | + boolean maximized; |
---|
| 661 | + |
---|
| 662 | + void Minimize() |
---|
| 663 | + { |
---|
| 664 | + frame.setState(Frame.ICONIFIED); |
---|
| 665 | + } |
---|
| 666 | + |
---|
| 667 | + void Maximize() |
---|
| 668 | + { |
---|
| 669 | + if (maximized) |
---|
| 670 | + { |
---|
| 671 | + frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); |
---|
| 672 | + } |
---|
| 673 | + else |
---|
| 674 | + { |
---|
| 675 | + keeprect = frame.getBounds(); |
---|
| 676 | + Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); |
---|
| 677 | + Dimension rect2 = frame.getToolkit().getScreenSize(); |
---|
| 678 | + frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height); |
---|
| 679 | +// frame.setState(Frame.MAXIMIZED_BOTH); |
---|
| 680 | + } |
---|
| 681 | + |
---|
| 682 | + maximized ^= true; |
---|
| 683 | + } |
---|
| 684 | + |
---|
585 | 685 | void ToggleFullScreen() |
---|
586 | 686 | { |
---|
587 | 687 | if (CameraPane.FULLSCREEN) |
---|
588 | 688 | { |
---|
589 | | - frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
590 | | - framePanel.add(bigThree); |
---|
591 | | - frame.getContentPane().add(/*"Center",*/framePanel); |
---|
| 689 | + device.setFullScreenWindow(null); |
---|
| 690 | + //frame.setVisible(false); |
---|
| 691 | +// frame.removeNotify(); |
---|
| 692 | +// frame.setUndecorated(false); |
---|
| 693 | +// frame.addNotify(); |
---|
| 694 | + //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height); |
---|
| 695 | + |
---|
| 696 | +// X frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
| 697 | +// X framePanel.add(bigThree); |
---|
| 698 | +// X frame.getContentPane().add(/*"Center",*/framePanel); |
---|
| 699 | + framePanel.setDividerLocation(1); |
---|
| 700 | + |
---|
| 701 | + //frame.setVisible(true); |
---|
| 702 | + radio.layout = keepButton; |
---|
| 703 | + //theFrame = null; |
---|
| 704 | + keepButton = null; |
---|
| 705 | + radio.layout.doClick(); |
---|
| 706 | + |
---|
592 | 707 | } else |
---|
593 | 708 | { |
---|
594 | | - frame.getContentPane().remove(/*"Center",*/framePanel); |
---|
595 | | - framePanel.remove(bigThree); |
---|
596 | | - frame.getContentPane().add(/*"Center",*/bigThree); |
---|
| 709 | + keepButton = radio.layout; |
---|
| 710 | + //keeprect = frame.getBounds(); |
---|
| 711 | +// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width, |
---|
| 712 | +// frame.getToolkit().getScreenSize().height); |
---|
| 713 | + //frame.setVisible(false); |
---|
| 714 | + device.setFullScreenWindow(frame); |
---|
| 715 | +// frame.removeNotify(); |
---|
| 716 | +// frame.setUndecorated(true); |
---|
| 717 | +// frame.addNotify(); |
---|
| 718 | +// X frame.getContentPane().remove(/*"Center",*/framePanel); |
---|
| 719 | +// X framePanel.remove(bigThree); |
---|
| 720 | +// X frame.getContentPane().add(/*"Center",*/bigThree); |
---|
| 721 | + framePanel.setDividerLocation(0); |
---|
| 722 | + |
---|
| 723 | + radio.layout = twoButton; |
---|
| 724 | + radio.layout.doClick(); |
---|
| 725 | + //frame.setVisible(true); |
---|
597 | 726 | } |
---|
| 727 | + |
---|
598 | 728 | cameraView.ToggleFullScreen(); |
---|
599 | 729 | } |
---|
600 | 730 | |
---|
.. | .. |
---|
745 | 875 | JButton fasterButton; |
---|
746 | 876 | JButton remarkButton; |
---|
747 | 877 | |
---|
| 878 | + cGridBag editPanel; |
---|
| 879 | + cGridBag editCommandsPanel; |
---|
| 880 | + |
---|
748 | 881 | cGridBag namePanel; |
---|
749 | 882 | cGridBag setupPanel; |
---|
750 | | - cGridBag commandsPanel; |
---|
| 883 | + cGridBag setupPanel2; |
---|
| 884 | + cGridBag objectCommandsPanel; |
---|
751 | 885 | cGridBag pushPanel; |
---|
752 | 886 | cGridBag fillPanel; |
---|
753 | 887 | |
---|
.. | .. |
---|
939 | 1073 | markCB = AddCheckBox(setupPanel, "Mark", copy.marked); |
---|
940 | 1074 | markCB.setToolTipText("Set the animation target transform"); |
---|
941 | 1075 | |
---|
942 | | - rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind); |
---|
| 1076 | + setupPanel2 = new cGridBag().setVertical(false); |
---|
| 1077 | + |
---|
| 1078 | + rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind); |
---|
943 | 1079 | rewindCB.setToolTipText("Rewind animation"); |
---|
944 | 1080 | |
---|
945 | | - randomCB = AddCheckBox(setupPanel, "Random", copy.random); |
---|
946 | | - randomCB.setToolTipText("Option for switch node"); |
---|
| 1081 | + randomCB = AddCheckBox(setupPanel2, "Rand", copy.random); |
---|
| 1082 | + randomCB.setToolTipText("Randomly Rewind or Go back and forth"); |
---|
947 | 1083 | |
---|
948 | 1084 | if (Globals.ADVANCED) |
---|
949 | 1085 | { |
---|
950 | | - link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master); |
---|
| 1086 | + link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); |
---|
951 | 1087 | link2masterCB.setToolTipText("Attach to support"); |
---|
952 | | - speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup); |
---|
| 1088 | + speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
953 | 1089 | speedupCB.setToolTipText("Option motion capture"); |
---|
954 | 1090 | } |
---|
955 | 1091 | |
---|
956 | 1092 | oe.ctrlPanel.add(setupPanel); |
---|
957 | 1093 | oe.ctrlPanel.Return(); |
---|
| 1094 | + oe.ctrlPanel.add(setupPanel2); |
---|
| 1095 | + oe.ctrlPanel.Return(); |
---|
958 | 1096 | |
---|
959 | | - commandsPanel = new cGridBag().setVertical(false); |
---|
| 1097 | + objectCommandsPanel = new cGridBag().setVertical(false); |
---|
960 | 1098 | |
---|
961 | | - resetButton = AddButton(commandsPanel, "Reset"); |
---|
| 1099 | + resetButton = AddButton(objectCommandsPanel, "Reset"); |
---|
962 | 1100 | resetButton.setToolTipText("Jump to frame zero"); |
---|
963 | | - stepButton = AddButton(commandsPanel, "Step"); |
---|
| 1101 | + stepButton = AddButton(objectCommandsPanel, "Step"); |
---|
964 | 1102 | stepButton.setToolTipText("Step one frame"); |
---|
965 | 1103 | // resetAllButton = AddButton(oe, "Reset All"); |
---|
966 | 1104 | // stepAllButton = AddButton(oe, "Step All"); |
---|
967 | 1105 | // Return(); |
---|
968 | | - slowerButton = AddButton(commandsPanel, "Slow"); |
---|
| 1106 | + slowerButton = AddButton(objectCommandsPanel, "Slow"); |
---|
969 | 1107 | slowerButton.setToolTipText("Decrease animation speed"); |
---|
970 | | - fasterButton = AddButton(commandsPanel, "Fast"); |
---|
| 1108 | + fasterButton = AddButton(objectCommandsPanel, "Fast"); |
---|
971 | 1109 | fasterButton.setToolTipText("Increase animation speed"); |
---|
972 | | - remarkButton = AddButton(commandsPanel, "Remark"); |
---|
| 1110 | + remarkButton = AddButton(objectCommandsPanel, "Remark"); |
---|
973 | 1111 | remarkButton.setToolTipText("Set the current transform as the target"); |
---|
974 | 1112 | |
---|
975 | | - oe.ctrlPanel.add(commandsPanel); |
---|
| 1113 | + oe.ctrlPanel.add(objectCommandsPanel); |
---|
976 | 1114 | oe.ctrlPanel.Return(); |
---|
977 | 1115 | |
---|
978 | 1116 | pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons |
---|
.. | .. |
---|
1178 | 1316 | //worldPanel.setName("World"); |
---|
1179 | 1317 | centralPanel = new cGridBag(); |
---|
1180 | 1318 | centralPanel.preferredWidth = 20; |
---|
1181 | | - timelinePanel = new JPanel(new BorderLayout()); |
---|
1182 | | - timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel); |
---|
| 1319 | + |
---|
| 1320 | + if (Globals.ADVANCED) |
---|
| 1321 | + { |
---|
| 1322 | + timelinePanel = new JPanel(new BorderLayout()); |
---|
| 1323 | + timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel); |
---|
1183 | 1324 | |
---|
1184 | 1325 | cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel); |
---|
1185 | 1326 | cameraPanel.setContinuousLayout(true); |
---|
.. | .. |
---|
1188 | 1329 | // cameraPanel.setDividerSize(9); |
---|
1189 | 1330 | cameraPanel.setResizeWeight(1.0); |
---|
1190 | 1331 | |
---|
| 1332 | + } |
---|
| 1333 | + |
---|
1191 | 1334 | centralPanel.add(cameraView); |
---|
| 1335 | + centralPanel.setFocusable(true); |
---|
1192 | 1336 | //frame.setJMenuBar(timelineMenubar); |
---|
1193 | 1337 | //centralPanel.add(timelinePanel); |
---|
1194 | 1338 | |
---|
.. | .. |
---|
1255 | 1399 | // north.setName("Edit"); |
---|
1256 | 1400 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1257 | 1401 | // objectPanel.add(north); |
---|
1258 | | - objectPanel.add(ctrlPanel); |
---|
| 1402 | + objectPanel.add(editPanel); |
---|
1259 | 1403 | objectPanel.add(infoPanel); |
---|
1260 | 1404 | |
---|
1261 | 1405 | /* |
---|
.. | .. |
---|
1386 | 1530 | frame.setSize(1280, 860); |
---|
1387 | 1531 | frame.setVisible(true); |
---|
1388 | 1532 | |
---|
| 1533 | + cameraView.requestFocusInWindow(); |
---|
| 1534 | + |
---|
1389 | 1535 | gridPanel.setDividerLocation(1.0); |
---|
1390 | 1536 | |
---|
1391 | 1537 | frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
---|
.. | .. |
---|
1935 | 2081 | e2.printStackTrace(); |
---|
1936 | 2082 | } |
---|
1937 | 2083 | } |
---|
| 2084 | + |
---|
1938 | 2085 | LoadJMEThread loadThread; |
---|
1939 | 2086 | |
---|
1940 | 2087 | class LoadJMEThread extends Thread |
---|
.. | .. |
---|
1992 | 2139 | //LoadFile0(filename, converter); |
---|
1993 | 2140 | } |
---|
1994 | 2141 | } |
---|
| 2142 | + |
---|
1995 | 2143 | LoadOBJThread loadObjThread; |
---|
1996 | 2144 | |
---|
1997 | 2145 | class LoadOBJThread extends Thread |
---|
.. | .. |
---|
2070 | 2218 | |
---|
2071 | 2219 | void LoadObjFile(String fullname) |
---|
2072 | 2220 | { |
---|
2073 | | - /* |
---|
| 2221 | + System.out.println("Loading " + fullname); |
---|
| 2222 | + /**/ |
---|
2074 | 2223 | //lastFilename = fullname; |
---|
2075 | 2224 | if(loadObjThread == null) |
---|
2076 | 2225 | { |
---|
2077 | | - loadObjThread = new LoadOBJThread(); |
---|
2078 | | - loadObjThread.start(); |
---|
| 2226 | + loadObjThread = new LoadOBJThread(); |
---|
| 2227 | + loadObjThread.start(); |
---|
2079 | 2228 | } |
---|
2080 | 2229 | |
---|
2081 | 2230 | loadObjThread.add(fullname); |
---|
2082 | | - */ |
---|
| 2231 | + /**/ |
---|
2083 | 2232 | |
---|
2084 | | - System.out.println("Loading " + fullname); |
---|
2085 | | - makeSomething(new FileObject(fullname, true), true); |
---|
| 2233 | + //makeSomething(new FileObject(fullname, true), true); |
---|
2086 | 2234 | } |
---|
2087 | 2235 | |
---|
2088 | 2236 | void LoadGFDFile(String fullname) |
---|
.. | .. |
---|
2925 | 3073 | return; |
---|
2926 | 3074 | } else if (event.getSource() == toggleSwitchItem) |
---|
2927 | 3075 | { |
---|
2928 | | - cameraView.ToggleRandom(); |
---|
| 3076 | + cameraView.ToggleSwitch(); |
---|
2929 | 3077 | cameraView.repaint(); |
---|
2930 | 3078 | return; |
---|
2931 | 3079 | } else if (event.getSource() == toggleHandleItem) |
---|
.. | .. |
---|
3207 | 3355 | { |
---|
3208 | 3356 | copy.remove(1); |
---|
3209 | 3357 | } |
---|
| 3358 | + |
---|
3210 | 3359 | ResetModel(); |
---|
3211 | 3360 | objEditor.refreshContents(); |
---|
3212 | 3361 | } |
---|
3213 | 3362 | |
---|
| 3363 | + static public byte[] Compress(Object3D o) |
---|
| 3364 | + { |
---|
| 3365 | + try |
---|
| 3366 | + { |
---|
| 3367 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 3368 | + java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3369 | + ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
| 3370 | + |
---|
| 3371 | + Object3D parent = o.parent; |
---|
| 3372 | + o.parent = null; |
---|
| 3373 | + |
---|
| 3374 | + out.writeObject(o); |
---|
| 3375 | + |
---|
| 3376 | + o.parent = parent; |
---|
| 3377 | + |
---|
| 3378 | + out.flush(); |
---|
| 3379 | + |
---|
| 3380 | + zstream.close(); |
---|
| 3381 | + out.close(); |
---|
| 3382 | + |
---|
| 3383 | + return baos.toByteArray(); |
---|
| 3384 | + } catch (Exception e) |
---|
| 3385 | + { |
---|
| 3386 | + System.err.println(e); |
---|
| 3387 | + return null; |
---|
| 3388 | + } |
---|
| 3389 | + } |
---|
| 3390 | + |
---|
| 3391 | + static public Object Uncompress(byte[] bytes) |
---|
| 3392 | + { |
---|
| 3393 | + System.out.println("#bytes = " + bytes.length); |
---|
| 3394 | + try |
---|
| 3395 | + { |
---|
| 3396 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
| 3397 | + java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3398 | + ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3399 | + Object obj = in.readObject(); |
---|
| 3400 | + in.close(); |
---|
| 3401 | + |
---|
| 3402 | + return obj; |
---|
| 3403 | + } catch (Exception e) |
---|
| 3404 | + { |
---|
| 3405 | + System.err.println(e); |
---|
| 3406 | + return null; |
---|
| 3407 | + } |
---|
| 3408 | + } |
---|
| 3409 | + |
---|
| 3410 | + static public Object clone(Object o) |
---|
| 3411 | + { |
---|
| 3412 | + try |
---|
| 3413 | + { |
---|
| 3414 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 3415 | + ObjectOutputStream out = new ObjectOutputStream(baos); |
---|
| 3416 | + |
---|
| 3417 | + out.writeObject(o); |
---|
| 3418 | + |
---|
| 3419 | + out.flush(); |
---|
| 3420 | + out.close(); |
---|
| 3421 | + |
---|
| 3422 | + byte[] bytes = baos.toByteArray(); |
---|
| 3423 | + |
---|
| 3424 | + System.out.println("clone = " + bytes.length); |
---|
| 3425 | + |
---|
| 3426 | + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
| 3427 | + ObjectInputStream in = new ObjectInputStream(bais); |
---|
| 3428 | + Object obj = in.readObject(); |
---|
| 3429 | + in.close(); |
---|
| 3430 | + |
---|
| 3431 | + return obj; |
---|
| 3432 | + } catch (Exception e) |
---|
| 3433 | + { |
---|
| 3434 | + System.err.println(e); |
---|
| 3435 | + return null; |
---|
| 3436 | + } |
---|
| 3437 | + } |
---|
| 3438 | + |
---|
| 3439 | + cRadio GetCurrentTab() |
---|
| 3440 | + { |
---|
| 3441 | + cRadio ab; |
---|
| 3442 | + for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) |
---|
| 3443 | + { |
---|
| 3444 | + ab = (cRadio)e.nextElement(); |
---|
| 3445 | + if(ab.GetObject() == copy) |
---|
| 3446 | + { |
---|
| 3447 | + return ab; |
---|
| 3448 | + } |
---|
| 3449 | + } |
---|
| 3450 | + |
---|
| 3451 | + return null; |
---|
| 3452 | + } |
---|
| 3453 | + |
---|
| 3454 | + java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3455 | + |
---|
| 3456 | + public void Save() |
---|
| 3457 | + { |
---|
| 3458 | + System.err.println("Save"); |
---|
| 3459 | + |
---|
| 3460 | + cRadio tab = GetCurrentTab(); |
---|
| 3461 | + |
---|
| 3462 | + boolean temp = CameraPane.SWITCH; |
---|
| 3463 | + CameraPane.SWITCH = false; |
---|
| 3464 | + |
---|
| 3465 | + copy.ExtractBigData(hashtable); |
---|
| 3466 | + |
---|
| 3467 | + //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
| 3468 | + tab.graphs[tab.undoindex++] = Compress(copy); |
---|
| 3469 | + |
---|
| 3470 | + copy.RestoreBigData(hashtable); |
---|
| 3471 | + |
---|
| 3472 | + CameraPane.SWITCH = temp; |
---|
| 3473 | + |
---|
| 3474 | + //assert(hashtable.isEmpty()); |
---|
| 3475 | + |
---|
| 3476 | + for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
| 3477 | + { |
---|
| 3478 | + tab.graphs[i] = null; |
---|
| 3479 | + } |
---|
| 3480 | + |
---|
| 3481 | + // test save |
---|
| 3482 | + if (false) |
---|
| 3483 | + { |
---|
| 3484 | + try |
---|
| 3485 | + { |
---|
| 3486 | + FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
| 3487 | + ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
| 3488 | + |
---|
| 3489 | + p.writeObject(copy); |
---|
| 3490 | + |
---|
| 3491 | + p.flush(); |
---|
| 3492 | + |
---|
| 3493 | + ostream.close(); |
---|
| 3494 | + } catch (Exception e) |
---|
| 3495 | + { |
---|
| 3496 | + e.printStackTrace(); |
---|
| 3497 | + } |
---|
| 3498 | + } |
---|
| 3499 | + } |
---|
| 3500 | + |
---|
| 3501 | + void CopyChanged(Object3D obj) |
---|
| 3502 | + { |
---|
| 3503 | + boolean temp = CameraPane.SWITCH; |
---|
| 3504 | + CameraPane.SWITCH = false; |
---|
| 3505 | + |
---|
| 3506 | + copy.ExtractBigData(hashtable); |
---|
| 3507 | + |
---|
| 3508 | + copy.clear(); |
---|
| 3509 | + |
---|
| 3510 | + for (int i=0; i<obj.Size(); i++) |
---|
| 3511 | + { |
---|
| 3512 | + copy.add(obj.get(i)); |
---|
| 3513 | + } |
---|
| 3514 | + |
---|
| 3515 | + copy.RestoreBigData(hashtable); |
---|
| 3516 | + |
---|
| 3517 | + CameraPane.SWITCH = temp; |
---|
| 3518 | + |
---|
| 3519 | + //assert(hashtable.isEmpty()); |
---|
| 3520 | + |
---|
| 3521 | + copy.Touch(); |
---|
| 3522 | + |
---|
| 3523 | + ResetModel(); |
---|
| 3524 | + copy.HardTouch(); // recompile? |
---|
| 3525 | + |
---|
| 3526 | + cRadio ab; |
---|
| 3527 | + for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();) |
---|
| 3528 | + { |
---|
| 3529 | + ab = (cRadio)e.nextElement(); |
---|
| 3530 | + Object3D test = copy.GetObject(ab.object.GetUUID()); |
---|
| 3531 | + //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID()); |
---|
| 3532 | + if (test != null) |
---|
| 3533 | + { |
---|
| 3534 | + test.editWindow = ab.object.editWindow; |
---|
| 3535 | + ab.object = test; |
---|
| 3536 | + } |
---|
| 3537 | + } |
---|
| 3538 | + |
---|
| 3539 | + refreshContents(); |
---|
| 3540 | + } |
---|
| 3541 | + |
---|
| 3542 | + public void Undo() |
---|
| 3543 | + { |
---|
| 3544 | + System.err.println("Undo"); |
---|
| 3545 | + |
---|
| 3546 | + cRadio tab = GetCurrentTab(); |
---|
| 3547 | + |
---|
| 3548 | + if (tab.undoindex == 0) |
---|
| 3549 | + { |
---|
| 3550 | + java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3551 | + return; |
---|
| 3552 | + } |
---|
| 3553 | + |
---|
| 3554 | + if (tab.graphs[tab.undoindex] == null) |
---|
| 3555 | + { |
---|
| 3556 | + Save(); |
---|
| 3557 | + tab.undoindex -= 1; |
---|
| 3558 | + } |
---|
| 3559 | + |
---|
| 3560 | + tab.undoindex -= 1; |
---|
| 3561 | + |
---|
| 3562 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3563 | + } |
---|
| 3564 | + |
---|
| 3565 | + public void Redo() |
---|
| 3566 | + { |
---|
| 3567 | + cRadio tab = GetCurrentTab(); |
---|
| 3568 | + |
---|
| 3569 | + if (tab.graphs[tab.undoindex + 1] == null) |
---|
| 3570 | + { |
---|
| 3571 | + java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3572 | + return; |
---|
| 3573 | + } |
---|
| 3574 | + |
---|
| 3575 | + tab.undoindex += 1; |
---|
| 3576 | + |
---|
| 3577 | + CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3578 | + } |
---|
| 3579 | + |
---|
3214 | 3580 | void ImportGFD() |
---|
3215 | 3581 | { |
---|
3216 | 3582 | FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD); |
---|
.. | .. |
---|
3855 | 4221 | |
---|
3856 | 4222 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
3857 | 4223 | { |
---|
| 4224 | + if (Globals.SAVEONMAKE) |
---|
| 4225 | + Save(); |
---|
3858 | 4226 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
3859 | 4227 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
3860 | 4228 | // if (thing instanceof GenericJointDemo) |
---|
.. | .. |
---|
4078 | 4446 | |
---|
4079 | 4447 | try |
---|
4080 | 4448 | { |
---|
| 4449 | + // Try compressed version first. |
---|
4081 | 4450 | java.io.FileInputStream istream = new java.io.FileInputStream(fullname); |
---|
4082 | 4451 | java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream); |
---|
4083 | 4452 | java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream); |
---|
.. | .. |
---|
4147 | 4516 | |
---|
4148 | 4517 | void LoadIt(Object obj) |
---|
4149 | 4518 | { |
---|
| 4519 | + if (obj == null) |
---|
| 4520 | + { |
---|
| 4521 | + // Invalid file |
---|
| 4522 | + return; |
---|
| 4523 | + } |
---|
| 4524 | + |
---|
4150 | 4525 | System.out.println("Loaded " + obj); |
---|
4151 | 4526 | //new Exception().printStackTrace(); |
---|
4152 | 4527 | Object3D readobj = (Object3D) obj; |
---|
.. | .. |
---|
4156 | 4531 | |
---|
4157 | 4532 | if (readobj != null) |
---|
4158 | 4533 | { |
---|
| 4534 | + if (Globals.SAVEONMAKE) |
---|
| 4535 | + Save(); |
---|
4159 | 4536 | try |
---|
4160 | 4537 | { |
---|
4161 | 4538 | //readobj.deepCopySelf(copy); |
---|