diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/NewGeometryAction.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/NewGeometryAction.java new file mode 100644 index 000000000..2ceffc9a7 --- /dev/null +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/NewGeometryAction.java @@ -0,0 +1,44 @@ +/* + * 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; + +import com.jme3.gde.core.sceneexplorer.nodes.JmeNode; +import javax.swing.Action; +import org.openide.loaders.DataObject; + +/** + * + * @author david.bernard.31 + */ +public interface NewGeometryAction { + public Action getAction(JmeNode rootNode, DataObject dataObject); +} diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/NewSpatialPopup.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/NewSpatialPopup.java index 1dcb8bf3a..c46c7a416 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/NewSpatialPopup.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/NewSpatialPopup.java @@ -81,6 +81,11 @@ public class NewSpatialPopup extends AbstractAction implements Presenter.Popup { for (NewSpatialAction di : Lookup.getDefault().lookupAll(NewSpatialAction.class)) { result.add(new JMenuItem(di.getAction(jmeNode, dataObject))); } + JMenu geometries = new JMenu("Primitives"); + for (NewGeometryAction di : Lookup.getDefault().lookupAll(NewGeometryAction.class)) { + geometries.add(new JMenuItem(di.getAction(jmeNode, dataObject))); + } + result.add(geometries); return result; } 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 e62d0cd7a..80eae6ba4 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 @@ -38,3 +38,15 @@ GenerateLODVisualPanel1.estLabel9.text= GenerateLODVisualPanel1.estLabel10.text= GenerateLODVisualPanel1.estLabel5.text= GenerateLODVisualPanel1.estLabel3.text= +NewGeometrySettingsTopComponent.jLabel5.text=y +NewGeometrySettingsTopComponent.jLabel4.text=x +NewGeometrySettingsTopComponent.jLabel3.text=Sphere +NewGeometrySettingsTopComponent.jLabel1.text=Box +NewGeometrySettingsTopComponent.jLabel13.text=interior +NewGeometrySettingsTopComponent.jLabel12.text=useEvenSlices +NewGeometrySettingsTopComponent.jLabel11.text=radius +NewGeometrySettingsTopComponent.jLabel10.text=radialSamples +NewGeometrySettingsTopComponent.jLabel9.text=zSamples +NewGeometrySettingsTopComponent.jCheckBox2.text= +NewGeometrySettingsTopComponent.jCheckBox1.text= +NewGeometrySettingsTopComponent.jLabel6.text=z diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryBoxAction.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryBoxAction.java new file mode 100644 index 000000000..a25156278 --- /dev/null +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometryBoxAction.java @@ -0,0 +1,65 @@ +/* + * 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.actions.AbstractNewSpatialAction; +import com.jme3.gde.core.sceneexplorer.nodes.actions.NewGeometryAction; +import com.jme3.material.Material; +import com.jme3.math.ColorRGBA; +import com.jme3.scene.Geometry; +import com.jme3.scene.Node; +import com.jme3.scene.Spatial; +import com.jme3.scene.shape.Box; + +/** + * + * @author david.bernard.31 + */ +@org.openide.util.lookup.ServiceProvider(service = NewGeometryAction.class) +public class NewGeometryBoxAction extends AbstractNewSpatialAction implements NewGeometryAction { + + public NewGeometryBoxAction() { + name = "Box"; + } + + @Override + protected Spatial doCreateSpatial(Node parent) { + NewGeometrySettings cfg = new NewGeometrySettings(); + Box b = new Box(cfg.getBoxX(), cfg.getBoxY(), cfg.getBoxZ()); // create cube shape + Geometry geom = new Geometry("Box", b); + Material mat = new Material(pm, "Common/MatDefs/Misc/Unshaded.j3md"); + mat.setColor("Color", ColorRGBA.randomColor()); + geom.setMaterial(mat); + parent.attachChild(geom); + return geom; + } +} diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometrySettings.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometrySettings.java new file mode 100644 index 000000000..274b19067 --- /dev/null +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometrySettings.java @@ -0,0 +1,161 @@ +/* + * 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.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.io.Serializable; +import java.util.prefs.PreferenceChangeEvent; +import java.util.prefs.PreferenceChangeListener; +import java.util.prefs.Preferences; +import org.openide.util.NbPreferences; + +/** + * + * @author david.bernard.31 + */ + + +public class NewGeometrySettings implements Serializable, PreferenceChangeListener { + + private transient final PropertyChangeSupport propertySupport; + private transient final Preferences pref; + + public NewGeometrySettings() { + propertySupport = new PropertyChangeSupport(this); + pref = NbPreferences.forModule(NewGeometrySettings.class); + } + + public void open() { + pref.addPreferenceChangeListener(this); + } + + public static final String PROP_BoxX = "BoxX"; + + public float getBoxX() { + return pref.getFloat(PROP_BoxX, 1.0f); + } + + public void setBoxX(float value) { + pref.putFloat(PROP_BoxX, value); + } + + public static final String PROP_BoxY = "BoxY"; + + public float getBoxY() { + return pref.getFloat(PROP_BoxY, 1.0f); + } + + public void setBoxY(float value) { + pref.putFloat(PROP_BoxY, value); + } + + public static final String PROP_BoxZ = "BoxZ"; + + public float getBoxZ() { + return pref.getFloat(PROP_BoxZ, 1.0f); + } + + public void setBoxZ(float value) { + pref.putFloat(PROP_BoxZ, value); + } + + public static final String PROP_SphereZSamples = "SphereZSamples"; + + public int getSphereZSamples() { + return pref.getInt(PROP_SphereZSamples, 10); + } + + public void setSphereZSamples(int value) { + pref.putInt(PROP_SphereZSamples, value); + } + + public static final String PROP_SpherRadialSamples = "SpherRadialSamples"; + + public int getSpherRadialSamples() { + return pref.getInt(PROP_SpherRadialSamples, 10); + } + + public void setSpherRadialSamples(int value) { + pref.putInt(PROP_SpherRadialSamples, value); + } + + public static final String PROP_SphereRadius = "SphereRadius"; + + public float getSphereRadius() { + return pref.getFloat(PROP_SphereRadius, 1.0f); + } + + public void setSphereRadius(float value) { + pref.putFloat(PROP_SphereRadius, value); + } + + public static final String PROP_SphereUseEvenSlices = "SphereUseEvenSlices"; + + public boolean getSphereUseEvenSlices() { + return pref.getBoolean(PROP_SphereUseEvenSlices, false); + } + + public void setSphereUseEvenSlices(boolean value) { + pref.putBoolean(PROP_SphereUseEvenSlices, value); + } + + public static final String PROP_SphereInterior = "SphereInterior"; + + public boolean getSphereInterior() { + return pref.getBoolean(PROP_SphereInterior, false); + } + + public void setSphereInterior(boolean value) { + pref.putBoolean(PROP_SphereInterior, value); + } + + + + public void addPropertyChangeListener(final PropertyChangeListener listener) { + propertySupport.addPropertyChangeListener(listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + propertySupport.removePropertyChangeListener(listener); + } + + public void preferenceChange(PreferenceChangeEvent evt) { + propertySupport.firePropertyChange(evt.getKey(), null, evt.getNewValue()); + } + + public void close() { + pref.removePreferenceChangeListener(this); + } + + +} diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometrySettingsTopComponent.form b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometrySettingsTopComponent.form new file mode 100644 index 000000000..58e989be5 --- /dev/null +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometrySettingsTopComponent.form @@ -0,0 +1,286 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometrySettingsTopComponent.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometrySettingsTopComponent.java new file mode 100644 index 000000000..0e78651d2 --- /dev/null +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometrySettingsTopComponent.java @@ -0,0 +1,300 @@ +/* + * 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 org.netbeans.api.settings.ConvertAsProperties; +import org.openide.awt.ActionID; +import org.openide.awt.ActionReference; +import org.openide.util.NbBundle.Messages; +import org.openide.windows.TopComponent; + +/** + * Top component which displays NewGeometryAction' Settings. + * + * @author david.bernard.31 + */ + + +@ConvertAsProperties( + dtd = "-//com.jme3.gde.core.sceneexplorer.nodes.actions.impl//NewGeometrySettings//EN", + autostore = true +) +@TopComponent.Description( + preferredID = "NewGeometrySettingsTopComponent", + //iconBase="SET/PATH/TO/ICON/HERE", + persistenceType = TopComponent.PERSISTENCE_ALWAYS +) +@TopComponent.Registration(mode = "output", openAtStartup = false) +@ActionID(category = "Window", id = "com.jme3.gde.core.sceneexplorer.nodes.actions.impl.NewGeometrySettingsTopComponent") +@ActionReference(path = "Menu/Window" /*, position = 333 */) +@TopComponent.OpenActionRegistration( + displayName = "#CTL_NewGeometrySettingsAction", + preferredID = "NewGeometrySettingsTopComponent" +) +@Messages({ + "CTL_NewGeometrySettingsAction=NewGeometrySettings", + "CTL_NewGeometrySettingsTopComponent=NewGeometrySettings Window", + "HINT_NewGeometrySettingsTopComponent=This is a NewGeometrySettings window" +}) +public final class NewGeometrySettingsTopComponent extends TopComponent { + + public NewGeometrySettingsTopComponent() { + initComponents(); + setName(Bundle.CTL_NewGeometrySettingsTopComponent()); + setToolTipText(Bundle.HINT_NewGeometrySettingsTopComponent()); + + } + + /** + * 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() { + bindingGroup = new org.jdesktop.beansbinding.BindingGroup(); + + newGeometrySettings1 = new com.jme3.gde.core.sceneexplorer.nodes.actions.impl.NewGeometrySettings(); + jLabel5 = new javax.swing.JLabel(); + jSpinner3 = new javax.swing.JSpinner(); + jLabel6 = new javax.swing.JLabel(); + jCheckBox1 = new javax.swing.JCheckBox(); + jSpinner4 = new javax.swing.JSpinner(); + jCheckBox2 = new javax.swing.JCheckBox(); + jSpinner5 = new javax.swing.JSpinner(); + jLabel9 = new javax.swing.JLabel(); + jLabel10 = new javax.swing.JLabel(); + jLabel11 = new javax.swing.JLabel(); + jLabel12 = new javax.swing.JLabel(); + jLabel13 = new javax.swing.JLabel(); + jLabel1 = new javax.swing.JLabel(); + jSpinner6 = new javax.swing.JSpinner(); + jLabel3 = new javax.swing.JLabel(); + jSpinner1 = new javax.swing.JSpinner(); + jLabel4 = new javax.swing.JLabel(); + jSpinner2 = new javax.swing.JSpinner(); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(NewGeometrySettingsTopComponent.class, "NewGeometrySettingsTopComponent.jLabel5.text")); // NOI18N + + jSpinner3.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(10), Integer.valueOf(1), null, Integer.valueOf(1))); + + org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, newGeometrySettings1, org.jdesktop.beansbinding.ELProperty.create("${sphereZSamples}"), jSpinner3, org.jdesktop.beansbinding.BeanProperty.create("value")); + bindingGroup.addBinding(binding); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel6, org.openide.util.NbBundle.getMessage(NewGeometrySettingsTopComponent.class, "NewGeometrySettingsTopComponent.jLabel6.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1, org.openide.util.NbBundle.getMessage(NewGeometrySettingsTopComponent.class, "NewGeometrySettingsTopComponent.jCheckBox1.text")); // NOI18N + + binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, newGeometrySettings1, org.jdesktop.beansbinding.ELProperty.create("${sphereUseEvenSlices}"), jCheckBox1, org.jdesktop.beansbinding.BeanProperty.create("selected")); + bindingGroup.addBinding(binding); + + jSpinner4.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(1.0f), Float.valueOf(0.0f), null, Float.valueOf(0.1f))); + + binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, newGeometrySettings1, org.jdesktop.beansbinding.ELProperty.create("${sphereRadius}"), jSpinner4, org.jdesktop.beansbinding.BeanProperty.create("value")); + bindingGroup.addBinding(binding); + + org.openide.awt.Mnemonics.setLocalizedText(jCheckBox2, org.openide.util.NbBundle.getMessage(NewGeometrySettingsTopComponent.class, "NewGeometrySettingsTopComponent.jCheckBox2.text")); // NOI18N + + binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, newGeometrySettings1, org.jdesktop.beansbinding.ELProperty.create("${sphereInterior}"), jCheckBox2, org.jdesktop.beansbinding.BeanProperty.create("selected")); + bindingGroup.addBinding(binding); + + binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, newGeometrySettings1, org.jdesktop.beansbinding.ELProperty.create("${spherRadialSamples}"), jSpinner5, org.jdesktop.beansbinding.BeanProperty.create("value")); + bindingGroup.addBinding(binding); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel9, org.openide.util.NbBundle.getMessage(NewGeometrySettingsTopComponent.class, "NewGeometrySettingsTopComponent.jLabel9.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jLabel10, org.openide.util.NbBundle.getMessage(NewGeometrySettingsTopComponent.class, "NewGeometrySettingsTopComponent.jLabel10.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jLabel11, org.openide.util.NbBundle.getMessage(NewGeometrySettingsTopComponent.class, "NewGeometrySettingsTopComponent.jLabel11.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jLabel12, org.openide.util.NbBundle.getMessage(NewGeometrySettingsTopComponent.class, "NewGeometrySettingsTopComponent.jLabel12.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jLabel13, org.openide.util.NbBundle.getMessage(NewGeometrySettingsTopComponent.class, "NewGeometrySettingsTopComponent.jLabel13.text")); // NOI18N + + jLabel1.setBackground(getBackground()); + jLabel1.setFont(new java.awt.Font("Dialog", 1, 11)); // NOI18N + jLabel1.setForeground(getForeground()); + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(NewGeometrySettingsTopComponent.class, "NewGeometrySettingsTopComponent.jLabel1.text")); // NOI18N + + jSpinner6.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(1.0f), Float.valueOf(0.0f), null, Float.valueOf(0.5f))); + + binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, newGeometrySettings1, org.jdesktop.beansbinding.ELProperty.create("${boxZ}"), jSpinner6, org.jdesktop.beansbinding.BeanProperty.create("value")); + bindingGroup.addBinding(binding); + + jLabel3.setFont(new java.awt.Font("Dialog", 1, 11)); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(NewGeometrySettingsTopComponent.class, "NewGeometrySettingsTopComponent.jLabel3.text")); // NOI18N + + jSpinner1.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(1.0f), null, null, Float.valueOf(0.5f))); + + binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, newGeometrySettings1, org.jdesktop.beansbinding.ELProperty.create("${boxX}"), jSpinner1, org.jdesktop.beansbinding.BeanProperty.create("value")); + bindingGroup.addBinding(binding); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(NewGeometrySettingsTopComponent.class, "NewGeometrySettingsTopComponent.jLabel4.text")); // NOI18N + + jSpinner2.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(1.0f), Float.valueOf(0.0f), null, Float.valueOf(0.5f))); + + binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, newGeometrySettings1, org.jdesktop.beansbinding.ELProperty.create("${boxY}"), jSpinner2, org.jdesktop.beansbinding.BeanProperty.create("value")); + bindingGroup.addBinding(binding); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1) + .addGap(433, 433, 433)) + .addGroup(layout.createSequentialGroup() + .addGap(12, 12, 12) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel4) + .addComponent(jLabel10) + .addComponent(jLabel12)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jSpinner3, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jCheckBox1)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel9)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel13, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jSpinner5, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel6) + .addComponent(jLabel11)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jSpinner4, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jSpinner6, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(layout.createSequentialGroup() + .addComponent(jCheckBox2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 193, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel3) + .addGap(412, 412, 412))) + .addGap(0, 196, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4) + .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5) + .addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel6) + .addComponent(jSpinner6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel10) + .addComponent(jLabel11) + .addComponent(jSpinner3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel9) + .addComponent(jSpinner5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jSpinner4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel12) + .addComponent(jCheckBox1) + .addComponent(jLabel13) + .addComponent(jCheckBox2)) + .addContainerGap(299, Short.MAX_VALUE)) + ); + + bindingGroup.bind(); + }// //GEN-END:initComponents + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JCheckBox jCheckBox1; + private javax.swing.JCheckBox jCheckBox2; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel11; + private javax.swing.JLabel jLabel12; + private javax.swing.JLabel jLabel13; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel9; + private javax.swing.JSpinner jSpinner1; + private javax.swing.JSpinner jSpinner2; + private javax.swing.JSpinner jSpinner3; + private javax.swing.JSpinner jSpinner4; + private javax.swing.JSpinner jSpinner5; + private javax.swing.JSpinner jSpinner6; + private com.jme3.gde.core.sceneexplorer.nodes.actions.impl.NewGeometrySettings newGeometrySettings1; + private org.jdesktop.beansbinding.BindingGroup bindingGroup; + // End of variables declaration//GEN-END:variables + @Override + public void componentOpened() { + // TODO add custom code on component opening + newGeometrySettings1.open(); + } + + @Override + public void componentClosed() { + // TODO add custom code on component closing + newGeometrySettings1.close(); + } + + void writeProperties(java.util.Properties p) { + // better to version settings since initial version as advocated at + // http://wiki.apidesign.org/wiki/PropertyFiles + p.setProperty("version", "1.0"); + // TODO store your settings + } + + void readProperties(java.util.Properties p) { + String version = p.getProperty("version"); + // TODO read your settings according to their version + } +} diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometrySphereAction.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometrySphereAction.java new file mode 100644 index 000000000..5617e2f35 --- /dev/null +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/NewGeometrySphereAction.java @@ -0,0 +1,71 @@ +/* + * 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.actions.AbstractNewSpatialAction; +import com.jme3.gde.core.sceneexplorer.nodes.actions.NewGeometryAction; +import com.jme3.material.Material; +import com.jme3.math.ColorRGBA; +import com.jme3.scene.Geometry; +import com.jme3.scene.Node; +import com.jme3.scene.Spatial; +import com.jme3.scene.shape.Sphere; + +/** + * + * @author david.bernard.31 + */ +@org.openide.util.lookup.ServiceProvider(service = NewGeometryAction.class) +public class NewGeometrySphereAction extends AbstractNewSpatialAction implements NewGeometryAction { + + public NewGeometrySphereAction() { + name = "Sphere"; + } + + @Override + protected Spatial doCreateSpatial(Node parent) { + NewGeometrySettings cfg = new NewGeometrySettings(); + Sphere b = new Sphere( + cfg.getSphereZSamples() + , cfg.getSpherRadialSamples() + , cfg.getSphereRadius() + , cfg.getSphereUseEvenSlices() + , cfg.getSphereInterior() + ); + Geometry geom = new Geometry("Sphere", b); + Material mat = new Material(pm, "Common/MatDefs/Misc/Unshaded.j3md"); + mat.setColor("Color", ColorRGBA.randomColor()); + geom.setMaterial(mat); + parent.attachChild(geom); + return geom; + } +}