001    /*
002     * FillElement.java
003     *
004     *
005     *  The Salamander Project - 2D and 3D graphics libraries in Java
006     *  Copyright (C) 2004 Mark McKay
007     *
008     *  This library is free software; you can redistribute it and/or
009     *  modify it under the terms of the GNU Lesser General Public
010     *  License as published by the Free Software Foundation; either
011     *  version 2.1 of the License, or (at your option) any later version.
012     *
013     *  This library is distributed in the hope that it will be useful,
014     *  but WITHOUT ANY WARRANTY; without even the implied warranty of
015     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016     *  Lesser General Public License for more details.
017     *
018     *  You should have received a copy of the GNU Lesser General Public
019     *  License along with this library; if not, write to the Free Software
020     *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
021     *
022     *  Mark McKay can be contacted at mark@kitfox.com.  Salamander and other
023     *  projects can be found at http://www.kitfox.com
024     *
025     * Created on March 18, 2004, 6:52 AM
026     */
027    
028    package com.kitfox.svg;
029    
030    import com.kitfox.svg.xml.StyleAttribute;
031    import java.awt.*;
032    import java.awt.geom.*;
033    import java.net.*;
034    import java.util.*;
035    
036    import com.kitfox.svg.xml.*;
037    import org.xml.sax.*;
038    
039    /**
040     * @author Mark McKay
041     * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
042     */
043    public class FeSpotLight extends FeLight 
044    {
045        float x = 0f;
046        float y = 0f;
047        float z = 0f;
048        float pointsAtX = 0f;
049        float pointsAtY = 0f;
050        float pointsAtZ = 0f;
051        float specularComponent = 0f;
052        float limitingConeAngle = 0f;
053        
054    
055        /** Creates a new instance of FillElement */
056        public FeSpotLight() {
057        }
058    
059        
060        protected void build() throws SVGException
061        {
062            super.build();
063            
064            StyleAttribute sty = new StyleAttribute();
065            String strn;
066            
067            if (getPres(sty.setName("x"))) x = sty.getFloatValueWithUnits();
068            if (getPres(sty.setName("y"))) y = sty.getFloatValueWithUnits();
069            if (getPres(sty.setName("z"))) z = sty.getFloatValueWithUnits();
070            if (getPres(sty.setName("pointsAtX"))) pointsAtX = sty.getFloatValueWithUnits();
071            if (getPres(sty.setName("pointsAtY"))) pointsAtY = sty.getFloatValueWithUnits();
072            if (getPres(sty.setName("pointsAtZ"))) pointsAtZ = sty.getFloatValueWithUnits();
073            if (getPres(sty.setName("specularComponent"))) specularComponent = sty.getFloatValueWithUnits();
074            if (getPres(sty.setName("limitingConeAngle"))) limitingConeAngle = sty.getFloatValueWithUnits();
075        }
076    
077        public float getX() { return x; }
078        public float getY() { return y; }
079        public float getZ() { return z; }
080        public float getPointsAtX() { return pointsAtX; }
081        public float getPointsAtY() { return pointsAtY; }
082        public float getPointsAtZ() { return pointsAtZ; }
083        public float getSpecularComponent() { return specularComponent; }
084        public float getLimitingConeAngle() { return limitingConeAngle; }
085        
086        public boolean updateTime(double curTime) throws SVGException
087        {
088    //        if (trackManager.getNumTracks() == 0) return false;
089    
090            //Get current values for parameters
091            StyleAttribute sty = new StyleAttribute();
092            boolean stateChange = false;
093            
094            if (getPres(sty.setName("x")))
095            {
096                float newVal = sty.getFloatValueWithUnits();
097                if (newVal != x)
098                {
099                    x = newVal;
100                    stateChange = true;
101                }
102            }
103            
104            if (getPres(sty.setName("y")))
105            {
106                float newVal = sty.getFloatValueWithUnits();
107                if (newVal != y)
108                {
109                    y = newVal;
110                    stateChange = true;
111                }
112            }
113            
114            if (getPres(sty.setName("z")))
115            {
116                float newVal = sty.getFloatValueWithUnits();
117                if (newVal != z)
118                {
119                    z = newVal;
120                    stateChange = true;
121                }
122            }
123            
124            if (getPres(sty.setName("pointsAtX")))
125            {
126                float newVal = sty.getFloatValueWithUnits();
127                if (newVal != pointsAtX)
128                {
129                    pointsAtX = newVal;
130                    stateChange = true;
131                }
132            }
133            
134            if (getPres(sty.setName("pointsAtY")))
135            {
136                float newVal = sty.getFloatValueWithUnits();
137                if (newVal != pointsAtY)
138                {
139                    pointsAtY = newVal;
140                    stateChange = true;
141                }
142            }
143            
144            if (getPres(sty.setName("pointsAtZ")))
145            {
146                float newVal = sty.getFloatValueWithUnits();
147                if (newVal != pointsAtZ)
148                {
149                    pointsAtZ = newVal;
150                    stateChange = true;
151                }
152            }
153            
154            if (getPres(sty.setName("specularComponent")))
155            {
156                float newVal = sty.getFloatValueWithUnits();
157                if (newVal != specularComponent)
158                {
159                    specularComponent = newVal;
160                    stateChange = true;
161                }
162            }
163            
164            if (getPres(sty.setName("limitingConeAngle")))
165            {
166                float newVal = sty.getFloatValueWithUnits();
167                if (newVal != limitingConeAngle)
168                {
169                    limitingConeAngle = newVal;
170                    stateChange = true;
171                }
172            }
173            
174            return stateChange;
175        }
176    }
177