javaquery/canvas/src/main/java/net/java/html/canvas/spi/GraphicsEnvironment.java
author Anton Epple <toni.epple@eppleton.de>
Sat, 07 Sep 2013 18:25:09 +0200
branchcanvas
changeset 1263 088331d4cb76
parent 1158 633572e14095
child 1302 e67363288df1
permissions -rw-r--r--
changes to canvas and graphicsenv to support additional methods fillPolygon and mergeImages
     1 /**
     2  * Back 2 Browser Bytecode Translator Copyright (C) 2012 Jaroslav Tulach
     3  * <jaroslav.tulach@apidesign.org>
     4  *
     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.
     8  *
     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
    12  * details.
    13  *
    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.
    17  */
    18 package net.java.html.canvas.spi;
    19 
    20 import net.java.html.canvas.Dimension;
    21 import net.java.html.canvas.Image;
    22 import net.java.html.canvas.ImageData;
    23 import net.java.html.canvas.Style;
    24 
    25 /**
    26  * Provider API for Canvas. Implement this to add support for your platform.
    27  *
    28  * @author antonepple
    29  */
    30 public interface GraphicsEnvironment {
    31 
    32     public void arc(double centerX,
    33             double centerY,
    34             double startAngle,
    35             double radius,
    36             double endAngle,
    37             boolean ccw);
    38 
    39     public void arcTo(double x1,
    40             double y1,
    41             double x2,
    42             double y2,
    43             double r);
    44 
    45     public boolean isPointInPath(double x, double y);
    46 
    47     public void fill();
    48 
    49     public void stroke();
    50 
    51     public void beginPath();
    52 
    53     public void closePath();
    54 
    55     public void clip();
    56 
    57     public void moveTo(double x, double y);
    58 
    59     public void lineTo(double x, double y);
    60 
    61     public void quadraticCurveTo(double cpx, double cpy, double x, double y);
    62 
    63     public void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y);
    64 
    65     public void fillRect(double x, double y, double width, double height);
    66 
    67     public void strokeRect(double x, double y, double width, double height);
    68 
    69     public void clearRect(double x, double y, double width, double height);
    70 
    71     public void rect(double x, double y, double width, double height);
    72 
    73     public void save();
    74 
    75     public void restore();
    76 
    77     public void rotate(double angle);
    78 
    79     public void transform(double a, double b, double c, double d, double e, double f);
    80 
    81     public void setTransform(double a, double b, double c, double d, double e, double f);
    82 
    83     public void translate(double x, double y);
    84 
    85     public void scale(double x, double y);
    86 
    87     public Object drawImage(Image image,  double x, double y, Object nativeImage);
    88 
    89     public Object drawImage(Image image, double x, double y, double width, double height, Object nativeImage);
    90 
    91     public Object drawImage(Image image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height, Object nativeImage);
    92 
    93    
    94     public int getWidth(Image image, Object nativeImage);
    95     
    96     public int getHeight(Image image, Object nativeImage);
    97     
    98     
    99     
   100     /**
   101      * When implementing you can return an Object of your choice to enable
   102      * caching. Returning null means no caching. When caching is enabled, and
   103      * the cache hasn't been invalidated, the Object you returned will be passed
   104      * as a parameter.
   105      *
   106      * @param style The style object you should use to create your native style
   107      * @param nativeStyle your native object if cached, null otherwise
   108      * @return return native Object for caching
   109      *
   110      */
   111     public Object setFillStyle(Style style, Object nativeStyle);
   112 
   113     /**
   114      * When implementing you can return an Object of your choice to enable
   115      * caching. Returning null means no caching. When caching is enabled, and
   116      * the cache hasn't been invalidated, the Object you returned will be passed
   117      * as a parameter.
   118      *
   119      * @param style The style object you should use to create your native style
   120      * @param nativeStyle your native object if cached, null otherwise
   121      * @return return native Object for caching
   122      *
   123      */
   124     public Object setStrokeStyle(Style style, Object nativeStyle);
   125 
   126     public void setShadowColor(String color);
   127 
   128     public void setShadowBlur(double blur);
   129 
   130     public void setShadowOffsetX(double x);
   131 
   132     public void setShadowOffsetY(double y);
   133     
   134     public String getShadowColor();
   135 
   136     public double getShadowBlur();
   137 
   138     public double getShadowOffsetX();
   139 
   140     public double getShadowOffsetY();
   141 
   142     public String getLineCap();
   143 
   144     public void setLineCap(String style);
   145 
   146     public String getLineJoin();
   147 
   148     public void setLineJoin(String style);
   149 
   150     public double getLineWidth();
   151 
   152     public void setLineWidth(double width);
   153 
   154     public double getMiterLimit();
   155 
   156     public void setMiterLimit(double limit);
   157 
   158     public String getFont();
   159 
   160     public void setFont(String font);
   161 
   162     public String getTextAlign();
   163 
   164     public void setTextAlign(String textAlign);
   165 
   166     public String getTextBaseline();
   167 
   168     public void setTextBaseline(String textbaseline);
   169 
   170     public void fillText(String text, double x, double y);
   171 
   172     public void fillText(String text, double x, double y, double maxWidth);
   173 
   174     public Dimension measureText(String text);
   175 
   176     public void strokeText(String text, double x, double y);
   177 
   178     public void strokeText(String text, double x, double y, double maxWidth);
   179 
   180     public ImageData createPixelMap(double x, double y);
   181 
   182     public ImageData createPixelMap(ImageData imageData);
   183 
   184     public ImageData getPixelMap(double x, double y, double width, double height);
   185 
   186     public void putPixelMap(ImageData imageData, double x, double y);
   187 
   188     public void putPixelMap(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight);
   189     
   190     public void setGlobalAlpha(double alpha);
   191 
   192     public double getGlobalAlpha();
   193 
   194     public void setGlobalCompositeOperation(String operation);
   195 
   196     public String getGlobalCompositeOperation();
   197     
   198     public int getHeight();
   199 
   200     public int getWidth();
   201 
   202     public void setHeight(int height);
   203 
   204     public void setWidth(int width);
   205 
   206     public Object mergeImages(Image a, Image b, Object cachedA, Object cachedB);
   207 }