diff -r 591d06d8e06f -r 69c81bdaf193 javaquery/canvas/src/main/java/net/java/html/canvas/Style.java --- a/javaquery/canvas/src/main/java/net/java/html/canvas/Style.java Thu May 23 15:36:42 2013 +0200 +++ b/javaquery/canvas/src/main/java/net/java/html/canvas/Style.java Fri May 24 12:29:58 2013 +0200 @@ -23,21 +23,34 @@ */ public class Style { + private Object cached; + private int cacheHash; + Style() { } - - public static final RadialGradient createRadialGradient( double x0, double y0,double r0, double x1, double y1, double r1){ + + public static final RadialGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1) { return new RadialGradient(x0, y0, r0, x1, y1, r1); } - - public static final LinearGradient createLinearGradient(double x0, double y0, double x1, double y1){ + + public static final LinearGradient createLinearGradient(double x0, double y0, double x1, double y1) { return new LinearGradient(x0, y0, x1, y1); } - - public static final Pattern createPattern(ImageData imageData, String repeat){ + + public static final Pattern createPattern(ImageData imageData, String repeat) { return new Pattern(imageData, repeat); } - - - + + void cache(Object toCache) { + cacheHash = hashCode(); + this.cached = toCache; + } + + private boolean isCached() { + return cacheHash == hashCode(); + } + + Object getCached() { + return isCached() ? cached : null; + } }