javaquery/canvas/src/main/java/net/java/html/canvas/spi/GraphicsEnvironment.java
author Anton Epple <toni.epple@eppleton.de>
Mon, 27 May 2013 08:30:18 +0200
branchcanvas
changeset 1144 5bf850c5b7f1
parent 1141 69c81bdaf193
child 1158 633572e14095
permissions -rw-r--r--
Readded Image and ImageData to have the complete API again. No need to use Data in API anymore. Added caching to Image. Image are not required to be added to the page anymore, but are created in javaScript instead.
toni@1129
     1
/**
toni@1129
     2
 * Back 2 Browser Bytecode Translator Copyright (C) 2012 Jaroslav Tulach
toni@1129
     3
 * <jaroslav.tulach@apidesign.org>
toni@1129
     4
 *
toni@1129
     5
 * This program is free software: you can redistribute it and/or modify it under
toni@1129
     6
 * the terms of the GNU General Public License as published by the Free Software
toni@1129
     7
 * Foundation, version 2 of the License.
toni@1129
     8
 *
toni@1129
     9
 * This program is distributed in the hope that it will be useful, but WITHOUT
toni@1129
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
toni@1129
    11
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
toni@1129
    12
 * details.
toni@1129
    13
 *
toni@1129
    14
 * You should have received a copy of the GNU General Public License along with
toni@1129
    15
 * this program. Look for COPYING file in the top folder. If not, see
toni@1129
    16
 * http://opensource.org/licenses/GPL-2.0.
toni@1128
    17
 */
toni@1136
    18
package net.java.html.canvas.spi;
toni@1128
    19
toni@1137
    20
import net.java.html.canvas.Dimension;
toni@1144
    21
import net.java.html.canvas.Image;
toni@1144
    22
import net.java.html.canvas.ImageData;
toni@1136
    23
import net.java.html.canvas.Style;
toni@1128
    24
toni@1128
    25
/**
toni@1136
    26
 * Provider API for Canvas. Implement this to add support for your platform.
toni@1141
    27
 *
toni@1128
    28
 * @author antonepple
toni@1128
    29
 */
toni@1128
    30
public interface GraphicsEnvironment {
toni@1129
    31
toni@1128
    32
    public void arc(double centerX,
toni@1128
    33
            double centerY,
toni@1128
    34
            double startAngle,
toni@1128
    35
            double radius,
toni@1128
    36
            double endAngle,
toni@1128
    37
            boolean ccw);
toni@1128
    38
toni@1128
    39
    public void arcTo(double x1,
toni@1128
    40
            double y1,
toni@1128
    41
            double x2,
toni@1128
    42
            double y2,
toni@1128
    43
            double r);
toni@1128
    44
toni@1128
    45
    public boolean isPointInPath(double x, double y);
toni@1128
    46
toni@1128
    47
    public void fill();
toni@1128
    48
toni@1128
    49
    public void stroke();
toni@1128
    50
toni@1128
    51
    public void beginPath();
toni@1128
    52
toni@1128
    53
    public void closePath();
toni@1128
    54
toni@1128
    55
    public void clip();
toni@1128
    56
toni@1128
    57
    public void moveTo(double x, double y);
toni@1128
    58
toni@1128
    59
    public void lineTo(double x, double y);
toni@1128
    60
toni@1128
    61
    public void quadraticCurveTo(double cpx, double cpy, double x, double y);
toni@1128
    62
toni@1128
    63
    public void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y);
toni@1128
    64
toni@1128
    65
    public void fillRect(double x, double y, double width, double height);
toni@1128
    66
toni@1128
    67
    public void strokeRect(double x, double y, double width, double height);
toni@1128
    68
toni@1128
    69
    public void clearRect(double x, double y, double width, double height);
toni@1128
    70
toni@1128
    71
    public void rect(double x, double y, double width, double height);
toni@1128
    72
toni@1128
    73
    public void save();
toni@1128
    74
toni@1128
    75
    public void restore();
toni@1128
    76
toni@1128
    77
    public void rotate(double angle);
toni@1128
    78
toni@1128
    79
    public void transform(double a, double b, double c, double d, double e, double f);
toni@1128
    80
toni@1128
    81
    public void setTransform(double a, double b, double c, double d, double e, double f);
toni@1128
    82
toni@1128
    83
    public void translate(double x, double y);
toni@1128
    84
toni@1128
    85
    public void scale(double x, double y);
toni@1128
    86
toni@1144
    87
    public Object drawImage(Image image,  double x, double y, Object nativeImage);
toni@1144
    88
toni@1144
    89
    public Object drawImage(Image image, double x, double y, double width, double height, Object nativeImage);
toni@1144
    90
toni@1144
    91
    public Object drawImage(Image image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height, Object nativeImage);
toni@1144
    92
toni@1128
    93
