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.*;
....@@ -19,6 +20,8 @@
1920 import //weka.core.
2021 matrix.Matrix;
2122
23
+import grafeme.ui.*;
24
+
2225 class ObjEditor /*extends JFrame*/ implements iCallBack, ObjectUI,
2326 ActionListener, ChangeListener,
2427 InputMethodListener,
....@@ -31,6 +34,57 @@
3134 boolean timeline;
3235 boolean wasFullScreen;
3336
37
+ GroupEditor callee;
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
+ }
87
+
3488 // SCRIPT
3589
3690 transient JFrame textpanel = null;
....@@ -121,47 +175,54 @@
121175 void keyPressed(int key, int modifiers)
122176 {
123177 System.out.println("KEY PRESSED");
124
- CameraPane.theRenderer.keyPressed(key, modifiers);
178
+ Globals.theRenderer.keyPressed(key, modifiers);
125179 }
126180 */
127181
128182 static GridBagConstraints aConstraints;
129183 static GridBagConstraints aWindowConstraints;
130
- GroupEditor callee;
131
- JFrame frame;
184
+
132185 static int GRIDWIDTH = 100; // 4;
133186
134187 public void closeUI()
135188 {
136189 //new Exception().printStackTrace();
137
- System.out.println("this = " + this);
138
- System.out.println("objEditor = " + objEditor);
190
+// System.out.println("this = " + this);
191
+// System.out.println("objEditor = " + objEditor);
139192 //nameField.removeActionListener(this);
140
- objEditor.ctrlPanel.remove(nameField);
193
+// objEditor.ctrlPanel.remove(nameField);
194
+
195
+ objEditor.ctrlPanel.remove(namePanel);
141196
142197 if (!GroupEditor.allparams)
143198 return;
144199
145
- objEditor.ctrlPanel.remove(liveCB);
146
- objEditor.ctrlPanel.remove(hideCB);
147
- objEditor.ctrlPanel.remove(markCB);
148
-
149
- objEditor.ctrlPanel.remove(randomCB);
150
- objEditor.ctrlPanel.remove(speedupCB);
151
- objEditor.ctrlPanel.remove(rewindCB);
152
-
153
- objEditor.ctrlPanel.remove(resetButton);
154
- objEditor.ctrlPanel.remove(stepButton);
155
-// objEditor.ctrlPanel.remove(stepAllButton);
156
-// objEditor.ctrlPanel.remove(resetAllButton);
157
- objEditor.ctrlPanel.remove(link2masterCB);
158
- //objEditor.ctrlPanel.remove(flipVCB);
159
- //objEditor.ctrlPanel.remove(texresMenu);
160
- objEditor.ctrlPanel.remove(slowerButton);
161
- objEditor.ctrlPanel.remove(fasterButton);
162
- objEditor.ctrlPanel.remove(remarkButton);
200
+// objEditor.ctrlPanel.remove(liveCB);
201
+// objEditor.ctrlPanel.remove(hideCB);
202
+// objEditor.ctrlPanel.remove(markCB);
203
+//
204
+// objEditor.ctrlPanel.remove(randomCB);
205
+// objEditor.ctrlPanel.remove(speedupCB);
206
+// objEditor.ctrlPanel.remove(rewindCB);
207
+//
208
+// objEditor.ctrlPanel.remove(resetButton);
209
+// objEditor.ctrlPanel.remove(stepButton);
210
+//// objEditor.ctrlPanel.remove(stepAllButton);
211
+//// objEditor.ctrlPanel.remove(resetAllButton);
212
+// objEditor.ctrlPanel.remove(link2masterCB);
213
+// //objEditor.ctrlPanel.remove(flipVCB);
214
+// //objEditor.ctrlPanel.remove(texresMenu);
215
+// objEditor.ctrlPanel.remove(slowerButton);
216
+// objEditor.ctrlPanel.remove(fasterButton);
217
+// objEditor.ctrlPanel.remove(remarkButton);
163218
164
- Remove(normalpushField);
219
+ objEditor.ctrlPanel.remove(setupPanel);
220
+ objEditor.ctrlPanel.remove(setupPanel2);
221
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
222
+ objEditor.ctrlPanel.remove(pushPanel);
223
+ //objEditor.ctrlPanel.remove(fillPanel);
224
+
225
+ //Remove(normalpushField);
165226 }
166227
167228 public ObjEditor GetEditor()
....@@ -232,6 +293,7 @@
232293 //localCopy.parent = null;
233294
234295 frame = new JFrame();
296
+ frame.setUndecorated(true);
235297 objEditor = this;
236298 this.callee = callee;
237299
....@@ -265,24 +327,40 @@
265327 void SetupMenu()
266328 {
267329 frame.setMenuBar(menuBar = new MenuBar());
268
- menuBar.add(windowMenu = new Menu("File"));
269
- windowMenu.add(loadItem = new MenuItem("Load..."));
270
- windowMenu.add("-");
271
- windowMenu.add(saveItem = new MenuItem("Save"));
272
- windowMenu.add(saveAsItem = new MenuItem("Save As..."));
330
+ menuBar.add(fileMenu = new Menu("File"));
331
+ fileMenu.add(newItem = new MenuItem("New"));
332
+ fileMenu.add(loadItem = new MenuItem("Open..."));
333
+
334
+ //oe.menuBar.add(menu = new Menu("Include"));
335
+ Menu menu = new Menu("Import");
336
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
337
+ importOBJItem.addActionListener(this);
338
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
339
+ import3DSItem.addActionListener(this);
340
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
341
+ importVRMLX3DItem.addActionListener(this);
342
+ menu.add("-");
343
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
344
+ importGFDItem.addActionListener(this);
345
+ fileMenu.add(menu);
346
+ fileMenu.add("-");
347
+
348
+ fileMenu.add(saveItem = new MenuItem("Save"));
349
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
273350 //windowMenu.add(povItem = new MenuItem("Emit POV-Ray..."));
274
- windowMenu.add("-");
275
- windowMenu.add(exportAsItem = new MenuItem("Export Selection..."));
276
- windowMenu.add(reexportItem = new MenuItem("Re-export"));
277
- windowMenu.add("-");
351
+ fileMenu.add("-");
352
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
353
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
354
+ fileMenu.add("-");
278355 if (client.parent != null)
279356 {
280
- windowMenu.add(closeItem = new MenuItem("Close"));
357
+ fileMenu.add(closeItem = new MenuItem("Close"));
281358 } else
282359 {
283
- windowMenu.add(closeItem = new MenuItem("Exit"));
360
+ fileMenu.add(closeItem = new MenuItem("Exit"));
284361 }
285362
363
+ newItem.addActionListener(this);
286364 loadItem.addActionListener(this);
287365 saveItem.addActionListener(this);
288366 saveAsItem.addActionListener(this);
....@@ -291,79 +369,35 @@
291369 //povItem.addActionListener(this);
292370 closeItem.addActionListener(this);
293371
294
- menuBar.add(cameraMenu = new Menu("View"));
295
- //cameraMenu.add(zBufferItem = new CheckboxMenuItem("Z Buffer"));
296
- //zBufferItem.addActionListener(this);
297
- //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens"));
298
- //normalLensItem.addActionListener(this);
299
- cameraMenu.add(revertCameraItem = new MenuItem("Revert Camera"));
300
- revertCameraItem.addActionListener(this);
301
- cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
302
- toggleTimelineItem.addItemListener(this);
303
- cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
304
- toggleFullScreenItem.addItemListener(this);
305
- toggleFullScreenItem.setState(CameraPane.FULLSCREEN);
306
- cameraMenu.add("-");
307
- cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
308
- toggleTextureItem.addItemListener(this);
309
- toggleTextureItem.setState(CameraPane.textureon);
310
- cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
311
- toggleLiveItem.addItemListener(this);
312
- toggleLiveItem.setState(CameraPane.isLIVE());
313
- cameraMenu.add(stepItem = new MenuItem("Step"));
314
- stepItem.addActionListener(this);
315
-// cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
316
-// toggleDLItem.addItemListener(this);
317
-// toggleDLItem.setState(false);
318
- cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
319
- toggleRenderItem.addItemListener(this);
320
- toggleRenderItem.setState(!CameraPane.frozen);
321
- cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
322
- toggleDebugItem.addItemListener(this);
323
- toggleDebugItem.setState(CameraPane.DEBUG);
324
- cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
325
- toggleFrustumItem.addItemListener(this);
326
- toggleFrustumItem.setState(CameraPane.FRUSTUM);
327
- cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
328
- toggleFootContactItem.addItemListener(this);
329
- toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
330
- cameraMenu.add(toggleRandomItem = new CheckboxMenuItem("Random"));
331
- toggleRandomItem.addItemListener(this);
332
- toggleRandomItem.setState(CameraPane.RANDOM);
333
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
334
- toggleHandleItem.addItemListener(this);
335
- toggleHandleItem.setState(CameraPane.HANDLES);
336
- cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
337
- togglePaintItem.addItemListener(this);
338
- togglePaintItem.setState(CameraPane.PAINTMODE);
339
-// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
340
-// toggleRootItem.addItemListener(this);
341
-// toggleRootItem.setState(false);
342
-// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
343
-// animationItem.addItemListener(this);
344
-// animationItem.setState(CameraPane.ANIMATION);
345
- cameraMenu.add("-");
346
- cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));
347
- editCameraItem.addActionListener(this);
348
-
349372 objectPanel = new JTabbedPane();
350373 toolbarPanel = new JPanel();
351374 toolbarPanel.setName("Toolbar");
352
- treePanel = new JPanel();
375
+ treePanel = new cGridBag();
353376 treePanel.setName("Tree");
354
- ctrlPanel = new JPanel(); // new GridBagLayout());
355
- ctrlPanel.setName("Edit");
356
- materialPanel = new JPanel();
377
+
378
+ editPanel = new cGridBag().setVertical(true);
379
+ editPanel.setName("Edit");
380
+
381
+ ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
382
+
383
+ editCommandsPanel = new cGridBag();
384
+ editPanel.add(editCommandsPanel);
385
+ editPanel.add(ctrlPanel);
386
+
387
+ materialPanel = new cGridBag().setVertical(true);
388
+
357389 materialPanel.setName("Material");
358390 /*JTextPane*/
359391 infoarea = createTextPane();
392
+ doc = infoarea.getStyledDocument();
393
+
360394 infoarea.setEditable(true);
361395 SetText();
362396 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
363397 // infoarea.setOpaque(false);
364398 // //infoarea.setForeground(textcolor);
365
- infoarea.setLineWrap(true);
366
- infoarea.setWrapStyleWord(true);
399
+// TEXTAREA infoarea.setLineWrap(true);
400
+// TEXTAREA infoarea.setWrapStyleWord(true);
367401 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
368402 infoPanel.setPreferredSize(new Dimension(50, 200));
369403 infoPanel.setName("Info");
....@@ -374,16 +408,16 @@
374408 mainPanel.setName("Main");
375409 mainPanel.setContinuousLayout(true);
376410 mainPanel.setOneTouchExpandable(true);
377
- mainPanel.setDividerLocation(1.0);
378411 mainPanel.setDividerSize(9);
379
- mainPanel.setResizeWeight(0);
412
+ mainPanel.setDividerLocation(0.5); //1.0);
413
+ mainPanel.setResizeWeight(0.5);
380414
381415 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
382416 //mainPanel.setLayout(new GridBagLayout());
383417 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
384
- treePanel.setLayout(new GridBagLayout());
385
- ctrlPanel.setLayout(new GridBagLayout());
386
- materialPanel.setLayout(new GridBagLayout());
418
+// treePanel.setLayout(new GridBagLayout());
419
+ //ctrlPanel.setLayout(new GridBagLayout());
420
+ //materialPanel.setLayout(new GridBagLayout());
387421
388422 aConstraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
389423 GridBagConstraints.NORTHEAST, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0);
....@@ -422,7 +456,7 @@
422456 static String newline = "\n";
423457 protected static final String buttonString = "JButton";
424458 StyledDocument doc;
425
- JTextArea infoarea;
459
+ JTextPane infoarea;
426460
427461 void ClearInfo()
428462 {
....@@ -445,10 +479,10 @@
445479 e.printStackTrace();
446480 }
447481
448
- String selection = infoarea.getText();
449
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
450
- java.awt.datatransfer.Clipboard clipboard =
451
- 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();
452486 //clipboard.setContents(data, data);
453487 }
454488
....@@ -471,13 +505,13 @@
471505 //SendInfo("Name:", "bold");
472506 if (sel.GetTextures() != null || debug)
473507 {
474
- si.SendInfo(sel.toString(), "bold");
508
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
475509 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
476510 if (sel.Size() > 0)
477511 {
478512 si.SendInfo("#children = " + sel.Size(), "regular");
479513 }
480
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
514
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
481515 if (debug)
482516 {
483517 try
....@@ -489,7 +523,10 @@
489523 }
490524
491525 if (full)
492
- si.SendInfo(" BBox: " + minima + " - " + maxima, "regular");
526
+ {
527
+ si.SendInfo(" BBox min: " + minima, "regular");
528
+ si.SendInfo(" BBox max: " + maxima, "regular");
529
+ }
493530
494531 if (sel.bRep != null)
495532 {
....@@ -516,7 +553,7 @@
516553 }
517554 if (sel.support != null)
518555 {
519
- si.SendInfo(" support: " + sel.support, "regular");
556
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
520557 }
521558 if (sel.scriptnode != null)
522559 {
....@@ -587,6 +624,9 @@
587624 {
588625 CameraPane.pointflow = (PointFlow) sel;
589626 }
627
+
628
+ si.SendInfo("_____________________", "regular");
629
+ si.SendInfo("", "regular");
590630 }
591631 }
592632
....@@ -602,68 +642,138 @@
602642 }
603643 }
604644
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
+
605685 void ToggleFullScreen()
606686 {
607687 if (CameraPane.FULLSCREEN)
608688 {
609
- frame.getContentPane().remove(/*"Center",*/bigThree);
610
- framePanel.add(bigThree);
611
- 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
+
612707 } else
613708 {
614
- frame.getContentPane().remove(/*"Center",*/framePanel);
615
- framePanel.remove(bigThree);
616
- 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);
617726 }
727
+
618728 cameraView.ToggleFullScreen();
619729 }
620730
621
- private JTextArea createTextPane()
731
+ private JTextPane createTextPane()
622732 {
623
- String[] initString =
624
- {
625
- "This is an editable JTextPane, ", //regular
626
- "another ", //italic
627
- "styled ", //bold
628
- "text ", //small
629
- "component, ", //large
630
- "which supports embedded components..." + newline,//regular
631
- " " + newline, //button
632
- "...and embedded icons..." + newline, //regular
633
- " ", //icon
634
- newline + "JTextPane is a subclass of JEditorPane that "
635
- + "uses a StyledEditorKit and StyledDocument, and provides "
636
- + "cover methods for interacting with those objects."
637
- };
733
+// TEXTAREA String[] initString =
734
+// {
735
+// "This is an editable JTextPane, ", //regular
736
+// "another ", //italic
737
+// "styled ", //bold
738
+// "text ", //small
739
+// "component, ", //large
740
+// "which supports embedded components..." + newline,//regular
741
+// " " + newline, //button
742
+// "...and embedded icons..." + newline, //regular
743
+// " ", //icon
744
+// newline + "JTextPane is a subclass of JEditorPane that "
745
+// + "uses a StyledEditorKit and StyledDocument, and provides "
746
+// + "cover methods for interacting with those objects."
747
+// };
748
+//
749
+// String[] initStyles =
750
+// {
751
+// "regular", "italic", "bold", "small", "large",
752
+// "regular", "button", "regular", "icon",
753
+// "regular"
754
+// };
755
+//
756
+// JTextPane textPane = new JTextPane();
757
+// textPane.setEditable(true);
758
+// /*StyledDocument*/ doc = textPane.getStyledDocument();
759
+// addStylesToDocument(doc);
760
+//
761
+// try
762
+// {
763
+// for (int j = 0; j < 2; j++)
764
+// {
765
+// for (int i = 0; i < initString.length; i++)
766
+// {
767
+// doc.insertString(doc.getLength(), initString[i],
768
+// doc.getStyle(initStyles[i]));
769
+// }
770
+// }
771
+// } catch (BadLocationException ble)
772
+// {
773
+// System.err.println("Couldn't insert initial text into text pane.");
774
+// }
638775
639
- String[] initStyles =
640
- {
641
- "regular", "italic", "bold", "small", "large",
642
- "regular", "button", "regular", "icon",
643
- "regular"
644
- };
645
-
646
- JTextPane textPane = new JTextPane();
647
- textPane.setEditable(true);
648
- /*StyledDocument*/ doc = textPane.getStyledDocument();
649
- addStylesToDocument(doc);
650
-
651
- try
652
- {
653
- for (int j = 0; j < 2; j++)
654
- {
655
- for (int i = 0; i < initString.length; i++)
656
- {
657
- doc.insertString(doc.getLength(), initString[i],
658
- doc.getStyle(initStyles[i]));
659
- }
660
- }
661
- } catch (BadLocationException ble)
662
- {
663
- System.err.println("Couldn't insert initial text into text pane.");
664
- }
665
-
666
- return new JTextArea(); // textPane;
776
+ return new JTextPane(); // textPane;
667777 }
668778
669779 protected void addStylesToDocument(StyledDocument doc)
....@@ -716,7 +826,7 @@
716826 protected static ImageIcon createImageIcon(String path,
717827 String description)
718828 {
719
- java.net.URL imgURL = GrafreeD.class.getResource(path);
829
+ java.net.URL imgURL = Grafreed.class.getResource(path);
720830 if (imgURL != null)
721831 {
722832 return new ImageIcon(imgURL, description);
....@@ -748,6 +858,7 @@
748858 // NumberSlider vDivsField;
749859 // JCheckBox endcaps;
750860 JCheckBox liveCB;
861
+ JCheckBox selectCB;
751862 JCheckBox hideCB;
752863 JCheckBox link2masterCB;
753864 JCheckBox markCB;
....@@ -763,115 +874,87 @@
763874 JButton slowerButton;
764875 JButton fasterButton;
765876 JButton remarkButton;
877
+
878
+ cGridBag editPanel;
879
+ cGridBag editCommandsPanel;
880
+
881
+ cGridBag namePanel;
882
+ cGridBag setupPanel;
883
+ cGridBag setupPanel2;
884
+ cGridBag objectCommandsPanel;
885
+ cGridBag pushPanel;
886
+ cGridBag fillPanel;
766887
767
- JCheckBox AddCheckBox(ObjEditor oe, String label, boolean on)
888
+ JCheckBox AddCheckBox(cGridBag panel, String label, boolean on)
768889 {
769890 JCheckBox cb;
770891
771
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
772
- oe.aConstraints.gridwidth = 1; // 3;
773
-// oe.aConstraints.weightx = 1;
774
-// oe.aConstraints.anchor = GridBagConstraints.WEST;
775
- oe.ctrlPanel.add(cb = new JCheckBox(label, on), oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
892
+ panel.add(cb = new JCheckBox(label, on)); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
776893 cb.addItemListener(this);
777
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
778
- oe.aConstraints.gridwidth = 1;
779
- oe.aConstraints.gridx += 1;
780894
781895 return cb;
782896 }
783897
784
- cButton AddButton(ObjEditor oe, String label)
898
+ cButton AddButton(cGridBag panel, String label)
785899 {
786900 cButton cb;
787901
788
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
789
- oe.aConstraints.gridwidth = 1;
790
-// oe.aConstraints.weightx = 1;
791
-// oe.aConstraints.anchor = GridBagConstraints.WEST;
792
- oe.ctrlPanel.add(cb = new cButton(label), oe.aConstraints, oe.ctrlPanel.getComponentCount() - 1);
902
+ panel.add(cb = new cButton(label)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount() - 1);
793903 cb.addActionListener(this);
794
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
795
- oe.aConstraints.gridwidth = 1;
796
- oe.aConstraints.gridx += 1;
797904
798905 return cb;
799906 }
800907
801
- JComboBox AddCombo(ObjEditor oe, java.util.Vector list, int item)
908
+ JComboBox AddCombo(cGridBag panel, java.util.Vector list, int item)
802909 {
803910 JComboBox combo;
804911
805
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
806
- oe.ctrlPanel.add(combo = new JComboBox(new cListModel(list, item)), oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
807
- oe.aConstraints.gridx += 1;
912
+ panel.add(combo = new JComboBox(new cListModel(list, item))); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
808913 combo.addActionListener(this);
809914
810915 return combo;
811916 }
812917
813
- NumberSlider AddSlider(JPanel ctrlPanel, String label, double min, double max, double current, double pow)
918
+ cGridBag AddSlider(cGridBag panel, String label, double min, double max, double current, double pow)
814919 {
815
- NumberSlider combo;
920
+ cGridBag control = new cGridBag();
921
+
922
+ cNumberSlider combo;
816923
817924 JLabel jlabel = new JLabel(label);
818
-
819
- aConstraints.fill = GridBagConstraints.VERTICAL;
820925 jlabel.setHorizontalAlignment(SwingConstants.TRAILING);
821
- aConstraints.gridwidth = 1;
822
- ctrlPanel.add(jlabel, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
823
- aConstraints.gridx += 1;
824
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
825
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
826
- ctrlPanel.add(combo = new NumberSlider(min, max, pow), aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
827
- aConstraints.gridx += 1;
828
- aConstraints.gridwidth = 1;
829
-
926
+ control.add(jlabel); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
927
+ control.add(combo = new cNumberSlider(this, min, max, pow)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
830928 combo.setFloat(current);
831
-
832
- combo.label = jlabel;
833
-
834
- combo.addChangeListener(this);
835
-
836
- return combo;
929
+
930
+ panel.add(control);
931
+
932
+ return control;
837933 }
838934
839
- NumberSlider AddSlider(JPanel ctrlPanel, String label, int min, int max, int current)
935
+ cGridBag AddSlider(cGridBag panel, String label, int min, int max, int current)
840936 {
841
- NumberSlider combo;
937
+ cGridBag control = new cGridBag();
938
+
939
+ cNumberSlider combo;
842940
843941 JLabel jlabel = new JLabel(label);
844
-
845
- aConstraints.fill = GridBagConstraints.VERTICAL;
846942 jlabel.setHorizontalAlignment(SwingConstants.TRAILING);
847
- aConstraints.gridwidth = 2;
848
- ctrlPanel.add(jlabel, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
849
- aConstraints.gridx += 1;
850
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
851
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
852
- ctrlPanel.add(combo = new NumberSlider(min, max), aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
853
- aConstraints.gridx += 1;
854
- aConstraints.gridwidth = 1;
855
-
943
+ control.add(jlabel); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
944
+ control.add(combo = new cNumberSlider(this, min, max)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
856945 combo.setInteger(current);
857946
858
- combo.label = jlabel;
859
-
860
- combo.addChangeListener(this);
861
-
862
- return combo;
947
+ panel.add(control);
948
+
949
+ return control;
863950 }
864951
865
- JTextArea AddText(JPanel ctrlPanel, String name)
952
+ JTextArea AddText(cGridBag ctrlPanel, String name)
866953 {
867954 JTextArea text;
868955
869
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
870
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
871
- ctrlPanel.add(text = new JTextArea(name), aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
956
+ ctrlPanel.add(text = new JTextArea(name)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
872957 text.addCaretListener(this);
873
- aConstraints.gridx += 1;
874
- aConstraints.gridwidth = 1;
875958
876959 return text;
877960 }
....@@ -901,9 +984,16 @@
901984 objEditor.ctrlPanel.remove(j);
902985 }
903986
987
+ void Remove(cNumberSlider j)
988
+ {
989
+ j.removeChangeListener(this);
990
+ //objEditor.ctrlPanel.remove(j.label);
991
+ objEditor.ctrlPanel.remove(j);
992
+ }
993
+
904994 /*
905995 */
906
- void Return() // ObjEditor oe)
996
+ void Return0() // ObjEditor oe)
907997 {
908998 aConstraints.gridy += 1;
909999 aConstraints.gridx = 0;
....@@ -958,37 +1048,76 @@
9581048
9591049 void SetupUI2(ObjEditor oe)
9601050 {
961
-// oe.aConstraints.weightx = 0;
962
-// oe.aConstraints.weighty = 0;
963
-// oe.aConstraints.gridx = 0;
964
-// oe.aConstraints.gridy = 0;
965
- SetupName(oe);
1051
+ //SetupName(oe);
1052
+
1053
+ namePanel = new cGridBag();
1054
+
1055
+ nameField = AddText(namePanel, copy.GetName());
1056
+ namePanel.add(nameField);
1057
+ oe.ctrlPanel.add(namePanel);
1058
+
1059
+ oe.ctrlPanel.Return();
9661060
9671061 if (!GroupEditor.allparams)
9681062 return;
9691063
970
- liveCB = AddCheckBox(oe, "Live", copy.live);
971
- link2masterCB = AddCheckBox(oe, "Supp", copy.link2master);
972
- hideCB = AddCheckBox(oe, "Hide", copy.hide);
1064
+ setupPanel = new cGridBag().setVertical(false);
1065
+
1066
+ liveCB = AddCheckBox(setupPanel, "Live", copy.live);
1067
+ liveCB.setToolTipText("Animate object");
1068
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1069
+ selectCB.setToolTipText("Make object selectable");
9731070 // Return();
974
- markCB = AddCheckBox(oe, "Mark", copy.marked);
975
- rewindCB = AddCheckBox(oe, "Rew", copy.rewind);
976
- randomCB = AddCheckBox(oe, "Rand", copy.random);
977
- Return();
978
- resetButton = AddButton(oe, "Reset");
979
- stepButton = AddButton(oe, "Step");
1071
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1072
+ hideCB.setToolTipText("Hide object");
1073
+ markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1074
+ markCB.setToolTipText("Set the animation target transform");
1075
+
1076
+ setupPanel2 = new cGridBag().setVertical(false);
1077
+
1078
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
1079
+ rewindCB.setToolTipText("Rewind animation");
1080
+
1081
+ randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1082
+ randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1083
+
1084
+ if (Globals.ADVANCED)
1085
+ {
1086
+ link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1087
+ link2masterCB.setToolTipText("Attach to support");
1088
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
1089
+ speedupCB.setToolTipText("Option motion capture");
1090
+ }
1091
+
1092
+ oe.ctrlPanel.add(setupPanel);
1093
+ oe.ctrlPanel.Return();
1094
+ oe.ctrlPanel.add(setupPanel2);
1095
+ oe.ctrlPanel.Return();
1096
+
1097
+ objectCommandsPanel = new cGridBag().setVertical(false);
1098
+
1099
+ resetButton = AddButton(objectCommandsPanel, "Reset");
1100
+ resetButton.setToolTipText("Jump to frame zero");
1101
+ stepButton = AddButton(objectCommandsPanel, "Step");
1102
+ stepButton.setToolTipText("Step one frame");
9801103 // resetAllButton = AddButton(oe, "Reset All");
9811104 // stepAllButton = AddButton(oe, "Step All");
982
- speedupCB = AddCheckBox(oe, "Speed", copy.speedup);
9831105 // Return();
984
- slowerButton = AddButton(oe, "Slow");
985
- fasterButton = AddButton(oe, "Fast");
986
- remarkButton = AddButton(oe, "Rem");
1106
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
1107
+ slowerButton.setToolTipText("Decrease animation speed");
1108
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
1109
+ fasterButton.setToolTipText("Increase animation speed");
1110
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
1111
+ remarkButton.setToolTipText("Set the current transform as the target");
9871112
988
- Return();
1113
+ oe.ctrlPanel.add(objectCommandsPanel);
1114
+ oe.ctrlPanel.Return();
9891115
990
- normalpushField = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, -1);
991
- Return();
1116
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
1117
+ normalpushField = (cNumberSlider)pushPanel.getComponent(1);
1118
+ //Return();
1119
+
1120
+ oe.ctrlPanel.Return();
9921121
9931122 // oe.ctrlPanel.add(stepButton = new cButton("Step"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
9941123 // ObjEditor.aConstraints.gridx += 1;
....@@ -1083,7 +1212,7 @@
10831212 oe.aConstraints.gridwidth = 1;
10841213 /**/
10851214 nameField = AddText(oe.ctrlPanel, copy.GetName());
1086
- Return();
1215
+ oe.ctrlPanel.Return();
10871216
10881217 //ctrlPanel.add(textureButton = new Button("Texture..."));
10891218 //textureButton.setEnabled(false);
....@@ -1185,9 +1314,13 @@
11851314 //JPanel worldPanel =
11861315 // new gov.nasa.worldwind.examples.ApplicationTemplate.AppPanel(null, true);
11871316 //worldPanel.setName("World");
1188
- centralPanel = new JPanel(new BorderLayout());
1189
- timelinePanel = new JPanel(new BorderLayout());
1190
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1317
+ centralPanel = new cGridBag();
1318
+ centralPanel.preferredWidth = 20;
1319
+
1320
+ if (Globals.ADVANCED)
1321
+ {
1322
+ timelinePanel = new JPanel(new BorderLayout());
1323
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11911324
11921325 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11931326 cameraPanel.setContinuousLayout(true);
....@@ -1196,7 +1329,10 @@
11961329 // cameraPanel.setDividerSize(9);
11971330 cameraPanel.setResizeWeight(1.0);
11981331
1332
+ }
1333
+
11991334 centralPanel.add(cameraView);
1335
+ centralPanel.setFocusable(true);
12001336 //frame.setJMenuBar(timelineMenubar);
12011337 //centralPanel.add(timelinePanel);
12021338
....@@ -1215,12 +1351,13 @@
12151351 //frontView.object = copy;
12161352 //sideView.object = copy;
12171353
1218
- XYZPanel = new JPanel();
1219
- XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
1354
+ XYZPanel = new cGridBag().setVertical(true);
1355
+ //XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
12201356
1221
- XYZPanel.add(/*BorderLayout.SOUTH,*/sideView); // Scroll);
1222
- XYZPanel.add(/*BorderLayout.CENTER,*/frontView); // Scroll);
1223
- XYZPanel.add(/*BorderLayout.NORTH,*/topView); // Scroll);
1357
+ XYZPanel.preferredWidth = 5;
1358
+ XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
1359
+ XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
1360
+ XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
12241361
12251362 /*
12261363 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1258,10 +1395,11 @@
12581395 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12591396 //tmp.setName("Edit");
12601397 objectPanel.add(materialPanel);
1261
- JPanel north = new JPanel(new BorderLayout());
1262
- north.setName("Edit");
1263
- north.add(ctrlPanel, BorderLayout.NORTH);
1264
- objectPanel.add(north);
1398
+// JPanel north = new JPanel(new BorderLayout());
1399
+// north.setName("Edit");
1400
+// north.add(ctrlPanel, BorderLayout.NORTH);
1401
+// objectPanel.add(north);
1402
+ objectPanel.add(editPanel);
12651403 objectPanel.add(infoPanel);
12661404
12671405 /*
....@@ -1282,16 +1420,23 @@
12821420 scrollpane.setWheelScrollingEnabled(true);
12831421 scrollpane.addMouseWheelListener(this); // Default not fast enough
12841422
1285
- /*JTabbedPane*/ scenePanel = new JTabbedPane();
1286
- scenePanel.add(scrollpane);
1423
+ /*JTabbedPane*/ scenePanel = new cGridBag();
1424
+ scenePanel.preferredWidth = 6;
1425
+
1426
+ JTabbedPane tabbedPane = new JTabbedPane();
1427
+ tabbedPane.add(scrollpane);
12871428
1288
- scenePanel.add(FSPane = new cFileSystemPane(this));
1429
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
12891430
1290
- optionsPanel = new JPanel(new GridBagLayout());
1431
+ optionsPanel = new cGridBag().setVertical(true);
12911432
12921433 optionsPanel.setName("Options");
1293
- scenePanel.add(optionsPanel);
1294
-
1434
+
1435
+ AddOptions(optionsPanel); //, aConstraints);
1436
+
1437
+ tabbedPane.add(optionsPanel);
1438
+
1439
+ scenePanel.add(tabbedPane);
12951440
12961441 /*
12971442 cTree jTree = new cTree(null);
....@@ -1325,6 +1470,7 @@
13251470 //bigPanel.setSize(new Dimension(10,10));
13261471 //bigPanel.add(ctrlPanel);
13271472 //bigPanel.add(gridPanel);
1473
+ /**
13281474 bigThree = new JPanel();
13291475 //big.setLayout(new FlowLayout(FlowLayout.LEFT));
13301476 bigThree.setLayout(new GridBagLayout()); //1,3,5,5));
....@@ -1348,7 +1494,13 @@
13481494 // aConstraints.gridheight = 3;
13491495 aWindowConstraints.fill = GridBagConstraints.VERTICAL;
13501496 bigThree.add(XYZPanel, aWindowConstraints);
1497
+ /**/
13511498
1499
+ bigThree = new cGridBag();
1500
+ bigThree.addComponent(scenePanel);
1501
+ bigThree.addComponent(centralPanel);
1502
+ bigThree.addComponent(XYZPanel);
1503
+
13521504 // // SIDE EFFECT!!!
13531505 // aConstraints.gridx = 0;
13541506 // aConstraints.gridy = 0;
....@@ -1369,14 +1521,17 @@
13691521 //worldPane.add(bigPanel);
13701522 //worldPane.add(worldPanel);
13711523 /**/
1372
- frame.getContentPane().add(/*"Center",*/framePanel);
1524
+ //frame.getContentPane().add(/*"Center",*/framePanel);
1525
+ frame.add(/*"Center",*/framePanel);
13731526 //frame.getContentPane().add(/*"Center",*/ worldPane);
13741527
13751528 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13761529
1377
- frame.setSize(1024, 768);
1378
- frame.show();
1530
+ frame.setSize(1280, 860);
1531
+ frame.setVisible(true);
13791532
1533
+ cameraView.requestFocusInWindow();
1534
+
13801535 gridPanel.setDividerLocation(1.0);
13811536
13821537 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
....@@ -1390,6 +1545,10 @@
13901545 });
13911546 }
13921547
1548
+ void AddOptions(cGridBag panel) //, GridBagConstraints constraints)
1549
+ {
1550
+ }
1551
+
13931552 JTree GetTree()
13941553 {
13951554 return objEditor.jTree;
....@@ -1401,260 +1560,173 @@
14011560 ctrlPanel.removeAll();
14021561 }
14031562
1404
- void SetupMaterial(JPanel ctrlPanel)
1563
+ void SetupMaterial(cGridBag panel)
14051564 {
1406
- aConstraints.weighty = 0;
1407
- //aConstraints.weightx = 1;
1408
- /*
1565
+ /*
14091566 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
14101567 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1411
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1412
- aConstraints.gridx += 1;
14131568 */
14141569
1415
- aConstraints.gridwidth = 1;
1416
- ctrlPanel.add(createMaterialButton = new cButton("Create"), aConstraints);
1417
- aConstraints.gridx += 1;
1418
- aConstraints.weighty = 0;
1419
- aConstraints.gridwidth = 1;
1570
+ cGridBag editBar = new cGridBag().setVertical(false);
1571
+
1572
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
1573
+ createMaterialButton.setToolTipText("Create material");
14201574
14211575 /*
14221576 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
1423
- aConstraints.gridx += 1;
1424
- aConstraints.weighty = 0;
1425
- aConstraints.gridwidth = 1;
14261577 */
14271578
1428
- ctrlPanel.add(clearMaterialButton = new cButton("Clear"), aConstraints);
1429
- aConstraints.gridx += 1;
1579
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
1580
+ clearMaterialButton.setToolTipText("Clear material");
1581
+
1582
+ if (Globals.ADVANCED)
1583
+ {
1584
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
1585
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1586
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1587
+ }
14301588
1431
- ctrlPanel.add(resetSlidersButton = new cButton("Reset"), aConstraints);
1432
-
1433
- aConstraints.gridx += 1;
1434
-
1435
- ctrlPanel.add(propagateToggle = new cCheckBox("Prop", propagate), aConstraints);
1436
-
1437
- aConstraints.gridx += 1;
1438
-
1439
- ctrlPanel.add(multiplyToggle = new cCheckBox("Mult", false), aConstraints);
1440
-
1441
- aConstraints.gridx = 0;
1442
- aConstraints.gridy += 1;
1443
- aConstraints.weighty = 0;
1444
- aConstraints.gridwidth = 1;
1589
+ editBar.preferredHeight = 15;
1590
+
1591
+ panel.add(editBar);
1592
+
14451593 /**/
14461594 //aConstraints.weighty = 0;
14471595 ////aConstraints.weightx = 1;
14481596 //aConstraints.weighty = 1;
14491597 aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // 100;
14501598 //aConstraints.gridx += 1;
1451
- ctrlPanel.add(new JLabel("----------------------------------"), aConstraints);
1452
- aConstraints.weighty = 0;
1453
- aConstraints.gridx = 0;
1454
- aConstraints.gridy += 1;
1455
- aConstraints.gridwidth = 1;
1599
+ //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14561600
1457
- ctrlPanel.add(colorLabel = new JLabel("Color/hue"), aConstraints);
1458
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1459
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1460
- aConstraints.gridx += 1;
1461
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1462
- //aConstraints.weightx = 0;
1463
- ctrlPanel.add(colorField = new NumberSlider(0.001, 1, -0.5), aConstraints);
1464
- aConstraints.gridx = 0;
1465
- aConstraints.gridy += 1;
1466
- aConstraints.gridwidth = 1;
1601
+ cGridBag colorSection = new cGridBag().setVertical(true);
1602
+
1603
+ cGridBag color = new cGridBag();
1604
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1605
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1606
+ color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1607
+ //colorField.preferredWidth = 200;
1608
+ colorSection.add(color);
14671609
1468
- ctrlPanel.add(modulationLabel = new JLabel("Saturation"), aConstraints);
1469
- modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1470
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1471
- aConstraints.gridx += 1;
1472
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1473
- ctrlPanel.add(modulationField = new NumberSlider(0.001, 1, -0.5), aConstraints);
1474
- aConstraints.gridx = 0;
1475
- aConstraints.gridy += 1;
1476
- aConstraints.gridwidth = 1;
1610
+ cGridBag modulation = new cGridBag();
1611
+ modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
1612
+ modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1613
+ modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1614
+ colorSection.add(modulation);
14771615
1478
- ctrlPanel.add(textureLabel = new JLabel("Texture"), aConstraints);
1479
- textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1480
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1481
- aConstraints.gridx += 1;
1482
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1483
- ctrlPanel.add(textureField = new NumberSlider(0.001, 1, -0.5), aConstraints);
1484
- aConstraints.gridx = 0;
1485
- aConstraints.gridy += 1;
1486
- aConstraints.gridwidth = 1;
1616
+ cGridBag texture = new cGridBag();
1617
+ texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
1618
+ textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1619
+ texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1620
+ colorSection.add(texture);
14871621
1488
- ctrlPanel.add(anisoLabel = new JLabel("AnisoU"), aConstraints);
1489
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1490
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1491
- aConstraints.gridx += 1;
1492
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1493
- ctrlPanel.add(anisoField = new NumberSlider(0.001, 1, -0.5), aConstraints);
1494
- aConstraints.gridx = 0;
1495
- aConstraints.gridy += 1;
1496
- aConstraints.gridwidth = 1;
1622
+ cGridBag anisoU = new cGridBag();
1623
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1624
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1625
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1626
+ colorSection.add(anisoU);
14971627
1498
- ctrlPanel.add(anisoVLabel = new JLabel("AnisoV"), aConstraints);
1499
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1500
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1501
- aConstraints.gridx += 1;
1502
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1503
- ctrlPanel.add(anisoVField = new NumberSlider(0.001, 1, -0.5), aConstraints);
1504
- aConstraints.gridx = 0;
1505
- aConstraints.gridy += 1;
1506
- aConstraints.gridwidth = 1;
1628
+ cGridBag anisoV = new cGridBag();
1629
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1630
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1631
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1632
+ colorSection.add(anisoV);
15071633
1508
- ctrlPanel.add(shadowbiasLabel = new JLabel("Shadowbias"), aConstraints);
1509
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1510
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1511
- aConstraints.gridx += 1;
1512
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1513
- ctrlPanel.add(shadowbiasField = new NumberSlider(0.001, 50, -1), aConstraints);
1514
- aConstraints.gridx = 0;
1515
- aConstraints.gridy += 1;
1516
- aConstraints.gridwidth = 1;
1634
+ cGridBag shadowbias = new cGridBag();
1635
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1636
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1637
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1638
+ colorSection.add(shadowbias);
15171639
1518
- //aConstraints.weighty = 1;
1519
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // 100;
1520
- //aConstraints.gridx += 1;
1521
- ctrlPanel.add(new JLabel("----------------------------------"), aConstraints);
1522
- aConstraints.weighty = 0;
1523
- aConstraints.gridx = 0;
1524
- aConstraints.gridy += 1;
1525
- aConstraints.gridwidth = 1;
1640
+ panel.add(new JSeparator());
1641
+
1642
+ panel.add(colorSection);
1643
+
1644
+ //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
1645
+
1646
+ cGridBag diffuseSection = new cGridBag().setVertical(true);
1647
+
1648
+ cGridBag diffuse = new cGridBag();
1649
+ diffuse.add(diffuseLabel = new JLabel("Diffuse")); // , aConstraints);
1650
+ diffuseLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1651
+ diffuse.add(diffuseField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1652
+ diffuseSection.add(diffuse);
15261653
1527
- ctrlPanel.add(diffuseLabel = new JLabel("Diffuse"), aConstraints);
1528
- diffuseLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1529
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1530
- aConstraints.gridx += 1;
1531
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1532
- ctrlPanel.add(diffuseField = new NumberSlider(0.001, 50, -1), aConstraints);
1533
- aConstraints.gridx = 0;
1534
- aConstraints.gridy += 1;
1535
- aConstraints.gridwidth = 1;
1654
+ cGridBag diffuseness = new cGridBag();
1655
+ diffuseness.add(diffusenessLabel = new JLabel("Diffusion")); // , aConstraints);
1656
+ diffusenessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1657
+ diffuseness.add(diffusenessField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1658
+ diffuseSection.add(diffuseness);
15361659
1537
- ctrlPanel.add(diffusenessLabel = new JLabel("Diffusion"), aConstraints);
1538
- diffusenessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1539
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1540
- aConstraints.gridx += 1;
1541
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1542
- ctrlPanel.add(diffusenessField = new NumberSlider(0.001, 50, -1), aConstraints);
1543
- aConstraints.gridx = 0;
1544
- aConstraints.gridy += 1;
1545
- aConstraints.gridwidth = 1;
1660
+ cGridBag selfshadow = new cGridBag();
1661
+ selfshadow.add(selfshadowLabel = new JLabel("Selfshadow")); // , aConstraints);
1662
+ selfshadowLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1663
+ selfshadow.add(selfshadowField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1664
+ diffuseSection.add(selfshadow);
15461665
1547
- ctrlPanel.add(selfshadowLabel = new JLabel("Selfshadow"), aConstraints);
1548
- selfshadowLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1549
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1550
- aConstraints.gridx += 1;
1551
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1552
- ctrlPanel.add(selfshadowField = new NumberSlider(0.001, 50, -1), aConstraints);
1553
- aConstraints.gridx = 0;
1554
- aConstraints.gridy += 1;
1555
- aConstraints.gridwidth = 1;
1666
+ cGridBag sheen = new cGridBag();
1667
+ sheen.add(sheenLabel = new JLabel("Sheen")); // , aConstraints);
1668
+ sheenLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1669
+ sheen.add(sheenField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1670
+ diffuseSection.add(sheen);
15561671
1557
- ctrlPanel.add(sheenLabel = new JLabel("Sheen"), aConstraints);
1558
- sheenLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1559
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1560
- aConstraints.gridx += 1;
1561
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1562
- ctrlPanel.add(sheenField = new NumberSlider(0.001, 50, -1), aConstraints);
1563
- aConstraints.gridx = 0;
1564
- aConstraints.gridy += 1;
1565
- aConstraints.gridwidth = 1;
1672
+ cGridBag subsurface = new cGridBag();
1673
+ subsurface.add(subsurfaceLabel = new JLabel("Subsurface")); // , aConstraints);
1674
+ subsurfaceLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1675
+ subsurface.add(subsurfaceField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1676
+ diffuseSection.add(subsurface);
15661677
1567
- ctrlPanel.add(subsurfaceLabel = new JLabel("Subsurface"), aConstraints);
1568
- subsurfaceLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1569
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1570
- aConstraints.gridx += 1;
1571
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1572
- ctrlPanel.add(subsurfaceField = new NumberSlider(0.001, 1, -0.5), aConstraints);
1573
- aConstraints.gridx = 0;
1574
- aConstraints.gridy += 1;
1575
- aConstraints.gridwidth = 1;
1678
+ cGridBag shadow = new cGridBag();
1679
+ shadow.add(shadowLabel = new JLabel("Shadowing")); // , aConstraints);
1680
+ shadowLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1681
+ shadow.add(shadowField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1682
+ diffuseSection.add(shadow);
15761683
1577
- ctrlPanel.add(shadowLabel = new JLabel("Shadowing"), aConstraints);
1578
- shadowLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1579
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1580
- aConstraints.gridx += 1;
1581
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1582
- ctrlPanel.add(shadowField = new NumberSlider(0.001, 50, -1), aConstraints);
1583
- aConstraints.gridx = 0;
1584
- aConstraints.gridy += 1;
1585
- aConstraints.gridwidth = 1;
1684
+ cGridBag fakedepth = new cGridBag();
1685
+ fakedepth.add(fakedepthLabel = new JLabel("Fakedepth")); // , aConstraints);
1686
+ fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1687
+ fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1688
+ diffuseSection.add(fakedepth);
15861689
1587
- ctrlPanel.add(fakedepthLabel = new JLabel("Fakedepth"), aConstraints);
1588
- fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1589
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1590
- aConstraints.gridx += 1;
1591
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1592
- ctrlPanel.add(fakedepthField = new NumberSlider(0.001, 50, -1), aConstraints);
1593
- aConstraints.gridx = 0;
1594
- aConstraints.gridy += 1;
1595
- aConstraints.gridwidth = 1;
1690
+ panel.add(new JSeparator());
1691
+
1692
+ panel.add(diffuseSection);
1693
+
1694
+ //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
1695
+
1696
+ cGridBag specularSection = new cGridBag().setVertical(true);
15961697
1597
- //aConstraints.weighty = 1;
1598
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // 100;
1599
- //aConstraints.gridx += 1;
1600
- ctrlPanel.add(new JLabel("----------------------------------"), aConstraints);
1601
- aConstraints.weighty = 0;
1602
- aConstraints.gridx = 0;
1603
- aConstraints.gridy += 1;
1604
- aConstraints.gridwidth = 1;
1698
+ cGridBag specular = new cGridBag();
1699
+ specular.add(specularLabel = new JLabel("Specular")); // , aConstraints);
1700
+ specularLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1701
+ specular.add(specularField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1702
+ specularSection.add(specular);
16051703
1606
- ctrlPanel.add(specularLabel = new JLabel("Specular"), aConstraints);
1607
- specularLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1608
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1609
- aConstraints.gridx += 1;
1610
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1611
- ctrlPanel.add(specularField = new NumberSlider(0.001, 50, -1), aConstraints);
1612
- aConstraints.gridx = 0;
1613
- aConstraints.gridy += 1;
1614
- aConstraints.gridwidth = 1;
1704
+ cGridBag lightarea = new cGridBag();
1705
+ lightarea.add(lightareaLabel = new JLabel("Lightarea")); // , aConstraints);
1706
+ lightareaLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1707
+ lightarea.add(lightareaField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1708
+ specularSection.add(lightarea);
16151709
1616
- ctrlPanel.add(lightareaLabel = new JLabel("Lightarea"), aConstraints);
1617
- lightareaLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1618
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1619
- aConstraints.gridx += 1;
1620
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1621
- ctrlPanel.add(lightareaField = new NumberSlider(0.001, 50, -1), aConstraints);
1622
- aConstraints.gridx = 0;
1623
- aConstraints.gridy += 1;
1624
- aConstraints.gridwidth = 1;
1710
+ cGridBag shininess = new cGridBag();
1711
+ shininess.add(shininessLabel = new JLabel("Roughness")); // , aConstraints);
1712
+ shininessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1713
+ shininess.add(shininessField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1714
+ specularSection.add(shininess);
16251715
1626
- ctrlPanel.add(shininessLabel = new JLabel("Roughness"), aConstraints);
1627
- shininessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1628
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1629
- aConstraints.gridx += 1;
1630
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1631
- ctrlPanel.add(shininessField = new NumberSlider(0.001, 50, -1), aConstraints);
1632
- aConstraints.gridx = 0;
1633
- aConstraints.gridy += 1;
1634
- aConstraints.gridwidth = 1;
1716
+ cGridBag metalness = new cGridBag();
1717
+ metalness.add(metalnessLabel = new JLabel("Metalness")); // , aConstraints);
1718
+ metalnessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1719
+ metalness.add(metalnessField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1720
+ specularSection.add(metalness);
16351721
1636
- ctrlPanel.add(metalnessLabel = new JLabel("Metalness"), aConstraints);
1637
- metalnessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1638
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1639
- aConstraints.gridx += 1;
1640
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1641
- ctrlPanel.add(metalnessField = new NumberSlider(0.001, 1, -0.5), aConstraints);
1642
- aConstraints.gridx = 0;
1643
- aConstraints.gridy += 1;
1644
- aConstraints.gridwidth = 1;
1722
+ cGridBag velvet = new cGridBag();
1723
+ velvet.add(velvetLabel = new JLabel("Velvet")); // , aConstraints);
1724
+ velvetLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1725
+ velvet.add(velvetField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1726
+ specularSection.add(velvet);
16451727
1646
- ctrlPanel.add(velvetLabel = new JLabel("Velvet"), aConstraints);
1647
- velvetLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1648
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1649
- aConstraints.gridx += 1;
1650
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1651
- ctrlPanel.add(velvetField = new NumberSlider(0.001, 50, -1), aConstraints);
1652
- aConstraints.gridx = 0;
1653
- aConstraints.gridy += 1;
1654
- aConstraints.gridwidth = 1;
1655
-
1656
- shiftField = AddSlider(ctrlPanel, "Shift", 0.001, 50, copy.material.shift, -1);
1657
- Return();
1728
+ shiftField = (cNumberSlider)AddSlider(specularSection, "Shift", 0.001, 50, copy.material.shift, -1).getComponent(1);
1729
+ //Return();
16581730 // ctrlPanel.add(shiftLabel = new JLabel("Shift"), aConstraints);
16591731 // shiftLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16601732 // aConstraints.fill = GridBagConstraints.HORIZONTAL;
....@@ -1665,130 +1737,93 @@
16651737 // aConstraints.gridy += 1;
16661738 // aConstraints.gridwidth = 1;
16671739
1668
- //aConstraints.weighty = 1;
1669
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // 100;
1670
- //aConstraints.gridx += 1;
1671
- ctrlPanel.add(new JLabel("----------------------------------"), aConstraints);
1672
- aConstraints.weighty = 0;
1673
- aConstraints.gridx = 0;
1674
- aConstraints.gridy += 1;
1675
- aConstraints.gridwidth = 1;
16761740
1677
- ctrlPanel.add(cameraLabel = new JLabel("GlobalLight"), aConstraints);
1678
- cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1679
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1680
- aConstraints.gridx += 1;
1681
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1682
- ctrlPanel.add(cameraField = new NumberSlider(0.001, 50, -1), aConstraints);
1683
- aConstraints.gridx = 0;
1684
- aConstraints.gridy += 1;
1685
- aConstraints.gridwidth = 1;
1741
+ panel.add(new JSeparator());
1742
+
1743
+ panel.add(specularSection);
1744
+
1745
+ //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
1746
+
1747
+ cGridBag globalSection = new cGridBag().setVertical(true);
16861748
1687
- ctrlPanel.add(ambientLabel = new JLabel("Ambient"), aConstraints);
1688
- ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1689
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1690
- aConstraints.gridx += 1;
1691
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1692
- ctrlPanel.add(ambientField = new NumberSlider(0.001, 50, -1), aConstraints);
1693
- aConstraints.gridx = 0;
1694
- aConstraints.gridy += 1;
1695
- aConstraints.gridwidth = 1;
1749
+ cGridBag camera = new cGridBag();
1750
+ camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
1751
+ cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1752
+ camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1753
+ globalSection.add(camera);
16961754
1697
- ctrlPanel.add(backlitLabel = new JLabel("Backlit"), aConstraints);
1698
- backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1699
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1700
- aConstraints.gridx += 1;
1701
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1702
- ctrlPanel.add(backlitField = new NumberSlider(0.001, 50, -1), aConstraints);
1703
- aConstraints.gridx = 0;
1704
- aConstraints.gridy += 1;
1705
- aConstraints.gridwidth = 1;
1755
+ cGridBag ambient = new cGridBag();
1756
+ ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
1757
+ ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1758
+ ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1759
+ globalSection.add(ambient);
17061760
1707
- ctrlPanel.add(opacityLabel = new JLabel("Opacity"), aConstraints);
1708
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1709
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1710
- aConstraints.gridx += 1;
1711
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1712
- ctrlPanel.add(opacityField = new NumberSlider(0.001, 1, -0.5), aConstraints);
1713
- aConstraints.gridx = 0;
1714
- aConstraints.gridy += 1;
1715
- aConstraints.gridwidth = 1;
1716
- aConstraints.weighty = 0;
1761
+ cGridBag backlit = new cGridBag();
1762
+ backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
1763
+ backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1764
+ backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1765
+ globalSection.add(backlit);
17171766
1718
- ctrlPanel.add(bumpLabel = new JLabel("Bump"), aConstraints);
1719
- bumpLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1720
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1721
- aConstraints.gridx += 1;
1722
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1723
- ctrlPanel.add(bumpField = new NumberSlider(0.0, 2), aConstraints);
1724
- aConstraints.gridx = 0;
1725
- aConstraints.gridy += 1;
1726
- aConstraints.gridwidth = 1;
1767
+ cGridBag opacity = new cGridBag();
1768
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1769
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1770
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1771
+ globalSection.add(opacity);
17271772
1728
- ctrlPanel.add(noiseLabel = new JLabel("Noise"), aConstraints);
1729
- noiseLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1730
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1731
- aConstraints.gridx += 1;
1732
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1733
- ctrlPanel.add(noiseField = new NumberSlider(0.0, 1/*5*/), aConstraints);
1734
- aConstraints.gridx = 0;
1735
- aConstraints.gridy += 1;
1736
- aConstraints.gridwidth = 1;
1773
+ panel.add(new JSeparator());
1774
+
1775
+ panel.add(globalSection);
1776
+
1777
+ //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
1778
+
1779
+ cGridBag textureSection = new cGridBag().setVertical(true);
17371780
1738
- ctrlPanel.add(powerLabel = new JLabel("Turbulance"), aConstraints);
1739
- powerLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1740
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1741
- aConstraints.gridx += 1;
1742
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1743
- ctrlPanel.add(powerField = new NumberSlider(0.0, 5), aConstraints);
1744
- aConstraints.gridx = 0;
1745
- aConstraints.gridy += 1;
1746
- aConstraints.gridwidth = 1;
1781
+ cGridBag bump = new cGridBag();
1782
+ bump.add(bumpLabel = new JLabel("Bump")); // , aConstraints);
1783
+ bumpLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1784
+ bump.add(bumpField = new cNumberSlider(this, 0.0, 2)); // , aConstraints);
1785
+ textureSection.add(bump);
17471786
1748
- ctrlPanel.add(borderfadeLabel = new JLabel("Borderfade"), aConstraints);
1749
- borderfadeLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1750
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1751
- aConstraints.gridx += 1;
1752
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1753
- ctrlPanel.add(borderfadeField = new NumberSlider(0.0, 2), aConstraints);
1754
- aConstraints.gridx = 0;
1755
- aConstraints.gridy += 1;
1756
- aConstraints.gridwidth = 1;
1787
+ cGridBag noise = new cGridBag();
1788
+ noise.add(noiseLabel = new JLabel("Noise")); // , aConstraints);
1789
+ noiseLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1790
+ noise.add(noiseField = new cNumberSlider(this, 0.0, 1/*5*/)); // , aConstraints);
1791
+ textureSection.add(noise);
17571792
1758
- ctrlPanel.add(fogLabel = new JLabel("Punch"), aConstraints);
1759
- fogLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1760
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1761
- aConstraints.gridx += 1;
1762
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1763
- ctrlPanel.add(fogField = new NumberSlider(0.0, 20), aConstraints);
1764
- aConstraints.gridx = 0;
1765
- aConstraints.gridy += 1;
1766
- aConstraints.gridwidth = 1;
1793
+ cGridBag power = new cGridBag();
1794
+ power.add(powerLabel = new JLabel("Turbulance")); // , aConstraints);
1795
+ powerLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1796
+ power.add(powerField = new cNumberSlider(this, 0.0, 5)); // , aConstraints);
1797
+ textureSection.add(power);
17671798
1768
- ctrlPanel.add(opacityPowerLabel = new JLabel("Halo"), aConstraints);
1769
- opacityPowerLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1770
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
1771
- aConstraints.gridx += 1;
1772
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
1773
- ctrlPanel.add(opacityPowerField = new NumberSlider(0.0, 10 /*10 dec 2013*/), aConstraints);
1774
- aConstraints.gridx = 0;
1775
- aConstraints.gridy += 1;
1776
- aConstraints.gridwidth = 1;
1799
+ cGridBag borderfade = new cGridBag();
1800
+ borderfade.add(borderfadeLabel = new JLabel("Borderfade")); // , aConstraints);
1801
+ borderfadeLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1802
+ borderfade.add(borderfadeField = new cNumberSlider(this, 0.0, 2)); // , aConstraints);
1803
+ textureSection.add(borderfade);
17771804
1778
- //aConstraints.weighty = 1;
1779
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // 100;
1780
- //aConstraints.gridx += 1;
1781
- ctrlPanel.add(new JLabel("----------------------------------"), aConstraints);
1782
- aConstraints.weighty = 0;
1805
+ cGridBag fog = new cGridBag();
1806
+ fog.add(fogLabel = new JLabel("Punch")); // , aConstraints);
1807
+ fogLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1808
+ fog.add(fogField = new cNumberSlider(this, 0.0, 20)); // , aConstraints);
1809
+ textureSection.add(fog);
17831810
1784
- aConstraints.gridx = 0;
1785
- aConstraints.gridy = 0;
1786
- aConstraints.gridwidth = 1;
1811
+ cGridBag opacityPower = new cGridBag();
1812
+ opacityPower.add(opacityPowerLabel = new JLabel("Halo")); // , aConstraints);
1813
+ opacityPowerLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1814
+ opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
1815
+ textureSection.add(opacityPower);
1816
+
1817
+ panel.add(new JSeparator());
1818
+
1819
+ panel.add(textureSection);
1820
+
1821
+ //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17871822
17881823 SetMaterial(copy); // .GetMaterial());
17891824
1790
- colorField.addChangeListener(this);
1791
- modulationField.addChangeListener(this);
1825
+ //colorField.addChangeListener(this);
1826
+// modulationField.addChangeListener(this);
17921827 metalnessField.addChangeListener(this);
17931828 diffuseField.addChangeListener(this);
17941829 specularField.addChangeListener(this);
....@@ -1818,12 +1853,15 @@
18181853 opacityPowerField.addChangeListener(this);
18191854 /**/
18201855
1821
- resetSlidersButton.addActionListener(this);
18221856 clearMaterialButton.addActionListener(this);
18231857 createMaterialButton.addActionListener(this);
1824
-
1825
- propagateToggle.addItemListener(this);
1826
- multiplyToggle.addItemListener(this);
1858
+
1859
+ if (Globals.ADVANCED)
1860
+ {
1861
+ resetSlidersButton.addActionListener(this);
1862
+ propagateToggle.addItemListener(this);
1863
+ multiplyToggle.addItemListener(this);
1864
+ }
18271865 }
18281866
18291867 void DropFile(java.io.File[] files, boolean textures)
....@@ -1994,7 +2032,7 @@
19942032
19952033 //? flashIt = false;
19962034 CameraPane pane = (CameraPane) cameraView;
1997
- pane.clickStart(location.x, location.y, 0);
2035
+ pane.clickStart(location.x, location.y, 0, 0);
19982036 pane.clickEnd(location.x, location.y, 0, true);
19992037
20002038 if (group.selection.size() == 1)
....@@ -2043,6 +2081,7 @@
20432081 e2.printStackTrace();
20442082 }
20452083 }
2084
+
20462085 LoadJMEThread loadThread;
20472086
20482087 class LoadJMEThread extends Thread
....@@ -2100,6 +2139,7 @@
21002139 //LoadFile0(filename, converter);
21012140 }
21022141 }
2142
+
21032143 LoadOBJThread loadObjThread;
21042144
21052145 class LoadOBJThread extends Thread
....@@ -2178,19 +2218,19 @@
21782218
21792219 void LoadObjFile(String fullname)
21802220 {
2181
- /*
2221
+ System.out.println("Loading " + fullname);
2222
+ /**/
21822223 //lastFilename = fullname;
21832224 if(loadObjThread == null)
21842225 {
2185
- loadObjThread = new LoadOBJThread();
2186
- loadObjThread.start();
2226
+ loadObjThread = new LoadOBJThread();
2227
+ loadObjThread.start();
21872228 }
21882229
21892230 loadObjThread.add(fullname);
2190
- */
2231
+ /**/
21912232
2192
- System.out.println("Loading " + fullname);
2193
- makeSomething(new FileObject(fullname, true), true);
2233
+ //makeSomething(new FileObject(fullname, true), true);
21942234 }
21952235
21962236 void LoadGFDFile(String fullname)
....@@ -2451,11 +2491,11 @@
24512491
24522492 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
24532493 {
2454
- if (GrafreeD.standAlone)
2494
+ if (Grafreed.standAlone)
24552495 {
24562496 /**/
24572497 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2458
- browser.show();
2498
+ browser.setVisible(true);
24592499 String filename = browser.getFile();
24602500 if (filename != null && filename.length() > 0)
24612501 {
....@@ -2600,6 +2640,7 @@
26002640 }
26012641 if (input == null)
26022642 {
2643
+ new Exception().printStackTrace();
26032644 System.exit(0);
26042645 }
26052646
....@@ -2814,7 +2855,8 @@
28142855 return;
28152856 }
28162857
2817
- multiplyToggle.setSelected(mat.multiply);
2858
+ if (multiplyToggle != null)
2859
+ multiplyToggle.setSelected(mat.multiply);
28182860
28192861 assert (object.projectedVertices != null);
28202862
....@@ -3029,9 +3071,9 @@
30293071 frame.validate();
30303072
30313073 return;
3032
- } else if (event.getSource() == toggleRandomItem)
3074
+ } else if (event.getSource() == toggleSwitchItem)
30333075 {
3034
- cameraView.ToggleRandom();
3076
+ cameraView.ToggleSwitch();
30353077 cameraView.repaint();
30363078 return;
30373079 } else if (event.getSource() == toggleHandleItem)
....@@ -3060,6 +3102,10 @@
30603102 {
30613103 copy.live ^= true;
30623104 return;
3105
+ } else if (event.getSource() == selectCB)
3106
+ {
3107
+ copy.dontselect ^= true;
3108
+ return;
30633109 } else if (event.getSource() == hideCB)
30643110 {
30653111 copy.hide ^= true;
....@@ -3074,6 +3120,7 @@
30743120 if (event.getSource() == randomCB)
30753121 {
30763122 copy.random ^= true;
3123
+ objEditor.refreshContents();
30773124 return;
30783125 }
30793126 if (event.getSource() == speedupCB)
....@@ -3097,8 +3144,9 @@
30973144
30983145 public void actionPerformed(ActionEvent event)
30993146 {
3147
+ Object source = event.getSource();
31003148 // SCRIPT DIALOG
3101
- if (event.getSource() == okbutton)
3149
+ if (source == okbutton)
31023150 {
31033151 textpanel.setVisible(false);
31043152 textpanel.remove(textarea);
....@@ -3110,7 +3158,7 @@
31103158 textarea = null;
31113159 textpanel = null;
31123160 }
3113
- if (event.getSource() == cancelbutton)
3161
+ if (source == cancelbutton)
31143162 {
31153163 textpanel.setVisible(false);
31163164 textpanel.remove(textarea);
....@@ -3122,49 +3170,50 @@
31223170 //applySelf();
31233171 //client.refreshEditWindow();
31243172 //refreshContents();
3125
- if (event.getSource() == nameField)
3173
+ if (source == nameField)
31263174 {
31273175 //System.out.println("ObjEditor " + event);
31283176 applySelf0(true);
31293177 //parent.applySelf();
31303178 objEditor.refreshContents();
3131
- } else if (event.getSource() == resetButton)
3179
+ } else if (source == resetButton)
31323180 {
31333181 CameraPane.fullreset = true;
31343182 copy.Reset(); // ResetMeshes();
31353183 copy.Touch();
31363184 objEditor.refreshContents();
3137
- } else if (event.getSource() == stepItem)
3185
+ } else if (source == stepItem)
31383186 {
3139
- cameraView.ONESTEP = true;
3187
+ //cameraView.ONESTEP = true;
3188
+ Globals.ONESTEP = true;
31403189 cameraView.repaint();
31413190 return;
3142
- } else if (event.getSource() == stepButton)
3191
+ } else if (source == stepButton)
31433192 {
31443193 copy.Step();
31453194 copy.Touch();
31463195 objEditor.refreshContents();
3147
- } else if (event.getSource() == slowerButton)
3196
+ } else if (source == slowerButton)
31483197 {
31493198 copy.Slower();
31503199 copy.Touch();
31513200 objEditor.refreshContents();
3152
- } else if (event.getSource() == fasterButton)
3201
+ } else if (source == fasterButton)
31533202 {
31543203 copy.Faster();
31553204 copy.Touch();
31563205 objEditor.refreshContents();
3157
- } else if (event.getSource() == remarkButton)
3206
+ } else if (source == remarkButton)
31583207 {
31593208 copy.Remark();
31603209 copy.Touch();
31613210 objEditor.refreshContents();
3162
- } else if (event.getSource() == stepAllButton)
3211
+ } else if (source == stepAllButton)
31633212 {
31643213 copy.StepAll();
31653214 copy.Touch();
31663215 objEditor.refreshContents();
3167
- } else if (event.getSource() == resetAllButton)
3216
+ } else if (source == resetAllButton)
31683217 {
31693218 //CameraPane.fullreset = true;
31703219 copy.ResetAll(); // ResetMeshes();
....@@ -3197,53 +3246,75 @@
31973246 // Close();
31983247 // }
31993248 // else
3200
- if (event.getSource() == resetSlidersButton)
3249
+ if (source == resetSlidersButton)
32013250 {
32023251 ResetSliders();
3203
- } else if (event.getSource() == clearMaterialButton)
3252
+ } else if (source == clearMaterialButton)
32043253 {
32053254 ClearMaterial();
3206
- } else if (event.getSource() == createMaterialButton)
3255
+ } else if (source == createMaterialButton)
32073256 {
32083257 CreateMaterial();
3209
- } else if (event.getSource() == clearPanelButton)
3258
+ } else if (source == clearPanelButton)
32103259 {
32113260 copy.ClearUI();
32123261 refreshContents(true);
3213
- } /*
3214
- }
3215
-
3216
- public boolean action(Event event, Object arg)
3217
- {
3218
- */ else if (event.getSource() == closeItem)
3262
+ } else if (source == importGFDItem)
3263
+ {
3264
+ ImportGFD();
3265
+ } else
3266
+ if (source == importVRMLX3DItem)
3267
+ {
3268
+ ImportVRMLX3D();
3269
+ } else
3270
+ if (source == import3DSItem)
3271
+ {
3272
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3273
+ } else
3274
+ if (source == importOBJItem)
3275
+ {
3276
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3277
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3278
+ browser.setVisible(true);
3279
+ String filename = browser.getFile();
3280
+ if (filename != null && filename.length() > 0)
3281
+ {
3282
+ String fullname = browser.getDirectory() + filename;
3283
+ makeSomething(ReadOBJ(fullname), true);
3284
+ }
3285
+ } else
3286
+ if (source == closeItem)
32193287 {
32203288 Close();
32213289 //return true;
3222
- } else if (event.getSource() == loadItem)
3290
+ } else if (source == loadItem)
32233291 {
32243292 load();
32253293 //return true;
3226
- } else if (event.getSource() == saveItem)
3294
+ } else if (source == newItem)
3295
+ {
3296
+ New();
3297
+ } else if (source == saveItem)
32273298 {
32283299 save();
32293300 //return true;
3230
- } else if (event.getSource() == saveAsItem)
3301
+ } else if (source == saveAsItem)
32313302 {
32323303 saveAs();
32333304 //return true;
3234
- } else if (event.getSource() == reexportItem)
3305
+ } else if (source == reexportItem)
32353306 {
32363307 reexport();
32373308 //return true;
3238
- } else if (event.getSource() == exportAsItem)
3309
+ } else if (source == exportAsItem)
32393310 {
32403311 export();
32413312 //return true;
3242
- } else if (event.getSource() == povItem)
3313
+ } else if (source == povItem)
32433314 {
32443315 generatePOV();
32453316 //return true;
3246
- } else if (event.getSource() == zBufferItem)
3317
+ } else if (source == zBufferItem)
32473318 {
32483319 try
32493320 {
....@@ -3265,21 +3336,8 @@
32653336 cameraView.repaint();
32663337 //return true;
32673338 }
3268
- */ else if (event.getSource() == editCameraItem)
3269
- {
3270
- cameraView.ProtectCamera();
3271
- cameraView.repaint();
3272
- return;
3273
- } else if (event.getSource() == revertCameraItem)
3274
- {
3275
- cameraView.RevertCamera();
3276
- cameraView.repaint();
3277
- return;
3278
-// } else if (event.getSource() == textureButton)
3279
-// {
3280
-// return; // true;
3281
- } else // combos...
3282
- if (event.getSource() == texresMenu)
3339
+ */ else // combos...
3340
+ if (source == texresMenu)
32833341 {
32843342 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
32853343 copy.texres = texresMenu.getSelectedIndex();
....@@ -3291,27 +3349,287 @@
32913349 }
32923350 }
32933351
3294
- void ToggleAnimation()
3352
+ void New()
32953353 {
3296
- if (!CameraPane.ANIMATION)
3354
+ while (copy.Size() > 1)
32973355 {
3298
- FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3356
+ copy.remove(1);
3357
+ }
3358
+
3359
+ ResetModel();
3360
+ objEditor.refreshContents();
3361
+ }
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
+
3580
+ void ImportGFD()
3581
+ {
3582
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
32993583 browser.show();
33003584 String filename = browser.getFile();
33013585 if (filename != null && filename.length() > 0)
33023586 {
3303
- CameraPane.filename = browser.getDirectory() + filename;
3587
+ String fullname = browser.getDirectory() + filename;
3588
+
3589
+ //Object3D readobj =
3590
+ objEditor.ReadGFD(fullname, objEditor);
3591
+ //makeSomething(readobj);
3592
+ }
3593
+ }
3594
+
3595
+ void ImportVRMLX3D()
3596
+ {
3597
+ if (Grafreed.standAlone)
3598
+ {
3599
+ /**/
3600
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3601
+ browser.show();
3602
+ String filename = browser.getFile();
3603
+ if (filename != null && filename.length() > 0)
3604
+ {
3605
+ String fullname = browser.getDirectory() + filename;
3606
+ LoadVRMLX3D(fullname);
3607
+ }
3608
+ /**/
3609
+ }
3610
+ }
3611
+
3612
+ void ToggleAnimation()
3613
+ {
3614
+ if (!Globals.ANIMATION)
3615
+ {
3616
+ FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3617
+ browser.setVisible(true);
3618
+ String filename = browser.getFile();
3619
+ if (filename != null && filename.length() > 0)
3620
+ {
3621
+ Globals.filename = browser.getDirectory() + filename;
33043622 //CameraPane.framecount = 0;
3305
- CameraPane.imagecount = 0;
3623
+ Globals.imagecount = 0;
33063624
3307
- CameraPane.ANIMATION ^= true;
3625
+ Globals.ANIMATION ^= true;
33083626
3309
- GrafreeD.wav.cursor = 0;
3310
- GrafreeD.wav.loop = 0;
3627
+ Grafreed.wav.cursor = 0;
3628
+ Grafreed.wav.loop = 0;
33113629 }
33123630 } else
33133631 {
3314
- CameraPane.ANIMATION ^= true;
3632
+ Globals.ANIMATION ^= true;
33153633 }
33163634 }
33173635
....@@ -3357,7 +3675,7 @@
33573675 void CreateMaterial()
33583676 {
33593677 //copy.ClearMaterial(); // PATCH
3360
- copy.CreateMaterialS(multiplyToggle.isSelected());
3678
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
33613679 if (copy.selection.size() > 0)
33623680 //SetMaterial(copy);
33633681 {
....@@ -3416,11 +3734,11 @@
34163734 {
34173735 copy.ResetBlockLoop(); // temporary problem
34183736
3419
- boolean random = CameraPane.RANDOM;
3420
- CameraPane.RANDOM = false; // parse everything
3737
+ boolean random = CameraPane.SWITCH;
3738
+ CameraPane.SWITCH = false; // parse everything
34213739 copy.ResetDisplayList();
34223740 copy.HardTouch();
3423
- CameraPane.RANDOM = random;
3741
+ CameraPane.SWITCH = random;
34243742 }
34253743
34263744 // public void applySelf()
....@@ -3490,10 +3808,40 @@
34903808 current.fakedepth = (float) fakedepthField.getFloat();
34913809 current.shadowbias = (float) shadowbiasField.getFloat();
34923810
3493
- if (!NumberSlider.frozen)
3811
+ if (!cNumberSlider.frozen)
34943812 {
34953813 //System.out.println("Propagate = " + propagate);
34963814 copy.UpdateMaterial(anchor, current, propagate);
3815
+
3816
+ if (copy.material != null)
3817
+ {
3818
+ cMaterial mat = copy.material;
3819
+
3820
+ colorField.SetToolTipValue((mat.color));
3821
+ modulationField.SetToolTipValue((mat.modulation));
3822
+ metalnessField.SetToolTipValue((mat.metalness));
3823
+ diffuseField.SetToolTipValue((mat.diffuse));
3824
+ specularField.SetToolTipValue((mat.specular));
3825
+ shininessField.SetToolTipValue((mat.shininess));
3826
+ shiftField.SetToolTipValue((mat.shift));
3827
+ ambientField.SetToolTipValue((mat.ambient));
3828
+ lightareaField.SetToolTipValue((mat.lightarea));
3829
+ diffusenessField.SetToolTipValue((mat.factor));
3830
+ velvetField.SetToolTipValue((mat.velvet));
3831
+ sheenField.SetToolTipValue((mat.sheen));
3832
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3833
+ backlitField.SetToolTipValue((mat.bump));
3834
+ anisoField.SetToolTipValue((mat.aniso));
3835
+ anisoVField.SetToolTipValue((mat.anisoV));
3836
+ cameraField.SetToolTipValue((mat.cameralight));
3837
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3838
+ shadowField.SetToolTipValue((mat.shadow));
3839
+ textureField.SetToolTipValue((mat.texture));
3840
+ opacityField.SetToolTipValue((mat.opacity));
3841
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3842
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3843
+ }
3844
+
34973845 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
34983846 {
34993847 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3538,6 +3886,7 @@
35383886 || e.getSource() == apertureField
35393887 || e.getSource() == shadowblurField)
35403888 {
3889
+ new Exception().printStackTrace();
35413890 System.exit(0);
35423891 cameraView.options1[0] = (float) focusField.getFloat() * 10;
35433892 cameraView.options1[1] = (float) apertureField.getFloat() / 1000;
....@@ -3608,7 +3957,7 @@
36083957 }
36093958
36103959 if (normalpushField != null)
3611
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
3960
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
36123961 }
36133962
36143963 void SnapObject()
....@@ -3863,7 +4212,7 @@
38634212
38644213 radioPanel.revalidate();
38654214 radioPanel.repaint();
3866
- ctrlPanel.revalidate(); // ? new
4215
+ ctrlPanel.validate(); // ? new
38674216 ctrlPanel.repaint();
38684217 }
38694218 }
....@@ -3872,6 +4221,8 @@
38724221
38734222 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
38744223 {
4224
+ if (Globals.SAVEONMAKE)
4225
+ Save();
38754226 //Tween.set(thing, 0).target(1).start(tweenManager);
38764227 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
38774228 // if (thing instanceof GenericJointDemo)
....@@ -4075,6 +4426,7 @@
40754426 }
40764427 }
40774428 }
4429
+
40784430 LoadGFDThread loadGFDThread;
40794431
40804432 void ReadGFD(String fullname, iCallBack cb)
....@@ -4094,8 +4446,10 @@
40944446
40954447 try
40964448 {
4449
+ // Try compressed version first.
40974450 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4098
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4451
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4452
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
40994453
41004454 readobj = (Object3D) p.readObject();
41014455 istream.close();
....@@ -4103,7 +4457,20 @@
41034457 readobj.ResetDisplayList();
41044458 } catch (Exception e)
41054459 {
4106
- e.printStackTrace();
4460
+ //e.printStackTrace();
4461
+ try
4462
+ {
4463
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4464
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4465
+
4466
+ readobj = (Object3D) p.readObject();
4467
+ istream.close();
4468
+
4469
+ readobj.ResetDisplayList();
4470
+ } catch (Exception e2)
4471
+ {
4472
+ e2.printStackTrace();
4473
+ }
41074474 }
41084475 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
41094476 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4149,6 +4516,12 @@
41494516
41504517 void LoadIt(Object obj)
41514518 {
4519
+ if (obj == null)
4520
+ {
4521
+ // Invalid file
4522
+ return;
4523
+ }
4524
+
41524525 System.out.println("Loaded " + obj);
41534526 //new Exception().printStackTrace();
41544527 Object3D readobj = (Object3D) obj;
....@@ -4158,6 +4531,8 @@
41584531
41594532 if (readobj != null)
41604533 {
4534
+ if (Globals.SAVEONMAKE)
4535
+ Save();
41614536 try
41624537 {
41634538 //readobj.deepCopySelf(copy);
....@@ -4220,7 +4595,7 @@
42204595
42214596 void load() // throws ClassNotFoundException
42224597 {
4223
- if (GrafreeD.standAlone)
4598
+ if (Grafreed.standAlone)
42244599 {
42254600 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
42264601 browser.show();
....@@ -4307,11 +4682,13 @@
43074682 try
43084683 {
43094684 FileOutputStream ostream = new FileOutputStream(lastname);
4310
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4685
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4686
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43114687
43124688 p.writeObject(copy);
43134689 p.flush();
43144690
4691
+ zstream.close();
43154692 ostream.close();
43164693
43174694 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4321,11 +4698,12 @@
43214698 {
43224699 }
43234700 }
4701
+
43244702 String lastname;
43254703
43264704 void saveAs()
43274705 {
4328
- if (GrafreeD.standAlone)
4706
+ if (Grafreed.standAlone)
43294707 {
43304708 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
43314709 browser.setVisible(true);
....@@ -4430,13 +4808,13 @@
44304808 try
44314809 {
44324810 FileOutputStream ostream = new FileOutputStream(filename);
4433
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4434
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4811
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4812
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
44354813
44364814 Object3D objectparent = obj.parent;
44374815 obj.parent = null;
44384816
4439
- Object3D object = (Object3D) GrafreeD.clone(obj);
4817
+ Object3D object = (Object3D) Grafreed.clone(obj);
44404818
44414819 obj.parent = objectparent;
44424820
....@@ -4448,8 +4826,8 @@
44484826 p.writeObject(object);
44494827 p.flush();
44504828
4829
+ zstream.close();
44514830 ostream.close();
4452
- // zstream.close();
44534831
44544832 // group.selection.get(0).parent = parent;
44554833 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4470,7 +4848,7 @@
44704848 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
44714849 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
44724850 copy.generatePOV(buffer);
4473
- if (GrafreeD.standAlone)
4851
+ if (Grafreed.standAlone)
44744852 {
44754853 FileDialog browser = new FileDialog(frame, "Export POV", 1);
44764854 browser.show();
....@@ -4496,7 +4874,8 @@
44964874 Object3D client;
44974875 Object3D copy;
44984876 MenuBar menuBar;
4499
- Menu windowMenu;
4877
+ Menu fileMenu;
4878
+ MenuItem newItem;
45004879 MenuItem loadItem;
45014880 MenuItem saveItem;
45024881 MenuItem saveAsItem;
....@@ -4504,13 +4883,11 @@
45044883 MenuItem reexportItem;
45054884 MenuItem povItem;
45064885 MenuItem closeItem;
4507
- Menu cameraMenu;
4886
+
45084887 CheckboxMenuItem zBufferItem;
45094888 //MenuItem normalLensItem;
4510
- MenuItem editCameraItem;
4511
- MenuItem revertCameraItem;
4512
- CheckboxMenuItem toggleLiveItem;
45134889 MenuItem stepItem;
4890
+ CheckboxMenuItem toggleLiveItem;
45144891 CheckboxMenuItem toggleFullScreenItem;
45154892 CheckboxMenuItem toggleTimelineItem;
45164893 CheckboxMenuItem toggleRenderItem;
....@@ -4519,7 +4896,7 @@
45194896 CheckboxMenuItem toggleFootContactItem;
45204897 CheckboxMenuItem toggleDLItem;
45214898 CheckboxMenuItem toggleTextureItem;
4522
- CheckboxMenuItem toggleRandomItem;
4899
+ CheckboxMenuItem toggleSwitchItem;
45234900 CheckboxMenuItem toggleRootItem;
45244901 CheckboxMenuItem animationItem;
45254902 CheckboxMenuItem toggleHandleItem;
....@@ -4527,20 +4904,20 @@
45274904 JSplitPane mainPanel;
45284905 JScrollPane scrollpane;
45294906 JPanel toolbarPanel;
4530
- JPanel treePanel;
4907
+ cGridBag treePanel;
45314908 JPanel radioPanel;
45324909 ButtonGroup buttonGroup;
4533
- JPanel ctrlPanel;
4534
- JPanel materialPanel;
4910
+ cGridBag ctrlPanel;
4911
+ cGridBag materialPanel;
45354912 JScrollPane infoPanel;
4536
- JPanel optionsPanel;
4913
+ cGridBag optionsPanel;
45374914 JTabbedPane objectPanel;
4538
- JPanel XYZPanel;
4915
+ cGridBag XYZPanel;
45394916 JSplitPane gridPanel;
45404917 JSplitPane bigPanel;
4541
- JPanel bigThree;
4542
- JTabbedPane scenePanel;
4543
- JPanel centralPanel;
4918
+ cGridBag bigThree;
4919
+ cGridBag scenePanel;
4920
+ cGridBag centralPanel;
45444921 JSplitPane cameraPanel;
45454922 JPanel timelinePanel;
45464923 JMenuBar timelineMenubar;
....@@ -4593,67 +4970,72 @@
45934970 // MATERIAL
45944971 JLabel materialLabel;
45954972 JLabel colorLabel;
4596
- NumberSlider colorField;
4973
+ cNumberSlider colorField;
45974974 JLabel modulationLabel;
4598
- NumberSlider modulationField;
4975
+ cNumberSlider modulationField;
45994976 JLabel metalnessLabel;
4600
- NumberSlider metalnessField;
4977
+ cNumberSlider metalnessField;
46014978 JLabel diffuseLabel;
4602
- NumberSlider diffuseField;
4979
+ cNumberSlider diffuseField;
46034980 JLabel specularLabel;
4604
- NumberSlider specularField;
4981
+ cNumberSlider specularField;
46054982 JLabel shininessLabel;
4606
- NumberSlider shininessField;
4983
+ cNumberSlider shininessField;
46074984 JLabel shiftLabel;
4608
- NumberSlider shiftField;
4985
+ cNumberSlider shiftField;
46094986 JLabel ambientLabel;
4610
- NumberSlider ambientField;
4987
+ cNumberSlider ambientField;
46114988 JLabel lightareaLabel;
4612
- NumberSlider lightareaField;
4989
+ cNumberSlider lightareaField;
46134990 JLabel diffusenessLabel;
4614
- NumberSlider diffusenessField;
4991
+ cNumberSlider diffusenessField;
46154992 JLabel velvetLabel;
4616
- NumberSlider velvetField;
4993
+ cNumberSlider velvetField;
46174994 JLabel sheenLabel;
4618
- NumberSlider sheenField;
4995
+ cNumberSlider sheenField;
46194996 JLabel subsurfaceLabel;
4620
- NumberSlider subsurfaceField;
4997
+ cNumberSlider subsurfaceField;
46214998 //JLabel bumpLabel;
46224999 //NumberSlider bumpField;
46235000 JLabel backlitLabel;
4624
- NumberSlider backlitField;
5001
+ cNumberSlider backlitField;
46255002 JLabel anisoLabel;
4626
- NumberSlider anisoField;
5003
+ cNumberSlider anisoField;
46275004 JLabel anisoVLabel;
4628
- NumberSlider anisoVField;
5005
+ cNumberSlider anisoVField;
46295006 JLabel cameraLabel;
4630
- NumberSlider cameraField;
5007
+ cNumberSlider cameraField;
46315008 JLabel selfshadowLabel;
4632
- NumberSlider selfshadowField;
5009
+ cNumberSlider selfshadowField;
46335010 JLabel shadowLabel;
4634
- NumberSlider shadowField;
5011
+ cNumberSlider shadowField;
46355012 JLabel textureLabel;
4636
- NumberSlider textureField;
5013
+ cNumberSlider textureField;
46375014 JLabel opacityLabel;
4638
- NumberSlider opacityField;
5015
+ cNumberSlider opacityField;
46395016 JLabel fakedepthLabel;
4640
- NumberSlider fakedepthField;
5017
+ cNumberSlider fakedepthField;
46415018 JLabel shadowbiasLabel;
4642
- NumberSlider shadowbiasField;
5019
+ cNumberSlider shadowbiasField;
46435020 JLabel bumpLabel;
4644
- NumberSlider bumpField;
5021
+ cNumberSlider bumpField;
46455022 JLabel noiseLabel;
4646
- NumberSlider noiseField;
5023
+ cNumberSlider noiseField;
46475024 JLabel powerLabel;
4648
- NumberSlider powerField;
5025
+ cNumberSlider powerField;
46495026 JLabel borderfadeLabel;
4650
- NumberSlider borderfadeField;
5027
+ cNumberSlider borderfadeField;
46515028 JLabel fogLabel;
4652
- NumberSlider fogField;
5029
+ cNumberSlider fogField;
46535030 JLabel opacityPowerLabel;
4654
- NumberSlider opacityPowerField;
5031
+ cNumberSlider opacityPowerField;
46555032 JTree jTree;
46565033 //ObjectUI parent;
46575034
4658
- NumberSlider normalpushField;
5035
+ cNumberSlider normalpushField;
5036
+
5037
+ private MenuItem importGFDItem;
5038
+ private MenuItem importVRMLX3DItem;
5039
+ private MenuItem import3DSItem;
5040
+ private MenuItem importOBJItem;
46595041 }