Added Dimension class to fix problem with TextMetrics canvas
authorAnton Epple <toni.epple@eppleton.de>
Fri, 24 May 2013 07:36:58 +0200
branchcanvas
changeset 1137964e42c9448d
parent 1136 591d06d8e06f
child 1138 94bd7330ff58
Added Dimension class to fix problem with TextMetrics
javaquery/canvas/src/main/java/net/java/html/canvas/Dimension.java
javaquery/canvas/src/main/java/net/java/html/canvas/GraphicsContext.java
javaquery/canvas/src/main/java/net/java/html/canvas/spi/GraphicsEnvironment.java
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/javaquery/canvas/src/main/java/net/java/html/canvas/Dimension.java	Fri May 24 07:36:58 2013 +0200
     1.3 @@ -0,0 +1,38 @@
     1.4 +/*
     1.5 + * To change this template, choose Tools | Templates
     1.6 + * and open the template in the editor.
     1.7 + */
     1.8 +package net.java.html.canvas;
     1.9 +
    1.10 +/**
    1.11 + *
    1.12 + * @author antonepple
    1.13 + */
    1.14 +public class Dimension {
    1.15 +    double width, height;
    1.16 +
    1.17 +    public Dimension(double width, double height) {
    1.18 +        this.width = width;
    1.19 +        this.height = height;
    1.20 +    }
    1.21 +
    1.22 +    
    1.23 +    
    1.24 +    public double getWidth() {
    1.25 +        return width;
    1.26 +    }
    1.27 +
    1.28 +    public void setWidth(double width) {
    1.29 +        this.width = width;
    1.30 +    }
    1.31 +
    1.32 +    public double getHeight() {
    1.33 +        return height;
    1.34 +    }
    1.35 +
    1.36 +    public void setHeight(double height) {
    1.37 +        this.height = height;
    1.38 +    }
    1.39 +    
    1.40 +    
    1.41 +}
     2.1 --- a/javaquery/canvas/src/main/java/net/java/html/canvas/GraphicsContext.java	Thu May 23 15:36:42 2013 +0200
     2.2 +++ b/javaquery/canvas/src/main/java/net/java/html/canvas/GraphicsContext.java	Fri May 24 07:36:58 2013 +0200
     2.3 @@ -18,7 +18,6 @@
     2.4  package net.java.html.canvas;
     2.5  
     2.6  import net.java.html.canvas.spi.GraphicsEnvironment;
     2.7 -import java.awt.Dimension;
     2.8  
     2.9  /**
    2.10   *
    2.11 @@ -133,17 +132,17 @@
    2.12          graphicsEnvironmentImpl.scale(x, y);
    2.13      }
    2.14  
    2.15 -    public void drawImage(ImageData image, double x, double y){
    2.16 -        graphicsEnvironmentImpl.drawImage(image, x, y);
    2.17 -    }
    2.18 -
    2.19 -    public void drawImage(ImageData image, double x, double y, double width, double height){
    2.20 -        graphicsEnvironmentImpl.drawImage(image, x, y, width, height);
    2.21 -    }
    2.22 -
    2.23 -    public void drawImage(ImageData image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height){
    2.24 -        graphicsEnvironmentImpl.drawImage(image, sx, sy, sWidth, sHeight, x, y, width, height);
    2.25 -    }
    2.26 +////    public void drawImage(ImageData image, double x, double y){
    2.27 +////        graphicsEnvironmentImpl.drawImage(image, x, y);
    2.28 +////    }
    2.29 +////
    2.30 +////    public void drawImage(ImageData image, double x, double y, double width, double height){
    2.31 +////        graphicsEnvironmentImpl.drawImage(image, x, y, width, height);
    2.32 +////    }
    2.33 +////
    2.34 +////    public void drawImage(ImageData image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height){
    2.35 +////        graphicsEnvironmentImpl.drawImage(image, sx, sy, sWidth, sHeight, x, y, width, height);
    2.36 +////    }
    2.37  
    2.38      public void setFillStyle(String style){
    2.39          graphicsEnvironmentImpl.setFillStyle(style);
    2.40 @@ -269,25 +268,25 @@
    2.41          graphicsEnvironmentImpl.strokeText(text, x, y, maxWidth);
    2.42      }
    2.43  
    2.44 -//    public ImageData createImageData(double x, double y){
    2.45 -//        return graphicsEnvironmentImpl.createImageData(x, y);
    2.46 -//    }
    2.47 -//
    2.48 -//    public ImageData createImageData(ImageData imageData){
    2.49 -//        return graphicsEnvironmentImpl.createImageData(imageData);
    2.50 -//    }
    2.51 -//
    2.52 -//    public ImageData getImageData(double x, double y, double width, double height){
    2.53 -//        return graphicsEnvironmentImpl.getImageData(x, y, width, height);
    2.54 -//    }
    2.55 -//
    2.56 -//    public void putImageData(ImageData imageData, double x, double y){
    2.57 -//        graphicsEnvironmentImpl.putImageData(imageData, x, y);
    2.58 -//    }
    2.59 -//
    2.60 -//    public void putImageData(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight){
    2.61 -//        graphicsEnvironmentImpl.putImageData(imageData, x, y, dirtyx, dirtyy, dirtywidth, dirtyheight);
    2.62 -//    }
    2.63 +////    public ImageData createImageData(double x, double y){
    2.64 +////        return graphicsEnvironmentImpl.createImageData(x, y);
    2.65 +////    }
    2.66 +////
    2.67 +////    public ImageData createImageData(ImageData imageData){
    2.68 +////        return graphicsEnvironmentImpl.createImageData(imageData);
    2.69 +////    }
    2.70 +////
    2.71 +////    public ImageData getImageData(double x, double y, double width, double height){
    2.72 +////        return graphicsEnvironmentImpl.getImageData(x, y, width, height);
    2.73 +////    }
    2.74 +////
    2.75 +////    public void putImageData(ImageData imageData, double x, double y){
    2.76 +////        graphicsEnvironmentImpl.putImageData(imageData, x, y);
    2.77 +////    }
    2.78 +////
    2.79 +////    public void putImageData(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight){
    2.80 +////        graphicsEnvironmentImpl.putImageData(imageData, x, y, dirtyx, dirtyy, dirtywidth, dirtyheight);
    2.81 +////    }
    2.82  
    2.83      public void setGlobalAlpha(double alpha){
    2.84          graphicsEnvironmentImpl.setGlobalAlpha(alpha);
    2.85 @@ -309,17 +308,17 @@
    2.86          return new LinearGradient(x0, y0, x1, y1);
    2.87      }
    2.88  
    2.89 -    public Pattern createPattern(ImageData image, String repeat){
    2.90 -        return new Pattern(image, repeat);
    2.91 -    }
    2.92 +////    public Pattern createPattern(ImageData image, String repeat){
    2.93 +////        return new Pattern(image, repeat);
    2.94 +////    }
    2.95  
    2.96      public RadialGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1){
    2.97          return new RadialGradient(x0, y0, r0, x1, y1, r1);
    2.98      }
    2.99  
   2.100 -//    public ImageData getImageDataForPath(String path){
   2.101 -//        return graphicsEnvironmentImpl.getImageForPath(path);
   2.102 -//    }
   2.103 +////    public ImageData getImageDataForPath(String path){
   2.104 +////        return graphicsEnvironmentImpl.getImageForPath(path);
   2.105 +////    }
   2.106  
   2.107      public int getHeight(){
   2.108          return graphicsEnvironmentImpl.getHeight();
     3.1 --- a/javaquery/canvas/src/main/java/net/java/html/canvas/spi/GraphicsEnvironment.java	Thu May 23 15:36:42 2013 +0200
     3.2 +++ b/javaquery/canvas/src/main/java/net/java/html/canvas/spi/GraphicsEnvironment.java	Fri May 24 07:36:58 2013 +0200
     3.3 @@ -17,8 +17,7 @@
     3.4   */
     3.5  package net.java.html.canvas.spi;
     3.6  
     3.7 -import java.awt.Dimension;
     3.8 -import net.java.html.canvas.ImageData;
     3.9 +import net.java.html.canvas.Dimension;
    3.10  import net.java.html.canvas.Style;
    3.11  
    3.12  /**
    3.13 @@ -82,12 +81,12 @@
    3.14  
    3.15      public void scale(double x, double y);
    3.16  
    3.17 -    public void drawImage(ImageData image, double x, double y);
    3.18 -
    3.19 -    public void drawImage(ImageData image, double x, double y, double width, double height);
    3.20 -
    3.21 -    public void drawImage(ImageData image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height);
    3.22 -
    3.23 +////    public void drawImage(ImageData image, double x, double y);
    3.24 +////
    3.25 +////    public void drawImage(ImageData image, double x, double y, double width, double height);
    3.26 +////
    3.27 +////    public void drawImage(ImageData image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height);
    3.28 +//
    3.29      public void setFillStyle(String style);
    3.30  
    3.31      public String getFillStyle();
    3.32 @@ -154,15 +153,15 @@
    3.33  
    3.34      public void strokeText(String text, double x, double y, double maxWidth);
    3.35  
    3.36 -//    public ImageData createImageData(double x, double y);
    3.37 -//
    3.38 -//    public ImageData createImageData(ImageData imageData);
    3.39 -//
    3.40 -//    public ImageData getImageData(double x, double y, double width, double height);
    3.41 -//
    3.42 -//    public void putImageData(ImageData imageData, double x, double y);
    3.43 -//
    3.44 -//    public void putImageData(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight);
    3.45 +////    public ImageData createImageData(double x, double y);
    3.46 +////
    3.47 +////    public ImageData createImageData(ImageData imageData);
    3.48 +////
    3.49 +////    public ImageData getImageData(double x, double y, double width, double height);
    3.50 +////
    3.51 +////    public void putImageData(ImageData imageData, double x, double y);
    3.52 +////
    3.53 +////    public void putImageData(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight);
    3.54  
    3.55      public void setGlobalAlpha(double alpha);
    3.56  
    3.57 @@ -172,7 +171,7 @@
    3.58  
    3.59      public String getGlobalCompositeOperation();
    3.60  
    3.61 -//    public ImageData getImageForPath(String path);
    3.62 +////    public ImageData getImageForPath(String path);
    3.63  
    3.64      public int getHeight();
    3.65