001: /*
002:
003: Licensed to the Apache Software Foundation (ASF) under one or more
004: contributor license agreements. See the NOTICE file distributed with
005: this work for additional information regarding copyright ownership.
006: The ASF licenses this file to You under the Apache License, Version 2.0
007: (the "License"); you may not use this file except in compliance with
008: the License. You may obtain a copy of the License at
009:
010: http://www.apache.org/licenses/LICENSE-2.0
011:
012: Unless required by applicable law or agreed to in writing, software
013: distributed under the License is distributed on an "AS IS" BASIS,
014: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: See the License for the specific language governing permissions and
016: limitations under the License.
017:
018: */
019: package org.apache.batik.anim.values;
020:
021: import org.apache.batik.dom.anim.AnimationTarget;
022:
023: /**
024: * A boolean value in the animation system.
025: *
026: * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
027: * @version $Id: AnimatableBooleanValue.java 475477 2006-11-15 22:44:28Z cam $
028: */
029: public class AnimatableBooleanValue extends AnimatableValue {
030:
031: /**
032: * The boolean value.
033: */
034: protected boolean value;
035:
036: /**
037: * Creates a new, uninitialized AnimatableBooleanValue.
038: */
039: protected AnimatableBooleanValue(AnimationTarget target) {
040: super (target);
041: }
042:
043: /**
044: * Creates a new AnimatableBooleanValue.
045: */
046: public AnimatableBooleanValue(AnimationTarget target, boolean b) {
047: super (target);
048: value = b;
049: }
050:
051: /**
052: * Performs interpolation to the given value. Boolean values cannot be
053: * interpolated.
054: */
055: public AnimatableValue interpolate(AnimatableValue result,
056: AnimatableValue to, float interpolation,
057: AnimatableValue accumulation, int multiplier) {
058: AnimatableBooleanValue res;
059: if (result == null) {
060: res = new AnimatableBooleanValue(target);
061: } else {
062: res = (AnimatableBooleanValue) result;
063: }
064:
065: boolean newValue;
066: if (to != null && interpolation >= 0.5) {
067: AnimatableBooleanValue toValue = (AnimatableBooleanValue) to;
068: newValue = toValue.value;
069: } else {
070: newValue = value;
071: }
072:
073: if (res.value != newValue) {
074: res.value = newValue;
075: res.hasChanged = true;
076: }
077: return res;
078: }
079:
080: /**
081: * Returns the boolean value.
082: */
083: public boolean getValue() {
084: return value;
085: }
086:
087: /**
088: * Returns whether two values of this type can have their distance
089: * computed, as needed by paced animation.
090: */
091: public boolean canPace() {
092: return false;
093: }
094:
095: /**
096: * Returns the absolute distance between this value and the specified other
097: * value.
098: */
099: public float distanceTo(AnimatableValue other) {
100: return 0f;
101: }
102:
103: /**
104: * Returns a zero value of this AnimatableValue's type.
105: */
106: public AnimatableValue getZeroValue() {
107: return new AnimatableBooleanValue(target, false);
108: }
109:
110: /**
111: * Returns the CSS text representation of the value.
112: */
113: public String getCssText() {
114: return (value) ? "true" : "false";
115: }
116: }
|