Normand Briere
2019-07-01 6600d22461ccc1cb602f238a9ffa83cf07dd830e
ObjEditor.java
....@@ -15,6 +15,9 @@
1515 //import javax.swing.plaf.ColorUIResource;
1616 //import javax.swing.plaf.metal.DefaultMetalTheme;
1717
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
20
+
1821 //import javax.media.opengl.GLCanvas;
1922
2023 import //weka.core.
....@@ -207,7 +210,7 @@
207210
208211 objEditor.ctrlPanel.remove(namePanel);
209212
210
- if (!GroupEditor.allparams)
213
+ if (!allparams)
211214 return;
212215
213216 // objEditor.ctrlPanel.remove(liveCB);
....@@ -306,7 +309,7 @@
306309 //localCopy.parent = null;
307310
308311 frame = new JFrame();
309
- frame.setUndecorated(true);
312
+ frame.setUndecorated(false);
310313 objEditor = this;
311314 this.callee = callee;
312315
....@@ -337,12 +340,17 @@
337340 return frame.action(event, obj);
338341 }
339342
343
+ // Cannot work without static
344
+ static boolean allparams = true;
345
+
346
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
347
+
340348 void SetupMenu()
341349 {
342350 frame.setMenuBar(menuBar = new MenuBar());
343351 menuBar.add(fileMenu = new Menu("File"));
344352 fileMenu.add(newItem = new MenuItem("New"));
345
- fileMenu.add(loadItem = new MenuItem("Open..."));
353
+ fileMenu.add(openItem = new MenuItem("Open..."));
346354
347355 //oe.menuBar.add(menu = new Menu("Include"));
348356 Menu menu = new Menu("Import");
....@@ -374,7 +382,7 @@
374382 }
375383
376384 newItem.addActionListener(this);
377
- loadItem.addActionListener(this);
385
+ openItem.addActionListener(this);
378386 saveItem.addActionListener(this);
379387 saveAsItem.addActionListener(this);
380388 exportAsItem.addActionListener(this);
....@@ -397,6 +405,11 @@
397405 // }
398406 //
399407 // materialFlushed = true;
408
+// }
409
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
410
+// {
411
+// if (listUI.size() == 0)
412
+// EditSelection(false);
400413 // }
401414
402415 refreshContents(false); // To refresh Info tab
....@@ -436,7 +449,7 @@
436449 // TEXTAREA infoarea.setLineWrap(true);
437450 // TEXTAREA infoarea.setWrapStyleWord(true);
438451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
439
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ infoPanel.setPreferredSize(new Dimension(1, 1));
440453 infoPanel.setName("Info");
441454 //infoPanel.setLayout(new BorderLayout());
442455 //infoPanel.add(createTextPane());
....@@ -448,7 +461,14 @@
448461 mainPanel.setDividerSize(9);
449462 mainPanel.setDividerLocation(0.5); //1.0);
450463 mainPanel.setResizeWeight(0.5);
451
-
464
+
465
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
466
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
467
+ divider.setDividerSize(15);
468
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
469
+
470
+ mainPanel.setUI(new BasicSplitPaneUI());
471
+
452472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
453473 //mainPanel.setLayout(new GridBagLayout());
454474 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -679,8 +699,8 @@
679699 }
680700 }
681701
682
-static GraphicsDevice device = GraphicsEnvironment
683
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
702
+//static GraphicsDevice device = GraphicsEnvironment
703
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
684704
685705 Rectangle keeprect;
686706 cRadio radio;
....@@ -701,10 +721,19 @@
701721 void Minimize()
702722 {
703723 frame.setState(Frame.ICONIFIED);
724
+ frame.validate();
704725 }
705726
727
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
728
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
729
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
706730 void Maximize()
707731 {
732
+ if (CameraPane.FULLSCREEN)
733
+ {
734
+ ToggleFullScreen();
735
+ }
736
+
708737 if (maximized)
709738 {
710739 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -712,20 +741,36 @@
712741 else
713742 {
714743 keeprect = frame.getBounds();
715
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
716
- Dimension rect2 = frame.getToolkit().getScreenSize();
717
- frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
744
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
745
+// Dimension rect2 = frame.getToolkit().getScreenSize();
746
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
718747 // frame.setState(Frame.MAXIMIZED_BOTH);
748
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
719749 }
720750
721751 maximized ^= true;
752
+
753
+ frame.validate();
722754 }
755
+
756
+ cButton minButton;
757
+ cButton maxButton;
758
+ cButton fullButton;
723759
724760 void ToggleFullScreen()
725761 {
726
- if (CameraPane.FULLSCREEN)
762
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763
+
764
+ cameraView.ToggleFullScreen();
765
+
766
+ if (!CameraPane.FULLSCREEN)
727767 {
728768 device.setFullScreenWindow(null);
769
+ frame.dispose();
770
+ frame.setUndecorated(false);
771
+ frame.validate();
772
+ frame.setVisible(true);
773
+
729774 //frame.setVisible(false);
730775 // frame.removeNotify();
731776 // frame.setUndecorated(false);
....@@ -735,7 +780,7 @@
735780 // X frame.getContentPane().remove(/*"Center",*/bigThree);
736781 // X framePanel.add(bigThree);
737782 // X frame.getContentPane().add(/*"Center",*/framePanel);
738
- framePanel.setDividerLocation(1);
783
+ framePanel.setDividerLocation(46);
739784
740785 //frame.setVisible(true);
741786 radio.layout = keepButton;
....@@ -750,7 +795,12 @@
750795 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
751796 // frame.getToolkit().getScreenSize().height);
752797 //frame.setVisible(false);
798
+
799
+ frame.dispose();
800
+ frame.setUndecorated(true);
753801 device.setFullScreenWindow(frame);
802
+ frame.validate();
803
+ frame.setVisible(true);
754804 // frame.removeNotify();
755805 // frame.setUndecorated(true);
756806 // frame.addNotify();
....@@ -763,8 +813,7 @@
763813 radio.layout.doClick();
764814 //frame.setVisible(true);
765815 }
766
-
767
- cameraView.ToggleFullScreen();
816
+ frame.validate();
768817 }
769818
770819 private JTextPane createTextPane()
....@@ -1097,12 +1146,12 @@
10971146 namePanel = new cGridBag();
10981147
10991148 nameField = AddText(namePanel, copy.GetName());
1100
- namePanel.add(nameField);
1149
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11011150 oe.ctrlPanel.add(namePanel);
11021151
11031152 oe.ctrlPanel.Return();
11041153
1105
- if (!GroupEditor.allparams)
1154
+ if (!allparams)
11061155 return;
11071156
11081157 setupPanel = new cGridBag().setVertical(false);
....@@ -1115,15 +1164,15 @@
11151164 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11161165 hideCB.setToolTipText("Hide object");
11171166 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1118
- markCB.setToolTipText("Set the animation target transform");
1167
+ markCB.setToolTipText("As animation target transform");
11191168
11201169 setupPanel2 = new cGridBag().setVertical(false);
11211170
11221171 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11231172 rewindCB.setToolTipText("Rewind animation");
11241173
1125
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1126
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1174
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1175
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11271176
11281177 if (Globals.ADVANCED)
11291178 {
....@@ -1439,13 +1488,16 @@
14391488 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14401489 //tmp.setName("Edit");
14411490 objectPanel.add(materialPanel);
1442
- objectPanel.add(toolboxPanel);
14431491 // JPanel north = new JPanel(new BorderLayout());
14441492 // north.setName("Edit");
14451493 // north.add(ctrlPanel, BorderLayout.NORTH);
14461494 // objectPanel.add(north);
14471495 objectPanel.add(editPanel);
1448
- objectPanel.add(infoPanel);
1496
+
1497
+ //if (Globals.ADVANCED)
1498
+ objectPanel.add(infoPanel);
1499
+
1500
+ objectPanel.add(toolboxPanel);
14491501
14501502 /*
14511503 aConstraints.gridx = 0;
....@@ -1454,7 +1506,7 @@
14541506 aConstraints.gridy += 1;
14551507 aConstraints.gridwidth = 1;
14561508 mainPanel.add(objectPanel, aConstraints);
1457
- */
1509
+ */
14581510
14591511 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
14601512 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1553,9 +1605,9 @@
15531605 // aConstraints.gridheight = 1;
15541606
15551607 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1556
- framePanel.setContinuousLayout(true);
1557
- framePanel.setOneTouchExpandable(true);
1558
- framePanel.setDividerLocation(0.8);
1608
+ framePanel.setContinuousLayout(false);
1609
+ framePanel.setOneTouchExpandable(false);
1610
+ //.setDividerLocation(0.8);
15591611 //framePanel.setDividerSize(15);
15601612 //framePanel.setResizeWeight(0.15);
15611613 framePanel.setName("Frame");
....@@ -1574,12 +1626,13 @@
15741626
15751627 frame.setSize(1280, 860);
15761628
1577
- frame.validate();
1578
- frame.setVisible(true);
1579
-
15801629 cameraView.requestFocusInWindow();
15811630
15821631 gridPanel.setDividerLocation(1.0);
1632
+
1633
+ frame.validate();
1634
+
1635
+ frame.setVisible(true);
15831636
15841637 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15851638 frame.addWindowListener(new WindowAdapter()
....@@ -1666,24 +1719,6 @@
16661719 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16671720 colorSection.add(texture);
16681721
1669
- cGridBag anisoU = new cGridBag();
1670
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1671
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1672
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1673
- colorSection.add(anisoU);
1674
-
1675
- cGridBag anisoV = new cGridBag();
1676
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1677
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1678
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1679
- colorSection.add(anisoV);
1680
-
1681
- cGridBag shadowbias = new cGridBag();
1682
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1683
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1684
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1685
- colorSection.add(shadowbias);
1686
-
16871722 panel.add(new JSeparator());
16881723
16891724 panel.add(colorSection);
....@@ -1733,6 +1768,12 @@
17331768 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17341769 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17351770 diffuseSection.add(fakedepth);
1771
+
1772
+ cGridBag shadowbias = new cGridBag();
1773
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1774
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1775
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1776
+ diffuseSection.add(shadowbias);
17361777
17371778 panel.add(new JSeparator());
17381779
....@@ -1784,6 +1825,18 @@
17841825 // aConstraints.gridy += 1;
17851826 // aConstraints.gridwidth = 1;
17861827
1828
+ cGridBag anisoU = new cGridBag();
1829
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1830
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1831
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1832
+ specularSection.add(anisoU);
1833
+
1834
+ cGridBag anisoV = new cGridBag();
1835
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1836
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1837
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1838
+ specularSection.add(anisoV);
1839
+
17871840
17881841 panel.add(new JSeparator());
17891842
....@@ -1791,35 +1844,35 @@
17911844
17921845 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17931846
1794
- cGridBag globalSection = new cGridBag().setVertical(true);
1847
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17951848
17961849 cGridBag camera = new cGridBag();
17971850 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17981851 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17991852 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1800
- globalSection.add(camera);
1853
+ colorSection.add(camera);
18011854
18021855 cGridBag ambient = new cGridBag();
18031856 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18041857 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18051858 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1806
- globalSection.add(ambient);
1859
+ colorSection.add(ambient);
18071860
18081861 cGridBag backlit = new cGridBag();
18091862 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18101863 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18111864 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1812
- globalSection.add(backlit);
1865
+ colorSection.add(backlit);
18131866
18141867 cGridBag opacity = new cGridBag();
18151868 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
18161869 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18171870 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1818
- globalSection.add(opacity);
1871
+ colorSection.add(opacity);
18191872
1820
- panel.add(new JSeparator());
1873
+ //panel.add(new JSeparator());
18211874
1822
- panel.add(globalSection);
1875
+ //panel.add(globalSection);
18231876
18241877 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18251878
....@@ -3007,12 +3060,17 @@
30073060 // }
30083061
30093062 /**/
3010
- if (deselect)
3063
+ if (deselect || child == null)
30113064 {
30123065 //group.deselectAll();
30133066 //freeze = true;
30143067 GetTree().clearSelection();
30153068 //freeze = false;
3069
+
3070
+ if (child == null)
3071
+ {
3072
+ return;
3073
+ }
30163074 }
30173075
30183076 //group.addSelectee(child);
....@@ -3336,9 +3394,9 @@
33363394 {
33373395 Close();
33383396 //return true;
3339
- } else if (source == loadItem)
3397
+ } else if (source == openItem)
33403398 {
3341
- load();
3399
+ Open();
33423400 //return true;
33433401 } else if (source == newItem)
33443402 {
....@@ -3363,6 +3421,10 @@
33633421 {
33643422 generatePOV();
33653423 //return true;
3424
+ } else if (event.getSource() == archiveItem)
3425
+ {
3426
+ cTools.Archive(frame);
3427
+ return;
33663428 } else if (source == zBufferItem)
33673429 {
33683430 try
....@@ -3513,8 +3575,10 @@
35133575
35143576 copy.ExtractBigData(hashtable);
35153577
3578
+ byte[] compress = Compress(copy);
3579
+
35163580 //EditorFrame.m_MainFrame.requestFocusInWindow();
3517
- tab.graphs[tab.undoindex++] = Compress(copy);
3581
+ tab.graphs[tab.undoindex++] = compress;
35183582
35193583 copy.RestoreBigData(hashtable);
35203584
....@@ -3527,6 +3591,8 @@
35273591 tab.graphs[i] = null;
35283592 }
35293593
3594
+ SetUndoStates();
3595
+
35303596 // test save
35313597 if (false)
35323598 {
....@@ -3549,6 +3615,8 @@
35493615
35503616 void CopyChanged(Object3D obj)
35513617 {
3618
+ SetUndoStates();
3619
+
35523620 boolean temp = CameraPane.SWITCH;
35533621 CameraPane.SWITCH = false;
35543622
....@@ -3586,6 +3654,17 @@
35863654 }
35873655
35883656 refreshContents();
3657
+ }
3658
+
3659
+ cButton undoButton;
3660
+ cButton redoButton;
3661
+
3662
+ void SetUndoStates()
3663
+ {
3664
+ cRadio tab = GetCurrentTab();
3665
+
3666
+ undoButton.setEnabled(tab.undoindex > 0);
3667
+ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
35893668 }
35903669
35913670 public void Undo()
....@@ -4648,7 +4727,7 @@
46484727 }
46494728 }
46504729
4651
- void load() // throws ClassNotFoundException
4730
+ void Open() // throws ClassNotFoundException
46524731 {
46534732 if (Grafreed.standAlone)
46544733 {
....@@ -4765,6 +4844,8 @@
47654844 String filename = browser.getFile();
47664845 if (filename != null && filename.length() > 0)
47674846 {
4847
+ if (!filename.endsWith(".gfd"))
4848
+ filename += ".gfd";
47684849 lastname = browser.getDirectory() + filename;
47694850 save();
47704851 }
....@@ -4931,7 +5012,7 @@
49315012 MenuBar menuBar;
49325013 Menu fileMenu;
49335014 MenuItem newItem;
4934
- MenuItem loadItem;
5015
+ MenuItem openItem;
49355016 MenuItem saveItem;
49365017 MenuItem saveAsItem;
49375018 MenuItem exportAsItem;
....@@ -4954,6 +5035,7 @@
49545035 CheckboxMenuItem toggleSwitchItem;
49555036 CheckboxMenuItem toggleRootItem;
49565037 CheckboxMenuItem animationItem;
5038
+ MenuItem archiveItem;
49575039 CheckboxMenuItem toggleHandleItem;
49585040 CheckboxMenuItem togglePaintItem;
49595041 JSplitPane mainPanel;