- cleanup some packages, move some classes - better names for some classes git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7771 75d07b2b-3a1a-0410-a2c5-0572b91ccdca3.0
parent
61b5134a5d
commit
b446c5c56d
@ -1,92 +0,0 @@ |
|||||||
/* |
|
||||||
* 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.properties; |
|
||||||
|
|
||||||
import com.jme3.animation.AnimControl; |
|
||||||
import com.jme3.gde.core.scene.SceneApplication; |
|
||||||
import java.beans.PropertyEditor; |
|
||||||
import java.lang.reflect.InvocationTargetException; |
|
||||||
import java.util.concurrent.Callable; |
|
||||||
import java.util.concurrent.ExecutionException; |
|
||||||
import org.openide.nodes.PropertySupport; |
|
||||||
import org.openide.util.Exceptions; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class AnimationProperty extends PropertySupport.ReadWrite<String> { |
|
||||||
|
|
||||||
private AnimControl control; |
|
||||||
private String anim = "null"; |
|
||||||
|
|
||||||
public AnimationProperty(AnimControl node) { |
|
||||||
super("Animation Control", String.class, "Animation Control", ""); |
|
||||||
this.control = node; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getValue() throws IllegalAccessException, InvocationTargetException { |
|
||||||
return anim; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setValue(final String val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { |
|
||||||
if (control == null) { |
|
||||||
return; |
|
||||||
} |
|
||||||
try { |
|
||||||
SceneApplication.getApplication().enqueue(new Callable<Void>() { |
|
||||||
|
|
||||||
public Void call() throws Exception { |
|
||||||
if ("null".equals(val)) { |
|
||||||
control.clearChannels(); |
|
||||||
return null; |
|
||||||
} |
|
||||||
anim = val; |
|
||||||
control.clearChannels(); |
|
||||||
control.createChannel().setAnim(val); |
|
||||||
return null; |
|
||||||
} |
|
||||||
}).get(); |
|
||||||
} catch (InterruptedException ex) { |
|
||||||
Exceptions.printStackTrace(ex); |
|
||||||
} catch (ExecutionException ex) { |
|
||||||
Exceptions.printStackTrace(ex); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public PropertyEditor getPropertyEditor() { |
|
||||||
return new AnimationPropertyEditor(control); |
|
||||||
} |
|
||||||
} |
|
@ -1,131 +0,0 @@ |
|||||||
/* |
|
||||||
* 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.properties; |
|
||||||
|
|
||||||
import com.jme3.animation.AnimControl; |
|
||||||
import java.awt.Component; |
|
||||||
import java.awt.Graphics; |
|
||||||
import java.awt.Rectangle; |
|
||||||
import java.beans.PropertyChangeEvent; |
|
||||||
import java.beans.PropertyChangeListener; |
|
||||||
import java.beans.PropertyEditor; |
|
||||||
import java.util.Collection; |
|
||||||
import java.util.Iterator; |
|
||||||
import java.util.LinkedList; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class AnimationPropertyEditor implements PropertyEditor { |
|
||||||
|
|
||||||
private LinkedList<PropertyChangeListener> listeners = new LinkedList<PropertyChangeListener>(); |
|
||||||
private String animName; |
|
||||||
private AnimControl control; |
|
||||||
|
|
||||||
public AnimationPropertyEditor(AnimControl control) { |
|
||||||
this.control = control; |
|
||||||
} |
|
||||||
|
|
||||||
public void setValue(Object value) { |
|
||||||
if (value instanceof String) { |
|
||||||
animName = (String) value; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public Object getValue() { |
|
||||||
return animName; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isPaintable() { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public void paintValue(Graphics gfx, Rectangle box) { |
|
||||||
throw new UnsupportedOperationException("Not supported yet."); |
|
||||||
} |
|
||||||
|
|
||||||
public String getJavaInitializationString() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public String getAsText() { |
|
||||||
return animName.toString(); |
|
||||||
} |
|
||||||
|
|
||||||
public void setAsText(String text) throws IllegalArgumentException { |
|
||||||
String old = animName; |
|
||||||
if ("".equals(text)) { |
|
||||||
animName = "null"; |
|
||||||
} |
|
||||||
animName = text; |
|
||||||
notifyListeners(old, animName); |
|
||||||
} |
|
||||||
|
|
||||||
public String[] getTags() { |
|
||||||
if(control==null)return new String[]{"none"}; |
|
||||||
Collection<String> names = control.getAnimationNames(); |
|
||||||
String[] strings = new String[names.size() + 1]; |
|
||||||
strings[0] = "null"; |
|
||||||
int i = 1; |
|
||||||
for (Iterator<String> it = names.iterator(); it.hasNext();) { |
|
||||||
strings[i] = it.next(); |
|
||||||
i++; |
|
||||||
} |
|
||||||
return strings; |
|
||||||
} |
|
||||||
|
|
||||||
public Component getCustomEditor() { |
|
||||||
// return new AnimationPanel(control);
|
|
||||||
throw new UnsupportedOperationException("Not supported yet."); |
|
||||||
} |
|
||||||
|
|
||||||
public boolean supportsCustomEditor() { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public void addPropertyChangeListener(PropertyChangeListener listener) { |
|
||||||
listeners.add(listener); |
|
||||||
} |
|
||||||
|
|
||||||
public void removePropertyChangeListener(PropertyChangeListener listener) { |
|
||||||
listeners.remove(listener); |
|
||||||
} |
|
||||||
|
|
||||||
private void notifyListeners(String before, String after) { |
|
||||||
for (Iterator<PropertyChangeListener> 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)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,102 +0,0 @@ |
|||||||
/* |
|
||||||
* 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.properties; |
|
||||||
|
|
||||||
import com.jme3.audio.AudioData; |
|
||||||
import com.jme3.audio.AudioKey; |
|
||||||
import com.jme3.audio.AudioNode; |
|
||||||
import com.jme3.gde.core.scene.SceneApplication; |
|
||||||
import com.jme3.gde.core.scene.SceneRequest; |
|
||||||
import java.beans.PropertyEditor; |
|
||||||
import java.lang.reflect.InvocationTargetException; |
|
||||||
import java.util.concurrent.Callable; |
|
||||||
import java.util.concurrent.ExecutionException; |
|
||||||
import org.openide.nodes.PropertySupport; |
|
||||||
import org.openide.util.Exceptions; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class AudioDataProperty extends PropertySupport.ReadWrite<String> { |
|
||||||
|
|
||||||
private AudioNode node; |
|
||||||
|
|
||||||
public AudioDataProperty(AudioNode node) { |
|
||||||
super("Audio Data", String.class, "Audio Data", ""); |
|
||||||
this.node = node; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getValue() throws IllegalAccessException, InvocationTargetException { |
|
||||||
if (node.getAudioData() != null) { |
|
||||||
return node.getAudioData().toString(); |
|
||||||
} else { |
|
||||||
return "null"; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setValue(final String val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { |
|
||||||
if ("null".equals(val)) { |
|
||||||
return; |
|
||||||
} |
|
||||||
if (node.getAudioData() == null) { |
|
||||||
// val = val.replace('[', ' ').trim();
|
|
||||||
// val = val.replace(']', ' ').trim();
|
|
||||||
// final String[] strings = val.split(",");
|
|
||||||
try { |
|
||||||
SceneApplication.getApplication().enqueue(new Callable<Void>() { |
|
||||||
|
|
||||||
public Void call() throws Exception { |
|
||||||
SceneRequest request = SceneApplication.getApplication().getCurrentSceneRequest(); |
|
||||||
AudioKey key = new AudioKey(val, false); |
|
||||||
AudioData localMaterial = request.getManager().loadAudio(key); |
|
||||||
if (localMaterial != null) { |
|
||||||
node.setAudioData(localMaterial, key); |
|
||||||
} |
|
||||||
return null; |
|
||||||
} |
|
||||||
}).get(); |
|
||||||
} catch (InterruptedException ex) { |
|
||||||
Exceptions.printStackTrace(ex); |
|
||||||
} catch (ExecutionException ex) { |
|
||||||
Exceptions.printStackTrace(ex); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public PropertyEditor getPropertyEditor() { |
|
||||||
return new AudioDataPropertyEditor(); |
|
||||||
} |
|
||||||
} |
|
@ -1,123 +0,0 @@ |
|||||||
/* |
|
||||||
* 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.properties; |
|
||||||
|
|
||||||
import com.jme3.audio.AudioData; |
|
||||||
import com.jme3.gde.core.scene.SceneApplication; |
|
||||||
import com.jme3.gde.core.scene.SceneRequest; |
|
||||||
import java.awt.Component; |
|
||||||
import java.awt.Graphics; |
|
||||||
import java.awt.Rectangle; |
|
||||||
import java.beans.PropertyChangeEvent; |
|
||||||
import java.beans.PropertyChangeListener; |
|
||||||
import java.beans.PropertyEditor; |
|
||||||
import java.util.Iterator; |
|
||||||
import java.util.LinkedList; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class AudioDataPropertyEditor implements PropertyEditor { |
|
||||||
|
|
||||||
private LinkedList<PropertyChangeListener> listeners = new LinkedList<PropertyChangeListener>(); |
|
||||||
private String material; |
|
||||||
|
|
||||||
public void setValue(Object value) { |
|
||||||
if (value instanceof String) { |
|
||||||
material = (String) value; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public Object getValue() { |
|
||||||
return material; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isPaintable() { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public void paintValue(Graphics gfx, Rectangle box) { |
|
||||||
throw new UnsupportedOperationException("Not supported yet."); |
|
||||||
} |
|
||||||
|
|
||||||
public String getJavaInitializationString() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public String getAsText() { |
|
||||||
return material.toString(); |
|
||||||
} |
|
||||||
|
|
||||||
public void setAsText(String text) throws IllegalArgumentException { |
|
||||||
String old=material; |
|
||||||
if ("".equals(text)) { |
|
||||||
material = "null"; |
|
||||||
} |
|
||||||
material = text; |
|
||||||
notifyListeners(old, material); |
|
||||||
} |
|
||||||
|
|
||||||
public String[] getTags() { |
|
||||||
if ("null".equals(material)) { |
|
||||||
SceneRequest request = SceneApplication.getApplication().getCurrentSceneRequest(); |
|
||||||
if(request==null) return new String[]{}; |
|
||||||
String[] mats = request.getManager().getSounds(); |
|
||||||
return mats; |
|
||||||
} |
|
||||||
return new String[]{"can set only once"}; |
|
||||||
} |
|
||||||
|
|
||||||
public Component getCustomEditor() { |
|
||||||
throw new UnsupportedOperationException("Not supported yet."); |
|
||||||
} |
|
||||||
|
|
||||||
public boolean supportsCustomEditor() { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public void addPropertyChangeListener(PropertyChangeListener listener) { |
|
||||||
listeners.add(listener); |
|
||||||
} |
|
||||||
|
|
||||||
public void removePropertyChangeListener(PropertyChangeListener listener) { |
|
||||||
listeners.remove(listener); |
|
||||||
} |
|
||||||
|
|
||||||
private void notifyListeners(String before, String after) { |
|
||||||
for (Iterator<PropertyChangeListener> 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)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,9 +0,0 @@ |
|||||||
ColorRGBADialog.jButton1.text=OK |
|
||||||
ColorRGBADialog.jButton2.text=Cancel |
|
||||||
ColorRGBADialog.alphaLabel.text=Alpha: |
|
||||||
AnimationPanel.pauseButton.text= |
|
||||||
AnimationPanel.playButton.text= |
|
||||||
TextureBrowser.cancelButton.text=Cancel |
|
||||||
TextureBrowser.okButton.text=Ok |
|
||||||
TextureBrowser.imagePreviewLabel.text= |
|
||||||
TextureBrowser.title=Texture Browser |
|
@ -1,97 +0,0 @@ |
|||||||
<?xml version="1.1" encoding="UTF-8" ?> |
|
||||||
|
|
||||||
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> |
|
||||||
<Properties> |
|
||||||
<Property name="defaultCloseOperation" type="int" value="2"/> |
|
||||||
</Properties> |
|
||||||
<SyntheticProperties> |
|
||||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/> |
|
||||||
</SyntheticProperties> |
|
||||||
<AuxValues> |
|
||||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/> |
|
||||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> |
|
||||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> |
|
||||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> |
|
||||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/> |
|
||||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> |
|
||||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> |
|
||||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> |
|
||||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> |
|
||||||
</AuxValues> |
|
||||||
|
|
||||||
<Layout> |
|
||||||
<DimensionLayout dim="0"> |
|
||||||
<Group type="103" groupAlignment="0" attributes="0"> |
|
||||||
<Group type="102" alignment="1" attributes="0"> |
|
||||||
<Component id="jToolBar1" pref="320" max="32767" attributes="0"/> |
|
||||||
<EmptySpace max="-2" attributes="0"/> |
|
||||||
<Component id="jButton2" min="-2" max="-2" attributes="0"/> |
|
||||||
<EmptySpace max="-2" attributes="0"/> |
|
||||||
<Component id="jButton1" min="-2" max="-2" attributes="0"/> |
|
||||||
</Group> |
|
||||||
<Component id="jColorChooser1" alignment="0" pref="496" max="32767" attributes="0"/> |
|
||||||
</Group> |
|
||||||
</DimensionLayout> |
|
||||||
<DimensionLayout dim="1"> |
|
||||||
<Group type="103" groupAlignment="0" attributes="0"> |
|
||||||
<Group type="102" alignment="1" attributes="0"> |
|
||||||
<Component id="jColorChooser1" pref="380" max="32767" attributes="0"/> |
|
||||||
<EmptySpace max="-2" attributes="0"/> |
|
||||||
<Group type="103" groupAlignment="1" attributes="0"> |
|
||||||
<Group type="103" groupAlignment="3" attributes="0"> |
|
||||||
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/> |
|
||||||
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/> |
|
||||||
</Group> |
|
||||||
<Component id="jToolBar1" min="-2" pref="25" max="-2" attributes="0"/> |
|
||||||
</Group> |
|
||||||
</Group> |
|
||||||
</Group> |
|
||||||
</DimensionLayout> |
|
||||||
</Layout> |
|
||||||
<SubComponents> |
|
||||||
<Component class="javax.swing.JColorChooser" name="jColorChooser1"> |
|
||||||
</Component> |
|
||||||
<Component class="javax.swing.JButton" name="jButton1"> |
|
||||||
<Properties> |
|
||||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> |
|
||||||
<ResourceString bundle="com/jme3/gde/core/sceneexplorer/nodes/properties/Bundle.properties" key="ColorRGBADialog.jButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> |
|
||||||
</Property> |
|
||||||
</Properties> |
|
||||||
<Events> |
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/> |
|
||||||
</Events> |
|
||||||
</Component> |
|
||||||
<Component class="javax.swing.JButton" name="jButton2"> |
|
||||||
<Properties> |
|
||||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> |
|
||||||
<ResourceString bundle="com/jme3/gde/core/sceneexplorer/nodes/properties/Bundle.properties" key="ColorRGBADialog.jButton2.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> |
|
||||||
</Property> |
|
||||||
</Properties> |
|
||||||
<Events> |
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/> |
|
||||||
</Events> |
|
||||||
</Component> |
|
||||||
<Container class="javax.swing.JToolBar" name="jToolBar1"> |
|
||||||
<Properties> |
|
||||||
<Property name="floatable" type="boolean" value="false"/> |
|
||||||
<Property name="rollover" type="boolean" value="true"/> |
|
||||||
</Properties> |
|
||||||
|
|
||||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/> |
|
||||||
<SubComponents> |
|
||||||
<Component class="javax.swing.JLabel" name="alphaLabel"> |
|
||||||
<Properties> |
|
||||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> |
|
||||||
<ResourceString bundle="com/jme3/gde/core/sceneexplorer/nodes/properties/Bundle.properties" key="ColorRGBADialog.alphaLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> |
|
||||||
</Property> |
|
||||||
</Properties> |
|
||||||
</Component> |
|
||||||
<Component class="javax.swing.JSlider" name="alphaSlider"> |
|
||||||
<Properties> |
|
||||||
<Property name="value" type="int" value="100"/> |
|
||||||
</Properties> |
|
||||||
</Component> |
|
||||||
</SubComponents> |
|
||||||
</Container> |
|
||||||
</SubComponents> |
|
||||||
</Form> |
|
@ -1,155 +0,0 @@ |
|||||||
/* |
|
||||||
* 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. |
|
||||||
*/ |
|
||||||
|
|
||||||
/* |
|
||||||
* ColorRGBADialog.java |
|
||||||
* |
|
||||||
* Created on 06.04.2010, 20:58:59 |
|
||||||
*/ |
|
||||||
package com.jme3.gde.core.sceneexplorer.nodes.properties; |
|
||||||
|
|
||||||
import com.jme3.math.ColorRGBA; |
|
||||||
import java.awt.Color; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class ColorRGBADialog extends javax.swing.JDialog { |
|
||||||
|
|
||||||
private ColorRGBAPropertyEditor editor; |
|
||||||
|
|
||||||
/** Creates new form ColorRGBADialog */ |
|
||||||
public ColorRGBADialog(java.awt.Frame parent, boolean modal, ColorRGBAPropertyEditor editor) { |
|
||||||
super(parent, modal); |
|
||||||
this.editor = editor; |
|
||||||
initComponents(); |
|
||||||
alphaSlider.setValue(Math.round(((ColorRGBA)editor.getValue()).getAlpha()*100)); |
|
||||||
} |
|
||||||
|
|
||||||
public ColorRGBA setColor() { |
|
||||||
Color cColor = jColorChooser1.getColor(); |
|
||||||
ColorRGBA color = new ColorRGBA(); |
|
||||||
float[] floats = new float[4]; |
|
||||||
cColor.getComponents(floats); |
|
||||||
color.set(floats[0], floats[1], floats[2], ((float)alphaSlider.getValue())/100.0f); |
|
||||||
ColorRGBA color2 = new ColorRGBA((ColorRGBA) editor.getValue()); |
|
||||||
editor.setValue(color); |
|
||||||
editor.notifyListeners(color2, color); |
|
||||||
return color; |
|
||||||
} |
|
||||||
|
|
||||||
/** 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. |
|
||||||
*/ |
|
||||||
@SuppressWarnings("unchecked") |
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
|
||||||
private void initComponents() { |
|
||||||
|
|
||||||
jColorChooser1 = new javax.swing.JColorChooser(); |
|
||||||
jButton1 = new javax.swing.JButton(); |
|
||||||
jButton2 = new javax.swing.JButton(); |
|
||||||
jToolBar1 = new javax.swing.JToolBar(); |
|
||||||
alphaLabel = new javax.swing.JLabel(); |
|
||||||
alphaSlider = new javax.swing.JSlider(); |
|
||||||
|
|
||||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); |
|
||||||
|
|
||||||
jButton1.setText(org.openide.util.NbBundle.getMessage(ColorRGBADialog.class, "ColorRGBADialog.jButton1.text")); // NOI18N
|
|
||||||
jButton1.addActionListener(new java.awt.event.ActionListener() { |
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) { |
|
||||||
jButton1ActionPerformed(evt); |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
jButton2.setText(org.openide.util.NbBundle.getMessage(ColorRGBADialog.class, "ColorRGBADialog.jButton2.text")); // NOI18N
|
|
||||||
jButton2.addActionListener(new java.awt.event.ActionListener() { |
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) { |
|
||||||
jButton2ActionPerformed(evt); |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
jToolBar1.setFloatable(false); |
|
||||||
jToolBar1.setRollover(true); |
|
||||||
|
|
||||||
alphaLabel.setText(org.openide.util.NbBundle.getMessage(ColorRGBADialog.class, "ColorRGBADialog.alphaLabel.text")); // NOI18N
|
|
||||||
jToolBar1.add(alphaLabel); |
|
||||||
|
|
||||||
alphaSlider.setValue(100); |
|
||||||
jToolBar1.add(alphaSlider); |
|
||||||
|
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); |
|
||||||
getContentPane().setLayout(layout); |
|
||||||
layout.setHorizontalGroup( |
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() |
|
||||||
.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 320, Short.MAX_VALUE) |
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
|
||||||
.addComponent(jButton2) |
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
|
||||||
.addComponent(jButton1)) |
|
||||||
.addComponent(jColorChooser1, javax.swing.GroupLayout.DEFAULT_SIZE, 496, Short.MAX_VALUE) |
|
||||||
); |
|
||||||
layout.setVerticalGroup( |
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() |
|
||||||
.addComponent(jColorChooser1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE) |
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) |
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) |
|
||||||
.addComponent(jButton1) |
|
||||||
.addComponent(jButton2)) |
|
||||||
.addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))) |
|
||||||
); |
|
||||||
|
|
||||||
pack(); |
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
|
||||||
|
|
||||||
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
|
||||||
setColor(); |
|
||||||
dispose(); |
|
||||||
}//GEN-LAST:event_jButton1ActionPerformed
|
|
||||||
|
|
||||||
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
|
|
||||||
dispose(); |
|
||||||
}//GEN-LAST:event_jButton2ActionPerformed
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
|
||||||
private javax.swing.JLabel alphaLabel; |
|
||||||
private javax.swing.JSlider alphaSlider; |
|
||||||
private javax.swing.JButton jButton1; |
|
||||||
private javax.swing.JButton jButton2; |
|
||||||
private javax.swing.JColorChooser jColorChooser1; |
|
||||||
private javax.swing.JToolBar jToolBar1; |
|
||||||
// End of variables declaration//GEN-END:variables
|
|
||||||
} |
|
@ -1,125 +0,0 @@ |
|||||||
/* |
|
||||||
* 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.properties; |
|
||||||
|
|
||||||
import com.jme3.math.ColorRGBA; |
|
||||||
import java.awt.Component; |
|
||||||
import java.awt.Graphics; |
|
||||||
import java.awt.Rectangle; |
|
||||||
import java.beans.PropertyChangeEvent; |
|
||||||
import java.beans.PropertyChangeListener; |
|
||||||
import java.beans.PropertyEditor; |
|
||||||
import java.util.Iterator; |
|
||||||
import java.util.LinkedList; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class ColorRGBAPropertyEditor implements PropertyEditor { |
|
||||||
|
|
||||||
private LinkedList<PropertyChangeListener> listeners = new LinkedList<PropertyChangeListener>(); |
|
||||||
private ColorRGBA color = new ColorRGBA(); |
|
||||||
|
|
||||||
public void setValue(Object value) { |
|
||||||
if (value instanceof ColorRGBA) { |
|
||||||
color.set((ColorRGBA) value); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public Object getValue() { |
|
||||||
return color; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isPaintable() { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public void paintValue(Graphics gfx, Rectangle box) { |
|
||||||
throw new UnsupportedOperationException("Not supported yet."); |
|
||||||
} |
|
||||||
|
|
||||||
public String getJavaInitializationString() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public String getAsText() { |
|
||||||
return "[" + color.r + ", " + color.g + ", " + color.b + ", " + color.a + "]"; |
|
||||||
} |
|
||||||
|
|
||||||
public void setAsText(String text) throws IllegalArgumentException { |
|
||||||
text = text.replace('[', ' '); |
|
||||||
text = text.replace(']', ' '); |
|
||||||
String[] values = text.split(","); |
|
||||||
ColorRGBA old=color; |
|
||||||
if (values.length != 4) { |
|
||||||
throw (new IllegalArgumentException("String not correct")); |
|
||||||
} |
|
||||||
float[] floats = new float[4]; |
|
||||||
for (int i = 0; i < values.length; i++) { |
|
||||||
String string = values[i]; |
|
||||||
floats[i] = Float.parseFloat(string); |
|
||||||
} |
|
||||||
color.set(floats[0], floats[1], floats[2], floats[3]); |
|
||||||
notifyListeners(old, color); |
|
||||||
} |
|
||||||
|
|
||||||
public String[] getTags() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public Component getCustomEditor() { |
|
||||||
ColorRGBADialog dialog = new ColorRGBADialog(null, true, this); |
|
||||||
dialog.setLocationRelativeTo(null); |
|
||||||
return dialog; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean supportsCustomEditor() { |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
public void addPropertyChangeListener(PropertyChangeListener listener) { |
|
||||||
listeners.add(listener); |
|
||||||
} |
|
||||||
|
|
||||||
public void removePropertyChangeListener(PropertyChangeListener listener) { |
|
||||||
listeners.remove(listener); |
|
||||||
} |
|
||||||
|
|
||||||
public void notifyListeners(ColorRGBA before, ColorRGBA after) { |
|
||||||
for (Iterator<PropertyChangeListener> it = listeners.iterator(); it.hasNext();) { |
|
||||||
PropertyChangeListener propertyChangeListener = it.next(); |
|
||||||
//TODO: check what the "programmatic name" is supposed to be here.. for now its ColorRGBA
|
|
||||||
propertyChangeListener.propertyChange(new PropertyChangeEvent(this, null, before, after)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,186 +0,0 @@ |
|||||||
/* |
|
||||||
* 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.properties; |
|
||||||
|
|
||||||
import com.jme3.effect.shapes.EmitterBoxShape; |
|
||||||
import com.jme3.effect.shapes.EmitterPointShape; |
|
||||||
import com.jme3.effect.shapes.EmitterShape; |
|
||||||
import com.jme3.effect.shapes.EmitterSphereShape; |
|
||||||
import com.jme3.math.Vector3f; |
|
||||||
import java.awt.Component; |
|
||||||
import java.awt.Graphics; |
|
||||||
import java.awt.Rectangle; |
|
||||||
import java.beans.PropertyChangeEvent; |
|
||||||
import java.beans.PropertyChangeListener; |
|
||||||
import java.beans.PropertyEditor; |
|
||||||
import java.util.Iterator; |
|
||||||
import java.util.LinkedList; |
|
||||||
import org.openide.awt.StatusDisplayer; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class EmitterShapePropertyEditor implements PropertyEditor { |
|
||||||
|
|
||||||
private LinkedList<PropertyChangeListener> listeners = new LinkedList<PropertyChangeListener>(); |
|
||||||
private EmitterShape emitter;// = new EmitterPointShape(Vector3f.ZERO);
|
|
||||||
|
|
||||||
public void setValue(Object value) { |
|
||||||
if (value instanceof EmitterShape) { |
|
||||||
emitter = (EmitterShape) value; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public Object getValue() { |
|
||||||
return emitter; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isPaintable() { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public void paintValue(Graphics gfx, Rectangle box) { |
|
||||||
throw new UnsupportedOperationException("Not supported yet."); |
|
||||||
} |
|
||||||
|
|
||||||
public String getJavaInitializationString() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public String getAsText() { |
|
||||||
if (emitter == null) { |
|
||||||
return "null"; |
|
||||||
} |
|
||||||
if (emitter instanceof EmitterBoxShape) { |
|
||||||
EmitterBoxShape shape = (EmitterBoxShape) emitter; |
|
||||||
return "[Box, " |
|
||||||
+ shape.getMin().x |
|
||||||
+ ", " |
|
||||||
+ shape.getMin().y |
|
||||||
+ ", " |
|
||||||
+ shape.getMin().z |
|
||||||
+ ", " |
|
||||||
+ shape.getMin().x + shape.getLen().x |
|
||||||
+ ", " |
|
||||||
+ shape.getMin().x + shape.getLen().y |
|
||||||
+ ", " |
|
||||||
+ shape.getMin().x + shape.getLen().z |
|
||||||
+ "]"; |
|
||||||
} else if (emitter instanceof EmitterPointShape) { |
|
||||||
EmitterPointShape shape = (EmitterPointShape) emitter; |
|
||||||
return "[Point, " |
|
||||||
+ shape.getPoint().x |
|
||||||
+ ", " |
|
||||||
+ shape.getPoint().y |
|
||||||
+ ", " |
|
||||||
+ shape.getPoint().z |
|
||||||
+ "]"; |
|
||||||
} else if (emitter instanceof EmitterSphereShape) { |
|
||||||
EmitterSphereShape shape = (EmitterSphereShape) emitter; |
|
||||||
return "[Sphere, " |
|
||||||
+ shape.getCenter().x |
|
||||||
+ ", " |
|
||||||
+ shape.getCenter().y |
|
||||||
+ ", " |
|
||||||
+ shape.getCenter().z |
|
||||||
+ ", " |
|
||||||
+ shape.getRadius() |
|
||||||
+ "]"; |
|
||||||
} |
|
||||||
return emitter.toString(); |
|
||||||
} |
|
||||||
|
|
||||||
public void setAsText(String text) throws IllegalArgumentException { |
|
||||||
text = text.replace('[', ' ').trim(); |
|
||||||
text = text.replace(']', ' ').trim(); |
|
||||||
String[] strings = text.split(","); |
|
||||||
EmitterShape old=emitter; |
|
||||||
if (strings.length == 0) { |
|
||||||
return; |
|
||||||
} |
|
||||||
if ("box".equals(strings[0].trim().toLowerCase())) { |
|
||||||
if (strings.length == 7) { |
|
||||||
StatusDisplayer.getDefault().setStatusText("try set parameterized box shape"); |
|
||||||
emitter = new EmitterBoxShape( |
|
||||||
new Vector3f(Float.parseFloat(strings[1]), Float.parseFloat(strings[2]), Float.parseFloat(strings[3])), new Vector3f(Float.parseFloat(strings[4]), Float.parseFloat(strings[5]), Float.parseFloat(strings[6]))); |
|
||||||
} else { |
|
||||||
StatusDisplayer.getDefault().setStatusText("try set standard box shape"); |
|
||||||
emitter = new EmitterBoxShape(new Vector3f(-.5f, -.5f, -.5f), new Vector3f(.5f, .5f, .5f)); |
|
||||||
} |
|
||||||
} else if ("point".equals(strings[0].trim().toLowerCase())) { |
|
||||||
if (strings.length == 4) { |
|
||||||
emitter = new EmitterPointShape( |
|
||||||
new Vector3f(Float.parseFloat(strings[1]), Float.parseFloat(strings[2]), Float.parseFloat(strings[3]))); |
|
||||||
} else { |
|
||||||
emitter = new EmitterPointShape(Vector3f.ZERO); |
|
||||||
} |
|
||||||
} else if ("sphere".equals(strings[0].trim().toLowerCase())) { |
|
||||||
if (strings.length == 5) { |
|
||||||
emitter = new EmitterSphereShape( |
|
||||||
new Vector3f(Float.parseFloat(strings[1]), Float.parseFloat(strings[2]), Float.parseFloat(strings[3])), Float.parseFloat(strings[4])); |
|
||||||
} else { |
|
||||||
emitter = new EmitterSphereShape(Vector3f.ZERO, .5f); |
|
||||||
} |
|
||||||
} |
|
||||||
notifyListeners(old, emitter); |
|
||||||
} |
|
||||||
|
|
||||||
public String[] getTags() { |
|
||||||
// String[] mats = new String[]{"[Point]", "[Sphere]", "[Box]"};
|
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public Component getCustomEditor() { |
|
||||||
throw new UnsupportedOperationException("Not supported yet."); |
|
||||||
} |
|
||||||
|
|
||||||
public boolean supportsCustomEditor() { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public void addPropertyChangeListener(PropertyChangeListener listener) { |
|
||||||
listeners.add(listener); |
|
||||||
} |
|
||||||
|
|
||||||
public void removePropertyChangeListener(PropertyChangeListener listener) { |
|
||||||
listeners.remove(listener); |
|
||||||
} |
|
||||||
|
|
||||||
private void notifyListeners(EmitterShape before, EmitterShape after) { |
|
||||||
for (Iterator<PropertyChangeListener> 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)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,124 +0,0 @@ |
|||||||
/* |
|
||||||
* 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.properties; |
|
||||||
|
|
||||||
import com.jme3.math.Matrix3f; |
|
||||||
import java.awt.Component; |
|
||||||
import java.awt.Graphics; |
|
||||||
import java.awt.Rectangle; |
|
||||||
import java.beans.PropertyChangeEvent; |
|
||||||
import java.beans.PropertyChangeListener; |
|
||||||
import java.beans.PropertyEditor; |
|
||||||
import java.util.Iterator; |
|
||||||
import java.util.LinkedList; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class Matrix3fPropertyEditor implements PropertyEditor { |
|
||||||
|
|
||||||
private LinkedList<PropertyChangeListener> listeners = new LinkedList<PropertyChangeListener>(); |
|
||||||
private Matrix3f vector = new Matrix3f(); |
|
||||||
|
|
||||||
public void setValue(Object value) { |
|
||||||
if (value instanceof Matrix3f) { |
|
||||||
vector.set((Matrix3f) value); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public Object getValue() { |
|
||||||
return vector; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isPaintable() { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public void paintValue(Graphics gfx, Rectangle box) { |
|
||||||
throw new UnsupportedOperationException("Not supported yet."); |
|
||||||
} |
|
||||||
|
|
||||||
public String getJavaInitializationString() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public String getAsText() { |
|
||||||
return vector.toString(); |
|
||||||
} |
|
||||||
|
|
||||||
public void setAsText(String text) throws IllegalArgumentException { |
|
||||||
text = text.replace('[', ' '); |
|
||||||
text = text.replace(']', ' '); |
|
||||||
String[] values = text.split(","); |
|
||||||
if (values.length != 3) { |
|
||||||
throw (new IllegalArgumentException("String not correct")); |
|
||||||
} |
|
||||||
float[] floats = new float[3]; |
|
||||||
for (int i = 0; i < values.length; i++) { |
|
||||||
String string = values[i]; |
|
||||||
floats[i] = Float.parseFloat(string); |
|
||||||
} |
|
||||||
Matrix3f old = new Matrix3f(); |
|
||||||
old.set(vector); |
|
||||||
// vector.set(floats[0], floats[1], floats[2]);
|
|
||||||
notifyListeners(old, vector); |
|
||||||
} |
|
||||||
|
|
||||||
public String[] getTags() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public Component getCustomEditor() { |
|
||||||
throw new UnsupportedOperationException("Not supported yet."); |
|
||||||
} |
|
||||||
|
|
||||||
public boolean supportsCustomEditor() { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public void addPropertyChangeListener(PropertyChangeListener listener) { |
|
||||||
listeners.add(listener); |
|
||||||
} |
|
||||||
|
|
||||||
public void removePropertyChangeListener(PropertyChangeListener listener) { |
|
||||||
listeners.remove(listener); |
|
||||||
} |
|
||||||
|
|
||||||
private void notifyListeners(Matrix3f before, Matrix3f after) { |
|
||||||
for (Iterator<PropertyChangeListener> it = listeners.iterator(); it.hasNext();) { |
|
||||||
PropertyChangeListener propertyChangeListener = it.next(); |
|
||||||
//TODO: check what the "programmatic name" is supposed to be here.. for now its Matrix3f
|
|
||||||
propertyChangeListener.propertyChange(new PropertyChangeEvent(this, null, before, after)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,125 +0,0 @@ |
|||||||
/* |
|
||||||
* 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.properties; |
|
||||||
|
|
||||||
import com.jme3.math.Quaternion; |
|
||||||
import java.awt.Component; |
|
||||||
import java.awt.Graphics; |
|
||||||
import java.awt.Rectangle; |
|
||||||
import java.beans.PropertyChangeEvent; |
|
||||||
import java.beans.PropertyChangeListener; |
|
||||||
import java.beans.PropertyEditor; |
|
||||||
import java.util.Iterator; |
|
||||||
import java.util.LinkedList; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class QuaternionPropertyEditor implements PropertyEditor { |
|
||||||
|
|
||||||
private LinkedList<PropertyChangeListener> listeners = new LinkedList<PropertyChangeListener>(); |
|
||||||
private Quaternion quaternion = new Quaternion(); |
|
||||||
|
|
||||||
public void setValue(Object value) { |
|
||||||
if (value instanceof Quaternion) { |
|
||||||
quaternion.set((Quaternion) value); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public Object getValue() { |
|
||||||
return quaternion; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isPaintable() { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public void paintValue(Graphics gfx, Rectangle box) { |
|
||||||
throw new UnsupportedOperationException("Not supported yet."); |
|
||||||
} |
|
||||||
|
|
||||||
public String getJavaInitializationString() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public String getAsText() { |
|
||||||
float[] angles=quaternion.toAngles(new float[3]); |
|
||||||
return "[" + (float)Math.toDegrees(angles[0]) + ", " + (float)Math.toDegrees(angles[1]) + ", " + (float)Math.toDegrees(angles[2]) + "]"; |
|
||||||
} |
|
||||||
|
|
||||||
public void setAsText(String text) throws IllegalArgumentException { |
|
||||||
text = text.replace('[', ' '); |
|
||||||
text = text.replace(']', ' '); |
|
||||||
String[] values = text.split(","); |
|
||||||
if (values.length != 3) { |
|
||||||
throw (new IllegalArgumentException("String not correct")); |
|
||||||
} |
|
||||||
float[] floats = new float[3]; |
|
||||||
for (int i = 0; i < values.length; i++) { |
|
||||||
String string = values[i]; |
|
||||||
floats[i] = (float)Math.toRadians(Float.parseFloat(string)); |
|
||||||
} |
|
||||||
Quaternion old=new Quaternion(); |
|
||||||
old.set(quaternion); |
|
||||||
quaternion.fromAngles(floats); |
|
||||||
notifyListeners(old,quaternion); |
|
||||||
} |
|
||||||
|
|
||||||
public String[] getTags() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public Component getCustomEditor() { |
|
||||||
throw new UnsupportedOperationException("Not supported yet."); |
|
||||||
} |
|
||||||
|
|
||||||
public boolean supportsCustomEditor() { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public void addPropertyChangeListener(PropertyChangeListener listener) { |
|
||||||
listeners.add(listener); |
|
||||||
} |
|
||||||
|
|
||||||
public void removePropertyChangeListener(PropertyChangeListener listener) { |
|
||||||
listeners.remove(listener); |
|
||||||
} |
|
||||||
|
|
||||||
private void notifyListeners(Quaternion before, Quaternion after) { |
|
||||||
for (Iterator<PropertyChangeListener> 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)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,209 +0,0 @@ |
|||||||
/* |
|
||||||
* 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.properties; |
|
||||||
|
|
||||||
import com.jme3.effect.shapes.EmitterShape; |
|
||||||
import com.jme3.gde.core.scene.SceneApplication; |
|
||||||
import com.jme3.gde.core.undoredo.AbstractUndoableSceneEdit; |
|
||||||
import com.jme3.gde.core.undoredo.SceneUndoRedoManager; |
|
||||||
import com.jme3.math.ColorRGBA; |
|
||||||
import com.jme3.math.Matrix3f; |
|
||||||
import com.jme3.math.Quaternion; |
|
||||||
import com.jme3.math.Vector2f; |
|
||||||
import com.jme3.math.Vector3f; |
|
||||||
import java.lang.reflect.InvocationTargetException; |
|
||||||
import java.util.Iterator; |
|
||||||
import java.util.LinkedList; |
|
||||||
import java.util.concurrent.Callable; |
|
||||||
import java.util.concurrent.ExecutionException; |
|
||||||
import java.util.logging.Level; |
|
||||||
import java.util.logging.Logger; |
|
||||||
import org.openide.nodes.PropertySupport; |
|
||||||
import org.openide.util.Exceptions; |
|
||||||
import org.openide.util.Lookup; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
@SuppressWarnings("unchecked") |
|
||||||
public class SceneExplorerProperty<T> extends PropertySupport.Reflection<T> { |
|
||||||
|
|
||||||
protected LinkedList<ScenePropertyChangeListener> listeners = new LinkedList<ScenePropertyChangeListener>(); |
|
||||||
|
|
||||||
public SceneExplorerProperty(T instance, Class valueType, String getter, String setter) throws NoSuchMethodException { |
|
||||||
this(instance, valueType, getter, setter, null); |
|
||||||
} |
|
||||||
|
|
||||||
public SceneExplorerProperty(T instance, Class valueType, String getter, String setter, ScenePropertyChangeListener listener) throws NoSuchMethodException { |
|
||||||
super(instance, valueType, getter, setter); |
|
||||||
addPropertyChangeListener(listener); |
|
||||||
if (valueType == Vector3f.class) { |
|
||||||
setPropertyEditorClass(Vector3fPropertyEditor.class); |
|
||||||
} else if (valueType == Quaternion.class) { |
|
||||||
setPropertyEditorClass(QuaternionPropertyEditor.class); |
|
||||||
} else if (valueType == Matrix3f.class) { |
|
||||||
setPropertyEditorClass(Matrix3fPropertyEditor.class); |
|
||||||
} else if (valueType == ColorRGBA.class) { |
|
||||||
setPropertyEditorClass(ColorRGBAPropertyEditor.class); |
|
||||||
} else if (valueType == EmitterShape.class) { |
|
||||||
setPropertyEditorClass(EmitterShapePropertyEditor.class); |
|
||||||
} else if (valueType == Vector2f.class) { |
|
||||||
setPropertyEditorClass(Vector2fPropertyEditor.class); |
|
||||||
} |
|
||||||
|
|
||||||
for (SceneExplorerPropertyEditor di : Lookup.getDefault().lookupAll(SceneExplorerPropertyEditor.class)) { |
|
||||||
di.setEditor(valueType, this); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public T getValue() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { |
|
||||||
return super.getValue(); |
|
||||||
// try {
|
|
||||||
// return SceneApplication.getApplication().enqueue(new Callable<T>() {
|
|
||||||
//
|
|
||||||
// public T call() throws Exception {
|
|
||||||
// return getSuperValue();
|
|
||||||
// }
|
|
||||||
// }).get();
|
|
||||||
// } catch (InterruptedException ex) {
|
|
||||||
// Exceptions.printStackTrace(ex);
|
|
||||||
// } catch (ExecutionException ex) {
|
|
||||||
// Exceptions.printStackTrace(ex);
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
} |
|
||||||
|
|
||||||
private T getSuperValue() { |
|
||||||
try { |
|
||||||
return super.getValue(); |
|
||||||
} catch (IllegalAccessException ex) { |
|
||||||
Exceptions.printStackTrace(ex); |
|
||||||
} catch (IllegalArgumentException ex) { |
|
||||||
Exceptions.printStackTrace(ex); |
|
||||||
} catch (InvocationTargetException ex) { |
|
||||||
Exceptions.printStackTrace(ex); |
|
||||||
} |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setValue(final T val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { |
|
||||||
try { |
|
||||||
notifyListeners(getSuperValue(), val); |
|
||||||
SceneApplication.getApplication().enqueue(new Callable<Void>() { |
|
||||||
|
|
||||||
public Void call() throws Exception { |
|
||||||
setSuperValue(val); |
|
||||||
return null; |
|
||||||
} |
|
||||||
}).get(); |
|
||||||
} catch (InterruptedException ex) { |
|
||||||
Exceptions.printStackTrace(ex); |
|
||||||
} catch (ExecutionException ex) { |
|
||||||
Exceptions.printStackTrace(ex); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private void setSuperValue(T val, boolean undo) { |
|
||||||
try { |
|
||||||
if (undo) { |
|
||||||
try { |
|
||||||
Object oldValue = getSuperValue(); |
|
||||||
if (oldValue.getClass().getMethod("clone") != null) { |
|
||||||
addUndo(oldValue.getClass().getMethod("clone").invoke(oldValue), val); |
|
||||||
Logger.getLogger(SceneExplorerProperty.class.getName()).log(Level.INFO, "Add cloned undo {0}", oldValue.getClass().getMethod("clone").invoke(oldValue)); |
|
||||||
} |
|
||||||
} catch (Exception e) { |
|
||||||
addUndo(getSuperValue(), val); |
|
||||||
Logger.getLogger(SceneExplorerProperty.class.getName()).log(Level.INFO, "Add undo {0}", getSuperValue()); |
|
||||||
} |
|
||||||
} |
|
||||||
super.setValue(val); |
|
||||||
} catch (IllegalAccessException ex) { |
|
||||||
Exceptions.printStackTrace(ex); |
|
||||||
} catch (IllegalArgumentException ex) { |
|
||||||
Exceptions.printStackTrace(ex); |
|
||||||
} catch (InvocationTargetException ex) { |
|
||||||
Exceptions.printStackTrace(ex); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private void setSuperValue(T val) { |
|
||||||
setSuperValue(val, true); |
|
||||||
} |
|
||||||
|
|
||||||
protected void addUndo(final Object before, final Object after) { |
|
||||||
SceneUndoRedoManager undoRedo = Lookup.getDefault().lookup(SceneUndoRedoManager.class); |
|
||||||
if (undoRedo == null) { |
|
||||||
Logger.getLogger(SceneExplorerProperty.class.getName()).log(Level.WARNING, "Cannot access SceneUndoRedoManager"); |
|
||||||
return; |
|
||||||
} |
|
||||||
undoRedo.addEdit(this, new AbstractUndoableSceneEdit() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public void sceneUndo() { |
|
||||||
Logger.getLogger(SceneExplorerProperty.class.getName()).log(Level.INFO, "Do undo {0}", before); |
|
||||||
setSuperValue((T) before, false); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void sceneRedo() { |
|
||||||
setSuperValue((T) after, false); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void awtUndo() { |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void awtRedo() { |
|
||||||
} |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
public void addPropertyChangeListener(ScenePropertyChangeListener listener) { |
|
||||||
listeners.add(listener); |
|
||||||
} |
|
||||||
|
|
||||||
public void removePropertyChangeListener(ScenePropertyChangeListener listener) { |
|
||||||
listeners.remove(listener); |
|
||||||
} |
|
||||||
|
|
||||||
private void notifyListeners(Object before, Object after) { |
|
||||||
for (Iterator<ScenePropertyChangeListener> it = listeners.iterator(); it.hasNext();) { |
|
||||||
ScenePropertyChangeListener propertyChangeListener = it.next(); |
|
||||||
propertyChangeListener.propertyChange(getName(), before, after); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,41 +0,0 @@ |
|||||||
/* |
|
||||||
* 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.properties; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public interface SceneExplorerPropertyEditor { |
|
||||||
public void setEditor(Class valueType, SceneExplorerProperty prop); |
|
||||||
} |
|
@ -1,41 +0,0 @@ |
|||||||
/* |
|
||||||
* 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.properties; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public interface ScenePropertyChangeListener { |
|
||||||
public void propertyChange(String property, Object oldValue, Object newValue); |
|
||||||
} |
|
@ -1,128 +0,0 @@ |
|||||||
<?xml version="1.1" encoding="UTF-8" ?> |
|
||||||
|
|
||||||
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> |
|
||||||
<Properties> |
|
||||||
<Property name="defaultCloseOperation" type="int" value="2"/> |
|
||||||
<Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> |
|
||||||
<ResourceString bundle="com/jme3/gde/core/assets/Bundle.properties" key="TextureBrowser.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> |
|
||||||
</Property> |
|
||||||
</Properties> |
|
||||||
<SyntheticProperties> |
|
||||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/> |
|
||||||
</SyntheticProperties> |
|
||||||
<AuxValues> |
|
||||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/> |
|
||||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> |
|
||||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> |
|
||||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> |
|
||||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/> |
|
||||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> |
|
||||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> |
|
||||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> |
|
||||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> |
|
||||||
</AuxValues> |
|
||||||
|
|
||||||
<Layout> |
|
||||||
<DimensionLayout dim="0"> |
|
||||||
<Group type="103" groupAlignment="0" attributes="0"> |
|
||||||
<Group type="102" alignment="1" attributes="0"> |
|
||||||
<EmptySpace pref="357" max="32767" attributes="0"/> |
|
||||||
<Component id="cancelButton" min="-2" max="-2" attributes="0"/> |
|
||||||
<EmptySpace max="-2" attributes="0"/> |
|
||||||
<Component id="okButton" min="-2" max="-2" attributes="0"/> |
|
||||||
<EmptySpace min="-2" pref="17" max="-2" attributes="0"/> |
|
||||||
</Group> |
|
||||||
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/> |
|
||||||
</Group> |
|
||||||
</DimensionLayout> |
|
||||||
<DimensionLayout dim="1"> |
|
||||||
<Group type="103" groupAlignment="0" attributes="0"> |
|
||||||
<Group type="102" alignment="1" attributes="0"> |
|
||||||
<Component id="jPanel1" max="32767" attributes="0"/> |
|
||||||
<EmptySpace type="unrelated" max="-2" attributes="0"/> |
|
||||||
<Group type="103" groupAlignment="3" attributes="0"> |
|
||||||
<Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/> |
|
||||||
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/> |
|
||||||
</Group> |
|
||||||
</Group> |
|
||||||
</Group> |
|
||||||
</DimensionLayout> |
|
||||||
</Layout> |
|
||||||
<SubComponents> |
|
||||||
<Component class="javax.swing.JButton" name="cancelButton"> |
|
||||||
<Properties> |
|
||||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> |
|
||||||
<ResourceString bundle="com/jme3/gde/core/sceneexplorer/nodes/properties/Bundle.properties" key="TextureBrowser.cancelButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> |
|
||||||
</Property> |
|
||||||
</Properties> |
|
||||||
<Events> |
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/> |
|
||||||
</Events> |
|
||||||
</Component> |
|
||||||
<Component class="javax.swing.JButton" name="okButton"> |
|
||||||
<Properties> |
|
||||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> |
|
||||||
<ResourceString bundle="com/jme3/gde/core/sceneexplorer/nodes/properties/Bundle.properties" key="TextureBrowser.okButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> |
|
||||||
</Property> |
|
||||||
</Properties> |
|
||||||
<Events> |
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/> |
|
||||||
</Events> |
|
||||||
</Component> |
|
||||||
<Container class="javax.swing.JPanel" name="jPanel1"> |
|
||||||
|
|
||||||
<Layout> |
|
||||||
<DimensionLayout dim="0"> |
|
||||||
<Group type="103" groupAlignment="0" attributes="0"> |
|
||||||
<Group type="102" alignment="0" attributes="0"> |
|
||||||
<Component id="jScrollPane1" pref="264" max="32767" attributes="0"/> |
|
||||||
<EmptySpace max="-2" attributes="0"/> |
|
||||||
<Component id="jScrollPane2" pref="267" max="32767" attributes="0"/> |
|
||||||
</Group> |
|
||||||
</Group> |
|
||||||
</DimensionLayout> |
|
||||||
<DimensionLayout dim="1"> |
|
||||||
<Group type="103" groupAlignment="0" attributes="0"> |
|
||||||
<Component id="jScrollPane2" alignment="0" pref="299" max="32767" attributes="0"/> |
|
||||||
<Component id="jScrollPane1" alignment="1" pref="299" max="32767" attributes="0"/> |
|
||||||
</Group> |
|
||||||
</DimensionLayout> |
|
||||||
</Layout> |
|
||||||
<SubComponents> |
|
||||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1"> |
|
||||||
<AuxValues> |
|
||||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> |
|
||||||
</AuxValues> |
|
||||||
|
|
||||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> |
|
||||||
<SubComponents> |
|
||||||
<Component class="javax.swing.JList" name="textureList"> |
|
||||||
<Properties> |
|
||||||
<Property name="selectionMode" type="int" value="0"/> |
|
||||||
<Property name="selectionModel" type="javax.swing.ListSelectionModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> |
|
||||||
<Connection code="new ToggleSelectionModel()" type="code"/> |
|
||||||
</Property> |
|
||||||
</Properties> |
|
||||||
<Events> |
|
||||||
<EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="textureListValueChanged"/> |
|
||||||
</Events> |
|
||||||
</Component> |
|
||||||
</SubComponents> |
|
||||||
</Container> |
|
||||||
<Container class="javax.swing.JScrollPane" name="jScrollPane2"> |
|
||||||
|
|
||||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> |
|
||||||
<SubComponents> |
|
||||||
<Component class="javax.swing.JLabel" name="imagePreviewLabel"> |
|
||||||
<Properties> |
|
||||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> |
|
||||||
<ResourceString bundle="com/jme3/gde/core/sceneexplorer/nodes/properties/Bundle.properties" key="TextureBrowser.imagePreviewLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> |
|
||||||
</Property> |
|
||||||
</Properties> |
|
||||||
</Component> |
|
||||||
</SubComponents> |
|
||||||
</Container> |
|
||||||
</SubComponents> |
|
||||||
</Container> |
|
||||||
</SubComponents> |
|
||||||
</Form> |
|
@ -1,264 +0,0 @@ |
|||||||
/* |
|
||||||
* 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.properties; |
|
||||||
|
|
||||||
import Model.DDSImageFile; |
|
||||||
import com.jme3.gde.core.assets.ProjectAssetManager; |
|
||||||
import com.jme3.texture.Texture; |
|
||||||
import java.awt.image.BufferedImage; |
|
||||||
import java.io.File; |
|
||||||
import java.io.IOException; |
|
||||||
import java.util.logging.Logger; |
|
||||||
import javax.swing.DefaultListSelectionModel; |
|
||||||
import javax.swing.Icon; |
|
||||||
import javax.swing.ImageIcon; |
|
||||||
import jme3tools.converters.ImageToAwt; |
|
||||||
import org.openide.filesystems.FileUtil; |
|
||||||
import org.openide.util.Exceptions; |
|
||||||
import org.openide.util.ImageUtilities; |
|
||||||
|
|
||||||
/** |
|
||||||
* Displays all textures in the ProjectAssetManager, |
|
||||||
* lets you select one, and shows a preview of it. |
|
||||||
* |
|
||||||
* The user can de-select the currently selected texture to specify they |
|
||||||
* do not want a texture, and in that case null is returned. |
|
||||||
* |
|
||||||
* @author bowens |
|
||||||
*/ |
|
||||||
public class TextureBrowser extends javax.swing.JDialog { |
|
||||||
|
|
||||||
private ProjectAssetManager assetManager; |
|
||||||
private TexturePropertyEditor editor; |
|
||||||
|
|
||||||
|
|
||||||
public TextureBrowser(java.awt.Frame parent, boolean modal, ProjectAssetManager assetManager, TexturePropertyEditor editor) { |
|
||||||
super(parent, modal); |
|
||||||
this.assetManager = assetManager; |
|
||||||
this.editor = editor; |
|
||||||
initComponents(); |
|
||||||
loadAvailableTextures(); |
|
||||||
setSelectedTexture((Texture)editor.getValue()); |
|
||||||
setLocationRelativeTo(null); |
|
||||||
} |
|
||||||
|
|
||||||
/** 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. |
|
||||||
*/ |
|
||||||
@SuppressWarnings("unchecked") |
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
|
||||||
private void initComponents() { |
|
||||||
|
|
||||||
cancelButton = new javax.swing.JButton(); |
|
||||||
okButton = new javax.swing.JButton(); |
|
||||||
jPanel1 = new javax.swing.JPanel(); |
|
||||||
jScrollPane1 = new javax.swing.JScrollPane(); |
|
||||||
textureList = new javax.swing.JList(); |
|
||||||
jScrollPane2 = new javax.swing.JScrollPane(); |
|
||||||
imagePreviewLabel = new javax.swing.JLabel(); |
|
||||||
|
|
||||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); |
|
||||||
setTitle(org.openide.util.NbBundle.getMessage(TextureBrowser.class, "TextureBrowser.title")); // NOI18N
|
|
||||||
|
|
||||||
cancelButton.setText(org.openide.util.NbBundle.getMessage(TextureBrowser.class, "TextureBrowser.cancelButton.text")); // NOI18N
|
|
||||||
cancelButton.addActionListener(new java.awt.event.ActionListener() { |
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) { |
|
||||||
cancelButtonActionPerformed(evt); |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
okButton.setText(org.openide.util.NbBundle.getMessage(TextureBrowser.class, "TextureBrowser.okButton.text")); // NOI18N
|
|
||||||
okButton.addActionListener(new java.awt.event.ActionListener() { |
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) { |
|
||||||
okButtonActionPerformed(evt); |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
textureList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
|
||||||
textureList.setSelectionModel(new ToggleSelectionModel()); |
|
||||||
textureList.addListSelectionListener(new javax.swing.event.ListSelectionListener() { |
|
||||||
public void valueChanged(javax.swing.event.ListSelectionEvent evt) { |
|
||||||
textureListValueChanged(evt); |
|
||||||
} |
|
||||||
}); |
|
||||||
jScrollPane1.setViewportView(textureList); |
|
||||||
|
|
||||||
imagePreviewLabel.setText(org.openide.util.NbBundle.getMessage(TextureBrowser.class, "TextureBrowser.imagePreviewLabel.text")); // NOI18N
|
|
||||||
jScrollPane2.setViewportView(imagePreviewLabel); |
|
||||||
|
|
||||||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); |
|
||||||
jPanel1.setLayout(jPanel1Layout); |
|
||||||
jPanel1Layout.setHorizontalGroup( |
|
||||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
|
||||||
.addGroup(jPanel1Layout.createSequentialGroup() |
|
||||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 264, Short.MAX_VALUE) |
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
|
||||||
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE)) |
|
||||||
); |
|
||||||
jPanel1Layout.setVerticalGroup( |
|
||||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
|
||||||
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE) |
|
||||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE) |
|
||||||
); |
|
||||||
|
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); |
|
||||||
getContentPane().setLayout(layout); |
|
||||||
layout.setHorizontalGroup( |
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
|
||||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() |
|
||||||
.addContainerGap(357, Short.MAX_VALUE) |
|
||||||
.addComponent(cancelButton) |
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
|
||||||
.addComponent(okButton) |
|
||||||
.addGap(17, 17, 17)) |
|
||||||
.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(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() |
|
||||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) |
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) |
|
||||||
.addComponent(okButton) |
|
||||||
.addComponent(cancelButton))) |
|
||||||
); |
|
||||||
|
|
||||||
pack(); |
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
|
||||||
|
|
||||||
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
|
|
||||||
setTexture(); |
|
||||||
dispose(); |
|
||||||
}//GEN-LAST:event_okButtonActionPerformed
|
|
||||||
|
|
||||||
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
|
|
||||||
dispose(); |
|
||||||
}//GEN-LAST:event_cancelButtonActionPerformed
|
|
||||||
|
|
||||||
private void textureListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_textureListValueChanged
|
|
||||||
selectionChanged(); |
|
||||||
}//GEN-LAST:event_textureListValueChanged
|
|
||||||
|
|
||||||
private void setTexture() { |
|
||||||
if (textureList.getSelectedIndex() > -1) { |
|
||||||
textureList.getSelectedValue(); |
|
||||||
String selected = (String) textureList.getSelectedValue(); |
|
||||||
Texture tex = assetManager.loadTexture(selected); |
|
||||||
editor.setValue(tex); |
|
||||||
editor.setAsText(selected); |
|
||||||
} else { |
|
||||||
editor.setValue(null); |
|
||||||
editor.setAsText(null); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
|
||||||
private javax.swing.JButton cancelButton; |
|
||||||
private javax.swing.JLabel imagePreviewLabel; |
|
||||||
private javax.swing.JPanel jPanel1; |
|
||||||
private javax.swing.JScrollPane jScrollPane1; |
|
||||||
private javax.swing.JScrollPane jScrollPane2; |
|
||||||
private javax.swing.JButton okButton; |
|
||||||
private javax.swing.JList textureList; |
|
||||||
// End of variables declaration//GEN-END:variables
|
|
||||||
|
|
||||||
private void loadAvailableTextures() { |
|
||||||
if (assetManager == null) |
|
||||||
return; |
|
||||||
|
|
||||||
textureList.setListData(assetManager.getTextures()); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
private void selectionChanged() { |
|
||||||
if (textureList.getSelectedIndex() > -1) { |
|
||||||
String selected = (String) textureList.getSelectedValue(); |
|
||||||
Texture tex = assetManager.loadTexture(selected); |
|
||||||
Icon newicon = null; |
|
||||||
if(selected.endsWith(".dds")||selected.endsWith(".DDS")){ |
|
||||||
try { |
|
||||||
File file = FileUtil.toFile(assetManager.getAssetFolder().getFileObject(selected)); |
|
||||||
DDSImageFile ddsImageFile = new DDSImageFile(file); |
|
||||||
BufferedImage bufferedImage = ddsImageFile.getData(); |
|
||||||
newicon = new ImageIcon(bufferedImage); |
|
||||||
} catch (IOException ex) { |
|
||||||
Exceptions.printStackTrace(ex); |
|
||||||
} |
|
||||||
}else{ |
|
||||||
newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0)); |
|
||||||
} |
|
||||||
imagePreviewLabel.setIcon(newicon); |
|
||||||
} else { |
|
||||||
imagePreviewLabel.setIcon(null); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private void setSelectedTexture(Texture texture) { |
|
||||||
if (texture != null) { |
|
||||||
Logger.getLogger(TextureBrowser.class.getName()).finer("Looking for Texture: "+texture.getName()); |
|
||||||
for (int i=0; i<textureList.getModel().getSize(); i++) { |
|
||||||
Logger.getLogger(TextureBrowser.class.getName()).finer("Texture name: "+textureList.getModel().getElementAt(i)); |
|
||||||
if (textureList.getModel().getElementAt(i).equals(texture.getName()) ) { |
|
||||||
textureList.setSelectedIndex(i); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
class ToggleSelectionModel extends DefaultListSelectionModel { |
|
||||||
boolean gestureStarted = false; |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setSelectionInterval(int index0, int index1) { |
|
||||||
if (isSelectedIndex(index0) && !gestureStarted) { |
|
||||||
super.removeSelectionInterval(index0, index1); |
|
||||||
} |
|
||||||
else { |
|
||||||
super.setSelectionInterval(index0, index1); |
|
||||||
} |
|
||||||
gestureStarted = true; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setValueIsAdjusting(boolean isAdjusting) { |
|
||||||
if (isAdjusting == false) { |
|
||||||
gestureStarted = false; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,139 +0,0 @@ |
|||||||
/* |
|
||||||
* 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.properties; |
|
||||||
|
|
||||||
import com.jme3.asset.AssetManager; |
|
||||||
import com.jme3.gde.core.assets.ProjectAssetManager; |
|
||||||
import com.jme3.gde.core.scene.SceneApplication; |
|
||||||
import com.jme3.texture.Texture; |
|
||||||
import java.awt.Component; |
|
||||||
import java.awt.Graphics; |
|
||||||
import java.awt.Rectangle; |
|
||||||
import java.beans.PropertyChangeListener; |
|
||||||
import java.beans.PropertyEditor; |
|
||||||
import java.util.LinkedList; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author bowens |
|
||||||
*/ |
|
||||||
public class TexturePropertyEditor implements PropertyEditor { |
|
||||||
|
|
||||||
private LinkedList<PropertyChangeListener> listeners = new LinkedList<PropertyChangeListener>(); |
|
||||||
private Texture texture; |
|
||||||
private AssetManager manager; |
|
||||||
private String assetKey; |
|
||||||
|
|
||||||
public TexturePropertyEditor() { |
|
||||||
} |
|
||||||
|
|
||||||
public TexturePropertyEditor(Texture texture) { |
|
||||||
this.texture = texture; |
|
||||||
} |
|
||||||
|
|
||||||
public TexturePropertyEditor(AssetManager manager) { |
|
||||||
this.manager = manager; |
|
||||||
} |
|
||||||
|
|
||||||
public TexturePropertyEditor(Texture texture, AssetManager manager) { |
|
||||||
this.texture = texture; |
|
||||||
this.manager = manager; |
|
||||||
} |
|
||||||
|
|
||||||
public void setValue(Object value) { |
|
||||||
if (value instanceof Texture) { |
|
||||||
texture = (Texture) value; |
|
||||||
} else { |
|
||||||
texture = null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public Object getValue() { |
|
||||||
return texture; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isPaintable() { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public void paintValue(Graphics gfx, Rectangle box) { |
|
||||||
} |
|
||||||
|
|
||||||
public String getJavaInitializationString() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public String getAsText() { |
|
||||||
// if (texture != null) {
|
|
||||||
// return texture.getName();
|
|
||||||
// }
|
|
||||||
return assetKey; |
|
||||||
} |
|
||||||
|
|
||||||
public void setAsText(String text) throws IllegalArgumentException { |
|
||||||
this.assetKey = text; |
|
||||||
//TODO: load texture if not done.. maybe load here instead of panel..
|
|
||||||
} |
|
||||||
|
|
||||||
public String[] getTags() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public Component getCustomEditor() { |
|
||||||
ProjectAssetManager currentProjectAssetManager = null; |
|
||||||
if (manager instanceof ProjectAssetManager) { |
|
||||||
currentProjectAssetManager = (ProjectAssetManager) manager; |
|
||||||
} |
|
||||||
//try {
|
|
||||||
if (currentProjectAssetManager == null) { |
|
||||||
currentProjectAssetManager = (ProjectAssetManager) SceneApplication.getApplication().getAssetManager(); |
|
||||||
} |
|
||||||
TextureBrowser textureBrowser = new TextureBrowser(null, true, currentProjectAssetManager, this); |
|
||||||
return textureBrowser; |
|
||||||
//} catch (Exception e) {
|
|
||||||
//Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, e.getMessage()+" Could not get project asset manager!", e);
|
|
||||||
//return null;
|
|
||||||
//}
|
|
||||||
} |
|
||||||
|
|
||||||
public boolean supportsCustomEditor() { |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
public void addPropertyChangeListener(PropertyChangeListener listener) { |
|
||||||
listeners.add(listener); |
|
||||||
} |
|
||||||
|
|
||||||
public void removePropertyChangeListener(PropertyChangeListener listener) { |
|
||||||
listeners.remove(listener); |
|
||||||
} |
|
||||||
} |
|
@ -1,144 +0,0 @@ |
|||||||
/* |
|
||||||
* 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.properties; |
|
||||||
|
|
||||||
import com.jme3.gde.core.scene.SceneApplication; |
|
||||||
import com.jme3.scene.Spatial; |
|
||||||
import java.beans.PropertyEditor; |
|
||||||
import java.lang.reflect.InvocationTargetException; |
|
||||||
import java.util.Iterator; |
|
||||||
import java.util.LinkedList; |
|
||||||
import java.util.List; |
|
||||||
import java.util.concurrent.Callable; |
|
||||||
import java.util.concurrent.ExecutionException; |
|
||||||
import org.openide.nodes.PropertySupport; |
|
||||||
import org.openide.util.Exceptions; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class UserDataProperty extends PropertySupport.ReadWrite<String> { |
|
||||||
|
|
||||||
private Spatial spatial; |
|
||||||
private String name = "null"; |
|
||||||
private int type = 0; |
|
||||||
private List<ScenePropertyChangeListener> listeners = new LinkedList<ScenePropertyChangeListener>(); |
|
||||||
|
|
||||||
public UserDataProperty(Spatial node, String name) { |
|
||||||
super(name, String.class, name, ""); |
|
||||||
this.spatial = node; |
|
||||||
this.name = name; |
|
||||||
this.type = getObjectType(node.getUserData(name)); |
|
||||||
} |
|
||||||
|
|
||||||
public static int getObjectType(Object type) { |
|
||||||
if (type instanceof Integer) { |
|
||||||
return 0; |
|
||||||
} else if (type instanceof Float) { |
|
||||||
return 1; |
|
||||||
} else if (type instanceof Boolean) { |
|
||||||
return 2; |
|
||||||
} else if (type instanceof String) { |
|
||||||
return 3; |
|
||||||
} else if (type instanceof Long) { |
|
||||||
return 4; |
|
||||||
} else { |
|
||||||
throw new IllegalArgumentException("Unsupported type: " + type); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getValue() throws IllegalAccessException, InvocationTargetException { |
|
||||||
return spatial.getUserData(name) + ""; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void setValue(final String val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { |
|
||||||
if (spatial == null) { |
|
||||||
return; |
|
||||||
} |
|
||||||
try { |
|
||||||
SceneApplication.getApplication().enqueue(new Callable<Void>() { |
|
||||||
|
|
||||||
public Void call() throws Exception { |
|
||||||
switch (type) { |
|
||||||
case 0: |
|
||||||
spatial.setUserData(name, Integer.parseInt(val)); |
|
||||||
break; |
|
||||||
case 1: |
|
||||||
spatial.setUserData(name, Float.parseFloat(val)); |
|
||||||
break; |
|
||||||
case 2: |
|
||||||
spatial.setUserData(name, Boolean.parseBoolean(val)); |
|
||||||
break; |
|
||||||
case 3: |
|
||||||
spatial.setUserData(name, val); |
|
||||||
break; |
|
||||||
case 4: |
|
||||||
spatial.setUserData(name, Long.parseLong(val)); |
|
||||||
break; |
|
||||||
default: |
|
||||||
throw new UnsupportedOperationException(); |
|
||||||
} |
|
||||||
return null; |
|
||||||
} |
|
||||||
}).get(); |
|
||||||
notifyListeners(null, val); |
|
||||||
} catch (InterruptedException ex) { |
|
||||||
Exceptions.printStackTrace(ex); |
|
||||||
} catch (ExecutionException ex) { |
|
||||||
Exceptions.printStackTrace(ex); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public PropertyEditor getPropertyEditor() { |
|
||||||
return null; |
|
||||||
// return new AnimationPropertyEditor(control);
|
|
||||||
} |
|
||||||
|
|
||||||
public void addPropertyChangeListener(ScenePropertyChangeListener listener) { |
|
||||||
listeners.add(listener); |
|
||||||
} |
|
||||||
|
|
||||||
public void removePropertyChangeListener(ScenePropertyChangeListener listener) { |
|
||||||
listeners.remove(listener); |
|
||||||
} |
|
||||||
|
|
||||||
private void notifyListeners(Object before, Object after) { |
|
||||||
for (Iterator<ScenePropertyChangeListener> it = listeners.iterator(); it.hasNext();) { |
|
||||||
ScenePropertyChangeListener propertyChangeListener = it.next(); |
|
||||||
propertyChangeListener.propertyChange(getName(), before, after); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,124 +0,0 @@ |
|||||||
/* |
|
||||||
* 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.properties; |
|
||||||
|
|
||||||
import com.jme3.math.Vector2f; |
|
||||||
import java.awt.Component; |
|
||||||
import java.awt.Graphics; |
|
||||||
import java.awt.Rectangle; |
|
||||||
import java.beans.PropertyChangeEvent; |
|
||||||
import java.beans.PropertyChangeListener; |
|
||||||
import java.beans.PropertyEditor; |
|
||||||
import java.util.Iterator; |
|
||||||
import java.util.LinkedList; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class Vector2fPropertyEditor implements PropertyEditor { |
|
||||||
|
|
||||||
private LinkedList<PropertyChangeListener> listeners = new LinkedList<PropertyChangeListener>(); |
|
||||||
private Vector2f vector = new Vector2f(); |
|
||||||
|
|
||||||
public void setValue(Object value) { |
|
||||||
if (value instanceof Vector2f) { |
|
||||||
vector.set((Vector2f) value); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public Object getValue() { |
|
||||||
return vector; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isPaintable() { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public void paintValue(Graphics gfx, Rectangle box) { |
|
||||||
throw new UnsupportedOperationException("Not supported yet."); |
|
||||||
} |
|
||||||
|
|
||||||
public String getJavaInitializationString() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public String getAsText() { |
|
||||||
return "[" + vector.x + ", " + vector.y + "]"; |
|
||||||
} |
|
||||||
|
|
||||||
public void setAsText(String text) throws IllegalArgumentException { |
|
||||||
text = text.replace('[', ' '); |
|
||||||
text = text.replace(']', ' '); |
|
||||||
String[] values = text.split(","); |
|
||||||
if (values.length != 2) { |
|
||||||
throw (new IllegalArgumentException("String not correct")); |
|
||||||
} |
|
||||||
float[] floats = new float[2]; |
|
||||||
for (int i = 0; i < values.length; i++) { |
|
||||||
String string = values[i]; |
|
||||||
floats[i] = Float.parseFloat(string); |
|
||||||
} |
|
||||||
Vector2f old = new Vector2f(); |
|
||||||
old.set(vector); |
|
||||||
vector.set(floats[0], floats[1]); |
|
||||||
notifyListeners(old, vector); |
|
||||||
} |
|
||||||
|
|
||||||
public String[] getTags() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public Component getCustomEditor() { |
|
||||||
throw new UnsupportedOperationException("Not supported yet."); |
|
||||||
} |
|
||||||
|
|
||||||
public boolean supportsCustomEditor() { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public void addPropertyChangeListener(PropertyChangeListener listener) { |
|
||||||
listeners.add(listener); |
|
||||||
} |
|
||||||
|
|
||||||
public void removePropertyChangeListener(PropertyChangeListener listener) { |
|
||||||
listeners.remove(listener); |
|
||||||
} |
|
||||||
|
|
||||||
private void notifyListeners(Vector2f before, Vector2f after) { |
|
||||||
for (Iterator<PropertyChangeListener> it = listeners.iterator(); it.hasNext();) { |
|
||||||
PropertyChangeListener propertyChangeListener = it.next(); |
|
||||||
//TODO: check what the "programmatic name" is supposed to be here.. for now its Vector2f
|
|
||||||
propertyChangeListener.propertyChange(new PropertyChangeEvent(this, null, before, after)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,124 +0,0 @@ |
|||||||
/* |
|
||||||
* 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.properties; |
|
||||||
|
|
||||||
import com.jme3.math.Vector3f; |
|
||||||
import java.awt.Component; |
|
||||||
import java.awt.Graphics; |
|
||||||
import java.awt.Rectangle; |
|
||||||
import java.beans.PropertyChangeEvent; |
|
||||||
import java.beans.PropertyChangeListener; |
|
||||||
import java.beans.PropertyEditor; |
|
||||||
import java.util.Iterator; |
|
||||||
import java.util.LinkedList; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class Vector3fPropertyEditor implements PropertyEditor { |
|
||||||
|
|
||||||
private LinkedList<PropertyChangeListener> listeners = new LinkedList<PropertyChangeListener>(); |
|
||||||
private Vector3f vector = new Vector3f(); |
|
||||||
|
|
||||||
public void setValue(Object value) { |
|
||||||
if (value instanceof Vector3f) { |
|
||||||
vector.set((Vector3f) value); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public Object getValue() { |
|
||||||
return vector; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean isPaintable() { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public void paintValue(Graphics gfx, Rectangle box) { |
|
||||||
throw new UnsupportedOperationException("Not supported yet."); |
|
||||||
} |
|
||||||
|
|
||||||
public String getJavaInitializationString() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public String getAsText() { |
|
||||||
return "[" + vector.x + ", " + vector.y + ", " + vector.z + "]"; |
|
||||||
} |
|
||||||
|
|
||||||
public void setAsText(String text) throws IllegalArgumentException { |
|
||||||
text = text.replace('[', ' '); |
|
||||||
text = text.replace(']', ' '); |
|
||||||
String[] values = text.split(","); |
|
||||||
if (values.length != 3) { |
|
||||||
throw (new IllegalArgumentException("String not correct")); |
|
||||||
} |
|
||||||
float[] floats = new float[3]; |
|
||||||
for (int i = 0; i < values.length; i++) { |
|
||||||
String string = values[i]; |
|
||||||
floats[i] = Float.parseFloat(string); |
|
||||||
} |
|
||||||
Vector3f old = new Vector3f(); |
|
||||||
old.set(vector); |
|
||||||
vector.set(floats[0], floats[1], floats[2]); |
|
||||||
notifyListeners(old, vector); |
|
||||||
} |
|
||||||
|
|
||||||
public String[] getTags() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
public Component getCustomEditor() { |
|
||||||
throw new UnsupportedOperationException("Not supported yet."); |
|
||||||
} |
|
||||||
|
|
||||||
public boolean supportsCustomEditor() { |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public void addPropertyChangeListener(PropertyChangeListener listener) { |
|
||||||
listeners.add(listener); |
|
||||||
} |
|
||||||
|
|
||||||
public void removePropertyChangeListener(PropertyChangeListener listener) { |
|
||||||
listeners.remove(listener); |
|
||||||
} |
|
||||||
|
|
||||||
private void notifyListeners(Vector3f before, Vector3f after) { |
|
||||||
for (Iterator<PropertyChangeListener> it = listeners.iterator(); it.hasNext();) { |
|
||||||
PropertyChangeListener propertyChangeListener = it.next(); |
|
||||||
//TODO: check what the "programmatic name" is supposed to be here.. for now its Vector3f
|
|
||||||
propertyChangeListener.propertyChange(new PropertyChangeEvent(this, null, before, after)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue