From a7e7618fb914f8b919a17daf6c020b860c5d11c9 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Tue, 10 Sep 2019 00:32:18 -0400 Subject: [PATCH] Lazy icons. --- ObjEditor.java | 9 +++++---- Torus.java | 4 ++-- Sphere.java | 8 ++++---- cButton.java | 32 ++++++++++++++++++++++++++++---- Grafreed.java | 7 +++++-- 5 files changed, 44 insertions(+), 16 deletions(-) diff --git a/Grafreed.java b/Grafreed.java index 423b52f..28064c8 100644 --- a/Grafreed.java +++ b/Grafreed.java @@ -688,10 +688,14 @@ public static void main(String argv[]) { - String osArch = System.getProperty("os.arch"); + String osArch = System.getProperty("os.arch"); if (Globals.DEBUG) System.out.println("os.arch = " + osArch); + String osName = System.getProperty("os.name"); + + isWindows = !osName.equals("Mac OS X"); + if (argv.length == 0) { String javaPath = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; @@ -717,7 +721,6 @@ // -Djava.library.path=/Users/nbriere/Projects/shared/lib if (jarfile.charAt(2) == ':') { - isWindows = true; command = "\"" + javaPath + "\" -Xmx1024m -Djava.library.path=" + jarpath; // On Windows systems, the path is /C:/ jarfile = jarfile.substring(1, jarfile.length()); diff --git a/ObjEditor.java b/ObjEditor.java index 6e8ba4c..4f82f20 100644 --- a/ObjEditor.java +++ b/ObjEditor.java @@ -98,10 +98,11 @@ cButton GetButton(String name, boolean border) { - ImageIcon icon = GetIcon(name); + //ImageIcon icon = GetIcon(name); boolean fit = !name.startsWith("icons"); - if (icon != null || name.contains("/")) - return new cButton(icon, border, fit); + if (//icon != null || + name.contains("/")) + return new cButton(name, border, fit); else return new cButton(name, border); } @@ -1787,7 +1788,7 @@ objectTabbedPane.setToolTipTextAt(objectTabCount++, "Material"); figurePanel = new cGridBag(); - figurePanel.add(new cButton("FIGURES amd POSES coming soon!")); + figurePanel.add(new cButton("FIGURES and POSES coming soon!")); objectTabbedPane.add(figurePanel); objectTabbedPane.setIconAt(objectTabCount, GetIcon("icons/figure.png")); objectTabbedPane.setToolTipTextAt(objectTabCount++, "Figures and poses"); diff --git a/Sphere.java b/Sphere.java index 4a0b298..af49eba 100644 --- a/Sphere.java +++ b/Sphere.java @@ -13,8 +13,8 @@ this(false); radius = 0.05f; - uDivs = 7; - vDivs = 6; + uDivs = 11; // 7; + vDivs = 4; // 6; center = new cVector(); center.set(x, y, z); @@ -44,8 +44,8 @@ inPnt = new cVector(); name = "Sphere"; //uDivs = vDivs = 16; - uDivs = 8; // 19; - vDivs = 8; // 18; + uDivs = 12; // 8; // 19; + vDivs = 6; // 8; // 18; minUDivs = 3; minVDivs = 2; //center = new cVector(); diff --git a/Torus.java b/Torus.java index 3b5ebd2..7bf9ec5 100644 --- a/Torus.java +++ b/Torus.java @@ -8,8 +8,8 @@ { inPnt = new cVector(); name = "Torus"; - uDivs = 35; // 64; - vDivs = 19; // 24; + uDivs = 61; // 35; // 64; + vDivs = 21; // 19; // 24; minUDivs = 3; minVDivs = 3; retile(); diff --git a/cButton.java b/cButton.java index 0a15961..701e0cf 100644 --- a/cButton.java +++ b/cButton.java @@ -1,5 +1,8 @@ public class cButton extends javax.swing.JButton { + String iconname; + boolean fit; + cButton(String name) { super(name); @@ -22,16 +25,20 @@ } } - cButton(javax.swing.ImageIcon icon, boolean border, boolean fit) + cButton(//javax.swing.ImageIcon icon, + String iconname, + boolean border, boolean fit) { - super(icon); + //super(icon); + this.iconname = iconname; + this.fit = fit; assert(border); //setMargin(new java.awt.Insets(1, 10, 1, 10)); // ?? - if (icon != null && fit) - this.image = icon.getImage(); +// if (icon != null && fit) +// this.image = icon.getImage(); //result = new JButton( icon ); //result.setBorderPainted( false ); @@ -53,6 +60,23 @@ //@Override protected void paintComponent(java.awt.Graphics g) { + if (iconname != null) + { + javax.swing.ImageIcon icon = ObjEditor.GetIcon(iconname); + + if (icon == null) + setName(iconname); + else + { + if (fit) + this.image = icon.getImage(); + else + setIcon(icon); + } + + iconname = null; + } + if (image != null) { //if (getWidth() > image.getWidth(null) + 8) -- Gitblit v1.6.2