toni@1129: /** toni@1303: * Back 2 Browser Bytecode Translator toni@1303: * Copyright (C) 2012 Jaroslav Tulach toni@1129: * toni@1303: * This program is free software: you can redistribute it and/or modify toni@1303: * it under the terms of the GNU General Public License as published by toni@1303: * the Free Software Foundation, version 2 of the License. toni@1129: * toni@1303: * This program is distributed in the hope that it will be useful, toni@1303: * but WITHOUT ANY WARRANTY; without even the implied warranty of toni@1303: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the toni@1303: * GNU General Public License for more details. toni@1129: * toni@1303: * You should have received a copy of the GNU General Public License toni@1303: * along with this program. Look for COPYING file in the top folder. toni@1303: * If not, see http://opensource.org/licenses/GPL-2.0. toni@1128: */ toni@1136: package net.java.html.canvas.spi; toni@1128: toni@1137: import net.java.html.canvas.Dimension; toni@1144: import net.java.html.canvas.Image; toni@1136: import net.java.html.canvas.Style; toni@1128: toni@1128: /** toni@1136: * Provider API for Canvas. Implement this to add support for your platform. toni@1141: * toni@1128: * @author antonepple toni@1128: */ toni@1128: public interface GraphicsEnvironment { toni@1129: toni@1128: public void arc(double centerX, toni@1128: double centerY, toni@1128: double startAngle, toni@1128: double radius, toni@1128: double endAngle, toni@1128: boolean ccw); toni@1128: toni@1128: public void arcTo(double x1, toni@1128: double y1, toni@1128: double x2, toni@1128: double y2, toni@1128: double r); toni@1128: toni@1128: public boolean isPointInPath(double x, double y); toni@1128: toni@1128: public void fill(); toni@1128: toni@1128: public void stroke(); toni@1128: toni@1128: public void beginPath(); toni@1128: toni@1128: public void closePath(); toni@1128: toni@1128: public void clip(); toni@1128: toni@1128: public void moveTo(double x, double y); toni@1128: toni@1128: public void lineTo(double x, double y); toni@1128: toni@1128: public void quadraticCurveTo(double cpx, double cpy, double x, double y); toni@1128: toni@1128: public void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); toni@1128: toni@1128: public void fillRect(double x, double y, double width, double height); toni@1128: toni@1128: public void strokeRect(double x, double y, double width, double height); toni@1128: toni@1128: public void clearRect(double x, double y, double width, double height); toni@1128: toni@1128: public void rect(double x, double y, double width, double height); toni@1128: toni@1128: public void save(); toni@1128: toni@1128: public void restore(); toni@1128: toni@1128: public void rotate(double angle); toni@1128: toni@1128: public void transform(double a, double b, double c, double d, double e, double f); toni@1128: toni@1128: public void setTransform(double a, double b, double c, double d, double e, double f); toni@1128: toni@1128: public void translate(double x, double y); toni@1128: toni@1128: public void scale(double x, double y); toni@1128: toni@1302: public Object drawImage(Image image, double x, double y, Object nativeImage); toni@1144: toni@1144: public Object drawImage(Image image, double x, double y, double width, double height, Object nativeImage); toni@1144: toni@1144: 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: toni@1263: public int getWidth(Image image, Object nativeImage); toni@1302: toni@1263: public int getHeight(Image image, Object nativeImage); toni@1302: toni@1141: /** toni@1141: * When implementing you can return an Object of your choice to enable toni@1141: * caching. Returning null means no caching. When caching is enabled, and toni@1141: * the cache hasn't been invalidated, the Object you returned will be passed toni@1141: * as a parameter. toni@1141: * toni@1141: * @param style The style object you should use to create your native style toni@1141: * @param nativeStyle your native object if cached, null otherwise toni@1141: * @return return native Object for caching toni@1141: * toni@1141: */ toni@1141: public Object setFillStyle(Style style, Object nativeStyle); toni@1128: toni@1141: /** toni@1141: * When implementing you can return an Object of your choice to enable toni@1141: * caching. Returning null means no caching. When caching is enabled, and toni@1141: * the cache hasn't been invalidated, the Object you returned will be passed toni@1141: * as a parameter. toni@1141: * toni@1141: * @param style The style object you should use to create your native style toni@1141: * @param nativeStyle your native object if cached, null otherwise toni@1141: * @return return native Object for caching toni@1141: * toni@1141: */ toni@1141: public Object setStrokeStyle(Style style, Object nativeStyle); toni@1128: toni@1302: // public void setShadowColor(String color); toni@1302: // toni@1302: // public void setShadowBlur(double blur); toni@1302: // toni@1302: // public void setShadowOffsetX(double x); toni@1302: // toni@1302: // public void setShadowOffsetY(double y); toni@1302: // toni@1302: // public String getShadowColor(); toni@1302: // toni@1302: // public double getShadowBlur(); toni@1302: // toni@1302: // public double getShadowOffsetX(); toni@1302: // toni@1302: // public double getShadowOffsetY(); toni@1302: /** toni@1302: * Gets the current stroke line cap. toni@1302: * toni@1302: * @return {@code StrokeLineCap} with a value of Butt, Round, or Square. toni@1302: */ toni@1128: public String getLineCap(); toni@1128: toni@1302: /** toni@1302: * Sets the current stroke line cap. toni@1302: * toni@1302: * @param style a value of Butt, Round, or Square. toni@1302: */ toni@1128: public void setLineCap(String style); toni@1128: toni@1302: /** toni@1302: * Gets the current stroke line join. toni@1302: * toni@1302: * @return a value of Miter, Bevel, or Round. toni@1302: */ toni@1128: public String getLineJoin(); toni@1128: toni@1302: /** toni@1302: * Sets the current stroke line join. toni@1302: * toni@1302: * @param style with a value of Miter, Bevel, or Round. toni@1302: */ toni@1128: public void setLineJoin(String style); toni@1128: toni@1302: /** toni@1302: * Gets the current line width. toni@1302: * toni@1302: * @return value between 0 and infinity. toni@1302: */ toni@1128: public double getLineWidth(); toni@1128: toni@1302: /** toni@1302: * Sets the current line width. toni@1302: * toni@1302: * @param width value in the range {0-positive infinity}, with any other toni@1302: * value being ignored and leaving the value unchanged. toni@1302: */ toni@1128: public void setLineWidth(double width); toni@1128: toni@1302: /** toni@1302: * Gets the current miter limit. v toni@1302: * toni@1302: * @return the miter limit value in the range {@code 0.0-positive infinity} toni@1302: */ toni@1128: public double getMiterLimit(); toni@1128: toni@1302: /** toni@1302: * Sets the current miter limit. toni@1302: * toni@1302: * @param limit miter limit value between 0 and positive infinity with any toni@1302: * other value being ignored and leaving the value unchanged. toni@1302: */ toni@1128: public void setMiterLimit(double limit); toni@1128: toni@1302: /** toni@1302: * Gets the current Font. toni@1302: * toni@1302: * @return the Font toni@1302: */ toni@1128: public String getFont(); toni@1128: toni@1302: /** toni@1302: * Sets the current Font. toni@1302: * toni@1302: */ toni@1128: public void setFont(String font); toni@1128: toni@1302: /** toni@1302: * Gets the current {@code TextAlignment}. toni@1302: * toni@1302: * @return TextAlignment with values of Left, Center, Right, or Justify. toni@1302: */ toni@1128: public String getTextAlign(); toni@1128: toni@1302: /** toni@1302: * Defines horizontal text alignment, relative to the text origin. toni@1302: * toni@1302: * @param textAlign with values of Left, Center, Right. toni@1302: */ toni@1128: public void setTextAlign(String textAlign); toni@1128: toni@1302: /** toni@1302: * Sets the current Text Baseline. toni@1302: * toni@1302: * @param baseline with values of Top, Center, Baseline, or Bottom toni@1302: */ toni@1128: public String getTextBaseline(); toni@1128: toni@1302: /** toni@1302: * Sets the current Text Baseline. toni@1302: * toni@1302: * @param baseline with values of Top, Center, Baseline, or Bottom toni@1302: */ toni@1302: public void setTextBaseline(String baseline); toni@1128: toni@1302: /** toni@1302: * Fills the given string of text at position x, y (0,0 at top left) with toni@1302: * the current fill paint attribute. toni@1302: * toni@1302: * @param text the string of text. toni@1302: * @param x position on the x axis. toni@1302: * @param y position on the y axis. toni@1302: */ toni@1128: public void fillText(String text, double x, double y); toni@1128: toni@1302: /** toni@1302: * Fills text and includes a maximum width of the string. toni@1302: * toni@1302: * If the width of the text extends past max width, then it will be sized to toni@1302: * fit. toni@1302: * toni@1302: * @param text the string of text. toni@1302: * @param x position on the x axis. toni@1302: * @param y position on the y axis. toni@1302: * @param maxWidth maximum width the text string can have. toni@1302: */ toni@1128: public void fillText(String text, double x, double y, double maxWidth); toni@1128: toni@1302: /** toni@1302: * The Dimension of this text using the current Font settings toni@1302: * toni@1302: * @param text toni@1302: * @return the Dimension of this text using the current Font settings toni@1302: */ toni@1128: public Dimension measureText(String text); toni@1128: toni@1302: /** toni@1302: * draws the given string of text at position x, y (0,0 at top left) with toni@1302: * the current stroke paint attribute. toni@1302: * toni@1302: * @param text the string of text. toni@1302: * @param x position on the x axis. toni@1302: * @param y position on the y axis. toni@1302: */ toni@1128: public void strokeText(String text, double x, double y); toni@1128: toni@1302: /** toni@1302: * Draws text with stroke paint and includes a maximum width of the string. toni@1302: * toni@1302: * If the width of the text extends past max width, then it will be sized to toni@1302: * fit. toni@1302: * toni@1302: * @param text the string of text. toni@1302: * @param x position on the x axis. toni@1302: * @param y position on the y axis. toni@1302: * @param maxWidth maximum width the text string can have. toni@1302: */ toni@1128: public void strokeText(String text, double x, double y, double maxWidth); toni@1128: toni@1302: // public ImageData createPixelMap(double x, double y); toni@1302: // toni@1302: // public ImageData createPixelMap(ImageData imageData); toni@1302: // toni@1302: // public ImageData getPixelMap(double x, double y, double width, double height); toni@1302: // toni@1302: // public void putPixelMap(ImageData imageData, double x, double y); toni@1302: // toni@1302: // public void putPixelMap(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight); toni@1302: /** toni@1302: * Sets the global alpha of the current state. toni@1302: * toni@1302: * @param alpha value in the range {@code 0.0-1.0}. The value is clamped if toni@1302: * it is out of range. toni@1302: */ toni@1128: public void setGlobalAlpha(double alpha); toni@1128: toni@1128: public double getGlobalAlpha(); toni@1128: toni@1128: public void setGlobalCompositeOperation(String operation); toni@1128: toni@1128: public String getGlobalCompositeOperation(); toni@1302: toni@1128: public int getHeight(); toni@1128: toni@1128: public int getWidth(); toni@1128: toni@1302: // public void setHeight(int height); toni@1302: // toni@1302: // public void setWidth(int width); toni@1263: toni@1263: public Object mergeImages(Image a, Image b, Object cachedA, Object cachedB); toni@1128: }