Package jsynoptic.plugins.java3d.edit

Source Code of jsynoptic.plugins.java3d.edit.SpotLightEdit$LightDirEdit

/* ========================
* 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: SpotLightEdit.java,v 1.1 2008/03/11 06:51:07 cazenave Exp $
*
* Changes
* -------
* 10 mars 08  : Initial public release
*
*/
package jsynoptic.plugins.java3d.edit;

import javax.media.j3d.Light;
import javax.media.j3d.SpotLight;
import javax.vecmath.Vector3f;

/**
*
*/
public class SpotLightEdit extends PointLightEdit {

    public static final String SpreadAngle = "SpreadAngle";
   
    /**
     * @param object
     */
    public SpotLightEdit(SpotLight object) {
        super(object);
    }
   
    @Override
    protected void buildProperties() {
        super.buildProperties();
        _properties.add(new LightDirEdit(_object));
        _properties.add(new SpreadAngleEdit(_object));
    }

    public static class LightDirEdit extends DirectionalLightEdit.LightDirEdit{

        public LightDirEdit(Light object) {
            super(object);
        }

        @Override
        public Vector3f getPropertyValue() {
            Vector3f res=new Vector3f();
            ((SpotLight)_object).getDirection(res);
            return res;
        }

        @Override
        public void setPropertyValue(Vector3f value) {
            boolean forced=forceCapability(SpotLight.ALLOW_DIRECTION_WRITE);
            ((SpotLight)_object).setDirection(value);
            if(forced) restoreCapability(SpotLight.ALLOW_DIRECTION_WRITE);
        }
    }

    public static class SpreadAngleEdit extends PropertyEdit<Light, Float>{

        public SpreadAngleEdit(Light object) {
            super(object, SpreadAngle);
        }

        @Override
        public Float getPropertyValue() {
            return ((SpotLight)_object).getSpreadAngle();
        }

        @Override
        public void setPropertyValue(Float value) {
            boolean forced=forceCapability(SpotLight.ALLOW_SPREAD_ANGLE_WRITE);
            ((SpotLight)_object).setSpreadAngle(value);
            if(forced) restoreCapability(SpotLight.ALLOW_SPREAD_ANGLE_WRITE);
        }

        @Override
        public String getDisplayClassName() {
            return "jsynoptic.plugins.java3d.panels.TextField$FloatValue";
        }
       
    }

}
TOP

Related Classes of jsynoptic.plugins.java3d.edit.SpotLightEdit$LightDirEdit

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.