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 FePointLight extends FeLight 
044    {
045        float x = 0f;
046        float y = 0f;
047        float z = 0f;
048        
049    
050        /** Creates a new instance of FillElement */
051        public FePointLight() {
052        }
053    
054        
055        protected void build() throws SVGException
056        {
057            super.build();
058            
059            StyleAttribute sty = new StyleAttribute();
060            String strn;
061            
062            if (getPres(sty.setName("x"))) x = sty.getFloatValueWithUnits();
063            
064            if (getPres(sty.setName("y"))) y = sty.getFloatValueWithUnits();
065            
066            if (getPres(sty.setName("z"))) z = sty.getFloatValueWithUnits();
067        }
068    
069        public float getX() { return x; }
070        public float getY() { return y; }
071        public float getZ() { return z; }
072        
073        public boolean updateTime(double curTime) throws SVGException
074        {
075    //        if (trackManager.getNumTracks() == 0) return false;
076    
077            //Get current values for parameters
078            StyleAttribute sty = new StyleAttribute();
079            boolean stateChange = false;
080            
081            if (getPres(sty.setName("x")))
082            {
083                float newVal = sty.getFloatValueWithUnits();
084                if (newVal != x)
085                {
086                    x = newVal;
087                    stateChange = true;
088                }
089            }
090            
091            if (getPres(sty.setName("y")))
092            {
093                float newVal = sty.getFloatValueWithUnits();
094                if (newVal != y)
095                {
096                    y = newVal;
097                    stateChange = true;
098                }
099            }
100            
101            if (getPres(sty.setName("z")))
102            {
103                float newVal = sty.getFloatValueWithUnits();
104                if (newVal != z)
105                {
106                    z = newVal;
107                    stateChange = true;
108                }
109            }
110            
111            return stateChange;
112        }
113    }
114