SDK Filter editor :

- dynamic properties introspection for all filters
- added support for SSAOFilter

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7764 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 14 years ago
parent f5ee0ca201
commit 3d80227b19
  1. 19
      sdk/jme3-core/src/com/jme3/gde/core/filters/AbstractFilterNode.java
  2. 11
      sdk/jme3-core/src/com/jme3/gde/core/filters/impl/JmeBloomFilter.java
  3. 15
      sdk/jme3-core/src/com/jme3/gde/core/filters/impl/JmeCartoonEdgeFilter.java
  4. 3
      sdk/jme3-core/src/com/jme3/gde/core/filters/impl/JmeColorOverlayFilter.java
  5. 15
      sdk/jme3-core/src/com/jme3/gde/core/filters/impl/JmeCrossHatchFilter.java
  6. 7
      sdk/jme3-core/src/com/jme3/gde/core/filters/impl/JmeDepthOfFieldFilter.java
  7. 7
      sdk/jme3-core/src/com/jme3/gde/core/filters/impl/JmeFogFilter.java
  8. 12
      sdk/jme3-core/src/com/jme3/gde/core/filters/impl/JmeLightScatteringFilter.java
  9. 7
      sdk/jme3-core/src/com/jme3/gde/core/filters/impl/JmePosterizationFilter.java
  10. 88
      sdk/jme3-core/src/com/jme3/gde/core/filters/impl/JmeSSAOFilter.java
  11. 10
      sdk/jme3-core/src/com/jme3/gde/core/filters/impl/JmeWaterFilter.java
  12. 55
      sdk/jme3-core/src/com/jme3/gde/core/filters/impl/NewSSAOFilterAction.java
  13. 74
      sdk/jme3-core/src/com/jme3/gde/core/util/PropertyUtils.java

@ -33,7 +33,9 @@ package com.jme3.gde.core.filters;
import com.jme3.gde.core.sceneexplorer.nodes.properties.SceneExplorerProperty;
import com.jme3.gde.core.sceneexplorer.nodes.properties.ScenePropertyChangeListener;
import com.jme3.gde.core.util.PropertyUtils;
import com.jme3.post.Filter;
import java.beans.PropertyDescriptor;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@ -166,21 +168,10 @@ public abstract class AbstractFilterNode extends AbstractNode implements FilterN
protected void createFields(Class c, Sheet.Set set, Object obj) throws SecurityException {
for (Field field : c.getDeclaredFields()) {
String name = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1);
String getter = "get";
if (field.getType().equals(boolean.class)) {
getter = "is";
}
try {
Method m=c.getMethod(getter + name, null);
m=c.getMethod("set" + name, field.getType());
} catch (NoSuchMethodException e) {
continue;
PropertyDescriptor prop=PropertyUtils.getPropertyDescriptor(c, field);
if(prop!=null){
set.put(makeProperty(obj, prop.getPropertyType() , prop.getReadMethod().getName(), prop.getWriteMethod().getName(), prop.getDisplayName()));
}
set.put(makeProperty(obj, field.getType(), getter + name, "set" + name, field.getName()));
}
}

