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