2 * Back 2 Browser Bytecode Translator
3 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. Look for COPYING file in the top folder.
16 * If not, see 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 {
31 public void arc(double centerX,
38 public void arcTo(double x1,
44 public boolean isPointInPath(double x, double y);
50 public void beginPath();
52 public void closePath();
56 public void moveTo(double x, double y);
58 public void lineTo(double x, double y);
60 public void quadraticCurveTo(double cpx, double cpy, double x, double y);
62 public void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y);
64 public void fillRect(double x, double y, double width, double height);
66 public void strokeRect(double x, double y, double width, double height);
68 public void clearRect(double x, double y, double width, double height);
70 public void rect(double x, double y, double width, double height);
74 public void restore();
76 public void rotate(double angle);
78 public void transform(double a, double b, double c, double d, double e, double f);
80 public void setTransform(double a, double b, double c, double d, double e, double f);
82 public void translate(double x, double y);
84 public void scale(double x, double y);
86 public Object drawImage(Image image, double x, double y, Object nativeImage);
88 public Object drawImage(Image image, double x, double y, double width, double height, Object nativeImage);
90 public Object drawImage(Image image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height, Object nativeImage);
92 public int getWidth(Image image, Object nativeImage);
94 public int getHeight(Image image, Object nativeImage);
97 * When implementing you can return an Object of your choice to enable
98 * caching. Returning null means no caching. When caching is enabled, and
99 * the cache hasn't been invalidated, the Object you returned will be passed
102 * @param style The style object you should use to create your native style
103 * @param nativeStyle your native object if cached, null otherwise
104 * @return return native Object for caching
107 public Object setFillStyle(Style style, Object nativeStyle);
110 * When implementing you can return an Object of your choice to enable
111 * caching. Returning null means no caching. When caching is enabled, and
112 * the cache hasn't been invalidated, the Object you returned will be passed
115 * @param style The style object you should use to create your native style
116 * @param nativeStyle your native object if cached, null otherwise
117 * @return return native Object for caching
120 public Object setStrokeStyle(Style style, Object nativeStyle);
122 // public void setShadowColor(String color);
124 // public void setShadowBlur(double blur);
126 // public void setShadowOffsetX(double x);
128 // public void setShadowOffsetY(double y);
130 // public String getShadowColor();
132 // public double getShadowBlur();
134 // public double getShadowOffsetX();
136 // public double getShadowOffsetY();
138 * Gets the current stroke line cap.
140 * @return {@code StrokeLineCap} with a value of Butt, Round, or Square.
142 public String getLineCap();
145 * Sets the current stroke line cap.
147 * @param style a value of Butt, Round, or Square.
149 public void setLineCap(String style);
152 * Gets the current stroke line join.
154 * @return a value of Miter, Bevel, or Round.
156 public String getLineJoin();
159 * Sets the current stroke line join.
161 * @param style with a value of Miter, Bevel, or Round.
163 public void setLineJoin(String style);
166 * Gets the current line width.
168 * @return value between 0 and infinity.
170 public double getLineWidth();
173 * Sets the current line width.
175 * @param width value in the range {0-positive infinity}, with any other
176 * value being ignored and leaving the value unchanged.
178 public void setLineWidth(double width);
181 * Gets the current miter limit. v
183 * @return the miter limit value in the range {@code 0.0-positive infinity}
185 public double getMiterLimit();
188 * Sets the current miter limit.
190 * @param limit miter limit value between 0 and positive infinity with any
191 * other value being ignored and leaving the value unchanged.
193 public void setMiterLimit(double limit);
196 * Gets the current Font.
200 public String getFont();
203 * Sets the current Font.
206 public void setFont(String font);
209 * Gets the current {@code TextAlignment}.
211 * @return TextAlignment with values of Left, Center, Right, or Justify.
213 public String getTextAlign();
216 * Defines horizontal text alignment, relative to the text origin.
218 * @param textAlign with values of Left, Center, Right.
220 public void setTextAlign(String textAlign);
223 * Sets the current Text Baseline.
225 * @param baseline with values of Top, Center, Baseline, or Bottom
227 public String getTextBaseline();
230 * Sets the current Text Baseline.
232 * @param baseline with values of Top, Center, Baseline, or Bottom
234 public void setTextBaseline(String baseline);
237 * Fills the given string of text at position x, y (0,0 at top left) with
238 * the current fill paint attribute.
240 * @param text the string of text.
241 * @param x position on the x axis.
242 * @param y position on the y axis.
244 public void fillText(String text, double x, double y);
247 * Fills text and includes a maximum width of the string.
249 * If the width of the text extends past max width, then it will be sized to
252 * @param text the string of text.
253 * @param x position on the x axis.
254 * @param y position on the y axis.
255 * @param maxWidth maximum width the text string can have.
257 public void fillText(String text, double x, double y, double maxWidth);
260 * The Dimension of this text using the current Font settings
263 * @return the Dimension of this text using the current Font settings
265 public Dimension measureText(String text);
268 * draws the given string of text at position x, y (0,0 at top left) with
269 * the current stroke paint attribute.
271 * @param text the string of text.
272 * @param x position on the x axis.
273 * @param y position on the y axis.
275 public void strokeText(String text, double x, double y);
278 * Draws text with stroke paint and includes a maximum width of the string.
280 * If the width of the text extends past max width, then it will be sized to
283 * @param text the string of text.
284 * @param x position on the x axis.
285 * @param y position on the y axis.
286 * @param maxWidth maximum width the text string can have.
288 public void strokeText(String text, double x, double y, double maxWidth);
290 // public ImageData createPixelMap(double x, double y);
292 // public ImageData createPixelMap(ImageData imageData);
294 // public ImageData getPixelMap(double x, double y, double width, double height);
296 // public void putPixelMap(ImageData imageData, double x, double y);
298 // public void putPixelMap(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight);
300 * Sets the global alpha of the current state.
302 * @param alpha value in the range {@code 0.0-1.0}. The value is clamped if
303 * it is out of range.
305 public void setGlobalAlpha(double alpha);
307 public double getGlobalAlpha();
309 public void setGlobalCompositeOperation(String operation);
311 public String getGlobalCompositeOperation();
313 public int getHeight();
315 public int getWidth();
317 // public void setHeight(int height);
319 // public void setWidth(int width);
321 public Object mergeImages(Image a, Image b, Object cachedA, Object cachedB);