001/* 002 * SVG Salamander 003 * Copyright (c) 2004, Mark McKay 004 * All rights reserved. 005 * 006 * Redistribution and use in source and binary forms, with or 007 * without modification, are permitted provided that the following 008 * conditions are met: 009 * 010 * - Redistributions of source code must retain the above 011 * copyright notice, this list of conditions and the following 012 * disclaimer. 013 * - Redistributions in binary form must reproduce the above 014 * copyright notice, this list of conditions and the following 015 * disclaimer in the documentation and/or other materials 016 * provided with the distribution. 017 * 018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 019 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 020 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 021 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 022 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 023 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 025 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 026 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 027 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 028 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 029 * OF THE POSSIBILITY OF SUCH DAMAGE. 030 * 031 * Mark McKay can be contacted at mark@kitfox.com. Salamander and other 032 * projects can be found at http://www.kitfox.com 033 * 034 * Created on March 18, 2004, 6:52 AM 035 */ 036package com.kitfox.svg; 037 038import com.kitfox.svg.xml.StyleAttribute; 039 040/** 041 * @author Mark McKay 042 * @author <a href="mailto:mark@kitfox.com">Mark McKay</a> 043 */ 044public class FeSpotLight extends FeLight 045{ 046 047 public static final String TAG_NAME = "fespotlight"; 048 float x = 0f; 049 float y = 0f; 050 float z = 0f; 051 float pointsAtX = 0f; 052 float pointsAtY = 0f; 053 float pointsAtZ = 0f; 054 float specularComponent = 0f; 055 float limitingConeAngle = 0f; 056 057 /** 058 * Creates a new instance of FillElement 059 */ 060 public FeSpotLight() 061 { 062 } 063 064 public String getTagName() 065 { 066 return TAG_NAME; 067 } 068 069 protected void build() throws SVGException 070 { 071 super.build(); 072 073 StyleAttribute sty = new StyleAttribute(); 074 String strn; 075 076 if (getPres(sty.setName("x"))) 077 { 078 x = sty.getFloatValueWithUnits(); 079 } 080 if (getPres(sty.setName("y"))) 081 { 082 y = sty.getFloatValueWithUnits(); 083 } 084 if (getPres(sty.setName("z"))) 085 { 086 z = sty.getFloatValueWithUnits(); 087 } 088 if (getPres(sty.setName("pointsAtX"))) 089 { 090 pointsAtX = sty.getFloatValueWithUnits(); 091 } 092 if (getPres(sty.setName("pointsAtY"))) 093 { 094 pointsAtY = sty.getFloatValueWithUnits(); 095 } 096 if (getPres(sty.setName("pointsAtZ"))) 097 { 098 pointsAtZ = sty.getFloatValueWithUnits(); 099 } 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}