Normand Briere
2019-08-01 c99d954f5e2bffa601c599142371cfeb45630f40
ObjEditor.java
....@@ -41,11 +41,25 @@
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 {
4755 ImageIcon icon = GetIcon(name);
4856 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);
4963 }
5064
5165 cToggleButton GetToggleButton(String name, boolean border)
....@@ -60,26 +74,40 @@
6074 return new cCheckBox(icon, border);
6175 }
6276
63
- private ImageIcon GetIcon(String name)
77
+ ImageIcon GetIcon(String name)
6478 {
6579 try
6680 {
6781 BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
6882
69
- if (image.getWidth() != 24 && image.getHeight() != 24)
70
- {
71
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
72
- Graphics2D g = resized.createGraphics();
73
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
74
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
75
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
76
- g.dispose();
77
-
78
- image = resized;
79
- }
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
+// }
8094
8195 javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
8296 return icon;
97
+ }
98
+ catch (Exception e)
99
+ {
100
+ return null;
101
+ }
102
+ }
103
+
104
+ BufferedImage GetImage(String name)
105
+ {
106
+ try
107
+ {
108
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
109
+
110
+ return image;
83111 }
84112 catch (Exception e)
85113 {
....@@ -327,8 +355,8 @@
327355
328356 if (copy.versions == null)
329357 {
330
- copy.versions = new byte[100][];
331
- copy.versionindex = -1;
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
332360 }
333361
334362 SetupMenu();
....@@ -436,7 +464,7 @@
436464 editPanel.add(editCommandsPanel);
437465 editPanel.add(ctrlPanel);
438466
439
- toolboxPanel = new cGridBag().setVertical(false);
467
+ toolboxPanel = new cGridBag().setVertical(true);
440468 //toolboxPanel.setName("Toolbox");
441469
442470 materialPanel = new cGridBag().setVertical(true);
....@@ -974,7 +1002,7 @@
9741002 // NumberSlider vDivsField;
9751003 // JCheckBox endcaps;
9761004 JCheckBox liveCB;
977
- JCheckBox selectCB;
1005
+ JCheckBox selectableCB;
9781006 JCheckBox hideCB;
9791007 JCheckBox link2masterCB;
9801008 JCheckBox markCB;
....@@ -1186,13 +1214,16 @@
11861214
11871215 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11881216 liveCB.setToolTipText("Animate object");
1189
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1190
- selectCB.setToolTipText("Make object selectable");
1217
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1218
+ selectableCB.setToolTipText("Make object selectable");
11911219 // Return();
1220
+
11921221 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11931222 hideCB.setToolTipText("Hide object");
11941223 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
11951224 markCB.setToolTipText("As animation target transform");
1225
+
1226
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11961227
11971228 setupPanel2 = new cGridBag().setVertical(false);
11981229
....@@ -1519,22 +1550,28 @@
15191550 //tmp.setName("Edit");
15201551 objectPanel.add(materialPanel);
15211552 objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1553
+ objectPanel.setToolTipTextAt(0, "Material panel");
1554
+
15221555 // JPanel north = new JPanel(new BorderLayout());
15231556 // north.setName("Edit");
15241557 // north.add(ctrlPanel, BorderLayout.NORTH);
15251558 // objectPanel.add(north);
15261559 objectPanel.add(editPanel);
15271560 objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1561
+ objectPanel.setToolTipTextAt(1, "Edit panel");
15281562
15291563 //if (Globals.ADVANCED)
15301564 objectPanel.add(infoPanel);
15311565 objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1566
+ objectPanel.setToolTipTextAt(2, "Info panel");
15321567
15331568 objectPanel.add(XYZPanel);
15341569 objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1570
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB panel");
15351571
15361572 objectPanel.add(toolboxPanel);
15371573 objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1574
+ objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel");
15381575
15391576 /*
15401577 aConstraints.gridx = 0;
....@@ -1674,7 +1711,6 @@
16741711 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16751712 frame.addWindowListener(new WindowAdapter()
16761713 {
1677
-
16781714 public void windowClosing(WindowEvent e)
16791715 {
16801716 Close();
....@@ -1736,27 +1772,48 @@
17361772 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17371773
17381774 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);
17391786
17401787 cGridBag color = new cGridBag();
1741
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1742
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1743
- 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
+
17441793 //colorField.preferredWidth = 200;
17451794 colorSection.add(color);
17461795
17471796 cGridBag modulation = new cGridBag();
17481797 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17491798 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1750
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1799
+ modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17511800 colorSection.add(modulation);
17521801
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
+
17531810 cGridBag texture = new cGridBag();
17541811 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17551812 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17561813 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17571814 colorSection.add(texture);
17581815
1759
- panel.add(new JSeparator());
1816
+ panel.add(GetSeparator());
17601817
17611818 panel.add(colorSection);
17621819
....@@ -1812,7 +1869,7 @@
18121869 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18131870 diffuseSection.add(shadowbias);
18141871
1815
- panel.add(new JSeparator());
1872
+ panel.add(GetSeparator());
18161873
18171874 panel.add(diffuseSection);
18181875
....@@ -1875,7 +1932,7 @@
18751932 specularSection.add(anisoV);
18761933
18771934
1878
- panel.add(new JSeparator());
1935
+ panel.add(GetSeparator());
18791936
18801937 panel.add(specularSection);
18811938
....@@ -1900,12 +1957,6 @@
19001957 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
19011958 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
19021959 colorSection.add(backlit);
1903
-
1904
- cGridBag opacity = new cGridBag();
1905
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1906
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1907
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1908
- colorSection.add(opacity);
19091960
19101961 //panel.add(new JSeparator());
19111962
....@@ -1951,7 +2002,7 @@
19512002 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19522003 textureSection.add(opacityPower);
19532004
1954
- panel.add(new JSeparator());
2005
+ panel.add(GetSeparator());
19552006
19562007 panel.add(textureSection);
19572008
....@@ -3250,7 +3301,7 @@
32503301 {
32513302 copy.live ^= true;
32523303 return;
3253
- } else if (event.getSource() == selectCB)
3304
+ } else if (event.getSource() == selectableCB)
32543305 {
32553306 copy.dontselect ^= true;
32563307 return;
....@@ -3641,7 +3692,7 @@
36413692
36423693 cRadio tab = GetCurrentTab();
36433694
3644
- byte[] compress = CompressCopy();
3695
+ byte[] compress = CompressCopy(); // Saved version. No need for "Replace".
36453696
36463697 boolean thesame = false;
36473698
....@@ -3708,6 +3759,9 @@
37083759
37093760 copy.clear();
37103761
3762
+ copy.skyboxname = obj.skyboxname;
3763
+ copy.skyboxext = obj.skyboxext;
3764
+
37113765 for (int i=0; i<obj.Size(); i++)
37123766 {
37133767 copy.add(obj.get(i));
....@@ -4768,7 +4822,9 @@
47684822 readobj.ResetDisplayList();
47694823 } catch (Exception e)
47704824 {
4771
- //e.printStackTrace();
4825
+ if (!e.toString().contains("GZIP"))
4826
+ e.printStackTrace();
4827
+
47724828 try
47734829 {
47744830 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4848,6 +4904,8 @@
48484904 {
48494905 //readobj.deepCopySelf(copy);
48504906 copy.clear(); // june 2014
4907
+ copy.skyboxname = readobj.skyboxname;
4908
+ copy.skyboxext = readobj.skyboxext;
48514909 for (int i = 0; i < readobj.size(); i++)
48524910 {
48534911 Object3D child = readobj.get(i); // reserve(i);
....@@ -4888,6 +4946,7 @@
48884946 }
48894947 } catch (ClassCastException e)
48904948 {
4949
+ e.printStackTrace();
48914950 assert (false);
48924951 Composite c = (Composite) copy;
48934952 c.children.clear();
....@@ -5018,6 +5077,7 @@
50185077 //ps.print(buffer.toString());
50195078 } catch (IOException e)
50205079 {
5080
+ e.printStackTrace();
50215081 }
50225082 }
50235083