[4256] | 1 | /*
|
---|
[6002] | 2 | * SVG Salamander
|
---|
| 3 | * Copyright (c) 2004, Mark McKay
|
---|
| 4 | * All rights reserved.
|
---|
[4256] | 5 | *
|
---|
[6002] | 6 | * Redistribution and use in source and binary forms, with or
|
---|
| 7 | * without modification, are permitted provided that the following
|
---|
| 8 | * conditions are met:
|
---|
[4256] | 9 | *
|
---|
[6002] | 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.
|
---|
[4256] | 17 | *
|
---|
[6002] | 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
|
---|
[4256] | 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 | */
|
---|
[6002] | 44 | public class FeSpotLight extends FeLight
|
---|
[4256] | 45 | {
|
---|
[6002] | 46 |
|
---|
| 47 | public static final String TAG_NAME = "fespotlight";
|
---|
[4256] | 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 |
|
---|
[6002] | 57 | /**
|
---|
| 58 | * Creates a new instance of FillElement
|
---|
| 59 | */
|
---|
| 60 | public FeSpotLight()
|
---|
| 61 | {
|
---|
[4256] | 62 | }
|
---|
| 63 |
|
---|
[6002] | 64 | public String getTagName()
|
---|
| 65 | {
|
---|
| 66 | return TAG_NAME;
|
---|
| 67 | }
|
---|
| 68 |
|
---|
[4256] | 69 | protected void build() throws SVGException
|
---|
| 70 | {
|
---|
| 71 | super.build();
|
---|
[6002] | 72 |
|
---|
[4256] | 73 | StyleAttribute sty = new StyleAttribute();
|
---|
| 74 | String strn;
|
---|
[6002] | 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 | }
|
---|
[4256] | 108 | }
|
---|
| 109 |
|
---|
[6002] | 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 |
|
---|
[4256] | 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;
|
---|
[6002] | 157 |
|
---|
[4256] | 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 | }
|
---|
[6002] | 167 |
|
---|
[4256] | 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 | }
|
---|
[6002] | 177 |
|
---|
[4256] | 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 | }
|
---|
[6002] | 187 |
|
---|
[4256] | 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 | }
|
---|
[6002] | 197 |
|
---|
[4256] | 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 | }
|
---|
[6002] | 207 |
|
---|
[4256] | 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 | }
|
---|
[6002] | 217 |
|
---|
[4256] | 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 | }
|
---|
[6002] | 227 |
|
---|
[4256] | 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 | }
|
---|
[6002] | 237 |
|
---|
[4256] | 238 | return stateChange;
|
---|
| 239 | }
|
---|
| 240 | }
|
---|