From 5892f05411c3d4dce2d8a59e0966dc2e1843a971 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Sat, 17 Aug 2019 08:33:35 -0400
Subject: [PATCH] Fix L&F nimbus too slow.
---
ObjEditor.java | 81 ++++++++++++++++++--------
GroupEditor.java | 4
Checker.java | 5 +
icons/white-sphere-icon.png | 0
cButton.java | 2
cToggleButton.java | 2
Composite.java | 1
Grafreed.java | 51 ++++++++++++++++-
8 files changed, 111 insertions(+), 35 deletions(-)
diff --git a/Checker.java b/Checker.java
index 1c59d2c..06f161e 100644
--- a/Checker.java
+++ b/Checker.java
@@ -11,10 +11,13 @@
material = new cMaterial();
- material.ambient = 100;
+ material.ambient = 1;
material.specular = 0.001f;
material.diffuse = 0.01f;
material.cameralight = 0.001f;
+ material.opacity = 0.5f;
+
+ flipV = true;
}
Object3D deepCopy()
diff --git a/Composite.java b/Composite.java
index 63b89d4..4aa0f45 100644
--- a/Composite.java
+++ b/Composite.java
@@ -401,7 +401,6 @@
{
child = (Object3D) e.nextElement();
}
-
}
void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
diff --git a/Grafreed.java b/Grafreed.java
index 99344db..39862ba 100644
--- a/Grafreed.java
+++ b/Grafreed.java
@@ -5,6 +5,7 @@
import java.io.*;
+import java.util.ArrayList;
import javax.swing.UIManager;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.plaf.ColorUIResource;
@@ -15,7 +16,7 @@
//import com.jamonapi.*;
public class Grafreed extends Applet implements ActionListener
{
- static boolean NIMBUSLAF = true;
+ static boolean NIMBUSLAF = false; // true;
static int RENDERME = 0;
@@ -898,6 +899,13 @@
//UIManager.setLookAndFeel("com.apple.laf.AquaLookAndFeel");
//UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
//UIManager.put("nimbusBase", new Color(0,0,0));
+
+ javax.swing.UIDefaults ui = UIManager.getDefaults();
+ for (java.util.Enumeration e = ui.keys(); e.hasMoreElements();)
+ {
+ Object key = e.nextElement();
+ System.out.println(key + " --> " + ui.get(key));
+ }
}
catch (Exception e)
{
@@ -907,12 +915,49 @@
{
try
{
- MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
- MetalLookAndFeel.setCurrentTheme(new Theme(Constants.yellowTheme));
+ //Object o = UIManager.getInstalledLookAndFeels();
+
+ MetalLookAndFeel.setCurrentTheme(new javax.swing.plaf.metal.DefaultMetalTheme());
+ //MetalLookAndFeel.setCurrentTheme(new Theme(Constants.yellowTheme));
+ //UIManager.put("ScrollBar.background", new javax.swing.plaf.ColorUIResource(100,0,0));
UIManager.setLookAndFeel(new MetalLookAndFeel());
//UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
//UIManager.setLookAndFeel("com.apple.laf.AquaLookAndFeel");
+ //UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
//UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
+
+ javax.swing.UIDefaults ui = UIManager.getDefaults();
+ ArrayList gradient = new java.util.ArrayList(5);
+ gradient.add(1.0);
+ gradient.add(0.0);
+ gradient.add(new javax.swing.plaf.ColorUIResource(255,255,255));
+ gradient.add(new javax.swing.plaf.ColorUIResource(192,192,192));
+ gradient.add(new javax.swing.plaf.ColorUIResource(0,0,0));
+
+ ui.put("Button.gradient", gradient);
+ ui.put("TabbedPane.tabInsets", new javax.swing.plaf.InsetsUIResource(0,8,0,0));
+ ui.put("Slider.foreground", new javax.swing.plaf.ColorUIResource(0,0,0));
+ ui.put("Slider.horizontalThumbIcon", ObjEditor.GetIcon("icons/white-sphere-icon.png"));
+
+ //javax.swing.plaf.metal.MetalIconFactory.getHorizontalSliderThumbIcon().
+ Object o = ui.get("Slider.horizontalThumbIcon");
+
+ gradient = new java.util.ArrayList(5);
+ gradient.add(1.0);
+ gradient.add(0.0);
+ gradient.add(new javax.swing.plaf.ColorUIResource(192,192,192));
+ gradient.add(new javax.swing.plaf.ColorUIResource(255,255,255));
+ gradient.add(new javax.swing.plaf.ColorUIResource(0,0,0));
+
+ ui.put("ToggleButton.gradient", gradient);
+ //ui.put("Button[MouseOver].backgroundPainter", new com.sun.java.swing.plaf.nimbus.ButtonPainter());
+ //ui.put("Button.highlight", new javax.swing.plaf.ColorUIResource(155,155,155));
+
+ for (java.util.Enumeration e = ui.keys(); e.hasMoreElements();)
+ {
+ Object key = e.nextElement();
+ //System.out.println(key + " --> " + ui.get(key));
+ }
} catch (Exception e)
{
}
diff --git a/GroupEditor.java b/GroupEditor.java
index 09250cb..08097bc 100644
--- a/GroupEditor.java
+++ b/GroupEditor.java
@@ -1040,7 +1040,7 @@
*/
cGridBag copyOptionsPanel = new cGridBag();
- copyOptionsPanel.preferredHeight = 2;
+ copyOptionsPanel.preferredHeight = 3;
//this.AddOptions(oe.toolbarPanel, oe.aConstraints);
@@ -1323,7 +1323,7 @@
oe.treePanel.Return();
cGridBag sliderPane = AddSlider(oe.treePanel, "Version", 0, 0, 0);
versionSlider = (cNumberSlider)sliderPane.getComponent(1);
- sliderPane.preferredHeight = 1;
+ sliderPane.preferredHeight = 2;
// mainPanel.setDividerLocation(0.1); //1.0);
mainPanel.setResizeWeight(0.4);
diff --git a/ObjEditor.java b/ObjEditor.java
index 2b68312..7bec816 100644
--- a/ObjEditor.java
+++ b/ObjEditor.java
@@ -106,7 +106,7 @@
static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
- ImageIcon GetIcon(String name)
+ static ImageIcon GetIcon(String name)
{
javax.swing.ImageIcon iconCache = icons.get(name);
if (iconCache != null)
@@ -116,7 +116,7 @@
try
{
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
+ BufferedImage image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
// if (image.getWidth() > 48 && image.getHeight() > 48)
// {
@@ -1715,7 +1715,7 @@
scrollpane.addMouseWheelListener(this); // Default not fast enough
/*JTabbedPane*/ scenePanel = new cGridBag();
- scenePanel.preferredWidth = 5;
+ scenePanel.preferredWidth = 6;
JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.add(scrollpane);
@@ -4738,6 +4738,12 @@
// else
// applySelf(true);
// }
+
+ boolean Equal(double a, double b)
+ {
+ return Math.abs(a - b) < 0.001;
+ }
+
void applySelf0(boolean name)
{
if (name)
@@ -4787,29 +4793,52 @@
{
cMaterial mat = copy.material;
- colorField.SetToolTipValue((mat.color));
- saturationField.SetToolTipValue((mat.modulation));
- metalnessField.SetToolTipValue((mat.metalness));
- diffuseField.SetToolTipValue((mat.diffuse));
- specularField.SetToolTipValue((mat.specular));
- shininessField.SetToolTipValue((mat.shininess));
- shiftField.SetToolTipValue((mat.shift));
- ambientField.SetToolTipValue((mat.ambient));
- lightareaField.SetToolTipValue((mat.lightarea));
- diffusenessField.SetToolTipValue((mat.factor));
- velvetField.SetToolTipValue((mat.velvet));
- sheenField.SetToolTipValue((mat.sheen));
- subsurfaceField.SetToolTipValue((mat.subsurface));
- backlitField.SetToolTipValue((mat.bump));
- anisoField.SetToolTipValue((mat.aniso));
- anisoVField.SetToolTipValue((mat.anisoV));
- cameraField.SetToolTipValue((mat.cameralight));
- selfshadowField.SetToolTipValue((mat.diffuseness));
- shadowField.SetToolTipValue((mat.shadow));
- textureField.SetToolTipValue((mat.texture));
- opacityField.SetToolTipValue((mat.opacity));
- fakedepthField.SetToolTipValue((mat.fakedepth));
- shadowbiasField.SetToolTipValue((mat.shadowbias));
+ if (!Equal(colorField.getFloat(), mat.color))
+ colorField.SetToolTipValue((mat.color));
+ if (!Equal(saturationField.getFloat(), mat.modulation))
+ saturationField.SetToolTipValue((mat.modulation));
+ if (!Equal(metalnessField.getFloat(), mat.metalness))
+ metalnessField.SetToolTipValue((mat.metalness));
+ if (!Equal(diffuseField.getFloat(), mat.diffuse))
+ diffuseField.SetToolTipValue((mat.diffuse));
+ if (!Equal(specularField.getFloat(), mat.specular))
+ specularField.SetToolTipValue((mat.specular));
+ if (!Equal(shininessField.getFloat(), mat.shininess))
+ shininessField.SetToolTipValue((mat.shininess));
+ if (!Equal(shiftField.getFloat(), mat.shift))
+ shiftField.SetToolTipValue((mat.shift));
+ if (!Equal(ambientField.getFloat(), mat.ambient))
+ ambientField.SetToolTipValue((mat.ambient));
+ if (!Equal(lightareaField.getFloat(), mat.lightarea))
+ lightareaField.SetToolTipValue((mat.lightarea));
+ if (!Equal(diffusenessField.getFloat(), mat.factor))
+ diffusenessField.SetToolTipValue((mat.factor));
+ if (!Equal(velvetField.getFloat(), mat.velvet))
+ velvetField.SetToolTipValue((mat.velvet));
+ if (!Equal(sheenField.getFloat(), mat.sheen))
+ sheenField.SetToolTipValue((mat.sheen));
+ if (!Equal(subsurfaceField.getFloat(), mat.subsurface))
+ subsurfaceField.SetToolTipValue((mat.subsurface));
+ if (!Equal(backlitField.getFloat(), mat.bump))
+ backlitField.SetToolTipValue((mat.bump));
+ if (!Equal(anisoField.getFloat(), mat.aniso))
+ anisoField.SetToolTipValue((mat.aniso));
+ if (!Equal(anisoVField.getFloat(), mat.anisoV))
+ anisoVField.SetToolTipValue((mat.anisoV));
+ if (!Equal(cameraField.getFloat(), mat.cameralight))
+ cameraField.SetToolTipValue((mat.cameralight));
+ if (!Equal(selfshadowField.getFloat(), mat.diffuseness))
+ selfshadowField.SetToolTipValue((mat.diffuseness));
+ if (!Equal(shadowField.getFloat(), mat.shadow))
+ shadowField.SetToolTipValue((mat.shadow));
+ if (!Equal(textureField.getFloat(), mat.texture))
+ textureField.SetToolTipValue((mat.texture));
+ if (!Equal(opacityField.getFloat(), mat.opacity))
+ opacityField.SetToolTipValue((mat.opacity));
+ if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
+ fakedepthField.SetToolTipValue((mat.fakedepth));
+ if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
}
if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
diff --git a/cButton.java b/cButton.java
index 2022871..9357d5b 100644
--- a/cButton.java
+++ b/cButton.java
@@ -26,7 +26,7 @@
{
super(icon);
- setMargin(new java.awt.Insets(-1, -1, -1, -1));
+ setMargin(new java.awt.Insets(1, 10, 1, 10)); // ??
//result = new JButton( icon );
//result.setBorderPainted( false );
diff --git a/cToggleButton.java b/cToggleButton.java
index a9a562a..06b84ac 100644
--- a/cToggleButton.java
+++ b/cToggleButton.java
@@ -37,7 +37,7 @@
//if (getWidth() > image.getWidth(null) + 8)
{
g.drawImage(image, this.getWidth()/2 - 12, this.getHeight()/2 - 12, this);
- g.drawRect(0, 0, this.getWidth()-1, this.getHeight()-1);
+ g.drawRect(2, 2, this.getWidth()-5, this.getHeight()-5);
}
}
}
diff --git a/icons/white-sphere-icon.png b/icons/white-sphere-icon.png
new file mode 100644
index 0000000..c4349a6
--- /dev/null
+++ b/icons/white-sphere-icon.png
Binary files differ
--
Gitblit v1.6.2