Normand Briere
2019-08-01 29d5516687020263d3ae0454ce81879a3a450af0
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 {
....@@ -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);
....@@ -1195,6 +1223,8 @@
11951223 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
11961224 markCB.setToolTipText("As animation target transform");
11971225
1226
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
1227
+
11981228 setupPanel2 = new cGridBag().setVertical(false);
11991229
12001230 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
....@@ -1520,22 +1550,28 @@
15201550 //tmp.setName("Edit");
15211551 objectPanel.add(materialPanel);
15221552 objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1553
+ objectPanel.setToolTipTextAt(0, "Material panel");
1554
+
15231555 // JPanel north = new JPanel(new BorderLayout());
15241556 // north.setName("Edit");
15251557 // north.add(ctrlPanel, BorderLayout.NORTH);
15261558 // objectPanel.add(north);
15271559 objectPanel.add(editPanel);
15281560 objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1561
+ objectPanel.setToolTipTextAt(1, "Edit panel");
15291562
15301563 //if (Globals.ADVANCED)
15311564 objectPanel.add(infoPanel);
15321565 objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1566
+ objectPanel.setToolTipTextAt(2, "Info panel");
15331567
15341568 objectPanel.add(XYZPanel);
15351569 objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1570
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB panel");
15361571
15371572 objectPanel.add(toolboxPanel);
15381573 objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1574
+ objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel");
15391575
15401576 /*
15411577 aConstraints.gridx = 0;
....@@ -1675,7 +1711,6 @@
16751711 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16761712 frame.addWindowListener(new WindowAdapter()
16771713 {
1678
-
16791714 public void windowClosing(WindowEvent e)
16801715 {
16811716 Close();
....@@ -1737,27 +1772,48 @@
17371772 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17381773
17391774 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);
17401786
17411787 cGridBag color = new cGridBag();
1742
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1743
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1744
- 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
+
17451793 //colorField.preferredWidth = 200;
17461794 colorSection.add(color);
17471795
17481796 cGridBag modulation = new cGridBag();
17491797 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17501798 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1751
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1799
+ modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17521800 colorSection.add(modulation);
17531801
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
+
17541810 cGridBag texture = new cGridBag();
17551811 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17561812 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17571813 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17581814 colorSection.add(texture);
17591815
1760
- panel.add(new JSeparator());
1816
+ panel.add(GetSeparator());
17611817
17621818 panel.add(colorSection);
17631819
....@@ -1813,7 +1869,7 @@
18131869 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18141870 diffuseSection.add(shadowbias);
18151871
1816
- panel.add(new JSeparator());
1872
+ panel.add(GetSeparator());
18171873
18181874 panel.add(diffuseSection);
18191875
....@@ -1876,7 +1932,7 @@
18761932 specularSection.add(anisoV);
18771933
18781934
1879
- panel.add(new JSeparator());
1935
+ panel.add(GetSeparator());
18801936
18811937 panel.add(specularSection);
18821938
....@@ -1901,12 +1957,6 @@
19011957 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
19021958 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
19031959 colorSection.add(backlit);
1904
-
1905
- cGridBag opacity = new cGridBag();
1906
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1907
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1908
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1909
- colorSection.add(opacity);
19101960
19111961 //panel.add(new JSeparator());
19121962
....@@ -1952,7 +2002,7 @@
19522002 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19532003 textureSection.add(opacityPower);
19542004
1955
- panel.add(new JSeparator());
2005
+ panel.add(GetSeparator());
19562006
19572007 panel.add(textureSection);
19582008
....@@ -3642,7 +3692,7 @@
36423692
36433693 cRadio tab = GetCurrentTab();
36443694
3645
- byte[] compress = CompressCopy();
3695
+ byte[] compress = CompressCopy(); // Saved version. No need for "Replace".
36463696
36473697 boolean thesame = false;
36483698
....@@ -3709,6 +3759,9 @@
37093759
37103760 copy.clear();
37113761
3762
+ copy.skyboxname = obj.skyboxname;
3763
+ copy.skyboxext = obj.skyboxext;
3764
+
37123765 for (int i=0; i<obj.Size(); i++)
37133766 {
37143767 copy.add(obj.get(i));
....@@ -4769,7 +4822,9 @@
47694822 readobj.ResetDisplayList();
47704823 } catch (Exception e)
47714824 {
4772
- //e.printStackTrace();
4825
+ if (!e.toString().contains("GZIP"))
4826
+ e.printStackTrace();
4827
+
47734828 try
47744829 {
47754830 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4849,6 +4904,8 @@
48494904 {
48504905 //readobj.deepCopySelf(copy);
48514906 copy.clear(); // june 2014
4907
+ copy.skyboxname = readobj.skyboxname;
4908
+ copy.skyboxext = readobj.skyboxext;
48524909 for (int i = 0; i < readobj.size(); i++)
48534910 {
48544911 Object3D child = readobj.get(i); // reserve(i);
....@@ -4889,6 +4946,7 @@
48894946 }
48904947 } catch (ClassCastException e)
48914948 {
4949
+ e.printStackTrace();
48924950 assert (false);
48934951 Composite c = (Composite) copy;
48944952 c.children.clear();
....@@ -5019,6 +5077,7 @@
50195077 //ps.print(buffer.toString());
50205078 } catch (IOException e)
50215079 {
5080
+ e.printStackTrace();
50225081 }
50235082 }
50245083