toni@1129
|
1 |
/**
|
toni@1129
|
2 |
* Back 2 Browser Bytecode Translator Copyright (C) 2012 Jaroslav Tulach
|
toni@1129
|
3 |
* <jaroslav.tulach@apidesign.org>
|
toni@1129
|
4 |
*
|
toni@1129
|
5 |
* This program is free software: you can redistribute it and/or modify it under
|
toni@1129
|
6 |
* the terms of the GNU General Public License as published by the Free Software
|
toni@1129
|
7 |
* Foundation, version 2 of the License.
|
toni@1129
|
8 |
*
|
toni@1129
|
9 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
toni@1129
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
toni@1129
|
11 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
toni@1129
|
12 |
* details.
|
toni@1129
|
13 |
*
|
toni@1129
|
14 |
* You should have received a copy of the GNU General Public License along with
|
toni@1129
|
15 |
* this program. Look for COPYING file in the top folder. If not, see
|
toni@1129
|
16 |
* http://opensource.org/licenses/GPL-2.0.
|
toni@1128
|
17 |
*/
|
toni@1136
|
18 |
package net.java.html.canvas.spi;
|
toni@1128
|
19 |
|
toni@1137
|
20 |
import net.java.html.canvas.Dimension;
|
toni@1144
|
21 |
import net.java.html.canvas.Image;
|
toni@1136
|
22 |
import net.java.html.canvas.Style;
|
toni@1128
|
23 |
|
toni@1128
|
24 |
/**
|
toni@1136
|
25 |
* Provider API for Canvas. Implement this to add support for your platform.
|
toni@1141
|
26 |
*
|
toni@1128
|
27 |
* @author antonepple
|
toni@1128
|
28 |
*/
|
toni@1128
|
29 |
public interface GraphicsEnvironment {
|
toni@1129
|
30 |
|
toni@1128
|
31 |
public void arc(double centerX,
|
toni@1128
|
32 |
double centerY,
|
toni@1128
|
33 |
double startAngle,
|
toni@1128
|
34 |
double radius,
|
toni@1128
|
35 |
double endAngle,
|
toni@1128
|
36 |
boolean ccw);
|
toni@1128
|
37 |
|
toni@1128
|
38 |
public void arcTo(double x1,
|
toni@1128
|
39 |
double y1,
|
toni@1128
|
40 |
double x2,
|
toni@1128
|
41 |
double y2,
|
toni@1128
|
42 |
double r);
|
toni@1128
|
43 |
|
toni@1128
|
44 |
public boolean isPointInPath(double x, double y);
|
toni@1128
|
45 |
|
toni@1128
|
46 |
public void fill();
|
toni@1128
|
47 |
|
toni@1128
|
48 |
public void stroke();
|
toni@1128
|
49 |
|
toni@1128
|
50 |
public void beginPath();
|
toni@1128
|
51 |
|
toni@1128
|
52 |
public void closePath();
|
toni@1128
|
53 |
|
toni@1128
|
54 |
public void clip();
|
toni@1128
|
55 |
|
toni@1128
|
56 |
public void moveTo(double x, double y);
|
toni@1128
|
57 |
|
toni@1128
|
58 |
public void lineTo(double x, double y);
|
toni@1128
|
59 |
|
toni@1128
|
60 |
public void quadraticCurveTo(double cpx, double cpy, double x, double y);
|
toni@1128
|
61 |
|
toni@1128
|
62 |
public void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y);
|
toni@1128
|
63 |
|
toni@1128
|
64 |
public void fillRect(double x, double y, double width, double height);
|
toni@1128
|
65 |
|
toni@1128
|
66 |
public void strokeRect(double x, double y, double width, double height);
|
toni@1128
|
67 |
|
toni@1128
|
68 |
public void clearRect(double x, double y, double width, double height);
|
toni@1128
|
69 |
|
toni@1128
|
70 |
public void rect(double x, double y, double width, double height);
|
toni@1128
|
71 |
|
toni@1128
|
72 |
public void save();
|
toni@1128
|
73 |
|
toni@1128
|
74 |
public void restore();
|
toni@1128
|
75 |
|
toni@1128
|
76 |
public void rotate(double angle);
|
toni@1128
|
77 |
|
toni@1128
|
78 |
public void transform(double a, double b, double c, double d, double e, double f);
|
toni@1128
|
79 |
|
toni@1128
|
80 |
public void setTransform(double a, double b, double c, double d, double e, double f);
|
toni@1128
|
81 |
|
toni@1128
|
82 |
public void translate(double x, double y);
|
toni@1128
|
83 |
|
toni@1128
|
84 |
public void scale(double x, double y);
|
toni@1128
|
85 |
|
toni@1302
|
86 |
public Object drawImage(Image image, double x, double y, Object nativeImage);
|
toni@1144
|
87 |
|
toni@1144
|
88 |
public Object drawImage(Image image, double x, double y, double width, double height, Object nativeImage);
|
toni@1144
|
89 |
|
toni@1144
|
90 |
public Object drawImage(Image image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height, Object nativeImage);
|
toni@1144
|
91 |
|
toni@1263
|
92 |
public int getWidth(Image image, Object nativeImage);
|
toni@1302
|
93 |
|
toni@1263
|
94 |
public int getHeight(Image image, Object nativeImage);
|
toni@1302
|
95 |
|
toni@1141
|
96 |
/**
|
toni@1141
|
97 |
* When implementing you can return an Object of your choice to enable
|
toni@1141
|
98 |
* caching. Returning null means no caching. When caching is enabled, and
|
toni@1141
|
99 |
* the cache hasn't been invalidated, the Object you returned will be passed
|
toni@1141
|
100 |
* as a parameter.
|
toni@1141
|
101 |
*
|
toni@1141
|
102 |
* @param style The style object you should use to create your native style
|
toni@1141
|
103 |
* @param nativeStyle your native object if cached, null otherwise
|
toni@1141
|
104 |
* @return return native Object for caching
|
toni@1141
|
105 |
*
|
toni@1141
|
106 |
*/
|
toni@1141
|
107 |
public Object setFillStyle(Style style, Object nativeStyle);
|
toni@1128
|
108 |
|
toni@1141
|
109 |
/**
|
toni@1141
|
110 |
* When implementing you can return an Object of your choice to enable
|
toni@1141
|
111 |
* caching. Returning null means no caching. When caching is enabled, and
|
toni@1141
|
112 |
* the cache hasn't been invalidated, the Object you returned will be passed
|
toni@1141
|
113 |
* as a parameter.
|
toni@1141
|
114 |
*
|
toni@1141
|
115 |
* @param style The style object you should use to create your native style
|
toni@1141
|
116 |
* @param nativeStyle your native object if cached, null otherwise
|
toni@1141
|
117 |
* @return return native Object for caching
|
toni@1141
|
118 |
*
|
toni@1141
|
119 |
*/
|
toni@1141
|
120 |
public Object setStrokeStyle(Style style, Object nativeStyle);
|
toni@1128
|
121 |
|
toni@1302
|
122 |
// public void setShadowColor(String color);
|
toni@1302
|
123 |
//
|
toni@1302
|
124 |
// public void setShadowBlur(double blur);
|
toni@1302
|
125 |
//
|
toni@1302
|
126 |
// public void setShadowOffsetX(double x);
|
toni@1302
|
127 |
//
|
toni@1302
|
128 |
// public void setShadowOffsetY(double y);
|
toni@1302
|
129 |
//
|
toni@1302
|
130 |
// public String getShadowColor();
|
toni@1302
|
131 |
//
|
toni@1302
|
132 |
// public double getShadowBlur();
|
toni@1302
|
133 |
//
|
toni@1302
|
134 |
// public double getShadowOffsetX();
|
toni@1302
|
135 |
//
|
toni@1302
|
136 |
// public double getShadowOffsetY();
|
toni@1302
|
137 |
/**
|
toni@1302
|
138 |
* Gets the current stroke line cap.
|
toni@1302
|
139 |
*
|
toni@1302
|
140 |
* @return {@code StrokeLineCap} with a value of Butt, Round, or Square.
|
toni@1302
|
141 |
*/
|
toni@1128
|
142 |
public String getLineCap();
|
toni@1128
|
143 |
|
toni@1302
|
144 |
/**
|
toni@1302
|
145 |
* Sets the current stroke line cap.
|
toni@1302
|
146 |
*
|
toni@1302
|
147 |
* @param style a value of Butt, Round, or Square.
|
toni@1302
|
148 |
*/
|
toni@1128
|
149 |
public void setLineCap(String style);
|
toni@1128
|
150 |
|
toni@1302
|
151 |
/**
|
toni@1302
|
152 |
* Gets the current stroke line join.
|
toni@1302
|
153 |
*
|
toni@1302
|
154 |
* @return a value of Miter, Bevel, or Round.
|
toni@1302
|
155 |
*/
|
toni@1128
|
156 |
public String getLineJoin();
|
toni@1128
|
157 |
|
toni@1302
|
158 |
/**
|
toni@1302
|
159 |
* Sets the current stroke line join.
|
toni@1302
|
160 |
*
|
toni@1302
|
161 |
* @param style with a value of Miter, Bevel, or Round.
|
toni@1302
|
162 |
*/
|
toni@1128
|
163 |
public void setLineJoin(String style);
|
toni@1128
|
164 |
|
toni@1302
|
165 |
/**
|
toni@1302
|
166 |
* Gets the current line width.
|
toni@1302
|
167 |
*
|
toni@1302
|
168 |
* @return value between 0 and infinity.
|
toni@1302
|
169 |
*/
|
toni@1128
|
170 |
public double getLineWidth();
|
toni@1128
|
171 |
|
toni@1302
|
172 |
/**
|
toni@1302
|
173 |
* Sets the current line width.
|
toni@1302
|
174 |
*
|
toni@1302
|
175 |
* @param width value in the range {0-positive infinity}, with any other
|
toni@1302
|
176 |
* value being ignored and leaving the value unchanged.
|
toni@1302
|
177 |
*/
|
toni@1128
|
178 |
public void setLineWidth(double width);
|
toni@1128
|
179 |
|
toni@1302
|
180 |
/**
|
toni@1302
|
181 |
* Gets the current miter limit. v
|
toni@1302
|
182 |
*
|
toni@1302
|
183 |
* @return the miter limit value in the range {@code 0.0-positive infinity}
|
toni@1302
|
184 |
*/
|
toni@1128
|
185 |
public double getMiterLimit();
|
toni@1128
|
186 |
|
toni@1302
|
187 |
/**
|
toni@1302
|
188 |
* Sets the current miter limit.
|
toni@1302
|
189 |
*
|
toni@1302
|
190 |
* @param limit miter limit value between 0 and positive infinity with any
|
toni@1302
|
191 |
* other value being ignored and leaving the value unchanged.
|
toni@1302
|
192 |
*/
|
toni@1128
|
193 |
public void setMiterLimit(double limit);
|
toni@1128
|
194 |
|
toni@1302
|
195 |
/**
|
toni@1302
|
196 |
* Gets the current Font.
|
toni@1302
|
197 |
*
|
toni@1302
|
198 |
* @return the Font
|
toni@1302
|
199 |
*/
|
toni@1128
|
200 |
public String getFont();
|
toni@1128
|
201 |
|
toni@1302
|
202 |
/**
|
toni@1302
|
203 |
* Sets the current Font.
|
toni@1302
|
204 |
*
|
toni@1302
|
205 |
*/
|
toni@1128
|
206 |
public void setFont(String font);
|
toni@1128
|
207 |
|
toni@1302
|
208 |
/**
|
toni@1302
|
209 |
* Gets the current {@code TextAlignment}.
|
toni@1302
|
210 |
*
|
toni@1302
|
211 |
* @return TextAlignment with values of Left, Center, Right, or Justify.
|
toni@1302
|
212 |
*/
|
toni@1128
|
213 |
public String getTextAlign();
|
toni@1128
|
214 |
|
toni@1302
|
215 |
/**
|
toni@1302
|
216 |
* Defines horizontal text alignment, relative to the text origin.
|
toni@1302
|
217 |
*
|
toni@1302
|
218 |
* @param textAlign with values of Left, Center, Right.
|
toni@1302
|
219 |
*/
|
toni@1128
|
220 |
public void setTextAlign(String textAlign);
|
toni@1128
|
221 |
|
toni@1302
|
222 |
/**
|
toni@1302
|
223 |
* Sets the current Text Baseline.
|
toni@1302
|
224 |
*
|
toni@1302
|
225 |
* @param baseline with values of Top, Center, Baseline, or Bottom
|
toni@1302
|
226 |
*/
|
toni@1128
|
227 |
public String getTextBaseline();
|
toni@1128
|
228 |
|
toni@1302
|
229 |
/**
|
toni@1302
|
230 |
* Sets the current Text Baseline.
|
toni@1302
|
231 |
*
|
toni@1302
|
232 |
* @param baseline with values of Top, Center, Baseline, or Bottom
|
toni@1302
|
233 |
*/
|
toni@1302
|
234 |
public void setTextBaseline(String baseline);
|
toni@1128
|
235 |
|
toni@1302
|
236 |
/**
|
toni@1302
|
237 |
* Fills the given string of text at position x, y (0,0 at top left) with
|
toni@1302
|
238 |
* the current fill paint attribute.
|
toni@1302
|
239 |
*
|
toni@1302
|
240 |
* @param text the string of text.
|
toni@1302
|
241 |
* @param x position on the x axis.
|
toni@1302
|
242 |
* @param y position on the y axis.
|
toni@1302
|
243 |
*/
|
toni@1128
|
244 |
public void fillText(String text, double x, double y);
|
toni@1128
|
245 |
|
toni@1302
|
246 |
/**
|
toni@1302
|
247 |
* Fills text and includes a maximum width of the string.
|
toni@1302
|
248 |
*
|
toni@1302
|
249 |
* If the width of the text extends past max width, then it will be sized to
|
toni@1302
|
250 |
* fit.
|
toni@1302
|
251 |
*
|
toni@1302
|
252 |
* @param text the string of text.
|
toni@1302
|
253 |
* @param x position on the x axis.
|
toni@1302
|
254 |
* @param y position on the y axis.
|
toni@1302
|
255 |
* @param maxWidth maximum width the text string can have.
|
toni@1302
|
256 |
*/
|
toni@1128
|
257 |
public void fillText(String text, double x, double y, double maxWidth);
|
toni@1128
|
258 |
|
toni@1302
|
259 |
/**
|
toni@1302
|
260 |
* The Dimension of this text using the current Font settings
|
toni@1302
|
261 |
*
|
toni@1302
|
262 |
* @param text
|
toni@1302
|
263 |
* @return the Dimension of this text using the current Font settings
|
toni@1302
|
264 |
*/
|
toni@1128
|
265 |
public Dimension measureText(String text);
|
toni@1128
|
266 |
|
toni@1302
|
267 |
/**
|
toni@1302
|
268 |
* draws the given string of text at position x, y (0,0 at top left) with
|
toni@1302
|
269 |
* the current stroke paint attribute.
|
toni@1302
|
270 |
*
|
toni@1302
|
271 |
* @param text the string of text.
|
toni@1302
|
272 |
* @param x position on the x axis.
|
toni@1302
|
273 |
* @param y position on the y axis.
|
toni@1302
|
274 |
*/
|
toni@1128
|
275 |
public void strokeText(String text, double x, double y);
|
toni@1128
|
276 |
|
toni@1302
|
277 |
/**
|
toni@1302
|
278 |
* Draws text with stroke paint and includes a maximum width of the string.
|
toni@1302
|
279 |
*
|
toni@1302
|
280 |
* If the width of the text extends past max width, then it will be sized to
|
toni@1302
|
281 |
* fit.
|
toni@1302
|
282 |
*
|
toni@1302
|
283 |
* @param text the string of text.
|
toni@1302
|
284 |
* @param x position on the x axis.
|
toni@1302
|
285 |
* @param y position on the y axis.
|
toni@1302
|
286 |
* @param maxWidth maximum width the text string can have.
|
toni@1302
|
287 |
*/
|
toni@1128
|
288 |
public void strokeText(String text, double x, double y, double maxWidth);
|
toni@1128
|
289 |
|
toni@1302
|
290 |
// public ImageData createPixelMap(double x, double y);
|
toni@1302
|
291 |
//
|
toni@1302
|
292 |
// public ImageData createPixelMap(ImageData imageData);
|
toni@1302
|
293 |
//
|
toni@1302
|
294 |
// public ImageData getPixelMap(double x, double y, double width, double height);
|
toni@1302
|
295 |
//
|
toni@1302
|
296 |
// public void putPixelMap(ImageData imageData, double x, double y);
|
toni@1302
|
297 |
//
|
toni@1302
|
298 |
// public void putPixelMap(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight);
|
toni@1302
|
299 |
/**
|
toni@1302
|
300 |
* Sets the global alpha of the current state.
|
toni@1302
|
301 |
*
|
toni@1302
|
302 |
* @param alpha value in the range {@code 0.0-1.0}. The value is clamped if
|
toni@1302
|
303 |
* it is out of range.
|
toni@1302
|
304 |
*/
|
toni@1128
|
305 |
public void setGlobalAlpha(double alpha);
|
toni@1128
|
306 |
|
toni@1128
|
307 |
public double getGlobalAlpha();
|
toni@1128
|
308 |
|
toni@1128
|
309 |
public void setGlobalCompositeOperation(String operation);
|
toni@1128
|
310 |
|
toni@1128
|
311 |
public String getGlobalCompositeOperation();
|
toni@1302
|
312 |
|
toni@1128
|
313 |
public int getHeight();
|
toni@1128
|
314 |
|
toni@1128
|
315 |
public int getWidth();
|
toni@1128
|
316 |
|
toni@1302
|
317 |
// public void setHeight(int height);
|
toni@1302
|
318 |
//
|
toni@1302
|
319 |
// public void setWidth(int width);
|
toni@1263
|
320 |
|
toni@1263
|
321 |
public Object mergeImages(Image a, Image b, Object cachedA, Object cachedB);
|
toni@1128
|
322 |
}
|