1 | /* BasicStroke.java --
|
---|
2 | Copyright (C) 2002, 2003 Free Software Foundation, Inc.
|
---|
3 |
|
---|
4 | This file is part of GNU Classpath.
|
---|
5 |
|
---|
6 | GNU Classpath is free software; you can redistribute it and/or modify
|
---|
7 | it under the terms of the GNU General Public License as published by
|
---|
8 | the Free Software Foundation; either version 2, or (at your option)
|
---|
9 | any later version.
|
---|
10 |
|
---|
11 | GNU Classpath is distributed in the hope that it will be useful, but
|
---|
12 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
14 | General Public License for more details.
|
---|
15 |
|
---|
16 | You should have received a copy of the GNU General Public License
|
---|
17 | along with GNU Classpath; see the file COPYING. If not, write to the
|
---|
18 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
---|
19 | 02111-1307 USA.
|
---|
20 |
|
---|
21 | Linking this library statically or dynamically with other modules is
|
---|
22 | making a combined work based on this library. Thus, the terms and
|
---|
23 | conditions of the GNU General Public License cover the whole
|
---|
24 | combination.
|
---|
25 |
|
---|
26 | As a special exception, the copyright holders of this library give you
|
---|
27 | permission to link this library with independent modules to produce an
|
---|
28 | executable, regardless of the license terms of these independent
|
---|
29 | modules, and to copy and distribute the resulting executable under
|
---|
30 | terms of your choice, provided that you also meet, for each linked
|
---|
31 | independent module, the terms and conditions of the license of that
|
---|
32 | module. An independent module is a module which is not derived from
|
---|
33 | or based on this library. If you modify this library, you may extend
|
---|
34 | this exception to your version of the library, but you are not
|
---|
35 | obligated to do so. If you do not wish to do so, delete this
|
---|
36 | exception statement from your version. */
|
---|
37 |
|
---|
38 |
|
---|
39 | package java.awt;
|
---|
40 |
|
---|
41 | import java.util.Arrays;
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * STUB CLASS ONLY
|
---|
45 | */
|
---|
46 | public class BasicStroke implements Stroke
|
---|
47 | {
|
---|
48 | public static final int JOIN_MITER = 0;
|
---|
49 | public static final int JOIN_ROUND = 1;
|
---|
50 | public static final int JOIN_BEVEL = 2;
|
---|
51 | public static final int CAP_BUTT = 0;
|
---|
52 | public static final int CAP_ROUND = 1;
|
---|
53 | public static final int CAP_SQUARE = 2;
|
---|
54 |
|
---|
55 | private final float width;
|
---|
56 | private final int cap;
|
---|
57 | private final int join;
|
---|
58 | private final float limit;
|
---|
59 | private final float[] dash;
|
---|
60 | private final float phase;
|
---|
61 |
|
---|
62 | /**
|
---|
63 | * Creates a basic stroke.
|
---|
64 | *
|
---|
65 | * @param width May not be negative .
|
---|
66 | * @param cap May be either CAP_BUTT, CAP_ROUND or CAP_SQUARE.
|
---|
67 | * @param join May be either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER.
|
---|
68 | * @param miterlimit the limit to trim the miter join. The miterlimit must be
|
---|
69 | * greater than or equal to 1.0f.
|
---|
70 | * @param dash The array representing the dashing pattern.
|
---|
71 | * @param dash_phase is negative and dash is not null.
|
---|
72 | *
|
---|
73 | * @exception IllegalArgumentException If one input parameter doesn't meet
|
---|
74 | * its needs.
|
---|
75 | */
|
---|
76 | public BasicStroke(float width, int cap, int join, float miterlimit,
|
---|
77 | float[] dash, float dashPhase)
|
---|
78 | {
|
---|
79 | if (width < 0 ||
|
---|
80 | miterlimit < 1.0f ||
|
---|
81 | cap < CAP_BUTT ||
|
---|
82 | cap > CAP_SQUARE ||
|
---|
83 | join < JOIN_MITER ||
|
---|
84 | join > JOIN_BEVEL)
|
---|
85 | throw new IllegalArgumentException();
|
---|
86 |
|
---|
87 | this.width = width;
|
---|
88 | this.cap = cap;
|
---|
89 | this.join = join;
|
---|
90 | limit = miterlimit;
|
---|
91 | this.dash = dash == null ? null : (float[]) dash.clone();
|
---|
92 | phase = dashPhase;
|
---|
93 | }
|
---|
94 |
|
---|
95 | /**
|
---|
96 | * Creates a basic stroke.
|
---|
97 | *
|
---|
98 | * @param width The width of the BasicStroke. May not be negative .
|
---|
99 | * @param cap May be either CAP_BUTT, CAP_ROUND or CAP_SQUARE.
|
---|
100 | * @param join May be either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER.
|
---|
101 | * @param miterlimit the limit to trim the miter join. The miterlimit must be
|
---|
102 | * greater than or equal to 1.0f.
|
---|
103 | *
|
---|
104 | * @exception IllegalArgumentException If one input parameter doesn't meet
|
---|
105 | * its needs.
|
---|
106 | */
|
---|
107 | public BasicStroke(float width, int cap, int join, float miterlimit)
|
---|
108 | {
|
---|
109 | this(width, cap, join, miterlimit, null, 0);
|
---|
110 | }
|
---|
111 |
|
---|
112 | /**
|
---|
113 | * Creates a basic stroke.
|
---|
114 | *
|
---|
115 | * @param width The width of the BasicStroke. May not be nehative.
|
---|
116 | * @param cap May be either CAP_BUTT, CAP_ROUND or CAP_SQUARE.
|
---|
117 | * @param join May be either JOIN_ROUND, JOIN_BEVEL, or JOIN_MITER.
|
---|
118 | *
|
---|
119 | * @exception IllegalArgumentException If one input parameter doesn't meet
|
---|
120 | * its needs.
|
---|
121 | * @exception IllegalArgumentException FIXME
|
---|
122 | */
|
---|
123 | public BasicStroke(float width, int cap, int join)
|
---|
124 | {
|
---|
125 | this(width, cap, join, 10, null, 0);
|
---|
126 | }
|
---|
127 |
|
---|
128 | /**
|
---|
129 | * Creates a basic stroke.
|
---|
130 | *
|
---|
131 | * @param width The width of the BasicStroke.
|
---|
132 | *
|
---|
133 | * @exception IllegalArgumentException If width is negative.
|
---|
134 | */
|
---|
135 | public BasicStroke(float width)
|
---|
136 | {
|
---|
137 | this(width, CAP_SQUARE, JOIN_MITER, 10, null, 0);
|
---|
138 | }
|
---|
139 |
|
---|
140 | /**
|
---|
141 | * Creates a basic stroke.
|
---|
142 | */
|
---|
143 | public BasicStroke()
|
---|
144 | {
|
---|
145 | this(1, CAP_SQUARE, JOIN_MITER, 10, null, 0);
|
---|
146 | }
|
---|
147 |
|
---|
148 | public Shape createStrokedShape(Shape s)
|
---|
149 | {
|
---|
150 | throw new Error("not implemented");
|
---|
151 | }
|
---|
152 |
|
---|
153 | public float getLineWidth()
|
---|
154 | {
|
---|
155 | return width;
|
---|
156 | }
|
---|
157 |
|
---|
158 | public int getEndCap()
|
---|
159 | {
|
---|
160 | return cap;
|
---|
161 | }
|
---|
162 |
|
---|
163 | public int getLineJoin()
|
---|
164 | {
|
---|
165 | return join;
|
---|
166 | }
|
---|
167 |
|
---|
168 | public float getMiterLimit()
|
---|
169 | {
|
---|
170 | return limit;
|
---|
171 | }
|
---|
172 |
|
---|
173 | public float[] getDashArray()
|
---|
174 | {
|
---|
175 | return dash;
|
---|
176 | }
|
---|
177 |
|
---|
178 | public float getDashPhase()
|
---|
179 | {
|
---|
180 | return phase;
|
---|
181 | }
|
---|
182 |
|
---|
183 | public int hashCode()
|
---|
184 | {
|
---|
185 | throw new Error("not implemented");
|
---|
186 | }
|
---|
187 |
|
---|
188 | public boolean equals(Object o)
|
---|
189 | {
|
---|
190 | if (! (o instanceof BasicStroke))
|
---|
191 | return false;
|
---|
192 | BasicStroke s = (BasicStroke) o;
|
---|
193 | return width == s.width && cap == s.cap && join == s.join
|
---|
194 | && limit == s.limit && Arrays.equals(dash, s.dash) && phase == s.phase;
|
---|
195 | }
|
---|
196 | } // class BasicStroke
|
---|