diff --git a/sdk/jme3-core/src/com/jme3/gde/core/properties/ComboBoxPropertyEditor.java b/sdk/jme3-core/src/com/jme3/gde/core/properties/ComboBoxPropertyEditor.java new file mode 100644 index 000000000..a180acf28 --- /dev/null +++ b/sdk/jme3-core/src/com/jme3/gde/core/properties/ComboBoxPropertyEditor.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2009-2010 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.gde.core.properties; + +import com.jme3.gde.core.util.ComboInplaceEditor; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.beans.PropertyEditorSupport; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import org.openide.explorer.propertysheet.ExPropertyEditor; +import org.openide.explorer.propertysheet.InplaceEditor; +import org.openide.explorer.propertysheet.PropertyEnv; + +/** + * + * @author Nehon + */ +public class ComboBoxPropertyEditor extends PropertyEditorSupport implements ExPropertyEditor, InplaceEditor.Factory { + + private LinkedList listeners = new LinkedList(); + PropertyEnv env; + private ComboInplaceEditor ed = null; + + public ComboBoxPropertyEditor(List list) { + ed = new ComboInplaceEditor(list); + } + + public void attachEnv(PropertyEnv env) { + this.env = env; + env.registerInplaceEditorFactory(this); + } + + public void setList(List list){ + ed.setList(list); + } + + public int getNumElements(){ + return ed.getNumElements(); + } + + @Override + public String getAsText() { + return ed.getValue().toString(); + } + + @Override + public void setAsText(String s) { + Object o = ed.getValue(); + ((ComboInplaceEditor) ed).setAsText(s); + notifyListeners(o, ed.getValue()); + } + + + public InplaceEditor getInplaceEditor() { + return ed; + } + + @Override + public void setValue(Object value) { + ed.setValue(value); + + } + + @Override + public Object getValue() { + return ed.getValue(); + } + + public PropertyEnv getEnv() { + return env; + } + + @Override + public void addPropertyChangeListener(PropertyChangeListener listener) { + listeners.add(listener); + } + + @Override + public void removePropertyChangeListener(PropertyChangeListener listener) { + listeners.remove(listener); + } + + private void notifyListeners(Object before, Object after) { + for (Iterator it = listeners.iterator(); it.hasNext();) { + PropertyChangeListener propertyChangeListener = it.next(); + //TODO: check what the "programmatic name" is supposed to be here.. for now its Quaternion + propertyChangeListener.propertyChange(new PropertyChangeEvent(this, null, before, after)); + } + } +} diff --git a/sdk/jme3-core/src/com/jme3/gde/core/properties/LodLevelProperty.java b/sdk/jme3-core/src/com/jme3/gde/core/properties/LodLevelProperty.java new file mode 100644 index 000000000..7ccb06dcc --- /dev/null +++ b/sdk/jme3-core/src/com/jme3/gde/core/properties/LodLevelProperty.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2009-2010 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.gde.core.properties; + +import com.jme3.gde.core.scene.SceneApplication; +import com.jme3.scene.Geometry; +import java.beans.PropertyEditor; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Callable; + +/** + * + * @author Nehon + */ +public class LodLevelProperty extends SceneExplorerProperty { + + ComboBoxPropertyEditor editor = null; + int hash = 0; + private Geometry geometry; + + public LodLevelProperty(Object instance, Class valueType, String getter, String setter) throws NoSuchMethodException { + super(instance, valueType, getter, setter); + geometry = (Geometry) instance; + } + + public LodLevelProperty(Object instance, Class valueType, String getter, String setter, ScenePropertyChangeListener listener) throws NoSuchMethodException { + super(instance, valueType, getter, setter, listener); + geometry = (Geometry) instance; + } + + @Override + public PropertyEditor getPropertyEditor() { + if (editor == null) { + List list = makeList(); + editor = new ComboBoxPropertyEditor(list); + } + return editor; + } + + private void refresh() { + List list = makeList(); + editor.setList(list); + } + + @Override + public String getName() { + return "Lod Level"; + } + + @Override + public Object getValue() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { + if (hash != computeHash()) { + refresh(); + } + return geometry.getLodLevel(); + } + + @Override + public void setValue(Object val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { + final int level = Integer.parseInt(((String) val).split(" - ")[0]); + SceneApplication.getApplication().enqueue(new Callable() { + public Void call() throws Exception { + if (geometry.getMesh().getNumLodLevels() > level) { + geometry.setLodLevel(level); + } + return null; + } + }); + + } + + private List makeList() { + List list = new ArrayList(); + if (geometry.getMesh().getNumLodLevels() > 0) { + for (int i = 0; i < geometry.getMesh().getNumLodLevels(); i++) { + int triNum = geometry.getMesh().getLodLevel(i).getNumElements(); + list.add(i + " - " + triNum + " triangles"); + } + } else { + list.add("0 - " + geometry.getMesh().getTriangleCount() + " triangles"); + } + + hash = computeHash(); + return list; + } + + private int computeHash() { + if (geometry.getMesh().getNumLodLevels() > 0) { + return geometry.getMesh().getLodLevel(geometry.getMesh().getNumLodLevels() - 1).hashCode(); + } + return 0; + } +} diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeGeometry.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeGeometry.java index 146c6e5a2..e55a84e5a 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeGeometry.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeGeometry.java @@ -32,6 +32,7 @@ package com.jme3.gde.core.sceneexplorer.nodes; import com.jme3.gde.core.icons.IconList; +import com.jme3.gde.core.properties.LodLevelProperty; import com.jme3.gde.core.scene.SceneApplication; import com.jme3.gde.core.sceneexplorer.MaterialChangeListener; import com.jme3.gde.core.sceneexplorer.SceneExplorerTopComponent; @@ -43,6 +44,7 @@ import java.io.IOException; import java.util.concurrent.Callable; import org.openide.loaders.DataObject; import org.openide.nodes.Sheet; +import org.openide.util.Exceptions; /** * @@ -68,7 +70,7 @@ public class JmeGeometry extends JmeSpatial implements MaterialChangeListener { SceneExplorerTopComponent.findInstance().addMaterialChangeListener(JmeGeometry.this); } catch (Exception e) { - e.printStackTrace(); + Exceptions.printStackTrace(e); } } }); @@ -95,7 +97,7 @@ public class JmeGeometry extends JmeSpatial implements MaterialChangeListener { SceneExplorerTopComponent.findInstance().removeMaterialChangeListener(JmeGeometry.this); } catch (Exception e) { - e.printStackTrace(); + Exceptions.printStackTrace(e); } } }); @@ -114,7 +116,11 @@ public class JmeGeometry extends JmeSpatial implements MaterialChangeListener { return sheet; } - set.put(makeProperty(obj, int.class, "getLodLevel", "setLodLevel", "Lod Level")); + try { + set.put(new LodLevelProperty(obj, int.class, "getLodLevel", "setLodLevel", this)); + } catch (NoSuchMethodException ex) { + Exceptions.printStackTrace(ex); + } set.put(makeProperty(obj, Material.class, "getMaterial", "setMaterial", "Material")); set.put(makeProperty(obj, Mesh.class, "getMesh", "Mesh")); @@ -151,7 +157,7 @@ public class JmeGeometry extends JmeSpatial implements MaterialChangeListener { try { SceneExplorerTopComponent.findInstance().swapMaterialChangeListener(JmeGeometry.this, ((Material) before).getAssetName(), ((Material) after).getAssetName()); } catch (Exception e) { - e.printStackTrace(); + Exceptions.printStackTrace(e); } } }); diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/Bundle.properties b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/Bundle.properties index e579d28ad..e62d0cd7a 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/Bundle.properties +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/Bundle.properties @@ -3,3 +3,38 @@ NewCustomControlVisualPanel1.jLabel1.text=Class Name: AtlasBatchGeometryVisualPanel1.jTextArea1.text=Note that all the textures of the batched geometry have to fit in the atlas texture, else not all will be added to the atlas. There is no scaling happening!\n\nAlso note that when batching geometry with normal maps you have to make sure the current normal map and color/diffuse map etc. match in size for each geometry. \nE.g. a model with a diffuse map of 256x256 has to use a normal map with 256x256 pixels as well. GenerateTangentsVisualPanel1.jTextPane1.text=Warning this will likely modify the mesh by adding vertices.\nUse this if your normal map has mirrored parts. GenerateTangentsVisualPanel1.splitMirrored.text=Split vertices with mirrored UVs +GenerateLODVisualPanel1.jPanel1.border.title=Reduction method +GenerateLODVisualPanel1.jPanel2.border.title=Reduction values +GenerateLODVisualPanel1.jLabel1.text=Type a value for each desired level +GenerateLODVisualPanel1.jLabel1.toolTipText= +GenerateLODVisualPanel1.labelLevel1.text=Level 1 +GenerateLODVisualPanel1.valueLevel1.text= +GenerateLODVisualPanel1.labelLevel2.text=Level 2 +GenerateLODVisualPanel1.valueLevel2.text= +GenerateLODVisualPanel1.labelLevel3.text=Level 3 +GenerateLODVisualPanel1.valueLevel3.text= +GenerateLODVisualPanel1.valueLevel4.text= +GenerateLODVisualPanel1.labelLevel4.text=Level 4 +GenerateLODVisualPanel1.labelLevel5.text=Level 4 +GenerateLODVisualPanel1.valueLevel5.text= +GenerateLODVisualPanel1.labelLevel6.text=Level 5 +GenerateLODVisualPanel1.valueLevel6.text= +GenerateLODVisualPanel1.valueLevel7.text= +GenerateLODVisualPanel1.labelLevel7.text=Level 6 +GenerateLODVisualPanel1.labelLevel8.text=Level 7 +GenerateLODVisualPanel1.valueLevel8.text= +GenerateLODVisualPanel1.valueLevel9.text= +GenerateLODVisualPanel1.labelLevel9.text=Level 8 +GenerateLODVisualPanel1.labelLevel10.text=Level 9 +GenerateLODVisualPanel1.valueLevel10.text= +GenerateLODVisualPanel1.labelLevel5.toolTipText= +GenerateLODVisualPanel1.estLabel1.text= +GenerateLODVisualPanel1.estLabel2.text= +GenerateLODVisualPanel1.estLabel4.text= +GenerateLODVisualPanel1.estLabel6.text= +GenerateLODVisualPanel1.estLabel7.text= +GenerateLODVisualPanel1.estLabel8.text= +GenerateLODVisualPanel1.estLabel9.text= +GenerateLODVisualPanel1.estLabel10.text= +GenerateLODVisualPanel1.estLabel5.text= +GenerateLODVisualPanel1.estLabel3.text= diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateLODTool.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateLODTool.java new file mode 100644 index 000000000..6623a4eeb --- /dev/null +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateLODTool.java @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2009-2010 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.gde.core.sceneexplorer.nodes.actions.impl; + +import com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode; +import com.jme3.gde.core.sceneexplorer.nodes.JmeGeometry; +import com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractToolWizardAction; +import com.jme3.gde.core.sceneexplorer.nodes.actions.ToolAction; +import com.jme3.scene.Geometry; +import com.jme3.scene.Mesh; +import com.jme3.scene.VertexBuffer; +import java.awt.Component; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; +import javax.swing.JComponent; +import jme3tools.optimize.LodGenerator; +import org.openide.DialogDisplayer; +import org.openide.WizardDescriptor; +import org.openide.nodes.Node; + +/** + * + * @author nehon + */ +@org.openide.util.lookup.ServiceProvider(service = ToolAction.class) +public class GenerateLODTool extends AbstractToolWizardAction { + + public GenerateLODTool() { + name = "Generate Levels of Detail"; + } + + @Override + protected void doUndoTool(AbstractSceneExplorerNode rootNode, Object undoObject) { + + Geometry geom = rootNode.getLookup().lookup(Geometry.class); + Mesh mesh = geom.getMesh(); + if (mesh != null) { + mesh.setLodLevels((VertexBuffer[]) undoObject); + } + + } + + public Class getNodeClass() { + return JmeGeometry.class; + } + + @Override + protected Object showWizard(Node node) { + AbstractSceneExplorerNode rootNode = (AbstractSceneExplorerNode) node; + Geometry geom = rootNode.getLookup().lookup(Geometry.class); + int triSize = geom.getMesh().getTriangleCount(); + + List> panels = new ArrayList>(); + panels.add(new GenerateLODWizardPanel1()); + for (int i = 0; i < panels.size(); i++) { + Component c = panels.get(i).getComponent(); + if (c instanceof JComponent) { // assume Swing components + JComponent jc = (JComponent) c; + jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i); + jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true); + jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true); + jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true); + } + } + WizardDescriptor wiz = new WizardDescriptor(new WizardDescriptor.ArrayIterator(panels)); + // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName() + wiz.setTitleFormat(new MessageFormat("{0}")); + wiz.setTitle("Generate Levels of Detail for this model"); + wiz.putProperty("triSize", triSize); + + if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) { + return wiz; + } + return null; + } + + @Override + protected Object doApplyTool(AbstractSceneExplorerNode rootNode, Object settings) { + WizardDescriptor wiz = (WizardDescriptor) settings; + + Geometry geom = rootNode.getLookup().lookup(Geometry.class); + Mesh mesh = geom.getMesh(); + if (mesh != null) { + //save old lods + VertexBuffer[] lods = null; + if (geom.getMesh().getNumLodLevels() > 0) { + lods = new VertexBuffer[geom.getMesh().getNumLodLevels()]; + for (int i = 0; i < lods.length; i++) { + lods[i] = geom.getMesh().getLodLevel(i); + } + } + + + if (wiz != null) { + float[] values = (float[]) wiz.getProperties().get("reductionValues"); + if (values != null) { + //generate lods + LodGenerator generator = new LodGenerator(geom); + LodGenerator.TriangleReductionMethod method = (LodGenerator.TriangleReductionMethod) wiz.getProperties().get("reductionMethod"); + generator.bakeLods(method, values); + }else{ + mesh.setLodLevels(null); + } + } + + return lods; + } + return null; + + } +} diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateLODVisualPanel1.form b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateLODVisualPanel1.form new file mode 100644 index 000000000..60caeb2a4 --- /dev/null +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateLODVisualPanel1.form @@ -0,0 +1,572 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateLODVisualPanel1.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateLODVisualPanel1.java new file mode 100644 index 000000000..cd75ff54e --- /dev/null +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateLODVisualPanel1.java @@ -0,0 +1,596 @@ + /* + * Copyright (c) 2009-2010 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.gde.core.sceneexplorer.nodes.actions.impl; + +import java.util.ArrayList; +import java.util.List; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import jme3tools.optimize.LodGenerator; + +public final class GenerateLODVisualPanel1 extends JPanel { + + private List valuesFields = new ArrayList(); + private List estimationFields = new ArrayList(); + private int triSize; + + /** + * Creates new form GenerateLODVisualPanel1 + */ + public GenerateLODVisualPanel1() { + initComponents(); + reductionMethod.setModel(new DefaultComboBoxModel()); + reductionMethod.addItem(LodGenerator.TriangleReductionMethod.PROPORTIONAL); + reductionMethod.addItem(LodGenerator.TriangleReductionMethod.CONSTANT); + + valuesFields.add(valueLevel1); + valuesFields.add(valueLevel2); + valuesFields.add(valueLevel3); + valuesFields.add(valueLevel4); + valuesFields.add(valueLevel5); + valuesFields.add(valueLevel6); + valuesFields.add(valueLevel7); + valuesFields.add(valueLevel8); + valuesFields.add(valueLevel9); + valuesFields.add(valueLevel10); + + estimationFields.add(estLabel1); + estimationFields.add(estLabel2); + estimationFields.add(estLabel3); + estimationFields.add(estLabel4); + estimationFields.add(estLabel5); + estimationFields.add(estLabel6); + estimationFields.add(estLabel7); + estimationFields.add(estLabel8); + estimationFields.add(estLabel9); + estimationFields.add(estLabel10); + } + + @Override + public String getName() { + return "Step #1"; + } + + public LodGenerator.TriangleReductionMethod getReducitonMethod() { + return (LodGenerator.TriangleReductionMethod) reductionMethod.getSelectedItem(); + } + + public List getValuesFields() { + return valuesFields; + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + reductionMethod = new javax.swing.JComboBox(); + jScrollPane1 = new javax.swing.JScrollPane(); + reductionDescription = new javax.swing.JTextPane(); + jPanel2 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + valuePanel = new javax.swing.JPanel(); + labelLevel1 = new javax.swing.JLabel(); + valueLevel1 = new javax.swing.JTextField(); + labelLevel2 = new javax.swing.JLabel(); + valueLevel2 = new javax.swing.JTextField(); + valueLevel3 = new javax.swing.JTextField(); + labelLevel3 = new javax.swing.JLabel(); + valueLevel4 = new javax.swing.JTextField(); + labelLevel4 = new javax.swing.JLabel(); + valueLevel5 = new javax.swing.JTextField(); + labelLevel5 = new javax.swing.JLabel(); + valueLevel6 = new javax.swing.JTextField(); + labelLevel6 = new javax.swing.JLabel(); + valueLevel7 = new javax.swing.JTextField(); + labelLevel7 = new javax.swing.JLabel(); + valueLevel8 = new javax.swing.JTextField(); + labelLevel8 = new javax.swing.JLabel(); + valueLevel9 = new javax.swing.JTextField(); + labelLevel9 = new javax.swing.JLabel(); + valueLevel10 = new javax.swing.JTextField(); + labelLevel10 = new javax.swing.JLabel(); + estLabel1 = new javax.swing.JLabel(); + estLabel2 = new javax.swing.JLabel(); + estLabel3 = new javax.swing.JLabel(); + estLabel4 = new javax.swing.JLabel(); + estLabel5 = new javax.swing.JLabel(); + estLabel6 = new javax.swing.JLabel(); + estLabel7 = new javax.swing.JLabel(); + estLabel8 = new javax.swing.JLabel(); + estLabel9 = new javax.swing.JLabel(); + estLabel10 = new javax.swing.JLabel(); + + jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.jPanel1.border.title"))); // NOI18N + + reductionMethod.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + reductionMethod.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + reductionMethodActionPerformed(evt); + } + }); + + reductionDescription.setBackground(new java.awt.Color(240, 240, 240)); + jScrollPane1.setViewportView(reductionDescription); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jScrollPane1) + .addComponent(reductionMethod, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(reductionMethod, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 74, Short.MAX_VALUE)) + ); + + jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.jPanel2.border.title"))); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.jLabel1.text")); // NOI18N + jLabel1.setToolTipText(org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.jLabel1.toolTipText")); // NOI18N + + valuePanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + + labelLevel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + org.openide.awt.Mnemonics.setLocalizedText(labelLevel1, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.labelLevel1.text")); // NOI18N + + valueLevel1.setText(org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.valueLevel1.text")); // NOI18N + valueLevel1.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + valueLevel1KeyReleased(evt); + } + }); + + labelLevel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + org.openide.awt.Mnemonics.setLocalizedText(labelLevel2, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.labelLevel2.text")); // NOI18N + + valueLevel2.setText(org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.valueLevel2.text")); // NOI18N + valueLevel2.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + valueLevel2KeyReleased(evt); + } + }); + + valueLevel3.setText(org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.valueLevel3.text")); // NOI18N + valueLevel3.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + valueLevel3KeyReleased(evt); + } + }); + + labelLevel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + org.openide.awt.Mnemonics.setLocalizedText(labelLevel3, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.labelLevel3.text")); // NOI18N + + valueLevel4.setText(org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.valueLevel4.text")); // NOI18N + valueLevel4.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + valueLevel4KeyReleased(evt); + } + }); + + labelLevel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + org.openide.awt.Mnemonics.setLocalizedText(labelLevel4, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.labelLevel4.text")); // NOI18N + + valueLevel5.setText(org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.valueLevel5.text")); // NOI18N + valueLevel5.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + valueLevel5KeyReleased(evt); + } + }); + + labelLevel5.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + org.openide.awt.Mnemonics.setLocalizedText(labelLevel5, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.labelLevel5.text")); // NOI18N + labelLevel5.setToolTipText(org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.labelLevel5.toolTipText")); // NOI18N + + valueLevel6.setText(org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.valueLevel6.text")); // NOI18N + valueLevel6.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + valueLevel6KeyReleased(evt); + } + }); + + labelLevel6.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + org.openide.awt.Mnemonics.setLocalizedText(labelLevel6, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.labelLevel6.text")); // NOI18N + + valueLevel7.setText(org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.valueLevel7.text")); // NOI18N + valueLevel7.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + valueLevel7KeyReleased(evt); + } + }); + + labelLevel7.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + org.openide.awt.Mnemonics.setLocalizedText(labelLevel7, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.labelLevel7.text")); // NOI18N + + valueLevel8.setText(org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.valueLevel8.text")); // NOI18N + valueLevel8.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + valueLevel8KeyReleased(evt); + } + }); + + labelLevel8.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + org.openide.awt.Mnemonics.setLocalizedText(labelLevel8, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.labelLevel8.text")); // NOI18N + + valueLevel9.setText(org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.valueLevel9.text")); // NOI18N + valueLevel9.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + valueLevel9KeyReleased(evt); + } + }); + + labelLevel9.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + org.openide.awt.Mnemonics.setLocalizedText(labelLevel9, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.labelLevel9.text")); // NOI18N + + valueLevel10.setText(org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.valueLevel10.text")); // NOI18N + valueLevel10.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + valueLevel10KeyReleased(evt); + } + }); + + labelLevel10.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + org.openide.awt.Mnemonics.setLocalizedText(labelLevel10, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.labelLevel10.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(estLabel1, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.estLabel1.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(estLabel2, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.estLabel2.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(estLabel3, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.estLabel3.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(estLabel4, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.estLabel4.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(estLabel5, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.estLabel5.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(estLabel6, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.estLabel6.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(estLabel7, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.estLabel7.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(estLabel8, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.estLabel8.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(estLabel9, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.estLabel9.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(estLabel10, org.openide.util.NbBundle.getMessage(GenerateLODVisualPanel1.class, "GenerateLODVisualPanel1.estLabel10.text")); // NOI18N + + javax.swing.GroupLayout valuePanelLayout = new javax.swing.GroupLayout(valuePanel); + valuePanel.setLayout(valuePanelLayout); + valuePanelLayout.setHorizontalGroup( + valuePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(valuePanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(valuePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(valuePanelLayout.createSequentialGroup() + .addComponent(labelLevel1, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(valueLevel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(estLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(valuePanelLayout.createSequentialGroup() + .addGroup(valuePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, valuePanelLayout.createSequentialGroup() + .addComponent(labelLevel10, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(valueLevel10)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, valuePanelLayout.createSequentialGroup() + .addComponent(labelLevel9, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(valueLevel9))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(valuePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(estLabel9, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(estLabel10, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(valuePanelLayout.createSequentialGroup() + .addComponent(labelLevel2, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(valueLevel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(estLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(valuePanelLayout.createSequentialGroup() + .addComponent(labelLevel3, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(valueLevel3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(estLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(valuePanelLayout.createSequentialGroup() + .addGroup(valuePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, valuePanelLayout.createSequentialGroup() + .addComponent(labelLevel8, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(valueLevel8)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, valuePanelLayout.createSequentialGroup() + .addComponent(labelLevel7, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(valueLevel7)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, valuePanelLayout.createSequentialGroup() + .addComponent(labelLevel6, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(valueLevel6)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, valuePanelLayout.createSequentialGroup() + .addComponent(labelLevel5, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(valueLevel5)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, valuePanelLayout.createSequentialGroup() + .addComponent(labelLevel4, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(valueLevel4))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(valuePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(estLabel4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(estLabel5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(estLabel6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(estLabel7, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(estLabel8, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap()) + ); + valuePanelLayout.setVerticalGroup( + valuePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(valuePanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(valuePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(labelLevel1) + .addComponent(valueLevel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(estLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(valuePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(labelLevel2) + .addComponent(valueLevel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(estLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(valuePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(labelLevel3) + .addComponent(valueLevel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(estLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(valuePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(labelLevel4) + .addComponent(valueLevel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(estLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(valuePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(labelLevel5) + .addComponent(valueLevel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(estLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(valuePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(labelLevel6) + .addComponent(valueLevel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(estLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(valuePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(labelLevel7) + .addComponent(valueLevel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(estLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(valuePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(labelLevel8) + .addComponent(valueLevel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(estLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(valuePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(labelLevel9) + .addComponent(valueLevel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(estLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(valuePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(labelLevel10) + .addComponent(valueLevel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(estLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(15, 15, 15)) + ); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(valuePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 506, Short.MAX_VALUE) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(valuePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap()) + ); + }// //GEN-END:initComponents + + public void setTriSize(int triSize) { + this.triSize = triSize; + } + + private int getIndex(JTextField field) { + for (int i = 0; i < valuesFields.size(); i++) { + if (valuesFields.get(i) == field) { + return i; + } + } + return -1; + } + + private void estimate(int index) { + JTextField field = valuesFields.get(index); + JLabel est = estimationFields.get(index); + + float value = 0; + try { + value = Float.parseFloat(field.getText()); + int trinum = 0; + if (reductionMethod.getSelectedItem() == LodGenerator.TriangleReductionMethod.PROPORTIONAL) { + trinum = (int) (triSize - (triSize * value)); + } else { + trinum = (int) (triSize - value); + } + est.setText("~ " + trinum + " triangles"); + } catch (NumberFormatException e) { + est.setText("-"); + return; + } + } + + private void clear(){ + for (JTextField text : valuesFields) { + text.setText(""); + } + for (JLabel label : estimationFields) { + label.setText(""); + } + } + + private void reductionMethodActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_reductionMethodActionPerformed + switch ((LodGenerator.TriangleReductionMethod) reductionMethod.getSelectedItem()) { + case PROPORTIONAL: + reductionDescription.setText("Enter float values from 0 to 1.\n each values represent the proportion of triangle to remove from the full mesh."); + break; + case CONSTANT: + reductionDescription.setText("Enter integrer values from 0 to " + triSize + " of the mesh.\n each values represent the number of triangle to remove from the full mesh. "); + break; + case COLLAPSE_COST: + reductionDescription.setText("Don't use this"); + break; + } + clear(); + }//GEN-LAST:event_reductionMethodActionPerformed + + private void valueLevel1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_valueLevel1KeyReleased + estimate(getIndex((JTextField) evt.getSource())); // TODO add your handling code here: + }//GEN-LAST:event_valueLevel1KeyReleased + + private void valueLevel2KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_valueLevel2KeyReleased + estimate(getIndex((JTextField) evt.getSource())); // TODO add your handling code here: + }//GEN-LAST:event_valueLevel2KeyReleased + + private void valueLevel3KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_valueLevel3KeyReleased + estimate(getIndex((JTextField) evt.getSource())); // TODO add your handling code here: + }//GEN-LAST:event_valueLevel3KeyReleased + + private void valueLevel4KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_valueLevel4KeyReleased + estimate(getIndex((JTextField) evt.getSource())); // TODO add your handling code here: + }//GEN-LAST:event_valueLevel4KeyReleased + + private void valueLevel5KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_valueLevel5KeyReleased + estimate(getIndex((JTextField) evt.getSource())); // TODO add your handling code here: + }//GEN-LAST:event_valueLevel5KeyReleased + + private void valueLevel6KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_valueLevel6KeyReleased + estimate(getIndex((JTextField) evt.getSource())); // TODO add your handling code here: + }//GEN-LAST:event_valueLevel6KeyReleased + + private void valueLevel7KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_valueLevel7KeyReleased + estimate(getIndex((JTextField) evt.getSource())); // TODO add your handling code here: + }//GEN-LAST:event_valueLevel7KeyReleased + + private void valueLevel8KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_valueLevel8KeyReleased + estimate(getIndex((JTextField) evt.getSource())); // TODO add your handling code here: + }//GEN-LAST:event_valueLevel8KeyReleased + + private void valueLevel9KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_valueLevel9KeyReleased + estimate(getIndex((JTextField) evt.getSource())); // TODO add your handling code here: + }//GEN-LAST:event_valueLevel9KeyReleased + + private void valueLevel10KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_valueLevel10KeyReleased + estimate(getIndex((JTextField) evt.getSource())); // TODO add your handling code here: + }//GEN-LAST:event_valueLevel10KeyReleased + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel estLabel1; + private javax.swing.JLabel estLabel10; + private javax.swing.JLabel estLabel2; + private javax.swing.JLabel estLabel3; + private javax.swing.JLabel estLabel4; + private javax.swing.JLabel estLabel5; + private javax.swing.JLabel estLabel6; + private javax.swing.JLabel estLabel7; + private javax.swing.JLabel estLabel8; + private javax.swing.JLabel estLabel9; + private javax.swing.JLabel jLabel1; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JLabel labelLevel1; + private javax.swing.JLabel labelLevel10; + private javax.swing.JLabel labelLevel2; + private javax.swing.JLabel labelLevel3; + private javax.swing.JLabel labelLevel4; + private javax.swing.JLabel labelLevel5; + private javax.swing.JLabel labelLevel6; + private javax.swing.JLabel labelLevel7; + private javax.swing.JLabel labelLevel8; + private javax.swing.JLabel labelLevel9; + private javax.swing.JTextPane reductionDescription; + private javax.swing.JComboBox reductionMethod; + private javax.swing.JTextField valueLevel1; + private javax.swing.JTextField valueLevel10; + private javax.swing.JTextField valueLevel2; + private javax.swing.JTextField valueLevel3; + private javax.swing.JTextField valueLevel4; + private javax.swing.JTextField valueLevel5; + private javax.swing.JTextField valueLevel6; + private javax.swing.JTextField valueLevel7; + private javax.swing.JTextField valueLevel8; + private javax.swing.JTextField valueLevel9; + private javax.swing.JPanel valuePanel; + // End of variables declaration//GEN-END:variables +} diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateLODWizardPanel1.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateLODWizardPanel1.java new file mode 100644 index 000000000..7480583cb --- /dev/null +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateLODWizardPanel1.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2009-2010 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.gde.core.sceneexplorer.nodes.actions.impl; + +import javax.swing.JOptionPane; +import javax.swing.event.ChangeListener; +import org.openide.WizardDescriptor; +import org.openide.WizardValidationException; +import org.openide.util.HelpCtx; + +public class GenerateLODWizardPanel1 implements WizardDescriptor.ValidatingPanel { + + private float[] values; + /** + * The visual component that displays this panel. If you need to access the + * component from this class, just use getComponent(). + */ + private GenerateLODVisualPanel1 component; + + // Get the visual component for the panel. In this template, the component + // is kept separate. This can be more efficient: if the wizard is created + // but never displayed, or not all panels are displayed, it is better to + // create only those which really need to be visible. + @Override + public GenerateLODVisualPanel1 getComponent() { + if (component == null) { + component = new GenerateLODVisualPanel1(); + } + return component; + } + + @Override + public HelpCtx getHelp() { + // Show no Help button for this panel: + return HelpCtx.DEFAULT_HELP; + // If you have context help: + // return new HelpCtx("help.key.here"); + } + + @Override + public boolean isValid() { + + + // If it is always OK to press Next or Finish, then: + return true; + // If it depends on some condition (form filled out...) and + // this condition changes (last form field filled in...) then + // use ChangeSupport to implement add/removeChangeListener below. + // WizardDescriptor.ERROR/WARNING/INFORMATION_MESSAGE will also be useful. + } + + @Override + public void addChangeListener(ChangeListener l) { + } + + @Override + public void removeChangeListener(ChangeListener l) { + } + + @Override + public void readSettings(WizardDescriptor wiz) { + component.setTriSize((Integer)wiz.getProperty("triSize")); + } + + @Override + public void storeSettings(WizardDescriptor wiz) { + wiz.putProperty("reductionMethod", component.getReducitonMethod()); + wiz.putProperty("reductionValues", values); + } + + public void validate() throws WizardValidationException { + + + float[] vals = new float[component.getValuesFields().size()]; + + for (int i = 0; i < component.getValuesFields().size(); i++) { + try { + String text = component.getValuesFields().get(i).getText(); + if(!text.trim().equals("")){ + vals[i] = Float.parseFloat(text); + }else{ + if (i == 0) { + if (JOptionPane.showConfirmDialog(getComponent(), + "Warning there is no level value set.\nThis will remove all existing Level of detail from this model.\nDo you wish to continue?", + "Deleting LOD", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { + values = null; + } else { + throw new WizardValidationException(null, "No reduction value set", null); + } + }else{ + values = new float[i]; + System.arraycopy(vals, 0, values, 0, i); + } + return; + } + } catch (NumberFormatException e) { + throw new WizardValidationException( component.getValuesFields().get(i), "Invalid value for level "+(i+1), null); + } + } + + } +} diff --git a/sdk/jme3-core/src/com/jme3/gde/core/util/ComboInplaceEditor.java b/sdk/jme3-core/src/com/jme3/gde/core/util/ComboInplaceEditor.java new file mode 100644 index 000000000..32816f5e5 --- /dev/null +++ b/sdk/jme3-core/src/com/jme3/gde/core/util/ComboInplaceEditor.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2009-2010 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.gde.core.util; + +import java.awt.Component; +import java.awt.event.ActionListener; +import java.beans.PropertyEditor; +import java.util.List; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.KeyStroke; +import org.openide.explorer.propertysheet.InplaceEditor; +import org.openide.explorer.propertysheet.PropertyEnv; +import org.openide.explorer.propertysheet.PropertyModel; + +/** + * + * @author Nehon + */ +public class ComboInplaceEditor implements InplaceEditor { + + private PropertyEditor editor = null; + private PropertyModel model; + private PropertyEnv env; + private JComboBox combo = new JComboBox(); + + public ComboInplaceEditor(List list) { + super(); + setList(list); + } + + public final void setList(List list) { + combo.removeAllItems(); + for (String string : list) { + combo.addItem(string); + } + } + + public int getNumElements(){ + return combo.getItemCount(); + } + + public void connect(PropertyEditor pe, PropertyEnv pe1) { + editor = pe; + env = pe1; + reset(); + } + + public JComponent getComponent() { + return combo; + } + + public void setAsText(String s) { + for (int i = 0; i < combo.getItemCount(); i++) { + if (((String) combo.getItemAt(i)).equals(s)) { + combo.setSelectedIndex(i); + return; + } + } + } + + public void clear() { + editor = null; + model = null; + } + + public Object getValue() { + return combo.getSelectedItem(); + + } + + public void setValue(Object o) { + for (int i = 0; i < combo.getItemCount(); i++) { + if ((combo.getItemAt(i)).equals(o)) { + combo.setSelectedIndex(i); + return; + } + } + } + + public boolean supportsTextEntry() { + return true; + } + + public void reset() { + + + } + + public KeyStroke[] getKeyStrokes() { + return new KeyStroke[0]; + } + + public PropertyEditor getPropertyEditor() { + return editor; + } + + public PropertyModel getPropertyModel() { + return model; + } + + public void setPropertyModel(PropertyModel pm) { + + this.model = pm; + } + + public boolean isKnownComponent(Component cmpnt) { + return cmpnt == combo || combo.isAncestorOf(cmpnt); + } + + public void addActionListener(ActionListener al) { + combo.addActionListener(al); + } + + public void removeActionListener(ActionListener al) { + combo.removeActionListener(al); + } +}