@ -64,11 +64,12 @@ public class JmeBloomFilter extends AbstractFilterNode {
if (obj == null) {
return sheet;
}
set.put(makeProperty(obj, float.class, "getBloomIntensity", "setBloomIntensity", "Intensity"));
set.put(makeProperty(obj, float.class, "getBlurScale", "setBlurScale", "Blur Scale"));
set.put(makeProperty(obj, float.class, "getDownSamplingFactor", "setDownSamplingFactor", "Downsampling Factor"));
set.put(makeProperty(obj, float.class, "getExposureCutOff", "setExposureCutOff", "Exposure Cutoff"));
set.put(makeProperty(obj, float.class, "getExposurePower", "setExposurePower", "Exposure Power"));
// set.put(makeProperty(obj, float.class, "getBloomIntensity", "setBloomIntensity", "Intensity"));
// set.put(makeProperty(obj, float.class, "getBlurScale", "setBlurScale", "Blur Scale"));
// set.put(makeProperty(obj, float.class, "getDownSamplingFactor", "setDownSamplingFactor", "Downsampling Factor"));
// set.put(makeProperty(obj, float.class, "getExposureCutOff", "setExposureCutOff", "Exposure Cutoff"));
// set.put(makeProperty(obj, float.class, "getExposurePower", "setExposurePower", "Exposure Power"));
createFields(BloomFilter.class, set, obj);
sheet.put(set);
return sheet;

@ -65,13 +65,14 @@ public class JmeCartoonEdgeFilter extends AbstractFilterNode {
if (obj == null) {
return sheet;
}
set.put(makeProperty(obj, float.class, "getDepthSensitivity", "setDepthSensitivity", "Depth Sensitivity"));
set.put(makeProperty(obj, float.class, "getDepthThreshold", "setDepthThreshold", "Depth Threshold"));
set.put(makeProperty(obj, ColorRGBA.class, "getEdgeColor", "setEdgeColor", "Edge Color"));
set.put(makeProperty(obj, float.class, "getEdgeIntensity", "setEdgeIntensity", "Edge Intensity"));
set.put(makeProperty(obj, float.class, "getEdgeWidth", "setEdgeWidth", "Edge Width"));
set.put(makeProperty(obj, float.class, "getNormalSensitivity", "setNormalSensitivity", "Normal Sensitivity"));
set.put(makeProperty(obj, float.class, "getNormalThreshold", "setNormalThreshold", "Normal Threshold"));
// set.put(makeProperty(obj, float.class, "getDepthSensitivity", "setDepthSensitivity", "Depth Sensitivity"));
// set.put(makeProperty(obj, float.class, "getDepthThreshold", "setDepthThreshold", "Depth Threshold"));
// set.put(makeProperty(obj, ColorRGBA.class, "getEdgeColor", "setEdgeColor", "Edge Color"));
// set.put(makeProperty(obj, float.class, "getEdgeIntensity", "setEdgeIntensity", "Edge Intensity"));
// set.put(makeProperty(obj, float.class, "getEdgeWidth", "setEdgeWidth", "Edge Width"));
// set.put(makeProperty(obj, float.class, "getNormalSensitivity", "setNormalSensitivity", "Normal Sensitivity"));
// set.put(makeProperty(obj, float.class, "getNormalThreshold", "setNormalThreshold", "Normal Threshold"));
createFields(CartoonEdgeFilter.class, set, obj);
sheet.put(set);
return sheet;

@ -65,7 +65,8 @@ public class JmeColorOverlayFilter extends AbstractFilterNode {
if (obj == null) {
return sheet;
}
set.put(makeProperty(obj, ColorRGBA.class, "getColor", "setColor", "Color"));
//set.put(makeProperty(obj, ColorRGBA.class, "getColor", "setColor", "Color"));
createFields(ColorOverlayFilter.class, set, obj);
sheet.put(set);
return sheet;

@ -65,13 +65,14 @@ public class JmeCrossHatchFilter extends AbstractFilterNode {
if (obj == null) {
return sheet;
}
set.put(makeProperty(obj, float.class, "getColorInfluenceLine", "setColorInfluenceLine", "Color Influence Line"));
set.put(makeProperty(obj, float.class, "getColorInfluencePaper", "setColorInfluencePaper", "Color Influence Paper"));
set.put(makeProperty(obj, float.class, "getFillValue", "setFillValue", "Fill Value"));
set.put(makeProperty(obj, ColorRGBA.class, "getPaperColor", "setPaperColor", "Paper Color"));
set.put(makeProperty(obj, ColorRGBA.class, "getLineColor", "setLineColor", "Line Color"));
set.put(makeProperty(obj, float.class, "getLineDistance", "setLineDistance", "Line Distance"));
set.put(makeProperty(obj, float.class, "getLineThickness", "setLineThickness", "Line Thickness"));
// set.put(makeProperty(obj, float.class, "getColorInfluenceLine", "setColorInfluenceLine", "Color Influence Line"));
// set.put(makeProperty(obj, float.class, "getColorInfluencePaper", "setColorInfluencePaper", "Color Influence Paper"));
// set.put(makeProperty(obj, float.class, "getFillValue", "setFillValue", "Fill Value"));
// set.put(makeProperty(obj, ColorRGBA.class, "getPaperColor", "setPaperColor", "Paper Color"));
// set.put(makeProperty(obj, ColorRGBA.class, "getLineColor", "setLineColor", "Line Color"));
// set.put(makeProperty(obj, float.class, "getLineDistance", "setLineDistance", "Line Distance"));
// set.put(makeProperty(obj, float.class, "getLineThickness", "setLineThickness", "Line Thickness"));
createFields(CrossHatchFilter.class, set, obj);
sheet.put(set);
return sheet;

@ -64,9 +64,10 @@ public class JmeDepthOfFieldFilter extends AbstractFilterNode {
if (obj == null) {
return sheet;
}
set.put(makeProperty(obj, float.class, "getBlurScale", "setBlurScale", "Blur Scale"));
set.put(makeProperty(obj, float.class, "getFocusDistance", "setFocusDistance", "Focus Distance"));
set.put(makeProperty(obj, float.class, "getFocusRange", "setFocusRange", "Focus Range"));
// set.put(makeProperty(obj, float.class, "getBlurScale", "setBlurScale", "Blur Scale"));
// set.put(makeProperty(obj, float.class, "getFocusDistance", "setFocusDistance", "Focus Distance"));
// set.put(makeProperty(obj, float.class, "getFocusRange", "setFocusRange", "Focus Range"));
createFields(DepthOfFieldFilter.class, set, obj);
sheet.put(set);
return sheet;

@ -65,9 +65,10 @@ public class JmeFogFilter extends AbstractFilterNode {
if (obj == null) {
return sheet;
}
set.put(makeProperty(obj, float.class, "getFogDistance", "setFogDistance", "Distance"));
set.put(makeProperty(obj, float.class, "getFogDensity", "setFogDensity", "Density"));
set.put(makeProperty(obj, ColorRGBA.class, "getFogColor", "setFogColor", "Color"));
// set.put(makeProperty(obj, float.class, "getFogDistance", "setFogDistance", "Distance"));
// set.put(makeProperty(obj, float.class, "getFogDensity", "setFogDensity", "Density"));
// set.put(makeProperty(obj, ColorRGBA.class, "getFogColor", "setFogColor", "Color"));
createFields(FogFilter.class, set, obj);
sheet.put(set);
return sheet;

@ -65,11 +65,13 @@ public class JmeLightScatteringFilter extends AbstractFilterNode {
if (obj == null) {
return sheet;
}
set.put(makeProperty(obj, float.class, "getBlurStart", "setBlurStart", "Blur Start"));
set.put(makeProperty(obj, float.class, "getBlurWidth", "setBlurWidth", "Blur Width"));
set.put(makeProperty(obj, float.class, "getLightDensity", "setLightDensity", "Light Density"));
set.put(makeProperty(obj, Vector3f.class, "getLightPosition", "setLightPosition", "Light Position"));
set.put(makeProperty(obj, int.class, "getNbSamples", "setNbSamples", "Sample Number"));
// set.put(makeProperty(obj, float.class, "getBlurStart", "setBlurStart", "Blur Start"));
// set.put(makeProperty(obj, float.class, "getBlurWidth", "setBlurWidth", "Blur Width"));
// set.put(makeProperty(obj, float.class, "getLightDensity", "setLightDensity", "Light Density"));
// set.put(makeProperty(obj, Vector3f.class, "getLightPosition", "setLightPosition", "Light Position"));
// set.put(makeProperty(obj, int.class, "getNbSamples", "setNbSamples", "Sample Number"));
createFields(LightScatteringFilter.class, set, obj);
sheet.put(set);
return sheet;

@ -64,9 +64,10 @@ public class JmePosterizationFilter extends AbstractFilterNode {
if (obj == null) {
return sheet;
}
set.put(makeProperty(obj, float.class, "getGamma", "setGamma", "Gamma"));
set.put(makeProperty(obj, int.class, "getNumColors", "setNumColors", "Color Number"));
set.put(makeProperty(obj, float.class, "getStrength", "setStrength", "Strength"));
// set.put(makeProperty(obj, float.class, "getGamma", "setGamma", "Gamma"));
// set.put(makeProperty(obj, int.class, "getNumColors", "setNumColors", "Color Number"));
// set.put(makeProperty(obj, float.class, "getStrength", "setStrength", "Strength"));
createFields(PosterizationFilter.class, set, obj);
sheet.put(set);
return sheet;

@ -0,0 +1,88 @@
/*
* 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.filters.impl;
import com.jme3.gde.core.filters.AbstractFilterNode;
import com.jme3.gde.core.filters.FilterNode;
import com.jme3.post.Filter;
import com.jme3.post.ssao.SSAOFilter;
import com.jme3.water.WaterFilter;
import org.openide.loaders.DataObject;
import org.openide.nodes.Node;
import org.openide.nodes.Sheet;
/**
*
* @author Rémy Bouquet
*/
@org.openide.util.lookup.ServiceProvider(service = FilterNode.class)
public class JmeSSAOFilter extends AbstractFilterNode {
public JmeSSAOFilter() {
}
public JmeSSAOFilter(SSAOFilter filter, DataObject object, boolean readOnly) {
super(filter);
this.dataObject = object;
this.readOnly = readOnly;
}
@Override
protected Sheet createSheet() {
Sheet sheet = super.createSheet();
Sheet.Set set = Sheet.createPropertiesSet();
set.setDisplayName("Water");
set.setName("Water");
SSAOFilter obj = (SSAOFilter) filter;
if (obj == null) {
return sheet;
}
createFields(SSAOFilter.class, set, obj);
sheet.put(set);
return sheet;
}
@Override
public Class<?> getExplorerObjectClass() {
return SSAOFilter.class;
}
@Override
public Node[] createNodes(Object key, DataObject dataObject, boolean readOnly) {
return new Node[]{new JmeSSAOFilter((SSAOFilter) key, dataObject, readOnly)};
}
}

@ -66,7 +66,7 @@ public class JmeWaterFilter extends AbstractFilterNode {
if (obj == null) {
return sheet;
}
}
createFields(WaterFilter.class, set, obj);
@ -75,14 +75,6 @@ public class JmeWaterFilter extends AbstractFilterNode {
}
// private boolean hasAnnotation(Field f, Class annotation){
// for (int i = 0; i < f.getDeclaredAnnotations().length; i++) {
// if(f.getAnnotations()[i].equals(annotation)){
// return true;
// }
// }
// return false;
// }
@Override
public Class<?> getExplorerObjectClass() {
return WaterFilter.class;

@ -0,0 +1,55 @@
/*
* 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.filters.impl;
import com.jme3.gde.core.filters.actions.AbstractNewFilterAction;
import com.jme3.gde.core.filters.actions.NewFilterAction;
import com.jme3.post.Filter;
import com.jme3.post.ssao.SSAOFilter;
import com.jme3.water.WaterFilter;
/**
*
* @author Rémy Bouquet
*/
@org.openide.util.lookup.ServiceProvider(service = NewFilterAction.class)
public class NewSSAOFilterAction extends AbstractNewFilterAction {
public NewSSAOFilterAction() {
name = "SSAO";
}
@Override
protected Filter doCreateFilter() {
return new SSAOFilter();
}
}

@ -0,0 +1,74 @@
/*
* Copyright (c) 2009-2010 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.jme3.gde.core.util;
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
/**
*
* @author Nehon
*/
public class PropertyUtils {
public static PropertyDescriptor getPropertyDescriptor(Class c, Field field) {
try {
PropertyDescriptor prop = new PropertyDescriptor(field.getName(), c);
prop.setDisplayName(splitCamelCase(field.getName()));
return prop;
} catch (IntrospectionException ex) {
//System.out.println(ex.getMessage());
return null;
}
}
static String splitCamelCase(String s) {
s = capitalizeString(s);
return s.replaceAll(
String.format("%s|%s|%s",
"(?<=[A-Z])(?=[A-Z][a-z])",
"(?<=[^A-Z])(?=[A-Z])",
"(?<=[A-Za-z])(?=[^A-Za-z])"),
" ");
}
public static String capitalizeString(String string) {
char[] chars = string.toCharArray();
chars[0] = Character.toUpperCase(chars[0]);
return String.valueOf(chars);
}
}
Loading…
Cancel
Save