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,19 +74,19 @@
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)
83
+// if (image.getWidth() > 48 && image.getHeight() > 48)
7084 // {
71
-// BufferedImage resized = new BufferedImage(24, 24, image.getType());
85
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
7286 // Graphics2D g = resized.createGraphics();
7387 // g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
7488 // //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
75
-// g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
89
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
7690 // g.dispose();
7791 //
7892 // image = resized;
....@@ -80,6 +94,20 @@
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 {
....@@ -1522,22 +1550,28 @@
15221550 //tmp.setName("Edit");
15231551 objectPanel.add(materialPanel);
15241552 objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1553
+ objectPanel.setToolTipTextAt(0, "Material panel");
1554
+
15251555 // JPanel north = new JPanel(new BorderLayout());
15261556 // north.setName("Edit");
15271557 // north.add(ctrlPanel, BorderLayout.NORTH);
15281558 // objectPanel.add(north);
15291559 objectPanel.add(editPanel);
15301560 objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1561
+ objectPanel.setToolTipTextAt(1, "Edit panel");
15311562
15321563 //if (Globals.ADVANCED)
15331564 objectPanel.add(infoPanel);
15341565 objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1566
+ objectPanel.setToolTipTextAt(2, "Info panel");
15351567
15361568 objectPanel.add(XYZPanel);
15371569 objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1570
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB panel");
15381571
15391572 objectPanel.add(toolboxPanel);
15401573 objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1574
+ objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel");
15411575
15421576 /*
15431577 aConstraints.gridx = 0;
....@@ -1634,8 +1668,8 @@
16341668 /**/
16351669
16361670 bigThree = new cGridBag();
1637
- bigThree.addComponent(centralPanel);
16381671 bigThree.addComponent(scenePanel);
1672
+ bigThree.addComponent(centralPanel);
16391673 //bigThree.addComponent(XYZPanel);
16401674
16411675 // // SIDE EFFECT!!!
....@@ -1677,7 +1711,6 @@
16771711 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16781712 frame.addWindowListener(new WindowAdapter()
16791713 {
1680
-
16811714 public void windowClosing(WindowEvent e)
16821715 {
16831716 Close();
....@@ -1739,27 +1772,48 @@
17391772 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17401773
17411774 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);
17421786
17431787 cGridBag color = new cGridBag();
1744
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1745
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1746
- 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
+
17471793 //colorField.preferredWidth = 200;
17481794 colorSection.add(color);
17491795
17501796 cGridBag modulation = new cGridBag();
17511797 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17521798 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1753
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1799
+ modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17541800 colorSection.add(modulation);
17551801
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
+
17561810 cGridBag texture = new cGridBag();
17571811 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17581812 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17591813 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17601814 colorSection.add(texture);
17611815
1762
- panel.add(new JSeparator());
1816
+ panel.add(GetSeparator());
17631817
17641818 panel.add(colorSection);
17651819
....@@ -1815,7 +1869,7 @@
18151869 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18161870 diffuseSection.add(shadowbias);
18171871
1818
- panel.add(new JSeparator());
1872
+ panel.add(GetSeparator());
18191873
18201874 panel.add(diffuseSection);
18211875
....@@ -1878,7 +1932,7 @@
18781932 specularSection.add(anisoV);
18791933
18801934
1881
- panel.add(new JSeparator());
1935
+ panel.add(GetSeparator());
18821936
18831937 panel.add(specularSection);
18841938
....@@ -1903,12 +1957,6 @@
19031957 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
19041958 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
19051959 colorSection.add(backlit);
1906
-
1907
- cGridBag opacity = new cGridBag();
1908
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1909
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1910
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1911
- colorSection.add(opacity);
19121960
19131961 //panel.add(new JSeparator());
19141962
....@@ -1954,7 +2002,7 @@
19542002 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19552003 textureSection.add(opacityPower);
19562004
1957
- panel.add(new JSeparator());
2005
+ panel.add(GetSeparator());
19582006
19592007 panel.add(textureSection);
19602008
....@@ -3644,7 +3692,7 @@
36443692
36453693 cRadio tab = GetCurrentTab();
36463694
3647
- byte[] compress = CompressCopy();
3695
+ byte[] compress = CompressCopy(); // Saved version. No need for "Replace".
36483696
36493697 boolean thesame = false;
36503698
....@@ -3711,6 +3759,9 @@
37113759
37123760 copy.clear();
37133761
3762
+ copy.skyboxname = obj.skyboxname;
3763
+ copy.skyboxext = obj.skyboxext;
3764
+
37143765 for (int i=0; i<obj.Size(); i++)
37153766 {
37163767 copy.add(obj.get(i));
....@@ -4853,6 +4904,8 @@
48534904 {
48544905 //readobj.deepCopySelf(copy);
48554906 copy.clear(); // june 2014
4907
+ copy.skyboxname = readobj.skyboxname;
4908
+ copy.skyboxext = readobj.skyboxext;
48564909 for (int i = 0; i < readobj.size(); i++)
48574910 {
48584911 Object3D child = readobj.get(i); // reserve(i);