~ubuntu-branches/ubuntu/karmic/batik/karmic

« back to all changes in this revision

Viewing changes to sources/org/apache/batik/anim/values/AnimatableAngleValue.java

  • Committer: Bazaar Package Importer
  • Author(s): Matvey Kozhev, Onkar Shinde, Matvey Kozhev
  • Date: 2008-07-19 01:03:05 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080719010305-0b24skqy185kdsb9
Tags: 1.7.dfsg-0ubuntu1
[ Onkar Shinde ]
* New upstream version (LP: #147818)
* debian/control
  - Add Sun JDK 1.5 as build dependency. Fixes FTBFS on buildd. (LP: #150484)
    Also add Sun JRE as runtime dependencies.
  - Add ant-optional as build dependency.
  - Add libxml-commons-external-java and libxmlgraphics-commons-java as
    build and runtime dependencies.
  - Add 'Homepage' field and correct the url.
  - Change standards version to 3.8.0.
  - Modify Maintainer value to match the DebianMaintainerField
    specification.
* debian/rules
  - Change JAVA_HOME_DIRS for Sun JDK.
  - Add jar file names to DEB_JARS to match new build requirements.
  - Extract version from changelog.
  - Delete bundled jar files in clean target.
  - Don't use hardcoded version in install target.
  - Add get-orig-source target.
* debian/README.Debian-source
  - Change the fo tag name to the one used for this version.
* debian/watch
  - Change expression to match src distribution.
* debian/patches/
  - 01_build_xml.patch, 02_fix_jar_target.patch - Refresh for current source.
  - 03_fix_lib_dirs.patch - Fix the library and classpath references needed
    for pdf transcoder build.
  - 04_fix_transcoder_pkg.patch - Fix transcoder-pkg target to not copy
    files from other jar files.

[ Matvey Kozhev ]
* debian/changelog:
  - Added ".dfsg" to version.
* debian/control, debian/rules:
  - Build with openjdk-6-jdk, depend on openjdk-6-jre.
  - Added java-6-sun as an alternate build JAVA_HOME directory.
  - Fixed get-orig-source to not include debian/ and delete the source dir,
    and made it delete jars from lib/, as done in the current batik package.
* debian/wrappers.sh:
  - Changed java-7-icedtea reference to java-6-openjdk, as the former has been
    removed back in Hardy.
  - Added newline.
* debian/libbatik-java.install:
  - Added newline.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
   Licensed to the Apache Software Foundation (ASF) under one or more
 
4
   contributor license agreements.  See the NOTICE file distributed with
 
5
   this work for additional information regarding copyright ownership.
 
6
   The ASF licenses this file to You under the Apache License, Version 2.0
 
7
   (the "License"); you may not use this file except in compliance with
 
8
   the License.  You may obtain a copy of the License at
 
9
 
 
10
       http://www.apache.org/licenses/LICENSE-2.0
 
11
 
 
12
   Unless required by applicable law or agreed to in writing, software
 
13
   distributed under the License is distributed on an "AS IS" BASIS,
 
14
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
15
   See the License for the specific language governing permissions and
 
16
   limitations under the License.
 
17
 
 
18
 */
 
19
package org.apache.batik.anim.values;
 
20
 
 
21
import org.apache.batik.dom.anim.AnimationTarget;
 
22
 
 
23
import org.w3c.dom.svg.SVGAngle;
 
24
 
 
25
/**
 
26
 * An SVG angle value in the animation system.
 
27
 *
 
28
 * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
 
29
 * @version $Id: AnimatableAngleValue.java 532986 2007-04-27 06:30:58Z cam $
 
30
 */
 
31
public class AnimatableAngleValue extends AnimatableNumberValue {
 
32
 
 
33
    /**
 
34
     * The unit string representations.
 
35
     */
 
36
    protected static final String[] UNITS = {
 
37
        "", "", "deg", "rad", "grad"
 
38
    };
 
39
 
 
40
    /**
 
41
     * The angle unit.
 
42
     */
 
43
    protected short unit;
 
44
 
 
45
    /**
 
46
     * Creates a new, uninitialized AnimatableAngleValue.
 
47
     */
 
48
    public AnimatableAngleValue(AnimationTarget target) {
 
49
        super(target);
 
50
    }
 
51
 
 
52
    /**
 
53
     * Creates a new AnimatableAngleValue.
 
54
     */
 
55
    public AnimatableAngleValue(AnimationTarget target, float v, short unit) {
 
56
        super(target, v);
 
57
        this.unit = unit;
 
58
    }
 
59
 
 
60
    /**
 
61
     * Performs interpolation to the given value.
 
62
     */
 
63
    public AnimatableValue interpolate(AnimatableValue result,
 
64
                                       AnimatableValue to,
 
65
                                       float interpolation,
 
66
                                       AnimatableValue accumulation,
 
67
                                       int multiplier) {
 
68
        AnimatableAngleValue res;
 
69
        if (result == null) {
 
70
            res = new AnimatableAngleValue(target);
 
71
        } else {
 
72
            res = (AnimatableAngleValue) result;
 
73
        }
 
74
 
 
75
        float v = value;
 
76
        short u = unit;
 
77
        if (to != null) {
 
78
            AnimatableAngleValue toAngle = (AnimatableAngleValue) to;
 
79
            if (toAngle.unit != u) {
 
80
                v = rad(v, u);
 
81
                v += interpolation * (rad(toAngle.value, toAngle.unit) - v);
 
82
                u = SVGAngle.SVG_ANGLETYPE_RAD;
 
83
            } else {
 
84
                v += interpolation * (toAngle.value - v);
 
85
            }
 
86
        }
 
87
        if (accumulation != null) {
 
88
            AnimatableAngleValue accAngle = (AnimatableAngleValue) accumulation;
 
89
            if (accAngle.unit != u) {
 
90
                v += multiplier * rad(accAngle.value, accAngle.unit);
 
91
                u = SVGAngle.SVG_ANGLETYPE_RAD;
 
92
            } else {
 
93
                v += multiplier * accAngle.value;
 
94
            }
 
95
        }
 
96
 
 
97
        if (res.value != v || res.unit != u) {
 
98
            res.value = v;
 
99
            res.unit = u;
 
100
            res.hasChanged = true;
 
101
        }
 
102
        return res;
 
103
    }
 
104
 
 
105
    /**
 
106
     * Returns the angle unit.
 
107
     */
 
108
    public short getUnit() {
 
109
        return unit;
 
110
    }
 
111
 
 
112
    /**
 
113
     * Returns the absolute distance between this value and the specified other
 
114
     * value.
 
115
     */
 
116
    public float distanceTo(AnimatableValue other) {
 
117
        AnimatableAngleValue o = (AnimatableAngleValue) other;
 
118
        return Math.abs(rad(value, unit) - rad(o.value, o.unit));
 
119
    }
 
120
 
 
121
    /**
 
122
     * Returns a zero value of this AnimatableValue's type.
 
123
     */
 
124
    public AnimatableValue getZeroValue() {
 
125
        return new AnimatableAngleValue
 
126
            (target, 0, SVGAngle.SVG_ANGLETYPE_UNSPECIFIED);
 
127
    }
 
128
 
 
129
    /**
 
130
     * Returns the CSS text representation of the value.
 
131
     */
 
132
    public String getCssText() {
 
133
        return super.getCssText() + UNITS[unit];
 
134
    }
 
135
 
 
136
    /**
 
137
     * Converts an angle value to radians.
 
138
     */
 
139
    public static float rad(float v, short unit) {
 
140
        switch (unit) {
 
141
            case SVGAngle.SVG_ANGLETYPE_RAD:
 
142
                return v;
 
143
            case SVGAngle.SVG_ANGLETYPE_GRAD:
 
144
                return (float) Math.PI * v / 200;
 
145
            default:
 
146
                return (float) Math.PI * v / 180;
 
147
        }
 
148
    }
 
149
}