- Changed properties layout - Added a button in the properties panel to emitt all particles - The mesh type can now be changed in the properties panel git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7948 75d07b2b-3a1a-0410-a2c5-0572b91ccdca3.0
parent
f5dceb6c4d
commit
3a6e089954
@ -0,0 +1,79 @@ |
||||
package com.jme3.gde.core.sceneexplorer.nodes; |
||||
|
||||
import com.jme3.effect.ParticleEmitter; |
||||
import com.jme3.gde.core.scene.SceneApplication; |
||||
import com.jme3.gde.core.util.ButtonInplaceEditor; |
||||
import java.awt.Color; |
||||
import java.awt.Font; |
||||
import java.awt.Graphics; |
||||
import java.awt.Rectangle; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.beans.PropertyEditorSupport; |
||||
import java.util.concurrent.Callable; |
||||
import org.openide.explorer.propertysheet.ExPropertyEditor; |
||||
import org.openide.explorer.propertysheet.InplaceEditor; |
||||
import org.openide.explorer.propertysheet.PropertyEnv; |
||||
|
||||
/** |
||||
* |
||||
* @author Nehon |
||||
*/ |
||||
public class JmeParticleEmitterButtonProperty extends PropertyEditorSupport implements ExPropertyEditor, InplaceEditor.Factory { |
||||
|
||||
JmeParticleEmitter pe; |
||||
|
||||
public JmeParticleEmitterButtonProperty(JmeParticleEmitter pe) { |
||||
super(); |
||||
|
||||
this.pe = pe; |
||||
} |
||||
PropertyEnv env; |
||||
|
||||
public void attachEnv(PropertyEnv env) { |
||||
this.env = env; |
||||
env.registerInplaceEditorFactory(this); |
||||
} |
||||
private ButtonInplaceEditor ed = null; |
||||
|
||||
public InplaceEditor getInplaceEditor() { |
||||
if (ed == null) { |
||||
ed = new ButtonInplaceEditor("Emitt!"); |
||||
ed.addActionListener(new ActionListener() { |
||||
|
||||
public void actionPerformed(ActionEvent e) { |
||||
|
||||
SceneApplication.getApplication().enqueue(new Callable<Object>() { |
||||
|
||||
public Object call() throws Exception { |
||||
|
||||
pe.getEmitter().killAllParticles(); |
||||
pe.getEmitter().emitAllParticles(); |
||||
return null; |
||||
} |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
return ed; |
||||
} |
||||
|
||||
@Override |
||||
public boolean isPaintable() { |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void paintValue(Graphics gfx, Rectangle box) { |
||||
if (ed == null) { |
||||
getInplaceEditor(); |
||||
} |
||||
ed.setSize(box.width, box.height); |
||||
ed.doLayout(); |
||||
Graphics g = gfx.create(box.x, box.y, box.width, box.height); |
||||
ed.setOpaque(false); |
||||
ed.paint(g); |
||||
g.dispose(); |
||||
pe.refresh(false); |
||||
} |
||||
} |
@ -0,0 +1,103 @@ |
||||
package com.jme3.gde.core.util; |
||||
|
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.beans.PropertyEditor; |
||||
import javax.swing.DefaultButtonModel; |
||||
import javax.swing.Icon; |
||||
import javax.swing.JButton; |
||||
import javax.swing.JComponent; |
||||
import javax.swing.KeyStroke; |
||||
import org.openide.explorer.propertysheet.InplaceEditor; |
||||
import org.openide.explorer.propertysheet.PropertyEnv; |
||||
import org.openide.explorer.propertysheet.PropertyModel; |
||||
|
||||
/** |
||||
* |
||||
* @author Nehon |
||||
*/ |
||||
public class ButtonInplaceEditor extends JButton implements InplaceEditor { |
||||
|
||||
private PropertyEditor editor = null; |
||||
private PropertyModel model; |
||||
private PropertyEnv env; |
||||
|
||||
public ButtonInplaceEditor() { |
||||
this("Click"); |
||||
setActionCommand(COMMAND_SUCCESS); |
||||
setForeground(Color.BLACK); |
||||
} |
||||
|
||||
public ButtonInplaceEditor(String text) { |
||||
super(text); |
||||
setActionCommand(COMMAND_SUCCESS); |
||||
setForeground(Color.BLACK); |
||||
} |
||||
|
||||
public ButtonInplaceEditor(Icon icon) { |
||||
super(icon); |
||||
setActionCommand(COMMAND_SUCCESS); |
||||
setForeground(Color.BLACK); |
||||
|
||||
} |
||||
|
||||
public ButtonInplaceEditor(String text, Icon icon) { |
||||
super(text, icon); |
||||
setActionCommand(COMMAND_SUCCESS); |
||||
setForeground(Color.BLACK); |
||||
} |
||||
|
||||
public void connect(PropertyEditor pe, PropertyEnv pe1) { |
||||
editor = pe; |
||||
env = pe1; |
||||
reset(); |
||||
} |
||||
|
||||
public JComponent getComponent() { |
||||
return this; |
||||
} |
||||
|
||||
public void clear() { |
||||
editor = null; |
||||
model = null; |
||||
} |
||||
|
||||
public Object getValue() { |
||||
repaint(); |
||||
updateUI(); |
||||
return ""; |
||||
} |
||||
|
||||
public void setValue(Object o) { |
||||
repaint(); |
||||
updateUI(); |
||||
} |
||||
|
||||
public boolean supportsTextEntry() { |
||||
return false; |
||||
} |
||||
|
||||
public void reset() { |
||||
} |
||||
|
||||
public KeyStroke[] getKeyStrokes() { |
||||
return new KeyStroke[0]; |
||||
} |
||||
|
||||
public PropertyEditor getPropertyEditor() { |
||||
return editor; |
||||
} |
||||
|
||||
public PropertyModel getPropertyModel() { |
||||
return model; |
||||
} |
||||
|
||||
public void setPropertyModel(PropertyModel pm) { |
||||
|
||||
this.model = pm; |
||||
} |
||||
|
||||
public boolean isKnownComponent(Component cmpnt) { |
||||
return false; |
||||
} |
||||
} |
Loading…
Reference in new issue