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. + */ + //