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