Normand Briere
2019-08-01 29d5516687020263d3ae0454ce81879a3a450af0
ObjEditor.java
....@@ -41,64 +41,78 @@
4141 JFrame frame;
4242
4343 static ObjEditor theFrame;
44
+
45
+ public cGridBag GetSeparator()
46
+ {
47
+ cGridBag separator = new cGridBag();
48
+ separator.add(new JSeparator());
49
+ separator.preferredHeight = 5;
50
+ return separator;
51
+ }
4452
4553 cButton GetButton(String name, boolean border)
4654 {
47
- try
48
- {
49
- ImageIcon icon = GetIcon(name);
50
- return new cButton(icon, border);
51
- }
52
- catch (Exception e)
53
- {
54
- return new cButton(name, border);
55
- }
55
+ ImageIcon icon = GetIcon(name);
56
+ return new cButton(icon, border);
57
+ }
58
+
59
+ cLabel GetLabel(String name, boolean border)
60
+ {
61
+ //ImageIcon icon = GetIcon(name);
62
+ return new cLabel(GetImage(name), border);
5663 }
5764
5865 cToggleButton GetToggleButton(String name, boolean border)
5966 {
60
- try
61
- {
62
- ImageIcon icon = GetIcon(name);
63
- return new cToggleButton(icon, border);
64
- }
65
- catch (Exception e)
66
- {
67
- return new cToggleButton(name, border);
68
- }
67
+ ImageIcon icon = GetIcon(name);
68
+ return new cToggleButton(icon, border);
6969 }
7070
7171 cCheckBox GetCheckBox(String name, boolean border)
7272 {
73
+ ImageIcon icon = GetIcon(name);
74
+ return new cCheckBox(icon, border);
75
+ }
76
+
77
+ ImageIcon GetIcon(String name)
78
+ {
7379 try
7480 {
75
- ImageIcon icon = GetIcon(name);
76
- return new cCheckBox(icon, border);
81
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
82
+
83
+// if (image.getWidth() > 48 && image.getHeight() > 48)
84
+// {
85
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
86
+// Graphics2D g = resized.createGraphics();
87
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
88
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
89
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
90
+// g.dispose();
91
+//
92
+// image = resized;
93
+// }
94
+
95
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
96
+ return icon;
7797 }
7898 catch (Exception e)
7999 {
80
- return new cCheckBox(name, border);
100
+ return null;
81101 }
82102 }
83
-
84
- private ImageIcon GetIcon(String name) throws IOException
103
+
104
+ BufferedImage GetImage(String name)
85105 {
86
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
87
-
88
- if (image.getWidth() != 24 && image.getHeight() != 24)
106
+ try
89107 {
90
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
91
- Graphics2D g = resized.createGraphics();
92
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
93
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
94
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
95
- g.dispose();
96
-
97
- image = resized;
108
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
109
+
110
+ return image;
98111 }
99
-
100
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
101
- return icon;
112
+ catch (Exception e)
113
+ {
114
+ return null;
115
+ }
102116 }
103117
104118 // SCRIPT
....@@ -341,8 +355,8 @@
341355
342356 if (copy.versions == null)
343357 {
344
- copy.versions = new byte[100][];
345
- copy.versionindex = -1;
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
346360 }
347361
348362 SetupMenu();
....@@ -437,11 +451,12 @@
437451
438452 toolbarPanel = new JPanel();
439453 toolbarPanel.setName("Toolbar");
454
+
440455 treePanel = new cGridBag();
441456 treePanel.setName("Tree");
442457
443458 editPanel = new cGridBag().setVertical(true);
444
- editPanel.setName("Edit");
459
+ //editPanel.setName("Edit");
445460
446461 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
447462
....@@ -449,11 +464,11 @@
449464 editPanel.add(editCommandsPanel);
450465 editPanel.add(ctrlPanel);
451466
452
- toolboxPanel = new cGridBag().setVertical(false);
453
- toolboxPanel.setName("Toolbox");
467
+ toolboxPanel = new cGridBag().setVertical(true);
468
+ //toolboxPanel.setName("Toolbox");
454469
455470 materialPanel = new cGridBag().setVertical(true);
456
- materialPanel.setName("Material");
471
+ //materialPanel.setName("Material");
457472
458473 /*JTextPane*/
459474 infoarea = createTextPane();
....@@ -461,6 +476,7 @@
461476
462477 infoarea.setEditable(true);
463478 SetText();
479
+
464480 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
465481 // infoarea.setOpaque(false);
466482 // //infoarea.setForeground(textcolor);
....@@ -468,7 +484,7 @@
468484 // TEXTAREA infoarea.setWrapStyleWord(true);
469485 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
470486 infoPanel.setPreferredSize(new Dimension(1, 1));
471
- infoPanel.setName("Info");
487
+ //infoPanel.setName("Info");
472488 //infoPanel.setLayout(new BorderLayout());
473489 //infoPanel.add(createTextPane());
474490
....@@ -986,7 +1002,7 @@
9861002 // NumberSlider vDivsField;
9871003 // JCheckBox endcaps;
9881004 JCheckBox liveCB;
989
- JCheckBox selectCB;
1005
+ JCheckBox selectableCB;
9901006 JCheckBox hideCB;
9911007 JCheckBox link2masterCB;
9921008 JCheckBox markCB;
....@@ -1198,13 +1214,16 @@
11981214
11991215 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
12001216 liveCB.setToolTipText("Animate object");
1201
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1202
- selectCB.setToolTipText("Make object selectable");
1217
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1218
+ selectableCB.setToolTipText("Make object selectable");
12031219 // Return();
1220
+
12041221 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
12051222 hideCB.setToolTipText("Hide object");
12061223 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
12071224 markCB.setToolTipText("As animation target transform");
1225
+
1226
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
12081227
12091228 setupPanel2 = new cGridBag().setVertical(false);
12101229
....@@ -1492,6 +1511,7 @@
14921511 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14931512 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14941513 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1514
+ //XYZPanel.setName("XYZ");
14951515
14961516 /*
14971517 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1529,16 +1549,29 @@
15291549 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
15301550 //tmp.setName("Edit");
15311551 objectPanel.add(materialPanel);
1552
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1553
+ objectPanel.setToolTipTextAt(0, "Material panel");
1554
+
15321555 // JPanel north = new JPanel(new BorderLayout());
15331556 // north.setName("Edit");
15341557 // north.add(ctrlPanel, BorderLayout.NORTH);
15351558 // objectPanel.add(north);
15361559 objectPanel.add(editPanel);
1560
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1561
+ objectPanel.setToolTipTextAt(1, "Edit panel");
15371562
15381563 //if (Globals.ADVANCED)
15391564 objectPanel.add(infoPanel);
1565
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1566
+ objectPanel.setToolTipTextAt(2, "Info panel");
1567
+
1568
+ objectPanel.add(XYZPanel);
1569
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1570
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB panel");
15401571
15411572 objectPanel.add(toolboxPanel);
1573
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1574
+ objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel");
15421575
15431576 /*
15441577 aConstraints.gridx = 0;
....@@ -1559,7 +1592,7 @@
15591592 scrollpane.addMouseWheelListener(this); // Default not fast enough
15601593
15611594 /*JTabbedPane*/ scenePanel = new cGridBag();
1562
- scenePanel.preferredWidth = 6;
1595
+ scenePanel.preferredWidth = 5;
15631596
15641597 JTabbedPane tabbedPane = new JTabbedPane();
15651598 tabbedPane.add(scrollpane);
....@@ -1637,7 +1670,7 @@
16371670 bigThree = new cGridBag();
16381671 bigThree.addComponent(scenePanel);
16391672 bigThree.addComponent(centralPanel);
1640
- bigThree.addComponent(XYZPanel);
1673
+ //bigThree.addComponent(XYZPanel);
16411674
16421675 // // SIDE EFFECT!!!
16431676 // aConstraints.gridx = 0;
....@@ -1678,7 +1711,6 @@
16781711 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16791712 frame.addWindowListener(new WindowAdapter()
16801713 {
1681
-
16821714 public void windowClosing(WindowEvent e)
16831715 {
16841716 Close();
....@@ -1740,27 +1772,48 @@
17401772 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17411773
17421774 cGridBag colorSection = new cGridBag().setVertical(true);
1775
+
1776
+ cGridBag huepanel = new cGridBag();
1777
+ cGridBag huelabel = new cGridBag();
1778
+ huelabel.add(GetLabel("icons/hue.png", false));
1779
+ huelabel.preferredWidth = 20;
1780
+ huepanel.add(new cGridBag()); // Label
1781
+ huepanel.add(huelabel); // Field/slider
1782
+
1783
+ huepanel.preferredHeight = 7;
1784
+
1785
+ colorSection.add(huepanel);
17431786
17441787 cGridBag color = new cGridBag();
1745
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1746
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1747
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1788
+
1789
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1790
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1791
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1792
+
17481793 //colorField.preferredWidth = 200;
17491794 colorSection.add(color);
17501795
17511796 cGridBag modulation = new cGridBag();
17521797 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17531798 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1754
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1799
+ modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17551800 colorSection.add(modulation);
17561801
1802
+ cGridBag opacity = new cGridBag();
1803
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1804
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1805
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1806
+ colorSection.add(opacity);
1807
+
1808
+ colorSection.add(GetSeparator());
1809
+
17571810 cGridBag texture = new cGridBag();
17581811 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17591812 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17601813 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17611814 colorSection.add(texture);
17621815
1763
- panel.add(new JSeparator());
1816
+ panel.add(GetSeparator());
17641817
17651818 panel.add(colorSection);
17661819
....@@ -1816,7 +1869,7 @@
18161869 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18171870 diffuseSection.add(shadowbias);
18181871
1819
- panel.add(new JSeparator());
1872
+ panel.add(GetSeparator());
18201873
18211874 panel.add(diffuseSection);
18221875
....@@ -1879,7 +1932,7 @@
18791932 specularSection.add(anisoV);
18801933
18811934
1882
- panel.add(new JSeparator());
1935
+ panel.add(GetSeparator());
18831936
18841937 panel.add(specularSection);
18851938
....@@ -1904,12 +1957,6 @@
19041957 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
19051958 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
19061959 colorSection.add(backlit);
1907
-
1908
- cGridBag opacity = new cGridBag();
1909
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1910
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1911
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1912
- colorSection.add(opacity);
19131960
19141961 //panel.add(new JSeparator());
19151962
....@@ -1955,7 +2002,7 @@
19552002 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19562003 textureSection.add(opacityPower);
19572004
1958
- panel.add(new JSeparator());
2005
+ panel.add(GetSeparator());
19592006
19602007 panel.add(textureSection);
19612008
....@@ -3254,7 +3301,7 @@
32543301 {
32553302 copy.live ^= true;
32563303 return;
3257
- } else if (event.getSource() == selectCB)
3304
+ } else if (event.getSource() == selectableCB)
32583305 {
32593306 copy.dontselect ^= true;
32603307 return;
....@@ -3645,7 +3692,7 @@
36453692
36463693 cRadio tab = GetCurrentTab();
36473694
3648
- byte[] compress = CompressCopy();
3695
+ byte[] compress = CompressCopy(); // Saved version. No need for "Replace".
36493696
36503697 boolean thesame = false;
36513698
....@@ -3712,6 +3759,9 @@
37123759
37133760 copy.clear();
37143761
3762
+ copy.skyboxname = obj.skyboxname;
3763
+ copy.skyboxext = obj.skyboxext;
3764
+
37153765 for (int i=0; i<obj.Size(); i++)
37163766 {
37173767 copy.add(obj.get(i));
....@@ -4772,7 +4822,9 @@
47724822 readobj.ResetDisplayList();
47734823 } catch (Exception e)
47744824 {
4775
- //e.printStackTrace();
4825
+ if (!e.toString().contains("GZIP"))
4826
+ e.printStackTrace();
4827
+
47764828 try
47774829 {
47784830 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4852,6 +4904,8 @@
48524904 {
48534905 //readobj.deepCopySelf(copy);
48544906 copy.clear(); // june 2014
4907
+ copy.skyboxname = readobj.skyboxname;
4908
+ copy.skyboxext = readobj.skyboxext;
48554909 for (int i = 0; i < readobj.size(); i++)
48564910 {
48574911 Object3D child = readobj.get(i); // reserve(i);
....@@ -4892,6 +4946,7 @@
48924946 }
48934947 } catch (ClassCastException e)
48944948 {
4949
+ e.printStackTrace();
48954950 assert (false);
48964951 Composite c = (Composite) copy;
48974952 c.children.clear();
....@@ -5022,6 +5077,7 @@
50225077 //ps.print(buffer.toString());
50235078 } catch (IOException e)
50245079 {
5080
+ e.printStackTrace();
50255081 }
50265082 }
50275083