| 1 | /*
|
|---|
| 2 | * FillElement.java
|
|---|
| 3 | *
|
|---|
| 4 | *
|
|---|
| 5 | * The Salamander Project - 2D and 3D graphics libraries in Java
|
|---|
| 6 | * Copyright (C) 2004 Mark McKay
|
|---|
| 7 | *
|
|---|
| 8 | * This library is free software; you can redistribute it and/or
|
|---|
| 9 | * modify it under the terms of the GNU Lesser General Public
|
|---|
| 10 | * License as published by the Free Software Foundation; either
|
|---|
| 11 | * version 2.1 of the License, or (at your option) any later version.
|
|---|
| 12 | *
|
|---|
| 13 | * This library is distributed in the hope that it will be useful,
|
|---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 16 | * Lesser General Public License for more details.
|
|---|
| 17 | *
|
|---|
| 18 | * You should have received a copy of the GNU Lesser General Public
|
|---|
| 19 | * License along with this library; if not, write to the Free Software
|
|---|
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 21 | *
|
|---|
| 22 | * Mark McKay can be contacted at mark@kitfox.com. Salamander and other
|
|---|
| 23 | * projects can be found at http://www.kitfox.com
|
|---|
| 24 | *
|
|---|
| 25 | * Created on March 18, 2004, 6:52 AM
|
|---|
| 26 | */
|
|---|
| 27 |
|
|---|
| 28 | package com.kitfox.svg;
|
|---|
| 29 |
|
|---|
| 30 | import com.kitfox.svg.xml.StyleAttribute;
|
|---|
| 31 | import java.awt.*;
|
|---|
| 32 | import java.awt.geom.*;
|
|---|
| 33 | import java.net.*;
|
|---|
| 34 | import java.util.*;
|
|---|
| 35 |
|
|---|
| 36 | import com.kitfox.svg.xml.*;
|
|---|
| 37 | import org.xml.sax.*;
|
|---|
| 38 |
|
|---|
| 39 | /**
|
|---|
| 40 | * @author Mark McKay
|
|---|
| 41 | * @author <a href="mailto:mark@kitfox.com">Mark McKay</a>
|
|---|
| 42 | */
|
|---|
| 43 | public class FeSpotLight extends FeLight
|
|---|
| 44 | {
|
|---|
| 45 | float x = 0f;
|
|---|
| 46 | float y = 0f;
|
|---|
| 47 | float z = 0f;
|
|---|
| 48 | float pointsAtX = 0f;
|
|---|
| 49 | float pointsAtY = 0f;
|
|---|
| 50 | float pointsAtZ = 0f;
|
|---|
| 51 | float specularComponent = 0f;
|
|---|
| 52 | float limitingConeAngle = 0f;
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 | /** Creates a new instance of FillElement */
|
|---|
| 56 | public FeSpotLight() {
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 | protected void build() throws SVGException
|
|---|
| 61 | {
|
|---|
| 62 | super.build();
|
|---|
| 63 |
|
|---|
| 64 | StyleAttribute sty = new StyleAttribute();
|
|---|
| 65 | String strn;
|
|---|
| 66 |
|
|---|
| 67 | if (getPres(sty.setName("x"))) x = sty.getFloatValueWithUnits();
|
|---|
| 68 | if (getPres(sty.setName("y"))) y = sty.getFloatValueWithUnits();
|
|---|
| 69 | if (getPres(sty.setName("z"))) z = sty.getFloatValueWithUnits();
|
|---|
| 70 | if (getPres(sty.setName("pointsAtX"))) pointsAtX = sty.getFloatValueWithUnits();
|
|---|
| 71 | if (getPres(sty.setName("pointsAtY"))) pointsAtY = sty.getFloatValueWithUnits();
|
|---|
| 72 | if (getPres(sty.setName("pointsAtZ"))) pointsAtZ = sty.getFloatValueWithUnits();
|
|---|
| 73 | if (getPres(sty.setName("specularComponent"))) specularComponent = sty.getFloatValueWithUnits();
|
|---|
| 74 | if (getPres(sty.setName("limitingConeAngle"))) limitingConeAngle = sty.getFloatValueWithUnits();
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | public float getX() { return x; }
|
|---|
| 78 | public float getY() { return y; }
|
|---|
| 79 | public float getZ() { return z; }
|
|---|
| 80 | public float getPointsAtX() { return pointsAtX; }
|
|---|
| 81 | public float getPointsAtY() { return pointsAtY; }
|
|---|
| 82 | public float getPointsAtZ() { return pointsAtZ; }
|
|---|
| 83 | public float getSpecularComponent() { return specularComponent; }
|
|---|
| 84 | public float getLimitingConeAngle() { return limitingConeAngle; }
|
|---|
| 85 |
|
|---|
| 86 | public boolean updateTime(double curTime) throws SVGException
|
|---|
| 87 | {
|
|---|
| 88 | // if (trackManager.getNumTracks() == 0) return false;
|
|---|
| 89 |
|
|---|
| 90 | //Get current values for parameters
|
|---|
| 91 | StyleAttribute sty = new StyleAttribute();
|
|---|
| 92 | boolean stateChange = false;
|
|---|
| 93 |
|
|---|
| 94 | if (getPres(sty.setName("x")))
|
|---|
| 95 | {
|
|---|
| 96 | float newVal = sty.getFloatValueWithUnits();
|
|---|
| 97 | if (newVal != x)
|
|---|
| 98 | {
|
|---|
| 99 | 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 |
|
|---|