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 | 172 ++++++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 120 insertions(+), 52 deletions(-) diff --git a/ObjEditor.java b/ObjEditor.java index d80b908..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) // { @@ -388,7 +388,8 @@ //parent = p; GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); - System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow()); + if (Globals.DEBUG) + System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow()); //gd.setFullScreenWindow(this); //setResizable(false); //if (!isDisplayable()) @@ -425,6 +426,9 @@ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>(); + // This is to refresh the UI of the material panel. + boolean patchMaterial; + void SetupMenu() { frame.setMenuBar(menuBar = new MenuBar()); @@ -950,18 +954,24 @@ boolean temp = CameraPane.SWITCH; CameraPane.SWITCH = false; - object.ExtractBigData(versiontable); + if (Grafreed.grafreed.universe.versiontable == null) + Grafreed.grafreed.universe.versiontable = new java.util.Hashtable<java.util.UUID, Object3D>(); + + object.ExtractBigData(Grafreed.grafreed.universe.versiontable); // if (copy == client) Object3D versions[] = object.versionlist; + java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe object.versionlist = null; + object.versiontable = null; //byte[] compress = Compress(copy); Object3D compress = (Object3D)Grafreed.clone(object); object.versionlist = versions; + object.versiontable = versiontable; // if Grafreed.grafreed.universe - object.RestoreBigData(versiontable); + object.RestoreBigData(Grafreed.grafreed.universe.versiontable); CameraPane.SWITCH = temp; @@ -1323,14 +1333,14 @@ liveCB = AddCheckBox(setupPanel, "Live", copy.live); liveCB.setToolTipText("Animate object"); + markCB = AddCheckBox(setupPanel, "Anim", copy.marked); + markCB.setToolTipText("Set target transform"); selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect); selectableCB.setToolTipText("Make object selectable"); // Return(); hideCB = AddCheckBox(setupPanel, "Hide", copy.hide); hideCB.setToolTipText("Hide object"); - markCB = AddCheckBox(setupPanel, "Mark", copy.marked); - markCB.setToolTipText("As animation target transform"); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); @@ -1532,6 +1542,7 @@ if (cam == null || !(copy.get(0) instanceof cGroup)) { + if (Globals.DEBUG) System.out.println("CREATE CAMERAS"); cams = new cTemplate(); cams.name = "Cameras"; @@ -1657,14 +1668,14 @@ //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //tmp.setName("Edit"); - objectPanel.add(materialPanel); - objectPanel.setIconAt(0, GetIcon("icons/material.png")); - objectPanel.setToolTipTextAt(0, "Material"); - objectPanel.add(toolboxPanel); - objectPanel.setIconAt(1, GetIcon("icons/primitives.png")); - objectPanel.setToolTipTextAt(1, "Objects & textures"); + objectPanel.setIconAt(0, GetIcon("icons/primitives.png")); + objectPanel.setToolTipTextAt(0, "Objects & textures"); + objectPanel.add(materialPanel); + objectPanel.setIconAt(1, GetIcon("icons/material.png")); + objectPanel.setToolTipTextAt(1, "Material"); + objectPanel.add(skyboxPanel); objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg")); objectPanel.setToolTipTextAt(2, "Backgrounds"); @@ -1681,6 +1692,10 @@ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png")); objectPanel.setToolTipTextAt(4, "XYZ/RGB transform"); + patchMaterial = true; + cameraView.patchMaterial = this; + objectPanel.setSelectedIndex(1); + /* aConstraints.gridx = 0; aConstraints.gridwidth = 1; @@ -1700,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); @@ -1878,7 +1893,15 @@ // Skin colorField.setFloat(material.color); - saturationField.setFloat(material.modulation); + float saturation = material.modulation; + + if (!cameraView.Skinshader) + { + saturation /= 1.5; + } + + saturationField.setFloat(saturation); + subsurfaceField.setFloat(material.subsurface); selfshadowField.setFloat(material.diffuseness); diffusenessField.setFloat(material.factor); @@ -2196,7 +2219,7 @@ public void mouseClicked(MouseEvent e) { borderfadeField.setFloat(0.5); - opacityField.setFloat(0.6); + opacityField.setFloat(0.75); materialtouched = true; applySelf(); @@ -2311,9 +2334,20 @@ cGridBag huepanel = new cGridBag(); cGridBag huelabel = new cGridBag(); - skin = GetLabel("icons/hue.png", false); - skin.fit = true; - huelabel.add(skin); + cLabel hue = GetLabel("icons/hue.png", false); + hue.fit = true; + + hue.addMouseListener(new MouseAdapter() + { + public void mousePressed(MouseEvent e) + { + int x = e.getX(); + + colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth()); + } + }); + + huelabel.add(hue); huelabel.preferredWidth = 20; huepanel.add(new cGridBag()); // Label huepanel.add(huelabel); // Field/slider @@ -3900,7 +3934,7 @@ //System.out.println("ObjEditor " + event); applySelf0(true); //parent.applySelf(); - objEditor.refreshContents(); + // conflicts with requestFocus objEditor.refreshContents(); } else if (source == resetButton) { CameraPane.fullreset = true; @@ -4212,8 +4246,6 @@ return true; } - java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>(); - void DeleteVersion() { for (int i = copy.versionindex; i < copy.versionlist.length-1; i++) @@ -4221,7 +4253,11 @@ copy.versionlist[i] = copy.versionlist[i+1]; } - CopyChanged(); + if (copy.versionlist[copy.versionindex] == null) + copy.versionindex -= 1; + + if (copy.versionindex != -1) + CopyChanged(); SetVersionStates(); } @@ -4334,7 +4370,7 @@ boolean temp = CameraPane.SWITCH; CameraPane.SWITCH = false; - copy.ExtractBigData(versiontable); + copy.ExtractBigData(Grafreed.grafreed.universe.versiontable); copy.clear(); @@ -4346,7 +4382,7 @@ copy.add(obj.get(i)); } - copy.RestoreBigData(versiontable); + copy.RestoreBigData(Grafreed.grafreed.universe.versiontable); CameraPane.SWITCH = temp; @@ -4409,8 +4445,8 @@ previousVersionButton.setEnabled(copy.versionindex > 0); nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null); - deleteVersionButton.setEnabled(//copy.versionindex > 0 && - copy.versionlist[copy.versionindex + 1] != null); + deleteVersionButton.setEnabled(copy.versionindex != -1); + //copy.versionlist[copy.versionindex + 1] != null); muteSlider = true; versionSlider.setMinimum(0); @@ -4475,7 +4511,7 @@ public boolean Replace() { - System.err.println("Replace"); + //System.err.println("Replace"); //cRadio tab = GetCurrentTab(); @@ -4702,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) @@ -4751,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) @@ -5178,6 +5243,8 @@ if (previousVersionButton != null && copy.versionlist != null) SetVersionStates(); + + cameraView.requestFocusInWindow(); } static TweenManager tweenManager = new TweenManager(); @@ -5209,7 +5276,7 @@ // group = (Composite) group.get(0); // } - System.out.println("makeSomething of " + thing); + //System.out.println("makeSomething of " + thing); /* if (deselect && jList != null) @@ -5563,6 +5630,7 @@ copy.versionlist = readobj.versionlist; copy.versionindex = readobj.versionindex; + copy.versiontable = readobj.versiontable; if (copy.versionlist == null) { -- Gitblit v1.6.2