Package jsynoptic.plugins.java3d.edit

Source Code of jsynoptic.plugins.java3d.edit.SwitchEdit

/* ========================
* 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-2008, by :
*     Corporate:
*         EADS Astrium
*     Individual:
*         Claude Cazenave
*
* $Id: SwitchEdit.java,v 1.2 2008/11/05 18:14:52 cazenave Exp $
*
* Changes
* -------
* 23 oct. 2008  : Initial public release
*
*/
package jsynoptic.plugins.java3d.edit;

import java.util.BitSet;

import javax.media.j3d.Switch;

import jsynoptic.plugins.java3d.SwitchAnimator;
import jsynoptic.plugins.java3d.AnimatorFactory.Parameters;

/**
*
*/
public class SwitchEdit extends SceneGraphObjectEdit<Switch> {

    public static final String Selection = "Selection";
    public static final String Mask = "Mask";

    /**
     * @param object
     */
    public SwitchEdit(Switch object) {
        super(object);
    }

    @Override
    protected void buildProperties() {
        super.buildProperties();
        _properties.add(new SelectionEdit(_object));
        _properties.add(new MaskEdit(_object));
    }
   
    @Override
    public String getPresentationName() {
        // TODO i18n
        return "Switch";
    }
   
    public static class SelectionEdit extends PropertyEdit<Switch, Integer> {
        public SelectionEdit(Switch object) {
            super(object, Selection);
        }

        @Override
        public Integer getPropertyValue() {
            return new Integer(_object.getWhichChild());
        }

        @Override
        public void setPropertyValue(Integer res) {
            boolean forced=forceCapability(Switch.ALLOW_SWITCH_WRITE);
            _object.setWhichChild(res.intValue());
            if(forced) restoreCapability(Switch.ALLOW_SWITCH_WRITE);
        }

        @Override
        public String getDisplayClassName() {
            return "jsynoptic.plugins.java3d.panels.TextField$IntegerValue";
        }        
        @Override
        public Parameters getAnimatorParameters() {
            return new Parameters(SwitchAnimator.class, SwitchAnimator.SwitchData.class, SwitchAnimator.SELECTION);
        }
    }
   
    public static class MaskEdit extends PropertyEdit<Switch, Integer> {
        public MaskEdit(Switch object) {
            super(object, Mask);
        }

        @Override
        public Integer getPropertyValue() {
            return new Integer(SwitchAnimator.bitSetToInt(_object.getChildMask()));
        }

        @Override
        public void setPropertyValue(Integer res) {
            boolean forced=forceCapability(Switch.ALLOW_SWITCH_WRITE);
            BitSet b=new BitSet();
            SwitchAnimator.intToBitSet(res.intValue(),b);
            _object.setChildMask(b);
            if(forced) restoreCapability(Switch.ALLOW_SWITCH_WRITE);
        }

        @Override
        public String getDisplayClassName() {
            return "jsynoptic.plugins.java3d.panels.TextField$IntegerValue";
        }
       
        @Override
        public Parameters getAnimatorParameters() {
            return new Parameters(SwitchAnimator.class, SwitchAnimator.SwitchData.class, SwitchAnimator.MASK);
        }
    }
}
TOP

Related Classes of jsynoptic.plugins.java3d.edit.SwitchEdit

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.