/* ========================
* JSynoptic : a free Synoptic editor
* ========================
*
* Project Info: http://jsynoptic.sourceforge.net/index.html
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* (C) Copyright 2001-2007, by :
* Corporate:
* EADS Astrium
* Individual:
* Claude Cazenave
*
* $Id: LightEdit.java,v 1.1 2008/03/11 06:51:07 cazenave Exp $
*
* Changes
* -------
* 22 janv. 08 : Initial public release
*
*/
package jsynoptic.plugins.java3d.edit;
import javax.media.j3d.Light;
import javax.vecmath.Color3f;
/**
*
*/
public class LightEdit extends SceneGraphObjectEdit<Light> {
public static final String LightState = "LighOn";
public static final String LightColor = "LighColor";
/**
* @param object
*/
public LightEdit(Light object) {
super(object);
}
@Override
protected void buildProperties() {
super.buildProperties();
_properties.add(new LightColorEdit(
_object));
_properties.add(new LightStateEdit(_object));
}
public String getPresentationName(){
// TODO i18n
return "Light";
}
public static class LightStateEdit extends PropertyEdit<Light, Boolean>{
public LightStateEdit(Light object) {
super(object, LightState);
}
@Override
public Boolean getPropertyValue() {
return _object.getEnable();
}
@Override
public void setPropertyValue(Boolean value) {
boolean forced=forceCapability(Light.ALLOW_STATE_WRITE);
_object.setEnable(value);
if(forced) restoreCapability(Light.ALLOW_STATE_WRITE);
}
@Override
public String getDisplayClassName() {
return "jsynoptic.plugins.java3d.panels.CheckBox";
}
}
public class LightColorEdit extends PropertyEdit<Light, Color3f>{
public LightColorEdit(Light object) {
super(object, LightColor);
}
@Override
public Color3f getPropertyValue() {
Color3f res=new Color3f();
_object.getColor(res);
return res;
}
@Override
public void setPropertyValue(Color3f res) {
boolean forced=forceCapability(Light.ALLOW_COLOR_WRITE);
_object.setColor(res);
if(forced) restoreCapability(Light.ALLOW_COLOR_WRITE);
}
@Override
public String getDisplayClassName() {
return "jsynoptic.plugins.java3d.panels.ColorButton";
}
}
}