javaquery/canvas/src/main/java/net/java/html/canvas/spi/GraphicsEnvironment.java
author Anton Epple <toni.epple@eppleton.de>
Mon, 27 May 2013 14:13:01 +0200
branchcanvas
changeset 1158 633572e14095
parent 1144 5bf850c5b7f1
child 1263 088331d4cb76
permissions -rw-r--r--
fixed bugs in Image Handling
     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     /**
    95      * When implementing you can return an Object of your choice to enable
    96      * caching. Returning null means no caching. When caching is enabled, and
    97      * the cache hasn't been invalidated, the Object you returned will be passed
    98      * as a parameter.
    99      *
   100      * @param style The style object you should use to create your native style
   101      * @param nativeStyle your native object if cached, null otherwise
   102      * @return return native Object for caching
   103      *
   104      */
   105     public Object setFillStyle(Style style, Object nativeStyle);
   106 
   107     /**
   108      * When implementing you can return an Object of your choice to enable
   109      * caching. Returning null means no caching. When caching is enabled, and
   110      * the cache hasn't been invalidated, the Object you returned will be passed
   111      * as a parameter.
   112      *
   113      * @param style The style object you should use to create your native style
   114      * @param nativeStyle your native object if cached, null otherwise
   115      * @return return native Object for caching
   116      *
   117      */
   118     public Object setStrokeStyle(Style style, Object nativeStyle);
   119 
   120     public void setShadowColor(String color);
   121 
   122     public void setShadowBlur(double blur);
   123 
   124     public void setShadowOffsetX(double x);
   125 
   126     public void setShadowOffsetY(double y);
   127     
   128     public String getShadowColor();
   129 
   130     public double getShadowBlur();
   131 
   132     public double getShadowOffsetX();
   133 
   134     public double getShadowOffsetY();
   135 
   136     public String getLineCap();
   137 
   138     public void setLineCap(String style);
   139 
   140     public String getLineJoin();
   141 
   142     public void setLineJoin(String style);
   143 
   144     public double getLineWidth();
   145 
   146     public void setLineWidth(double width);
   147 
   148     public double getMiterLimit();
   149 
   150     public void setMiterLimit(double limit);
   151 
   152     public String getFont();
   153 
   154     public void setFont(String font);
   155 
   156     public String getTextAlign();
   157 
   158     public void setTextAlign(String textAlign);
   159 
   160     public String getTextBaseline();
   161 
   162     public void setTextBaseline(String textbaseline);
   163 
   164     public void fillText(String text, double x, double y);
   165 
   166     public void fillText(String text, double x, double y, double maxWidth);
   167 
   168     public Dimension measureText(String text);
   169 
   170     public void strokeText(String text, double x, double y);
   171 
   172     public void strokeText(String text, double x, double y, double maxWidth);
   173 
   174     public ImageData createPixelMap(double x, double y);
   175 
   176     public ImageData createPixelMap(ImageData imageData);
   177 
   178     public ImageData getPixelMap(double x, double y, double width, double height);
   179 
   180     public void putPixelMap(ImageData imageData, double x, double y);
   181 
   182     public void putPixelMap(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight);
   183     
   184     public void setGlobalAlpha(double alpha);
   185 
   186     public double getGlobalAlpha();
   187 
   188     public void setGlobalCompositeOperation(String operation);
   189 
   190     public String getGlobalCompositeOperation();
   191     
   192     public int getHeight();
   193 
   194     public int getWidth();
   195 
   196     public void setHeight(int height);
   197 
   198     public void setWidth(int width);
   199 }