Normand Briere
2019-08-12 b1d79b74514041a059b454a9f6fc3970773c0cb8
GroupEditor.java
....@@ -16,7 +16,7 @@
1616 //import buoy.widget.BFileChooser;
1717
1818 class GroupEditor extends ObjEditor implements //iParse, //iCallBack,
19
- Grafreed.iResourceCallBack,
19
+ Grafreed.iResourceCallBack,
2020 ObjectUI,
2121 Runnable,
2222 ActionListener,
....@@ -42,6 +42,22 @@
4242 });
4343 }
4444
45
+ public void AddTextureButton(String f, String c, final String t, int count, cGridBag row)
46
+ {
47
+ cButton textureButton;
48
+ final String path = "textures/" + f + "/" + c + "/"; // + t;
49
+ row.add(textureButton = GetButton(path + "icons/" + t, !Grafreed.NIMBUSLAF));
50
+ textureButton.setToolTipText(c + count);
51
+ textureButton.addActionListener(new ActionListener()
52
+ {
53
+ @Override
54
+ public void actionPerformed(ActionEvent e)
55
+ {
56
+ ChangeTexture(path + t);
57
+ }
58
+ });
59
+ }
60
+
4561 public void AddSkyboxTab0(JTabbedPane skyboxpanel)
4662 {
4763 cGridBag tab0 = new cGridBag().setVertical(true);
....@@ -312,26 +328,47 @@
312328 }
313329 }
314330
315
- public void CallBack(String[] path)
316
- {
317
- for (int i = 0; i < path.length; i++)
318
- {
319
- System.out.print(path[i] + "/");
320
- }
321
-
322
- System.out.println();
323
- }
324
-
325331 public void ChangeSkybox(String skybox)
326332 {
327333 //cameraView.envyoff = false;
328334 group.skyboxname = skybox;
329335 group.skyboxext = "jpg";
330336 cameraView.repaint();
337
+ }
331338
332
- Grafreed.ParseResources("textures", this);
339
+ public void CreateSkyboxPanel(cGridBag skyboxPanel)
340
+ {
341
+ JTabbedPane skyboxpane = new JTabbedPane();
342
+
343
+ AddSkyboxTab0(skyboxpane);
344
+ AddSkyboxTab1(skyboxpane);
345
+ AddSkyboxTab2(skyboxpane);
346
+ AddSkyboxTab3(skyboxpane);
347
+
348
+ skyboxPanel.add(skyboxpane);
333349 }
334350
351
+ public void ChangeTexture(String texture)
352
+ {
353
+ for (int i=0; i<group.selection.size(); i++)
354
+ {
355
+ Object3D obj = group.selection.get(i);
356
+ obj.SetPigmentTexture("@" + texture);
357
+ }
358
+
359
+ refreshContents();
360
+ }
361
+
362
+ public void Show3DView()
363
+ {
364
+ // bug
365
+ //gridPanel.setDividerLocation(1.0);
366
+ //bigPanel.setDividerLocation(0.0);
367
+ bigThree.ClearUI();
368
+ bigThree.add(centralPanel);
369
+ bigThree.FlushUI();
370
+ }
371
+
335372 //ObjEditor objEditor;
336373 public void closeUI2()
337374 {
....@@ -872,6 +909,73 @@
872909 buildToolsMenu(menu);
873910 }
874911
912
+ JTabbedPane resourcecontainer;
913
+ cGridBag currenttab;
914
+ boolean added; // patch for jar
915
+
916
+ int tabcount = 0;
917
+ int colcount = 0;
918
+ int rowcount = 0;
919
+ int texturecount = 0;
920
+
921
+ int columns = 5;
922
+ int rows = 7;
923
+
924
+ public void ResourceCallBack(String[] path)
925
+ {
926
+// for (int i = 0; i < path.length; i++)
927
+// System.out.print(path[i] + "/");
928
+// System.out.println();
929
+
930
+ if (//rowcount == 0 ||
931
+ path.length == 1)
932
+ {
933
+ currenttab = new cGridBag();
934
+ added = false;
935
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
936
+ currenttab.setName(tabname);
937
+ rowcount = 1;
938
+ colcount = 0;
939
+ texturecount = 0;
940
+ }
941
+
942
+ if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
943
+ {
944
+ if (!added)
945
+ {
946
+ added = true;
947
+ resourcecontainer.add(currenttab);
948
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
949
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
950
+ }
951
+
952
+ AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
953
+
954
+ if (++colcount >= columns)
955
+ {
956
+ colcount = 0;
957
+ currenttab.Return();
958
+
959
+ if (rowcount++ >= rows)
960
+ {
961
+ rowcount = 0;
962
+ }
963
+ }
964
+ }
965
+ else
966
+ {
967
+// if (!path[path.length-1].equals("icons"))
968
+// resourcecontainer.Return();
969
+ }
970
+ }
971
+
972
+ void CreateTexturePanel(cGridBag container)
973
+ {
974
+ resourcecontainer = new JTabbedPane(JTabbedPane.LEFT);
975
+ container.add(resourcecontainer);
976
+
977
+ Grafreed.ParseResources("textures", this);
978
+ }
875979
876980 void SetupUI2(ObjEditor oe)
877981 {
....@@ -890,11 +994,6 @@
890994 //new Exception().printStackTrace();
891995
892996 oe.radioPanel = new JPanel(new GridBagLayout());
893
- oe.aConstraints.weightx = 1;
894
- oe.aConstraints.weighty = 0;
895
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
896
- oe.aConstraints.gridwidth = 100;
897
- oe.aConstraints.gridheight = 1;
898997 // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
899998
900999 oe.buttonGroup = new ButtonGroup();
....@@ -931,6 +1030,45 @@
9311030 maxButton.setToolTipText("Maximize window");
9321031 maxButton.addActionListener(this);
9331032 }
1033
+
1034
+ cButton gcButton;
1035
+
1036
+ oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1037
+ gcButton.setToolTipText("Garbage collect");
1038
+ gcButton.addActionListener(new ActionListener()
1039
+ {
1040
+ public void actionPerformed(ActionEvent e)
1041
+ {
1042
+ System.gc();
1043
+ }
1044
+ });
1045
+
1046
+ oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1047
+ collapseButton.setToolTipText("Collapse toolbar");
1048
+ collapseButton.addActionListener(this);
1049
+
1050
+ oe.toolbarPanel.add(maximize3DButton = GetButton("", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1051
+ maximize3DButton.setToolTipText("Maximize 3D view");
1052
+ maximize3DButton.addActionListener(this);
1053
+
1054
+ oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1055
+ twoButton.setToolTipText("Show 3D view only");
1056
+ twoButton.addActionListener(this);
1057
+ this.fullscreenLayout = twoButton;
1058
+
1059
+ oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1060
+ threeButton.setToolTipText("Show controls and 3D view");
1061
+ threeButton.addActionListener(this);
1062
+ if (Globals.ADVANCED)
1063
+ {
1064
+ oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1065
+ sixButton.setToolTipText("Show 3D view and controls");
1066
+ sixButton.addActionListener(this);
1067
+ }
1068
+// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1069
+// sevenButton.setToolTipText("3-column layout");
1070
+// sevenButton.addActionListener(this);
1071
+ //
9341072
9351073 oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9361074 fullButton.setToolTipText("Full-screen window");
....@@ -975,14 +1113,14 @@
9751113 nextVersionButton.addActionListener(this);
9761114 nextVersionButton.setEnabled(false);
9771115
978
- oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
979
- liveCB.setToolTipText("Enable animation");
980
- liveCB.addItemListener(this);
981
-
9821116 oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9831117 oneStepButton.setToolTipText("Animate one step forward");
9841118 oneStepButton.addActionListener(this);
9851119
1120
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
1121
+ liveCB.setToolTipText("Enable animation");
1122
+ liveCB.addItemListener(this);
1123
+
9861124 oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
9871125 fastCB.setToolTipText("Fast mode");
9881126 fastCB.addItemListener(this);
....@@ -1009,21 +1147,6 @@
10091147
10101148 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
10111149
1012
- oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1013
- twoButton.setToolTipText("Show 3D view only");
1014
- twoButton.addActionListener(this);
1015
- this.fullscreenLayout = twoButton;
1016
-
1017
- oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1018
- threeButton.setToolTipText("Show controls and 3D view");
1019
- threeButton.addActionListener(this);
1020
- oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1021
- sixButton.setToolTipText("Show 3D view and controls");
1022
- sixButton.addActionListener(this);
1023
-// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1024
-// sevenButton.setToolTipText("3-column layout");
1025
-// sevenButton.addActionListener(this);
1026
- //
10271150
10281151 oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10291152 rootButton.setToolTipText("Open selection in new tab");
....@@ -1107,19 +1230,15 @@
11071230
11081231 oe.toolboxPanel.add(row2);
11091232
1110
- // ENVYMAPS
1111
- cGridBag skyboxpane = new cGridBag();
1112
- skyboxpane.preferredHeight = 100;
1233
+ cGridBag textures = new cGridBag();
11131234
1114
- oe.skyboxPanel.add(skyboxpane);
1235
+ CreateTexturePanel(textures);
11151236
1116
- JTabbedPane skyboxpanel = new JTabbedPane();
1117
- skyboxpane.add(skyboxpanel);
1237
+ oe.toolboxPanel.add(textures);
11181238
1119
- AddSkyboxTab0(skyboxpanel);
1120
- AddSkyboxTab1(skyboxpanel);
1121
- AddSkyboxTab2(skyboxpanel);
1122
- AddSkyboxTab3(skyboxpanel);
1239
+ textures.preferredHeight = 100;
1240
+
1241
+ CreateSkyboxPanel(oe.skyboxPanel);
11231242
11241243 // EDIT panel
11251244 editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1131,11 +1250,11 @@
11311250 uneditButton.addActionListener(this);
11321251
11331252 editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
1134
- allParamsButton.setToolTipText("Show all controle");
1253
+ allParamsButton.setToolTipText("Show all controls");
11351254 allParamsButton.addActionListener(this);
11361255
11371256 editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1138
- clearPanelButton.setToolTipText("Clear edit panel");
1257
+ clearPanelButton.setToolTipText("Clear all controls");
11391258 clearPanelButton.addActionListener(this);
11401259
11411260 //editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1725,7 +1844,12 @@
17251844 TreePath path;
17261845
17271846 public TransferableTreePath(TreePath tp) {
1728
- path = tp;
1847
+ Object[] objs = new Object[tp.getPathCount()];
1848
+ for (int i=0; i<objs.length; i++)
1849
+ {
1850
+ objs[i] = ((Object3D)tp.getPathComponent(i)).GetUUID();
1851
+ }
1852
+ path = new TreePath(objs);
17291853 }
17301854
17311855 public synchronized DataFlavor[] getTransferDataFlavors() {
....@@ -2618,6 +2742,18 @@
26182742 if (source == fullButton)
26192743 {
26202744 ToggleFullScreen();
2745
+ } else
2746
+ if (source == collapseButton)
2747
+ {
2748
+ this.expandedLayout = radio.layout;
2749
+ CollapseToolbar();
2750
+ } else
2751
+ if (source == maximize3DButton)
2752
+ {
2753
+ this.expandedLayout = radio.layout;
2754
+ radio.layout = twoButton;
2755
+ Show3DView();
2756
+ CollapseToolbar();
26212757 } else
26222758 if (source == previousVersionButton)
26232759 {
....@@ -3570,38 +3706,7 @@
35703706 if (CameraPane.FULLSCREEN)
35713707 fullscreenLayout = radio.layout;
35723708
3573
- // bug
3574
- //gridPanel.setDividerLocation(1.0);
3575
- //bigPanel.setDividerLocation(0.0);
3576
-// bigThree.remove(scenePanel);
3577
-// bigThree.remove(centralPanel);
3578
-// bigThree.remove(XYZPanel);
3579
-// aWindowConstraints.gridx = 0;
3580
-// aWindowConstraints.gridy = 0;
3581
-// aWindowConstraints.gridwidth = 1;
3582
-// // aConstraints.gridheight = 3;
3583
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3584
-// aWindowConstraints.weightx = 0;
3585
-// aWindowConstraints.weighty = 1;
3586
-// //bigThree.add(jtp, aWindowConstraints);
3587
-// aWindowConstraints.weightx = 1;
3588
-// aWindowConstraints.gridwidth = 3;
3589
-// // aConstraints.gridheight = 3;
3590
-// aWindowConstraints.gridx = 1;
3591
-// aWindowConstraints.fill = GridBagConstraints.BOTH;
3592
-// bigThree.add(centralPanel, aWindowConstraints);
3593
-// aWindowConstraints.weightx = 0;
3594
-// aWindowConstraints.gridx = 4;
3595
-// aWindowConstraints.gridwidth = 1;
3596
-// // aConstraints.gridheight = 3;
3597
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3598
-// //bigThree.add(XYZPanel, aWindowConstraints);
3599
-// scenePanel.setVisible(false);
3600
-// centralPanel.setVisible(true);
3601
-// XYZPanel.setVisible(false);
3602
- bigThree.ClearUI();
3603
- bigThree.add(centralPanel);
3604
- bigThree.FlushUI();
3709
+ Show3DView();
36053710
36063711 cameraView.requestFocusInWindow();
36073712
....@@ -5200,7 +5305,7 @@
52005305 Object3D child = (Object3D) group.selection.get(i);
52015306
52025307 objEditor.AddInfo(child, this, true);
5203
- System.err.println("info : " + child.GetPath());
5308
+// System.err.println("info : " + child.GetPath());
52045309 }
52055310
52065311 objEditor.SetText(); // jan 2014