toni@1141
    94
    /**
toni@1141
    95
     * When implementing you can return an Object of your choice to enable
toni@1141
    96
     * caching. Returning null means no caching. When caching is enabled, and
toni@1141
    97
     * the cache hasn't been invalidated, the Object you returned will be passed
toni@1141
    98
     * as a parameter.
toni@1141
    99
     *
toni@1141
   100
     * @param style The style object you should use to create your native style
toni@1141
   101
     * @param nativeStyle your native object if cached, null otherwise
toni@1141
   102
     * @return return native Object for caching
toni@1141
   103
     *
toni@1141
   104
     */
toni@1141
   105
    public Object setFillStyle(Style style, Object nativeStyle);
toni@1128
   106
toni@1141
   107
    /**
toni@1141
   108
     * When implementing you can return an Object of your choice to enable
toni@1141
   109
     * caching. Returning null means no caching. When caching is enabled, and
toni@1141
   110
     * the cache hasn't been invalidated, the Object you returned will be passed
toni@1141
   111
     * as a parameter.
toni@1141
   112
     *
toni@1141
   113
     * @param style The style object you should use to create your native style
toni@1141
   114
     * @param nativeStyle your native object if cached, null otherwise
toni@1141
   115
     * @return return native Object for caching
toni@1141
   116
     *
toni@1141
   117
     */
toni@1141
   118
    public Object setStrokeStyle(Style style, Object nativeStyle);
toni@1128
   119
toni@1128
   120
    public void setShadowColor(String color);
toni@1128
   121
toni@1128
   122
    public void setShadowBlur(double blur);
toni@1128
   123
toni@1128
   124
    public void setShadowOffsetX(double x);
toni@1128
   125
toni@1128
   126
    public void setShadowOffsetY(double y);
toni@1144
   127
    
toni@1128
   128
    public String getShadowColor();
toni@1128
   129
toni@1128
   130
    public double getShadowBlur();
toni@1128
   131
toni@1128
   132
    public double getShadowOffsetX();
toni@1128
   133
toni@1128
   134
    public double getShadowOffsetY();
toni@1128
   135
toni@1128
   136
    public String getLineCap();
toni@1128
   137
toni@1128
   138
    public void setLineCap(String style);
toni@1128
   139
toni@1128
   140
    public String getLineJoin();
toni@1128
   141
toni@1128
   142
    public void setLineJoin(String style);
toni@1128
   143
toni@1128
   144
    public double getLineWidth();
toni@1128
   145
toni@1128
   146
    public void setLineWidth(double width);
toni@1128
   147
toni@1128
   148
    public double getMiterLimit();
toni@1128
   149
toni@1128
   150
    public void setMiterLimit(double limit);
toni@1128
   151
toni@1128
   152
    public String getFont();
toni@1128
   153
toni@1128
   154
    public void setFont(String font);
toni@1128
   155
toni@1128
   156
    public String getTextAlign();
toni@1128
   157
toni@1128
   158
    public void setTextAlign(String textAlign);
toni@1128
   159
toni@1128
   160
    public String getTextBaseline();
toni@1128
   161
toni@1128
   162
    public void setTextBaseline(String textbaseline);
toni@1128
   163
toni@1128
   164
    public void fillText(String text, double x, double y);
toni@1128
   165
toni@1128
   166
    public void fillText(String text, double x, double y, double maxWidth);
toni@1128
   167
toni@1128
   168
    public Dimension measureText(String text);
toni@1128
   169
toni@1128
   170
    public void strokeText(String text, double x, double y);
toni@1128
   171
toni@1128
   172
    public void strokeText(String text, double x, double y, double maxWidth);
toni@1128
   173
toni@1144
   174
    public ImageData createPixelMap(double x, double y);
toni@1144
   175
toni@1144
   176
    public ImageData createPixelMap(ImageData imageData);
toni@1144
   177
toni@1144
   178
    public ImageData getPixelMap(double x, double y, double width, double height);
toni@1144
   179
toni@1144
   180
    public void putPixelMap(ImageData imageData, double x, double y);
toni@1144
   181
toni@1144
   182
    public void putPixelMap(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight);
toni@1144
   183
    
toni@1128
   184
    public void setGlobalAlpha(double alpha);
toni@1128
   185
toni@1128
   186
    public double getGlobalAlpha();
toni@1128
   187
toni@1128
   188
    public void setGlobalCompositeOperation(String operation);
toni@1128
   189
toni@1128
   190
    public String getGlobalCompositeOperation();
toni@1128
   191
toni@1144
   192
    public Image getImageForPath(String path);
toni@1144
   193
    
toni@1128
   194
    public int getHeight();
toni@1128
   195
toni@1128
   196
    public int getWidth();
toni@1128
   197
toni@1128
   198
    public void setHeight(int height);
toni@1128
   199
toni@1128
   200
    public void setWidth(int width);
toni@1128
   201
}