More JavaDoc improvements.
2 * Back 2 Browser Bytecode Translator Copyright (C) 2012 Jaroslav Tulach
3 * <jaroslav.tulach@apidesign.org>
5 * This program is free software: you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation, version 2 of the License.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 * You should have received a copy of the GNU General Public License along with
15 * this program. Look for COPYING file in the top folder. If not, see
16 * http://opensource.org/licenses/GPL-2.0.
18 package net.java.html.canvas.spi;
20 import net.java.html.canvas.Dimension;
21 import net.java.html.canvas.Image;
22 import net.java.html.canvas.Style;
25 * Provider API for Canvas. Implement this to add support for your platform.
29 public interface GraphicsEnvironment {
32 * Adds path elements to the current path to make an arc.
34 * @param centerX the center x position of the arc.
35 * @param centerY the center y position of the arc.
36 * @param startAngle the startAngle of the arc
37 * @param radius the radius of the arc.
38 * @param endAngle the endAngle of the arc
39 * @param ccw the direction of the arc (counterclockwise)
41 public void arc(double centerX,
49 * Adds segments to the current path to make an arc.
51 * @param x1 the X coordinate of the first point of the arc.
52 * @param y1 the Y coordinate of the first point of the arc.
53 * @param x2 the X coordinate of the second point of the arc.
54 * @param y2 the Y coordinate of the second point of the arc.
55 * @param radius the radius of the arc in the range {0.0-positive infinity}.
57 public void arcTo(double x1,
64 * Returns true if the the given x,y point is inside the path.
66 * @param x the X coordinate to use for the check.
67 * @param y the Y coordinate to use for the check.
68 * @return true if the point given is inside the path, false otherwise.
70 public boolean isPointInPath(double x, double y);
73 * Fills the path with the current fill paint.
78 * Strokes the path with the current stroke paint.
85 public void beginPath();
90 public void closePath();
93 * Clips using the current path
98 * Issues a move command for the current path to the given x,y coordinate.
100 * @param x the X position for the move to command.
101 * @param y the Y position for the move to command.
103 public void moveTo(double x, double y);
106 * Adds segments to the current path to make a line at the given x,y
109 * @param x the X coordinate of the ending point of the line.
110 * @param y the Y coordinate of the ending point of the line.
112 public void lineTo(double x, double y);
115 * Adds segments to the current path to make a quadratic curve.
117 * @param cpx the X coordinate of the control point
118 * @param cpy the Y coordinate of the control point
119 * @param x the X coordinate of the end point
120 * @param y the Y coordinate of the end point
122 public void quadraticCurveTo(double cpx, double cpy, double x, double y);
125 * Adds segments to the current path to make a cubic bezier curve.
127 * @param cp1x the X coordinate of first bezier control point.
128 * @param cp1y the Y coordinate of the first bezier control point.
129 * @param cp2x the X coordinate of the second bezier control point.
130 * @param cp2y the Y coordinate of the second bezier control point.
131 * @param x the X coordinate of the end point.
132 * @param y the Y coordinate of the end point.
134 public void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y);
137 * Fills a rectangle using the current fill paint.
139 * @param x the X position of the upper left corner of the rectangle.
140 * @param y the Y position of the upper left corner of the rectangle.
141 * @param width the width of the rectangle.
142 * @param height the height of the rectangle.
144 public void fillRect(double x, double y, double width, double height);
147 * Strokes a rectangle using the current stroke paint.
149 * @param x the X position of the upper left corner of the rectangle.
150 * @param y the Y position of the upper left corner of the rectangle.
151 * @param width the width of the rectangle.
152 * @param height the height of the rectangle.
154 public void strokeRect(double x, double y, double width, double height);
157 * Clears a portion of the canvas with a transparent color value.
159 * @param x X position of the upper left corner of the rectangle.
160 * @param y Y position of the upper left corner of the rectangle.
161 * @param width width of the rectangle.
162 * @param height height of the rectangle.
164 public void clearRect(double x, double y, double width, double height);
167 * Clears a portion of the canvas with a transparent color value.
169 * @param x X position of the upper left corner of the rectangle.
170 * @param y Y position of the upper left corner of the rectangle.
171 * @param width width of the rectangle.
172 * @param height height of the rectangle.
174 public void rect(double x, double y, double width, double height);
177 * Saves the following attributes onto a stack.
179 * <li>Global Alpha</li>
180 * <li>Global Blend Operation</li>
182 * <li>Fill Paint</li>
183 * <li>Stroke Paint</li>
184 * <li>Line Width</li>
187 * <li>Miter Limit</li>
188 * <li>Number of Clip Paths</li>
190 * <li>Text Align</li>
191 * <li>Text Baseline</li>
195 * This method does NOT alter the current state in any way. Also, not that
196 * the current path is not saved.
201 * Pops the state off of the stack, setting the following attributes to
202 * their value at the time when that state was pushed onto the stack. If the
203 * stack is empty then nothing is changed.
206 * <li>Global Alpha</li>
207 * <li>Global Blend Operation</li>
209 * <li>Fill Paint</li>
210 * <li>Stroke Paint</li>
211 * <li>Line Width</li>
214 * <li>Miter Limit</li>
215 * <li>Number of Clip Paths</li>
217 * <li>Text Align</li>
218 * <li>Text Baseline</li>
223 public void restore();
226 * Rotates the current transform in degrees.
228 * @param angle value in degrees to rotate the current transform.
230 public void rotate(double angle);
233 * Concatenates the input with the current transform.
235 * @param a - the X coordinate scaling element of the 3x4 matrix
236 * @param b - the Y coordinate shearing element of the 3x4 matrix
237 * @param c - the X coordinate shearing element of the 3x4 matrix
238 * @param d - the Y coordinate scaling element of the 3x4 matrix
239 * @param e - the X coordinate translation element of the 3x4 matrix
240 * @param f - the Y coordinate translation element of the 3x4 matrix
242 public void transform(double a, double b, double c, double d, double e, double f);
245 * Concatenates the input with the current transform.
247 * @param a - the X coordinate scaling element of the 3x4 matrix
248 * @param b - the Y coordinate shearing element of the 3x4 matrix
249 * @param c - the X coordinate shearing element of the 3x4 matrix
250 * @param d - the Y coordinate scaling element of the 3x4 matrix
251 * @param e - the X coordinate translation element of the 3x4 matrix
252 * @param f - the Y coordinate translation element of the 3x4 matrix
254 public void setTransform(double a, double b, double c, double d, double e, double f);
257 * Translates the current transform by x, y.
259 * @param x value to translate along the x axis.
260 * @param y value to translate along the y axis.
262 public void translate(double x, double y);
265 * Scales the current transform by x, y.
267 * @param x value to scale in the x axis.
268 * @param y value to scale in the y axis.
270 public void scale(double x, double y);
273 * Draws an image at the given x, y position using the width and height of
276 * @param image the image to be drawn.
277 * @param x the X coordinate on the destination for the upper left of the
279 * @param y the Y coordinate on the destination for the upper left of the
281 * @return the native Image for caching.
283 public Object drawImage(Image image, double x, double y, Object nativeImage);
286 * Draws an image into the given destination rectangle of the canvas. The
287 * Image is scaled to fit into the destination rectagnle.
289 * @param image the image to be drawn.
290 * @param x the X coordinate on the destination for the upper left of the
292 * @param y the Y coordinate on the destination for the upper left of the
294 * @param width the width of the destination rectangle.
295 * @param height the height of the destination rectangle.
296 * @return the native Image for caching.
299 public Object drawImage(Image image, double x, double y, double width, double height, Object nativeImage);
302 * Draws the current source rectangle of the given image to the given
303 * destination rectangle of the Canvas.
305 * @param image the image to be drawn.
306 * @param sx the source rectangle's X coordinate position.
307 * @param sy the source rectangle's Y coordinate position.
308 * @param sWidth the source rectangle's width.
309 * @param sHeight the source rectangle's height.
310 * @param x the destination rectangle's X coordinate position.
311 * @param y the destination rectangle's Y coordinate position.
312 * @param width the destination rectangle's width.
313 * @param height the destination rectangle's height.
314 * @return the native Image for caching.
316 public Object drawImage(Image image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height, Object nativeImage);
319 * Get the width of this Image
321 * @param image the image to measure
322 * @param nativeImage the cached native Image or null
323 * @return the width of the image
325 public int getWidth(Image image, Object nativeImage);
328 * Get the height of this Image
330 * @param image the image to measure
331 * @param nativeImage the cached native Image or null
332 * @return the height of the image
334 public int getHeight(Image image, Object nativeImage);
337 * When implementing you can return an Object of your choice to enable
338 * caching. Returning null means no caching. When caching is enabled, and
339 * the cache hasn't been invalidated, the Object you returned will be passed
342 * @param style The style object you should use to create your native style
343 * @param nativeStyle your native object if cached, null otherwise
344 * @return return native Object for caching
347 public Object setFillStyle(Style style, Object nativeStyle);
350 * When implementing you can return an Object of your choice to enable
351 * caching. Returning null means no caching. When caching is enabled, and
352 * the cache hasn't been invalidated, the Object you returned will be passed
355 * @param style The style object you should use to create your native style
356 * @param nativeStyle your native object if cached, null otherwise
357 * @return return native Object for caching
360 public Object setStrokeStyle(Style style, Object nativeStyle);
362 // public void setShadowColor(String color);
364 // public void setShadowBlur(double blur);
366 // public void setShadowOffsetX(double x);
368 // public void setShadowOffsetY(double y);
370 // public String getShadowColor();
372 // public double getShadowBlur();
374 // public double getShadowOffsetX();
376 // public double getShadowOffsetY();
378 * Gets the current stroke line cap.
380 * @return {@code StrokeLineCap} with a value of Butt, Round, or Square.
382 public String getLineCap();
385 * Sets the current stroke line cap.
387 * @param style a value of Butt, Round, or Square.
389 public void setLineCap(String style);
392 * Gets the current stroke line join.
394 * @return a value of Miter, Bevel, or Round.
396 public String getLineJoin();
399 * Sets the current stroke line join.
401 * @param style with a value of Miter, Bevel, or Round.
403 public void setLineJoin(String style);
406 * Gets the current line width.
408 * @return value between 0 and infinity.
410 public double getLineWidth();
413 * Sets the current line width.
415 * @param width value in the range {0-positive infinity}, with any other
416 * value being ignored and leaving the value unchanged.
418 public void setLineWidth(double width);
421 * Gets the current miter limit. v
423 * @return the miter limit value in the range {@code 0.0-positive infinity}
425 public double getMiterLimit();
428 * Sets the current miter limit.
430 * @param limit miter limit value between 0 and positive infinity with any
431 * other value being ignored and leaving the value unchanged.
433 public void setMiterLimit(double limit);
436 * Gets the current Font.
440 public String getFont();
443 * Sets the current Font.
446 public void setFont(String font);
449 * Gets the current {@code TextAlignment}.
451 * @return TextAlignment with values of Left, Center, Right, or Justify.
453 public String getTextAlign();
456 * Defines horizontal text alignment, relative to the text origin.
458 * @param textAlign with values of Left, Center, Right.
460 public void setTextAlign(String textAlign);
463 * Sets the current Text Baseline.
465 * @param baseline with values of Top, Center, Baseline, or Bottom
467 public String getTextBaseline();
470 * Sets the current Text Baseline.
472 * @param baseline with values of Top, Center, Baseline, or Bottom
474 public void setTextBaseline(String baseline);
477 * Fills the given string of text at position x, y (0,0 at top left) with
478 * the current fill paint attribute.
480 * @param text the string of text.
481 * @param x position on the x axis.
482 * @param y position on the y axis.
484 public void fillText(String text, double x, double y);
487 * Fills text and includes a maximum width of the string.
489 * If the width of the text extends past max width, then it will be sized to
492 * @param text the string of text.
493 * @param x position on the x axis.
494 * @param y position on the y axis.
495 * @param maxWidth maximum width the text string can have.
497 public void fillText(String text, double x, double y, double maxWidth);
500 * The Dimension of this text using the current Font settings
503 * @return the Dimension of this text using the current Font settings
505 public Dimension measureText(String text);
508 * draws the given string of text at position x, y (0,0 at top left) with
509 * the current stroke paint attribute.
511 * @param text the string of text.
512 * @param x position on the x axis.
513 * @param y position on the y axis.
515 public void strokeText(String text, double x, double y);
518 * Draws text with stroke paint and includes a maximum width of the string.
520 * If the width of the text extends past max width, then it will be sized to
523 * @param text the string of text.
524 * @param x position on the x axis.
525 * @param y position on the y axis.
526 * @param maxWidth maximum width the text string can have.
528 public void strokeText(String text, double x, double y, double maxWidth);
530 // public ImageData createPixelMap(double x, double y);
532 // public ImageData createPixelMap(ImageData imageData);
534 // public ImageData getPixelMap(double x, double y, double width, double height);
536 // public void putPixelMap(ImageData imageData, double x, double y);
538 // public void putPixelMap(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight);
540 * Sets the global alpha of the current state.
542 * @param alpha value in the range {@code 0.0-1.0}. The value is clamped if
543 * it is out of range.
545 public void setGlobalAlpha(double alpha);
548 * Get the global alpha of the current state.
550 * @return alpha value in the range {@code 0.0-1.0}.
552 public double getGlobalAlpha();
555 * Sets the global blend mode.
557 * @param operation the BlendMode that will be set.
559 public void setGlobalCompositeOperation(String operation);
562 * Gets the global blend mode.
564 * @return the global BlendMode of the current state.
566 public String getGlobalCompositeOperation();
569 * Get the height of this GraphicsContext (which should be the same as the
570 * enclosing canvas height)
572 * @return the height of this GraphicsContext
574 public int getHeight();
577 * Get the width of this GraphicsContext (which should be the same as the
578 * enclosing canvas height)
580 * @return the width of this GraphicsContext
582 public int getWidth();
584 // public void setHeight(int height);
586 // public void setWidth(int width);
588 * Merges two images drawing one on top of the other and returning the
591 * @param a the lower Image
592 * @param b the upper Image
593 * @param cachedA the native cached Image, if available, or null.
594 * @param cachedB the native cached Image, if available, or null.
597 public Object mergeImages(Image a, Image b, Object cachedA, Object cachedB);