KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > gvt > text > TextPath


1 /*
2
3    Copyright 2001,2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.gvt.text;
19
20 import java.awt.geom.GeneralPath JavaDoc;
21 import java.awt.geom.Point2D JavaDoc;
22
23 import org.apache.batik.ext.awt.geom.PathLength;
24
25 /**
26  * A text path describes a path along which some text will be rendered.
27  *
28  * @author <a HREF="mailto:bella.robinson@cmis.csiro.au">Bella Robinson</a>
29  * @version $Id: TextPath.java,v 1.6 2004/08/18 07:14:42 vhardy Exp $
30  */

31 public class TextPath {
32
33     private PathLength pathLength;
34     private float startOffset;
35
36     /**
37      * Constructs a TextPath based on the specified path.
38      *
39      * @param path The general path along which text is to be laid.
40      */

41     public TextPath(GeneralPath JavaDoc path) {
42         pathLength = new PathLength(path);
43         startOffset = 0;
44     }
45
46     /**
47      * Sets the offset along the path where the first glyph should be rendered.
48      *
49      * @param startOffset An offset from the start of the path.
50      */

51     public void setStartOffset(float startOffset) {
52         this.startOffset = startOffset;
53     }
54
55     /**
56      * Returns the start offset of this text path.
57      *
58      * @return The start offset of this text path.
59      */

60     public float getStartOffset() {
61         return startOffset;
62     }
63
64     /**
65      * Returns the total length of the path.
66      *
67      * @return The lenght of the path.
68      */

69     public float lengthOfPath() {
70         return pathLength.lengthOfPath();
71     }
72
73     /**
74      * Returns the angle at the specified length
75      * along the path.
76      *
77      * @param length The length along the path.
78      * @return The angle.
79      */

80     public float angleAtLength(float length) {
81         return pathLength.angleAtLength(length);
82     }
83
84     /**
85      * Returns the point that is at the specified length
86      * along the path.
87      *
88      * @param length The length along the path.
89      * @return The point.
90      */

91     public Point2D JavaDoc pointAtLength(float length) {
92         return pathLength.pointAtLength(length);
93     }
94 }
95
Popular Tags