Normand Briere
2019-06-24 914255f70cf047897212839cbf3a6722703f4457
ObjEditor.java
....@@ -4,6 +4,7 @@
44
55 import java.awt.*;
66 import java.awt.event.*;
7
+import java.awt.image.BufferedImage;
78 import javax.swing.*;
89 import javax.swing.event.*;
910 import javax.swing.text.*;
....@@ -35,6 +36,54 @@
3536
3637 GroupEditor callee;
3738 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
+ }
3887
3988 // SCRIPT
4089
....@@ -169,7 +218,7 @@
169218
170219 objEditor.ctrlPanel.remove(setupPanel);
171220 objEditor.ctrlPanel.remove(setupPanel2);
172
- objEditor.ctrlPanel.remove(commandsPanel);
221
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
173222 objEditor.ctrlPanel.remove(pushPanel);
174223 //objEditor.ctrlPanel.remove(fillPanel);
175224
....@@ -244,6 +293,7 @@
244293 //localCopy.parent = null;
245294
246295 frame = new JFrame();
296
+ frame.setUndecorated(true);
247297 objEditor = this;
248298 this.callee = callee;
249299
....@@ -324,9 +374,18 @@
324374 toolbarPanel.setName("Toolbar");
325375 treePanel = new cGridBag();
326376 treePanel.setName("Tree");
377
+
378
+ editPanel = new cGridBag().setVertical(true);
379
+ editPanel.setName("Edit");
380
+
327381 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
328
- ctrlPanel.setName("Edit");
382
+
383
+ editCommandsPanel = new cGridBag();
384
+ editPanel.add(editCommandsPanel);
385
+ editPanel.add(ctrlPanel);
386
+
329387 materialPanel = new cGridBag().setVertical(true);
388
+
330389 materialPanel.setName("Material");
331390 /*JTextPane*/
332391 infoarea = createTextPane();
....@@ -583,19 +642,89 @@
583642 }
584643 }
585644
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
+
586685 void ToggleFullScreen()
587686 {
588687 if (CameraPane.FULLSCREEN)
589688 {
590
- frame.getContentPane().remove(/*"Center",*/bigThree);
591
- framePanel.add(bigThree);
592
- 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
+
593707 } else
594708 {
595
- frame.getContentPane().remove(/*"Center",*/framePanel);
596
- framePanel.remove(bigThree);
597
- 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);
598726 }
727
+
599728 cameraView.ToggleFullScreen();
600729 }
601730
....@@ -746,10 +875,13 @@
746875 JButton fasterButton;
747876 JButton remarkButton;
748877
878
+ cGridBag editPanel;
879
+ cGridBag editCommandsPanel;
880
+
749881 cGridBag namePanel;
750882 cGridBag setupPanel;
751883 cGridBag setupPanel2;
752
- cGridBag commandsPanel;
884
+ cGridBag objectCommandsPanel;
753885 cGridBag pushPanel;
754886 cGridBag fillPanel;
755887
....@@ -947,7 +1079,7 @@
9471079 rewindCB.setToolTipText("Rewind animation");
9481080
9491081 randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
950
- randomCB.setToolTipText("Rewind or Go back and forth randomly");
1082
+ randomCB.setToolTipText("Randomly Rewind or Go back and forth");
9511083
9521084 if (Globals.ADVANCED)
9531085 {
....@@ -962,23 +1094,23 @@
9621094 oe.ctrlPanel.add(setupPanel2);
9631095 oe.ctrlPanel.Return();
9641096
965
- commandsPanel = new cGridBag().setVertical(false);
1097
+ objectCommandsPanel = new cGridBag().setVertical(false);
9661098
967
- resetButton = AddButton(commandsPanel, "Reset");
1099
+ resetButton = AddButton(objectCommandsPanel, "Reset");
9681100 resetButton.setToolTipText("Jump to frame zero");
969
- stepButton = AddButton(commandsPanel, "Step");
1101
+ stepButton = AddButton(objectCommandsPanel, "Step");
9701102 stepButton.setToolTipText("Step one frame");
9711103 // resetAllButton = AddButton(oe, "Reset All");
9721104 // stepAllButton = AddButton(oe, "Step All");
9731105 // Return();
974
- slowerButton = AddButton(commandsPanel, "Slow");
1106
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
9751107 slowerButton.setToolTipText("Decrease animation speed");
976
- fasterButton = AddButton(commandsPanel, "Fast");
1108
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
9771109 fasterButton.setToolTipText("Increase animation speed");
978
- remarkButton = AddButton(commandsPanel, "Remark");
1110
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
9791111 remarkButton.setToolTipText("Set the current transform as the target");
9801112
981
- oe.ctrlPanel.add(commandsPanel);
1113
+ oe.ctrlPanel.add(objectCommandsPanel);
9821114 oe.ctrlPanel.Return();
9831115
9841116 pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
....@@ -1184,8 +1316,11 @@
11841316 //worldPanel.setName("World");
11851317 centralPanel = new cGridBag();
11861318 centralPanel.preferredWidth = 20;
1187
- timelinePanel = new JPanel(new BorderLayout());
1188
- 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);
11891324
11901325 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11911326 cameraPanel.setContinuousLayout(true);
....@@ -1194,7 +1329,10 @@
11941329 // cameraPanel.setDividerSize(9);
11951330 cameraPanel.setResizeWeight(1.0);
11961331
1332
+ }
1333
+
11971334 centralPanel.add(cameraView);
1335
+ centralPanel.setFocusable(true);
11981336 //frame.setJMenuBar(timelineMenubar);
11991337 //centralPanel.add(timelinePanel);
12001338
....@@ -1261,7 +1399,7 @@
12611399 // north.setName("Edit");
12621400 // north.add(ctrlPanel, BorderLayout.NORTH);
12631401 // objectPanel.add(north);
1264
- objectPanel.add(ctrlPanel);
1402
+ objectPanel.add(editPanel);
12651403 objectPanel.add(infoPanel);
12661404
12671405 /*
....@@ -1392,6 +1530,8 @@
13921530 frame.setSize(1280, 860);
13931531 frame.setVisible(true);
13941532
1533
+ cameraView.requestFocusInWindow();
1534
+
13951535 gridPanel.setDividerLocation(1.0);
13961536
13971537 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
....@@ -3315,6 +3455,8 @@
33153455
33163456 public void Save()
33173457 {
3458
+ System.err.println("Save");
3459
+
33183460 cRadio tab = GetCurrentTab();
33193461
33203462 boolean temp = CameraPane.SWITCH;
....@@ -3399,6 +3541,8 @@
33993541
34003542 public void Undo()
34013543 {
3544
+ System.err.println("Undo");
3545
+
34023546 cRadio tab = GetCurrentTab();
34033547
34043548 if (tab.undoindex == 0)
....@@ -4077,7 +4221,8 @@
40774221
40784222 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
40794223 {
4080
- Save();
4224
+ if (Globals.SAVEONMAKE)
4225
+ Save();
40814226 //Tween.set(thing, 0).target(1).start(tweenManager);
40824227 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
40834228 // if (thing instanceof GenericJointDemo)
....@@ -4386,6 +4531,7 @@
43864531
43874532 if (readobj != null)
43884533 {
4534
+ if (Globals.SAVEONMAKE)
43894535 Save();
43904536 try
43914537 {