javaquery/canvas/src/main/java/net/java/html/canvas/GraphicsContext.java
author Anton Epple <toni.epple@eppleton.de>
Thu, 23 May 2013 15:36:42 +0200
branchcanvas
changeset 1136 591d06d8e06f
parent 1133 0ae830f00e0c
child 1137 964e42c9448d
permissions -rw-r--r--
moved GRaphicsEnvironment to SPI package
     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;
    19 
    20 import net.java.html.canvas.spi.GraphicsEnvironment;
    21 import java.awt.Dimension;
    22 
    23 /**
    24  *
    25  * @author antonepple
    26  */
    27 public final class GraphicsContext {
    28 
    29     GraphicsEnvironment graphicsEnvironmentImpl;
    30 
    31     public GraphicsContext(GraphicsEnvironment graphicsEnvironment) {
    32         this.graphicsEnvironmentImpl = graphicsEnvironment;
    33     }
    34 
    35     public void arc(double centerX,
    36             double centerY,
    37             double startAngle,
    38             double radius,
    39             double endAngle,
    40             boolean ccw) {
    41         graphicsEnvironmentImpl.arc(centerX, centerY, startAngle, radius, endAngle, ccw);
    42     }
    43 
    44     public void arcTo(double x1,
    45             double y1,
    46             double x2,
    47             double y2,
    48             double r) {
    49         graphicsEnvironmentImpl.arcTo(x1, y1, x2, y2, r);
    50     }
    51 
    52     public boolean isPointInPath(double x, double y) {
    53         return graphicsEnvironmentImpl.isPointInPath(x, y);
    54     }
    55 
    56     public void fill() {
    57         graphicsEnvironmentImpl.fill();
    58     }
    59 
    60     public void stroke() {
    61         graphicsEnvironmentImpl.stroke();
    62     }
    63 
    64     public void beginPath() {
    65         graphicsEnvironmentImpl.beginPath();
    66     }
    67 
    68     public void closePath(){
    69         graphicsEnvironmentImpl.closePath();
    70     }
    71 
    72     public void clip(){
    73         graphicsEnvironmentImpl.clip();
    74     }
    75 
    76     public void moveTo(double x, double y){
    77         graphicsEnvironmentImpl.moveTo(x, y);
    78     }
    79 
    80     public void lineTo(double x, double y){
    81         graphicsEnvironmentImpl.lineTo(x, y);
    82     }
    83 
    84     public void quadraticCurveTo(double cpx, double cpy, double x, double y){
    85     graphicsEnvironmentImpl.quadraticCurveTo(cpx, cpy, x, y);
    86     }
    87 
    88     public void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y){
    89         graphicsEnvironmentImpl.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
    90     }
    91 
    92     public void fillRect(double x, double y, double width, double height){
    93         graphicsEnvironmentImpl.fillRect(x, y, width, height);
    94     }
    95 
    96     public void strokeRect(double x, double y, double width, double height){
    97     graphicsEnvironmentImpl.strokeRect(x, y, width, height);
    98     }
    99 
   100     public void clearRect(double x, double y, double width, double height){
   101         graphicsEnvironmentImpl.clearRect(x, y, width, height);
   102     }
   103 
   104     public void rect(double x, double y, double width, double height){
   105         graphicsEnvironmentImpl.rect(x, y, width, height);
   106     }
   107 
   108     public void save(){
   109         graphicsEnvironmentImpl.save();
   110     }
   111 
   112     public void restore(){
   113         graphicsEnvironmentImpl.restore();
   114     }
   115 
   116     public void rotate(double angle){
   117         graphicsEnvironmentImpl.rotate(angle);
   118     }
   119 
   120     public void transform(double a, double b, double c, double d, double e, double f){
   121         graphicsEnvironmentImpl.transform(a, b, c, d, e, f);
   122     }
   123 
   124     public void setTransform(double a, double b, double c, double d, double e, double f){
   125         graphicsEnvironmentImpl.setTransform(a, b, c, d, e, f);
   126     }
   127 
   128     public void translate(double x, double y){
   129         graphicsEnvironmentImpl.translate(x, y);
   130     }
   131 
   132     public void scale(double x, double y){
   133         graphicsEnvironmentImpl.scale(x, y);
   134     }
   135 
   136     public void drawImage(ImageData image, double x, double y){
   137         graphicsEnvironmentImpl.drawImage(image, x, y);
   138     }
   139 
   140     public void drawImage(ImageData image, double x, double y, double width, double height){
   141         graphicsEnvironmentImpl.drawImage(image, x, y, width, height);
   142     }
   143 
   144     public void drawImage(ImageData image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height){
   145         graphicsEnvironmentImpl.drawImage(image, sx, sy, sWidth, sHeight, x, y, width, height);
   146     }
   147 
   148     public void setFillStyle(String style){
   149         graphicsEnvironmentImpl.setFillStyle(style);
   150     }
   151 
   152     public String getFillStyle(){
   153         return graphicsEnvironmentImpl.getFillStyle();
   154     }
   155 
   156     public void setStrokeStyle(String style){
   157         graphicsEnvironmentImpl.setStrokeStyle(style);
   158     }
   159 
   160     public void setShadowColor(String color){
   161         graphicsEnvironmentImpl.setShadowColor(color);
   162     }
   163 
   164     public void setShadowBlur(double blur){
   165         graphicsEnvironmentImpl.setShadowBlur(blur);
   166     }
   167 
   168     public void setShadowOffsetX(double x){
   169         graphicsEnvironmentImpl.setShadowOffsetX(x);
   170     }
   171 
   172     public void setShadowOffsetY(double y){
   173         graphicsEnvironmentImpl.setShadowOffsetY(y);
   174     }
   175 
   176     public String getStrokeStyle(){
   177         return graphicsEnvironmentImpl.getStrokeStyle();
   178     }
   179 
   180     public String getShadowColor(){
   181         return graphicsEnvironmentImpl.getShadowColor();
   182     }
   183 
   184     public double getShadowBlur(){
   185         return graphicsEnvironmentImpl.getShadowBlur();
   186         }
   187 
   188     public double getShadowOffsetX(){
   189         return graphicsEnvironmentImpl.getShadowOffsetX();
   190     }
   191 
   192     public double getShadowOffsetY(){
   193         return graphicsEnvironmentImpl.getShadowOffsetY();
   194     }
   195 
   196     public String getLineCap(){
   197         return graphicsEnvironmentImpl.getLineCap();
   198     }
   199 
   200     public void setLineCap(String style){
   201         graphicsEnvironmentImpl.setLineCap(style);
   202     }
   203 
   204     public String getLineJoin(){
   205         return graphicsEnvironmentImpl.getLineJoin();
   206     }
   207 
   208     public void setLineJoin(String style){
   209         graphicsEnvironmentImpl.setLineJoin(style);
   210     }
   211 
   212     public double getLineWidth(){
   213         return graphicsEnvironmentImpl.getLineWidth();
   214     }
   215 
   216     public void setLineWidth(double width){
   217         graphicsEnvironmentImpl.setLineWidth(width);
   218     }
   219 
   220     public double getMiterLimit(){
   221         return graphicsEnvironmentImpl.getMiterLimit();
   222     }
   223 
   224     public void setMiterLimit(double limit){
   225         graphicsEnvironmentImpl.setMiterLimit(limit);
   226     }
   227 
   228     public String getFont(){
   229         return graphicsEnvironmentImpl.getFont();
   230     }
   231 
   232     public void setFont(String font){
   233         graphicsEnvironmentImpl.setFont(font);
   234     }
   235 
   236     public String getTextAlign(){
   237         return graphicsEnvironmentImpl.getTextAlign();
   238     }
   239 
   240     public void setTextAlign(String textAlign){
   241         graphicsEnvironmentImpl.setTextAlign(textAlign);
   242     }
   243 
   244     public String getTextBaseline(){
   245         return graphicsEnvironmentImpl.getTextBaseline();
   246     }
   247 
   248     public void setTextBaseline(String textbaseline){
   249         graphicsEnvironmentImpl.setTextBaseline(textbaseline);
   250     }
   251 
   252     public void fillText(String text, double x, double y){
   253         graphicsEnvironmentImpl.fillText(text, x, y);
   254     }
   255 
   256     public void fillText(String text, double x, double y, double maxWidth){
   257         graphicsEnvironmentImpl.fillText(text, x, y, maxWidth);
   258     }
   259 
   260     public Dimension measureText(String text){
   261         return graphicsEnvironmentImpl.measureText(text);
   262     }
   263 
   264     public void strokeText(String text, double x, double y){
   265         graphicsEnvironmentImpl.strokeText(text, x, y);
   266     }
   267 
   268     public void strokeText(String text, double x, double y, double maxWidth){
   269         graphicsEnvironmentImpl.strokeText(text, x, y, maxWidth);
   270     }
   271 
   272 //    public ImageData createImageData(double x, double y){
   273 //        return graphicsEnvironmentImpl.createImageData(x, y);
   274 //    }
   275 //
   276 //    public ImageData createImageData(ImageData imageData){
   277 //        return graphicsEnvironmentImpl.createImageData(imageData);
   278 //    }
   279 //
   280 //    public ImageData getImageData(double x, double y, double width, double height){
   281 //        return graphicsEnvironmentImpl.getImageData(x, y, width, height);
   282 //    }
   283 //
   284 //    public void putImageData(ImageData imageData, double x, double y){
   285 //        graphicsEnvironmentImpl.putImageData(imageData, x, y);
   286 //    }
   287 //
   288 //    public void putImageData(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight){
   289 //        graphicsEnvironmentImpl.putImageData(imageData, x, y, dirtyx, dirtyy, dirtywidth, dirtyheight);
   290 //    }
   291 
   292     public void setGlobalAlpha(double alpha){
   293         graphicsEnvironmentImpl.setGlobalAlpha(alpha);
   294     }
   295 
   296     public double getGlobalAlpha(){
   297         return graphicsEnvironmentImpl.getGlobalAlpha();
   298     }
   299 
   300     public void setGlobalCompositeOperation(String operation){
   301         graphicsEnvironmentImpl.setGlobalCompositeOperation(operation);
   302     }
   303 
   304     public String getGlobalCompositeOperation(){
   305         return graphicsEnvironmentImpl.getGlobalCompositeOperation();
   306     }
   307 
   308     public LinearGradient createLinearGradient(double x0, double y0, double x1, double y1){
   309         return new LinearGradient(x0, y0, x1, y1);
   310     }
   311 
   312     public Pattern createPattern(ImageData image, String repeat){
   313         return new Pattern(image, repeat);
   314     }
   315 
   316     public RadialGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1){
   317         return new RadialGradient(x0, y0, r0, x1, y1, r1);
   318     }
   319 
   320 //    public ImageData getImageDataForPath(String path){
   321 //        return graphicsEnvironmentImpl.getImageForPath(path);
   322 //    }
   323 
   324     public int getHeight(){
   325         return graphicsEnvironmentImpl.getHeight();
   326     }
   327 
   328     public int getWidth(){
   329         return graphicsEnvironmentImpl.getWidth();
   330     }
   331 
   332     public void setHeight(int height){
   333         graphicsEnvironmentImpl.setHeight(height);
   334     }
   335 
   336     public void setWidth(int width){
   337         graphicsEnvironmentImpl.setWidth(width);
   338     }
   339 }