1 | /*
|
---|
2 | * SVG Salamander
|
---|
3 | * Copyright (c) 2004, Mark McKay
|
---|
4 | * All rights reserved.
|
---|
5 | *
|
---|
6 | * Redistribution and use in source and binary forms, with or
|
---|
7 | * without modification, are permitted provided that the following
|
---|
8 | * conditions are met:
|
---|
9 | *
|
---|
10 | * - Redistributions of source code must retain the above
|
---|
11 | * copyright notice, this list of conditions and the following
|
---|
12 | * disclaimer.
|
---|
13 | * - Redistributions in binary form must reproduce the above
|
---|
14 | * copyright notice, this list of conditions and the following
|
---|
15 | * disclaimer in the documentation and/or other materials
|
---|
16 | * provided with the distribution.
|
---|
17 | *
|
---|
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
---|
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
---|
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
---|
21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
---|
22 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
---|
23 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
---|
24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
---|
25 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
---|
27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
---|
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
---|
29 | * OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
30 | *
|
---|
31 | * Mark McKay can be contacted at mark@kitfox.com. Salamander and other
|
---|
32 | * projects can be found at http://www.kitfox.com
|
---|
33 | *
|
---|
34 | * Created on March 18, 2004, 6:52 AM
|
---|
35 | */
|
---|
36 | package com.kitfox.svg;
|
---|
37 |
|
---|
38 | import com.kitfox.svg.xml.StyleAttribute;
|
---|
39 |
|
---|
40 | /**
|
---|
41 | * @author Mark McKay
|
---|
42 | * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
|
---|
43 | */
|
---|
44 | public class FeSpotLight extends FeLight
|
---|
45 | {
|
---|
46 |
|
---|
47 | public static final String TAG_NAME = "fespotlight";
|
---|
48 | float x = 0f;
|
---|
49 | float y = 0f;
|
---|
50 | float z = 0f;
|
---|
51 | float pointsAtX = 0f;
|
---|
52 | float pointsAtY = 0f;
|
---|
53 | float pointsAtZ = 0f;
|
---|
54 | float specularComponent = 0f;
|
---|
55 | float limitingConeAngle = 0f;
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * Creates a new instance of FillElement
|
---|
59 | */
|
---|
60 | public FeSpotLight()
|
---|
61 | {
|
---|
62 | }
|
---|
63 |
|
---|
64 | public String getTagName()
|
---|
65 | {
|
---|
66 | return TAG_NAME;
|
---|
67 | }
|
---|
68 |
|
---|
69 | protected void build() throws SVGException
|
---|
70 | {
|
---|
71 | super.build();
|
---|
72 |
|
---|
73 | StyleAttribute sty = new StyleAttribute();
|
---|
74 | String strn;
|
---|
75 |
|
---|
76 | if (getPres(sty.setName("x")))
|
---|
77 | {
|
---|
78 | x = sty.getFloatValueWithUnits();
|
---|
79 | }
|
---|
80 | if (getPres(sty.setName("y")))
|
---|
81 | {
|
---|
82 | y = sty.getFloatValueWithUnits();
|
---|
83 | }
|
---|
84 | if (getPres(sty.setName("z")))
|
---|
85 | {
|
---|
86 | z = sty.getFloatValueWithUnits();
|
---|
87 | }
|
---|
88 | if (getPres(sty.setName("pointsAtX")))
|
---|
89 | {
|
---|
90 | pointsAtX = sty.getFloatValueWithUnits();
|
---|
91 | }
|
---|
92 | if (getPres(sty.setName("pointsAtY")))
|
---|
93 | {
|
---|
94 | pointsAtY = sty.getFloatValueWithUnits();
|
---|
95 | }
|
---|
96 | if (getPres(sty.setName("pointsAtZ")))
|
---|
97 | {
|
---|
98 | pointsAtZ = sty.getFloatValueWithUnits();
|
---|
99 | }
|
---|
100 | if (getPres(sty.setName("specularComponent")))
|
---|
101 | {
|
---|
102 | specularComponent = sty.getFloatValueWithUnits();
|
---|
103 | }
|
---|
104 | if (getPres(sty.setName("limitingConeAngle")))
|
---|
105 | {
|
---|
106 | limitingConeAngle = sty.getFloatValueWithUnits();
|
---|
107 | }
|
---|
108 | }
|
---|
109 |
|
---|
110 | public float getX()
|
---|
111 | {
|
---|
112 | return x;
|
---|
113 | }
|
---|
114 |
|
---|
115 | public float getY()
|
---|
116 | {
|
---|
117 | return y;
|
---|
118 | }
|
---|
119 |
|
---|
120 | public float getZ()
|
---|
121 | {
|
---|
122 | return z;
|
---|
123 | }
|
---|
124 |
|
---|
125 | public float getPointsAtX()
|
---|
126 | {
|
---|
127 | return pointsAtX;
|
---|
128 | }
|
---|
129 |
|
---|
130 | public float getPointsAtY()
|
---|
131 | {
|
---|
132 | return pointsAtY;
|
---|
133 | }
|
---|
134 |
|
---|
135 | public float getPointsAtZ()
|
---|
136 | {
|
---|
137 | return pointsAtZ;
|
---|
138 | }
|
---|
139 |
|
---|
140 | public float getSpecularComponent()
|
---|
141 | {
|
---|
142 | return specularComponent;
|
---|
143 | }
|
---|
144 |
|
---|
145 | public float getLimitingConeAngle()
|
---|
146 | {
|
---|
147 | return limitingConeAngle;
|
---|
148 | }
|
---|
149 |
|
---|
150 | public boolean updateTime(double curTime) throws SVGException
|
---|
151 | {
|
---|
152 | // if (trackManager.getNumTracks() == 0) return false;
|
---|
153 |
|
---|
154 | //Get current values for parameters
|
---|
155 | StyleAttribute sty = new StyleAttribute();
|
---|
156 | boolean stateChange = false;
|
---|
157 |
|
---|
158 | if (getPres(sty.setName("x")))
|
---|
159 | {
|
---|
160 | float newVal = sty.getFloatValueWithUnits();
|
---|
161 | if (newVal != x)
|
---|
162 | {
|
---|
163 | x = newVal;
|
---|
164 | stateChange = true;
|
---|
165 | }
|
---|
166 | }
|
---|
167 |
|
---|
168 | if (getPres(sty.setName("y")))
|
---|
169 | {
|
---|
170 | float newVal = sty.getFloatValueWithUnits();
|
---|
171 | if (newVal != y)
|
---|
172 | {
|
---|
173 | y = newVal;
|
---|
174 | stateChange = true;
|
---|
175 | }
|
---|
176 | }
|
---|
177 |
|
---|
178 | if (getPres(sty.setName("z")))
|
---|
179 | {
|
---|
180 | float newVal = sty.getFloatValueWithUnits();
|
---|
181 | if (newVal != z)
|
---|
182 | {
|
---|
183 | z = newVal;
|
---|
184 | stateChange = true;
|
---|
185 | }
|
---|
186 | }
|
---|
187 |
|
---|
188 | if (getPres(sty.setName("pointsAtX")))
|
---|
189 | {
|
---|
190 | float newVal = sty.getFloatValueWithUnits();
|
---|
191 | if (newVal != pointsAtX)
|
---|
192 | {
|
---|
193 | pointsAtX = newVal;
|
---|
194 | stateChange = true;
|
---|
195 | }
|
---|
196 | }
|
---|
197 |
|
---|
198 | if (getPres(sty.setName("pointsAtY")))
|
---|
199 | {
|
---|
200 | float newVal = sty.getFloatValueWithUnits();
|
---|
201 | if (newVal != pointsAtY)
|
---|
202 | {
|
---|
203 | pointsAtY = newVal;
|
---|
204 | stateChange = true;
|
---|
205 | }
|
---|
206 | }
|
---|
207 |
|
---|
208 | if (getPres(sty.setName("pointsAtZ")))
|
---|
209 | {
|
---|
210 | float newVal = sty.getFloatValueWithUnits();
|
---|
211 | if (newVal != pointsAtZ)
|
---|
212 | {
|
---|
213 | pointsAtZ = newVal;
|
---|
214 | stateChange = true;
|
---|
215 | }
|
---|
216 | }
|
---|
217 |
|
---|
218 | if (getPres(sty.setName("specularComponent")))
|
---|
219 | {
|
---|
220 | float newVal = sty.getFloatValueWithUnits();
|
---|
221 | if (newVal != specularComponent)
|
---|
222 | {
|
---|
223 | specularComponent = newVal;
|
---|
224 | stateChange = true;
|
---|
225 | }
|
---|
226 | }
|
---|
227 |
|
---|
228 | if (getPres(sty.setName("limitingConeAngle")))
|
---|
229 | {
|
---|
230 | float newVal = sty.getFloatValueWithUnits();
|
---|
231 | if (newVal != limitingConeAngle)
|
---|
232 | {
|
---|
233 | limitingConeAngle = newVal;
|
---|
234 | stateChange = true;
|
---|
235 | }
|
---|
236 | }
|
---|
237 |
|
---|
238 | return stateChange;
|
---|
239 | }
|
---|
240 | }
|
---|