The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 17 | package android.graphics; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 18 | |
| 19 | import com.android.layoutlib.api.ILayoutLog; |
| 20 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | import android.graphics.DrawFilter; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | import android.graphics.Picture; |
| 23 | import android.graphics.PorterDuff; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | import android.graphics.Rect; |
| 25 | import android.graphics.RectF; |
| 26 | import android.graphics.Region; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | import android.graphics.Xfermode; |
| 28 | import android.graphics.Paint.Align; |
Xavier Ducrohet | 9a4593f | 2009-11-08 15:15:01 -0800 | [diff] [blame] | 29 | import android.graphics.Paint.FontInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | import android.graphics.Paint.Style; |
| 31 | import android.graphics.Region.Op; |
| 32 | |
| 33 | import java.awt.AlphaComposite; |
Xavier Ducrohet | 5ac8f40 | 2010-01-14 19:19:06 -0800 | [diff] [blame] | 34 | import java.awt.BasicStroke; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | import java.awt.Color; |
| 36 | import java.awt.Composite; |
| 37 | import java.awt.Graphics2D; |
| 38 | import java.awt.Rectangle; |
| 39 | import java.awt.RenderingHints; |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 40 | import java.awt.geom.AffineTransform; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | import java.awt.image.BufferedImage; |
Xavier Ducrohet | 9a4593f | 2009-11-08 15:15:01 -0800 | [diff] [blame] | 42 | import java.util.List; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | import java.util.Stack; |
| 44 | |
| 45 | import javax.microedition.khronos.opengles.GL; |
| 46 | |
| 47 | /** |
| 48 | * Re-implementation of the Canvas, 100% in java on top of a BufferedImage. |
| 49 | */ |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 50 | public class Canvas extends _Original_Canvas { |
| 51 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | private BufferedImage mBufferedImage; |
| 53 | private final Stack<Graphics2D> mGraphicsStack = new Stack<Graphics2D>(); |
| 54 | private final ILayoutLog mLogger; |
| 55 | |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 56 | public Canvas() { |
| 57 | mLogger = null; |
| 58 | // the mBufferedImage will be taken from a bitmap in #setBitmap() |
| 59 | } |
| 60 | |
| 61 | public Canvas(Bitmap bitmap) { |
| 62 | mLogger = null; |
| 63 | mBufferedImage = bitmap.getImage(); |
| 64 | mGraphicsStack.push(mBufferedImage.createGraphics()); |
| 65 | } |
| 66 | |
| 67 | public Canvas(int nativeCanvas) { |
| 68 | mLogger = null; |
| 69 | throw new UnsupportedOperationException("Can't create Canvas(int)"); |
| 70 | } |
| 71 | |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 72 | // custom constructors for our use. |
| 73 | public Canvas(int width, int height, ILayoutLog logger) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | mLogger = logger; |
| 75 | mBufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); |
| 76 | mGraphicsStack.push(mBufferedImage.createGraphics()); |
| 77 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 78 | |
| 79 | public Canvas(int width, int height) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | this(width, height, null /* logger*/); |
| 81 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 82 | |
| 83 | // custom mehtods |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 84 | public BufferedImage getImage() { |
| 85 | return mBufferedImage; |
| 86 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 87 | |
| 88 | public Graphics2D getGraphics2d() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 89 | return mGraphicsStack.peek(); |
| 90 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 91 | |
| 92 | public void dispose() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 93 | while (mGraphicsStack.size() > 0) { |
| 94 | mGraphicsStack.pop().dispose(); |
| 95 | } |
| 96 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 97 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 98 | /** |
| 99 | * Creates a new {@link Graphics2D} based on the {@link Paint} parameters. |
| 100 | * <p/>The object must be disposed ({@link Graphics2D#dispose()}) after being used. |
| 101 | */ |
Xavier Ducrohet | 36ab128 | 2010-01-15 11:24:44 -0800 | [diff] [blame] | 102 | private Graphics2D getCustomGraphics(Paint paint) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 103 | // make new one |
Xavier Ducrohet | 36ab128 | 2010-01-15 11:24:44 -0800 | [diff] [blame] | 104 | Graphics2D g = getGraphics2d(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | g = (Graphics2D)g.create(); |
Xavier Ducrohet | 36ab128 | 2010-01-15 11:24:44 -0800 | [diff] [blame] | 106 | |
| 107 | // configure it |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 108 | g.setColor(new Color(paint.getColor())); |
| 109 | int alpha = paint.getAlpha(); |
| 110 | float falpha = alpha / 255.f; |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 111 | |
Xavier Ducrohet | 36ab128 | 2010-01-15 11:24:44 -0800 | [diff] [blame] | 112 | Style style = paint.getStyle(); |
| 113 | if (style == Style.STROKE || style == Style.FILL_AND_STROKE) { |
| 114 | PathEffect e = paint.getPathEffect(); |
| 115 | if (e instanceof DashPathEffect) { |
| 116 | DashPathEffect dpe = (DashPathEffect)e; |
| 117 | g.setStroke(new BasicStroke( |
| 118 | paint.getStrokeWidth(), |
| 119 | paint.getStrokeCap().getJavaCap(), |
| 120 | paint.getStrokeJoin().getJavaJoin(), |
| 121 | paint.getStrokeMiter(), |
| 122 | dpe.getIntervals(), |
| 123 | dpe.getPhase())); |
| 124 | } else { |
| 125 | g.setStroke(new BasicStroke( |
| 126 | paint.getStrokeWidth(), |
| 127 | paint.getStrokeCap().getJavaCap(), |
| 128 | paint.getStrokeJoin().getJavaJoin(), |
| 129 | paint.getStrokeMiter())); |
| 130 | } |
Xavier Ducrohet | 5ac8f40 | 2010-01-14 19:19:06 -0800 | [diff] [blame] | 131 | } |
| 132 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 133 | Xfermode xfermode = paint.getXfermode(); |
| 134 | if (xfermode instanceof PorterDuffXfermode) { |
| 135 | PorterDuff.Mode mode = ((PorterDuffXfermode)xfermode).getMode(); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 136 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 137 | setModeInGraphics(mode, g, falpha); |
| 138 | } else { |
| 139 | if (mLogger != null && xfermode != null) { |
| 140 | mLogger.warning(String.format( |
| 141 | "Xfermode '%1$s' is not supported in the Layout Editor.", |
| 142 | xfermode.getClass().getCanonicalName())); |
| 143 | } |
| 144 | g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, falpha)); |
| 145 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 146 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 147 | Shader shader = paint.getShader(); |
Xavier Ducrohet | 63b2e61 | 2010-01-13 20:30:26 -0800 | [diff] [blame] | 148 | if (shader != null) { |
Xavier Ducrohet | 5e08302 | 2010-01-14 10:30:16 -0800 | [diff] [blame] | 149 | java.awt.Paint shaderPaint = shader.getJavaPaint(); |
Xavier Ducrohet | 63b2e61 | 2010-01-13 20:30:26 -0800 | [diff] [blame] | 150 | if (shaderPaint != null) { |
| 151 | g.setPaint(shaderPaint); |
| 152 | } else { |
| 153 | if (mLogger != null) { |
| 154 | mLogger.warning(String.format( |
| 155 | "Shader '%1$s' is not supported in the Layout Editor.", |
| 156 | shader.getClass().getCanonicalName())); |
| 157 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 158 | } |
| 159 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 160 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 161 | return g; |
| 162 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 163 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 164 | private void setModeInGraphics(PorterDuff.Mode mode, Graphics2D g, float falpha) { |
| 165 | switch (mode) { |
| 166 | case CLEAR: |
| 167 | g.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, falpha)); |
| 168 | break; |
| 169 | case DARKEN: |
| 170 | break; |
| 171 | case DST: |
| 172 | g.setComposite(AlphaComposite.getInstance(AlphaComposite.DST, falpha)); |
| 173 | break; |
| 174 | case DST_ATOP: |
| 175 | g.setComposite(AlphaComposite.getInstance(AlphaComposite.DST_ATOP, falpha)); |
| 176 | break; |
| 177 | case DST_IN: |
| 178 | g.setComposite(AlphaComposite.getInstance(AlphaComposite.DST_IN, falpha)); |
| 179 | break; |
| 180 | case DST_OUT: |
| 181 | g.setComposite(AlphaComposite.getInstance(AlphaComposite.DST_OUT, falpha)); |
| 182 | break; |
| 183 | case DST_OVER: |
| 184 | g.setComposite(AlphaComposite.getInstance(AlphaComposite.DST_OVER, falpha)); |
| 185 | break; |
| 186 | case LIGHTEN: |
| 187 | break; |
| 188 | case MULTIPLY: |
| 189 | break; |
| 190 | case SCREEN: |
| 191 | break; |
| 192 | case SRC: |
| 193 | g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, falpha)); |
| 194 | break; |
| 195 | case SRC_ATOP: |
| 196 | g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, falpha)); |
| 197 | break; |
| 198 | case SRC_IN: |
| 199 | g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_IN, falpha)); |
| 200 | break; |
| 201 | case SRC_OUT: |
| 202 | g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OUT, falpha)); |
| 203 | break; |
| 204 | case SRC_OVER: |
| 205 | g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, falpha)); |
| 206 | break; |
| 207 | case XOR: |
| 208 | g.setComposite(AlphaComposite.getInstance(AlphaComposite.XOR, falpha)); |
| 209 | break; |
| 210 | } |
| 211 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 212 | |
| 213 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 214 | // -------------------- |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 215 | // OVERRIDEN ENUMS |
| 216 | // This is needed since we rename Canvas into _Original_Canvas |
| 217 | // -------------------- |
| 218 | |
| 219 | public enum EdgeType { |
| 220 | BW(0), //!< treat edges by just rounding to nearest pixel boundary |
| 221 | AA(1); //!< treat edges by rounding-out, since they may be antialiased |
| 222 | |
| 223 | EdgeType(int nativeInt) { |
| 224 | this.nativeInt = nativeInt; |
| 225 | } |
| 226 | final int nativeInt; |
| 227 | } |
| 228 | |
| 229 | |
| 230 | // -------------------- |
| 231 | // OVERRIDEN METHODS |
| 232 | // -------------------- |
| 233 | |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 234 | /* (non-Javadoc) |
| 235 | * @see android.graphics.Canvas#setBitmap(android.graphics.Bitmap) |
| 236 | */ |
| 237 | @Override |
| 238 | public void setBitmap(Bitmap bitmap) { |
| 239 | mBufferedImage = bitmap.getImage(); |
| 240 | mGraphicsStack.push(mBufferedImage.createGraphics()); |
| 241 | } |
| 242 | |
| 243 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 244 | /* (non-Javadoc) |
| 245 | * @see android.graphics.Canvas#translate(float, float) |
| 246 | */ |
| 247 | @Override |
| 248 | public void translate(float dx, float dy) { |
| 249 | getGraphics2d().translate(dx, dy); |
| 250 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 251 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 252 | /* (non-Javadoc) |
| 253 | * @see android.graphics.Canvas#save() |
| 254 | */ |
| 255 | @Override |
| 256 | public int save() { |
Xavier Ducrohet | 608cd11 | 2010-01-13 18:06:00 -0800 | [diff] [blame] | 257 | // get the current save count |
| 258 | int count = mGraphicsStack.size(); |
| 259 | |
| 260 | // create a new graphics and add it to the stack |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 261 | Graphics2D g = (Graphics2D)getGraphics2d().create(); |
| 262 | mGraphicsStack.push(g); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 263 | |
Xavier Ducrohet | 608cd11 | 2010-01-13 18:06:00 -0800 | [diff] [blame] | 264 | // return the old save count |
| 265 | return count; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | /* (non-Javadoc) |
| 269 | * @see android.graphics.Canvas#save(int) |
| 270 | */ |
| 271 | @Override |
| 272 | public int save(int saveFlags) { |
| 273 | // For now we ignore saveFlags |
| 274 | return save(); |
| 275 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 276 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 277 | /* (non-Javadoc) |
| 278 | * @see android.graphics.Canvas#restore() |
| 279 | */ |
| 280 | @Override |
| 281 | public void restore() { |
| 282 | mGraphicsStack.pop(); |
| 283 | } |
| 284 | |
| 285 | /* (non-Javadoc) |
| 286 | * @see android.graphics.Canvas#restoreToCount(int) |
| 287 | */ |
| 288 | @Override |
| 289 | public void restoreToCount(int saveCount) { |
| 290 | while (mGraphicsStack.size() > saveCount) { |
| 291 | mGraphicsStack.pop(); |
| 292 | } |
| 293 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 294 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 295 | /* (non-Javadoc) |
| 296 | * @see android.graphics.Canvas#getSaveCount() |
| 297 | */ |
| 298 | @Override |
| 299 | public int getSaveCount() { |
Xavier Ducrohet | 608cd11 | 2010-01-13 18:06:00 -0800 | [diff] [blame] | 300 | return mGraphicsStack.size(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 301 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 302 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 303 | /* (non-Javadoc) |
| 304 | * @see android.graphics.Canvas#clipRect(float, float, float, float, android.graphics.Region.Op) |
| 305 | */ |
| 306 | @Override |
| 307 | public boolean clipRect(float left, float top, float right, float bottom, Op op) { |
| 308 | return clipRect(left, top, right, bottom); |
| 309 | } |
| 310 | |
| 311 | /* (non-Javadoc) |
| 312 | * @see android.graphics.Canvas#clipRect(float, float, float, float) |
| 313 | */ |
| 314 | @Override |
| 315 | public boolean clipRect(float left, float top, float right, float bottom) { |
| 316 | getGraphics2d().clipRect((int)left, (int)top, (int)(right-left), (int)(bottom-top)); |
| 317 | return true; |
| 318 | } |
| 319 | |
| 320 | /* (non-Javadoc) |
| 321 | * @see android.graphics.Canvas#clipRect(int, int, int, int) |
| 322 | */ |
| 323 | @Override |
| 324 | public boolean clipRect(int left, int top, int right, int bottom) { |
| 325 | getGraphics2d().clipRect(left, top, right-left, bottom-top); |
| 326 | return true; |
| 327 | } |
| 328 | |
| 329 | /* (non-Javadoc) |
| 330 | * @see android.graphics.Canvas#clipRect(android.graphics.Rect, android.graphics.Region.Op) |
| 331 | */ |
| 332 | @Override |
| 333 | public boolean clipRect(Rect rect, Op op) { |
| 334 | return clipRect(rect.left, rect.top, rect.right, rect.bottom); |
| 335 | } |
| 336 | |
| 337 | /* (non-Javadoc) |
| 338 | * @see android.graphics.Canvas#clipRect(android.graphics.Rect) |
| 339 | */ |
| 340 | @Override |
| 341 | public boolean clipRect(Rect rect) { |
| 342 | return clipRect(rect.left, rect.top, rect.right, rect.bottom); |
| 343 | } |
| 344 | |
| 345 | /* (non-Javadoc) |
| 346 | * @see android.graphics.Canvas#clipRect(android.graphics.RectF, android.graphics.Region.Op) |
| 347 | */ |
| 348 | @Override |
| 349 | public boolean clipRect(RectF rect, Op op) { |
| 350 | return clipRect(rect.left, rect.top, rect.right, rect.bottom); |
| 351 | } |
| 352 | |
| 353 | /* (non-Javadoc) |
| 354 | * @see android.graphics.Canvas#clipRect(android.graphics.RectF) |
| 355 | */ |
| 356 | @Override |
| 357 | public boolean clipRect(RectF rect) { |
| 358 | return clipRect(rect.left, rect.top, rect.right, rect.bottom); |
| 359 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 360 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 361 | public boolean quickReject(RectF rect, EdgeType type) { |
| 362 | return false; |
| 363 | } |
| 364 | |
| 365 | @Override |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 366 | public boolean quickReject(RectF rect, _Original_Canvas.EdgeType type) { |
| 367 | throw new UnsupportedOperationException("CALL TO PARENT FORBIDDEN"); |
| 368 | } |
| 369 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 370 | public boolean quickReject(Path path, EdgeType type) { |
| 371 | return false; |
| 372 | } |
| 373 | |
| 374 | @Override |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 375 | public boolean quickReject(Path path, _Original_Canvas.EdgeType type) { |
| 376 | throw new UnsupportedOperationException("CALL TO PARENT FORBIDDEN"); |
| 377 | } |
| 378 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 379 | public boolean quickReject(float left, float top, float right, float bottom, |
| 380 | EdgeType type) { |
| 381 | return false; |
| 382 | } |
| 383 | |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 384 | @Override |
| 385 | public boolean quickReject(float left, float top, float right, float bottom, |
| 386 | _Original_Canvas.EdgeType type) { |
| 387 | throw new UnsupportedOperationException("CALL TO PARENT FORBIDDEN"); |
| 388 | } |
| 389 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 390 | /** |
| 391 | * Retrieve the clip bounds, returning true if they are non-empty. |
| 392 | * |
| 393 | * @param bounds Return the clip bounds here. If it is null, ignore it but |
| 394 | * still return true if the current clip is non-empty. |
| 395 | * @return true if the current clip is non-empty. |
| 396 | */ |
| 397 | @Override |
| 398 | public boolean getClipBounds(Rect bounds) { |
| 399 | Rectangle rect = getGraphics2d().getClipBounds(); |
| 400 | if (rect != null) { |
| 401 | bounds.left = rect.x; |
| 402 | bounds.top = rect.y; |
| 403 | bounds.right = rect.x + rect.width; |
| 404 | bounds.bottom = rect.y + rect.height; |
| 405 | return true; |
| 406 | } |
| 407 | return false; |
| 408 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 409 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 410 | /* (non-Javadoc) |
| 411 | * @see android.graphics.Canvas#drawColor(int, android.graphics.PorterDuff.Mode) |
| 412 | */ |
| 413 | @Override |
| 414 | public void drawColor(int color, PorterDuff.Mode mode) { |
| 415 | Graphics2D g = getGraphics2d(); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 416 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 417 | // save old color |
| 418 | Color c = g.getColor(); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 419 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 420 | Composite composite = g.getComposite(); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 421 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 422 | // get the alpha from the color |
| 423 | int alpha = color >>> 24; |
| 424 | float falpha = alpha / 255.f; |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 425 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 426 | setModeInGraphics(mode, g, falpha); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 427 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 428 | g.setColor(new Color(color)); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 429 | |
Xavier Ducrohet | 63b2e61 | 2010-01-13 20:30:26 -0800 | [diff] [blame] | 430 | g.fillRect(0, 0, getWidth(), getHeight()); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 431 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 432 | g.setComposite(composite); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 433 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 434 | // restore color |
| 435 | g.setColor(c); |
| 436 | } |
| 437 | |
| 438 | /* (non-Javadoc) |
| 439 | * @see android.graphics.Canvas#drawColor(int) |
| 440 | */ |
| 441 | @Override |
| 442 | public void drawColor(int color) { |
| 443 | drawColor(color, PorterDuff.Mode.SRC_OVER); |
| 444 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 445 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 446 | /* (non-Javadoc) |
| 447 | * @see android.graphics.Canvas#drawARGB(int, int, int, int) |
| 448 | */ |
| 449 | @Override |
| 450 | public void drawARGB(int a, int r, int g, int b) { |
| 451 | drawColor(a << 24 | r << 16 | g << 8 | b, PorterDuff.Mode.SRC_OVER); |
| 452 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 453 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 454 | /* (non-Javadoc) |
| 455 | * @see android.graphics.Canvas#drawRGB(int, int, int) |
| 456 | */ |
| 457 | @Override |
| 458 | public void drawRGB(int r, int g, int b) { |
| 459 | drawColor(0xFF << 24 | r << 16 | g << 8 | b, PorterDuff.Mode.SRC_OVER); |
| 460 | } |
| 461 | |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 462 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 463 | /* (non-Javadoc) |
| 464 | * @see android.graphics.Canvas#getWidth() |
| 465 | */ |
| 466 | @Override |
| 467 | public int getWidth() { |
| 468 | return mBufferedImage.getWidth(); |
| 469 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 470 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 471 | /* (non-Javadoc) |
| 472 | * @see android.graphics.Canvas#getHeight() |
| 473 | */ |
| 474 | @Override |
| 475 | public int getHeight() { |
| 476 | return mBufferedImage.getHeight(); |
| 477 | } |
| 478 | |
| 479 | /* (non-Javadoc) |
| 480 | * @see android.graphics.Canvas#drawPaint(android.graphics.Paint) |
| 481 | */ |
| 482 | @Override |
| 483 | public void drawPaint(Paint paint) { |
| 484 | drawColor(paint.getColor()); |
| 485 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 486 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 487 | /* (non-Javadoc) |
| 488 | * @see android.graphics.Canvas#drawBitmap(android.graphics.Bitmap, float, float, android.graphics.Paint) |
| 489 | */ |
| 490 | @Override |
| 491 | public void drawBitmap(Bitmap bitmap, float left, float top, Paint paint) { |
| 492 | drawBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), |
| 493 | (int)left, (int)top, |
| 494 | (int)left+bitmap.getWidth(), (int)top+bitmap.getHeight(), paint); |
| 495 | } |
| 496 | |
| 497 | /* (non-Javadoc) |
| 498 | * @see android.graphics.Canvas#drawBitmap(android.graphics.Bitmap, android.graphics.Matrix, android.graphics.Paint) |
| 499 | */ |
| 500 | @Override |
| 501 | public void drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint) { |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 502 | boolean needsRestore = false; |
| 503 | if (matrix.isIdentity() == false) { |
| 504 | // create a new graphics and apply the matrix to it |
| 505 | save(); // this creates a new Graphics2D, and stores it for children call to use |
| 506 | needsRestore = true; |
| 507 | Graphics2D g = getGraphics2d(); // get the newly create Graphics2D |
| 508 | |
| 509 | // get the Graphics2D current matrix |
| 510 | AffineTransform currentTx = g.getTransform(); |
| 511 | // get the AffineTransform from the matrix |
| 512 | AffineTransform matrixTx = matrix.getTransform(); |
| 513 | |
| 514 | // combine them so that the matrix is applied after. |
| 515 | currentTx.preConcatenate(matrixTx); |
| 516 | |
| 517 | // give it to the graphics as a new matrix replacing all previous transform |
| 518 | g.setTransform(currentTx); |
| 519 | } |
| 520 | |
| 521 | // draw the bitmap |
| 522 | drawBitmap(bitmap, 0, 0, paint); |
| 523 | |
| 524 | if (needsRestore) { |
| 525 | // remove the new graphics |
| 526 | restore(); |
| 527 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 528 | } |
| 529 | |
| 530 | /* (non-Javadoc) |
| 531 | * @see android.graphics.Canvas#drawBitmap(android.graphics.Bitmap, android.graphics.Rect, android.graphics.Rect, android.graphics.Paint) |
| 532 | */ |
| 533 | @Override |
| 534 | public void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint) { |
| 535 | if (src == null) { |
| 536 | drawBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), |
| 537 | dst.left, dst.top, dst.right, dst.bottom, paint); |
| 538 | } else { |
| 539 | drawBitmap(bitmap, src.left, src.top, src.width(), src.height(), |
| 540 | dst.left, dst.top, dst.right, dst.bottom, paint); |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | /* (non-Javadoc) |
| 545 | * @see android.graphics.Canvas#drawBitmap(android.graphics.Bitmap, android.graphics.Rect, android.graphics.RectF, android.graphics.Paint) |
| 546 | */ |
| 547 | @Override |
| 548 | public void drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint) { |
| 549 | if (src == null) { |
| 550 | drawBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), |
| 551 | (int)dst.left, (int)dst.top, (int)dst.right, (int)dst.bottom, paint); |
| 552 | } else { |
| 553 | drawBitmap(bitmap, src.left, src.top, src.width(), src.height(), |
| 554 | (int)dst.left, (int)dst.top, (int)dst.right, (int)dst.bottom, paint); |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | /* (non-Javadoc) |
| 559 | * @see android.graphics.Canvas#drawBitmap(int[], int, int, int, int, int, int, boolean, android.graphics.Paint) |
| 560 | */ |
| 561 | @Override |
| 562 | public void drawBitmap(int[] colors, int offset, int stride, int x, int y, int width, |
| 563 | int height, boolean hasAlpha, Paint paint) { |
| 564 | throw new UnsupportedOperationException(); |
| 565 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 566 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 567 | private void drawBitmap(Bitmap bitmap, int sleft, int stop, int sright, int sbottom, int dleft, |
| 568 | int dtop, int dright, int dbottom, Paint paint) { |
| 569 | BufferedImage image = bitmap.getImage(); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 570 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 571 | Graphics2D g = getGraphics2d(); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 572 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 573 | Composite c = null; |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 574 | |
| 575 | if (paint != null) { |
| 576 | if (paint.isFilterBitmap()) { |
| 577 | g = (Graphics2D)g.create(); |
| 578 | g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, |
| 579 | RenderingHints.VALUE_INTERPOLATION_BILINEAR); |
| 580 | } |
| 581 | |
| 582 | if (paint.getAlpha() != 0xFF) { |
| 583 | c = g.getComposite(); |
| 584 | g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, |
| 585 | paint.getAlpha()/255.f)); |
| 586 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 587 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 588 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 589 | g.drawImage(image, dleft, dtop, dright, dbottom, |
| 590 | sleft, stop, sright, sbottom, null); |
| 591 | |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 592 | if (paint != null) { |
| 593 | if (paint.isFilterBitmap()) { |
| 594 | g.dispose(); |
| 595 | } |
| 596 | if (c != null) { |
| 597 | g.setComposite(c); |
| 598 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 599 | } |
| 600 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 601 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 602 | /* (non-Javadoc) |
| 603 | * @see android.graphics.Canvas#rotate(float, float, float) |
| 604 | */ |
| 605 | @Override |
| 606 | public void rotate(float degrees, float px, float py) { |
| 607 | if (degrees != 0) { |
| 608 | Graphics2D g = getGraphics2d(); |
| 609 | g.translate(px, py); |
| 610 | g.rotate(Math.toRadians(degrees)); |
| 611 | g.translate(-px, -py); |
| 612 | } |
| 613 | } |
| 614 | |
| 615 | /* (non-Javadoc) |
| 616 | * @see android.graphics.Canvas#rotate(float) |
| 617 | */ |
| 618 | @Override |
| 619 | public void rotate(float degrees) { |
| 620 | getGraphics2d().rotate(Math.toRadians(degrees)); |
| 621 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 622 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 623 | /* (non-Javadoc) |
| 624 | * @see android.graphics.Canvas#scale(float, float, float, float) |
| 625 | */ |
| 626 | @Override |
| 627 | public void scale(float sx, float sy, float px, float py) { |
| 628 | Graphics2D g = getGraphics2d(); |
| 629 | g.translate(px, py); |
| 630 | g.scale(sx, sy); |
| 631 | g.translate(-px, -py); |
| 632 | } |
| 633 | |
| 634 | /* (non-Javadoc) |
| 635 | * @see android.graphics.Canvas#scale(float, float) |
| 636 | */ |
| 637 | @Override |
| 638 | public void scale(float sx, float sy) { |
| 639 | getGraphics2d().scale(sx, sy); |
| 640 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 641 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 642 | /* (non-Javadoc) |
| 643 | * @see android.graphics.Canvas#drawText(char[], int, int, float, float, android.graphics.Paint) |
| 644 | */ |
| 645 | @Override |
| 646 | public void drawText(char[] text, int index, int count, float x, float y, Paint paint) { |
Xavier Ducrohet | 9a4593f | 2009-11-08 15:15:01 -0800 | [diff] [blame] | 647 | // WARNING: the logic in this method is similar to Paint.measureText. |
| 648 | // Any change to this method should be reflected in Paint.measureText |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 649 | Graphics2D g = getGraphics2d(); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 650 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 651 | g = (Graphics2D)g.create(); |
| 652 | g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 653 | |
Xavier Ducrohet | 9a4593f | 2009-11-08 15:15:01 -0800 | [diff] [blame] | 654 | // set the color. because this only handles RGB, the alpha channel is handled |
| 655 | // as a composite. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 656 | g.setColor(new Color(paint.getColor())); |
| 657 | int alpha = paint.getAlpha(); |
| 658 | float falpha = alpha / 255.f; |
| 659 | g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, falpha)); |
| 660 | |
Xavier Ducrohet | 9a4593f | 2009-11-08 15:15:01 -0800 | [diff] [blame] | 661 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 662 | // Paint.TextAlign indicates how the text is positioned relative to X. |
| 663 | // LEFT is the default and there's nothing to do. |
| 664 | if (paint.getTextAlign() != Align.LEFT) { |
| 665 | float m = paint.measureText(text, index, count); |
| 666 | if (paint.getTextAlign() == Align.CENTER) { |
| 667 | x -= m / 2; |
| 668 | } else if (paint.getTextAlign() == Align.RIGHT) { |
| 669 | x -= m; |
| 670 | } |
| 671 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 672 | |
Xavier Ducrohet | 9a4593f | 2009-11-08 15:15:01 -0800 | [diff] [blame] | 673 | List<FontInfo> fonts = paint.getFonts(); |
| 674 | try { |
| 675 | if (fonts.size() > 0) { |
| 676 | FontInfo mainFont = fonts.get(0); |
| 677 | int i = index; |
| 678 | int lastIndex = index + count; |
| 679 | while (i < lastIndex) { |
| 680 | // always start with the main font. |
| 681 | int upTo = mainFont.mFont.canDisplayUpTo(text, i, lastIndex); |
| 682 | if (upTo == -1) { |
| 683 | // draw all the rest and exit. |
| 684 | g.setFont(mainFont.mFont); |
| 685 | g.drawChars(text, i, lastIndex - i, (int)x, (int)y); |
| 686 | return; |
| 687 | } else if (upTo > 0) { |
| 688 | // draw what's possible |
| 689 | g.setFont(mainFont.mFont); |
| 690 | g.drawChars(text, i, upTo - i, (int)x, (int)y); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 691 | |
Xavier Ducrohet | 9a4593f | 2009-11-08 15:15:01 -0800 | [diff] [blame] | 692 | // compute the width that was drawn to increase x |
| 693 | x += mainFont.mMetrics.charsWidth(text, i, upTo - i); |
| 694 | |
| 695 | // move index to the first non displayed char. |
| 696 | i = upTo; |
| 697 | |
| 698 | // don't call continue at this point. Since it is certain the main font |
| 699 | // cannot display the font a index upTo (now ==i), we move on to the |
| 700 | // fallback fonts directly. |
| 701 | } |
| 702 | |
| 703 | // no char supported, attempt to read the next char(s) with the |
| 704 | // fallback font. In this case we only test the first character |
| 705 | // and then go back to test with the main font. |
| 706 | // Special test for 2-char characters. |
| 707 | boolean foundFont = false; |
| 708 | for (int f = 1 ; f < fonts.size() ; f++) { |
| 709 | FontInfo fontInfo = fonts.get(f); |
| 710 | |
| 711 | // need to check that the font can display the character. We test |
| 712 | // differently if the char is a high surrogate. |
| 713 | int charCount = Character.isHighSurrogate(text[i]) ? 2 : 1; |
| 714 | upTo = fontInfo.mFont.canDisplayUpTo(text, i, i + charCount); |
| 715 | if (upTo == -1) { |
| 716 | // draw that char |
| 717 | g.setFont(fontInfo.mFont); |
| 718 | g.drawChars(text, i, charCount, (int)x, (int)y); |
| 719 | |
| 720 | // update x |
| 721 | x += fontInfo.mMetrics.charsWidth(text, i, charCount); |
| 722 | |
| 723 | // update the index in the text, and move on |
| 724 | i += charCount; |
| 725 | foundFont = true; |
| 726 | break; |
| 727 | |
| 728 | } |
| 729 | } |
| 730 | |
| 731 | // in case no font can display the char, display it with the main font. |
| 732 | // (it'll put a square probably) |
| 733 | if (foundFont == false) { |
| 734 | int charCount = Character.isHighSurrogate(text[i]) ? 2 : 1; |
| 735 | |
| 736 | g.setFont(mainFont.mFont); |
| 737 | g.drawChars(text, i, charCount, (int)x, (int)y); |
| 738 | |
| 739 | // measure it to advance x |
| 740 | x += mainFont.mMetrics.charsWidth(text, i, charCount); |
| 741 | |
| 742 | // and move to the next chars. |
| 743 | i += charCount; |
| 744 | } |
| 745 | } |
| 746 | } |
| 747 | } finally { |
| 748 | g.dispose(); |
| 749 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 750 | } |
| 751 | |
| 752 | /* (non-Javadoc) |
| 753 | * @see android.graphics.Canvas#drawText(java.lang.CharSequence, int, int, float, float, android.graphics.Paint) |
| 754 | */ |
| 755 | @Override |
| 756 | public void drawText(CharSequence text, int start, int end, float x, float y, Paint paint) { |
| 757 | drawText(text.toString().toCharArray(), start, end - start, x, y, paint); |
| 758 | } |
| 759 | |
| 760 | /* (non-Javadoc) |
| 761 | * @see android.graphics.Canvas#drawText(java.lang.String, float, float, android.graphics.Paint) |
| 762 | */ |
| 763 | @Override |
| 764 | public void drawText(String text, float x, float y, Paint paint) { |
| 765 | drawText(text.toCharArray(), 0, text.length(), x, y, paint); |
| 766 | } |
| 767 | |
| 768 | /* (non-Javadoc) |
| 769 | * @see android.graphics.Canvas#drawText(java.lang.String, int, int, float, float, android.graphics.Paint) |
| 770 | */ |
| 771 | @Override |
| 772 | public void drawText(String text, int start, int end, float x, float y, Paint paint) { |
| 773 | drawText(text.toCharArray(), start, end - start, x, y, paint); |
| 774 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 775 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 776 | /* (non-Javadoc) |
| 777 | * @see android.graphics.Canvas#drawRect(android.graphics.RectF, android.graphics.Paint) |
| 778 | */ |
| 779 | @Override |
| 780 | public void drawRect(RectF rect, Paint paint) { |
| 781 | doDrawRect((int)rect.left, (int)rect.top, (int)rect.width(), (int)rect.height(), paint); |
| 782 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 783 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 784 | /* (non-Javadoc) |
| 785 | * @see android.graphics.Canvas#drawRect(float, float, float, float, android.graphics.Paint) |
| 786 | */ |
| 787 | @Override |
| 788 | public void drawRect(float left, float top, float right, float bottom, Paint paint) { |
| 789 | doDrawRect((int)left, (int)top, (int)(right-left), (int)(bottom-top), paint); |
| 790 | } |
| 791 | |
| 792 | /* (non-Javadoc) |
| 793 | * @see android.graphics.Canvas#drawRect(android.graphics.Rect, android.graphics.Paint) |
| 794 | */ |
| 795 | @Override |
| 796 | public void drawRect(Rect r, Paint paint) { |
| 797 | doDrawRect(r.left, r.top, r.width(), r.height(), paint); |
| 798 | } |
| 799 | |
| 800 | private final void doDrawRect(int left, int top, int width, int height, Paint paint) { |
Xavier Ducrohet | 5ac8f40 | 2010-01-14 19:19:06 -0800 | [diff] [blame] | 801 | if (width > 0 && height > 0) { |
Xavier Ducrohet | 36ab128 | 2010-01-15 11:24:44 -0800 | [diff] [blame] | 802 | // get a Graphics2D object configured with the drawing parameters. |
| 803 | Graphics2D g = getCustomGraphics(paint); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 804 | |
Xavier Ducrohet | 89d538dc | 2010-01-14 18:37:21 -0800 | [diff] [blame] | 805 | Style style = paint.getStyle(); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 806 | |
Xavier Ducrohet | 89d538dc | 2010-01-14 18:37:21 -0800 | [diff] [blame] | 807 | // draw |
| 808 | if (style == Style.FILL || style == Style.FILL_AND_STROKE) { |
| 809 | g.fillRect(left, top, width, height); |
| 810 | } |
| 811 | |
| 812 | if (style == Style.STROKE || style == Style.FILL_AND_STROKE) { |
| 813 | g.drawRect(left, top, width, height); |
| 814 | } |
| 815 | |
| 816 | // dispose Graphics2D object |
| 817 | g.dispose(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 818 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 819 | } |
| 820 | |
| 821 | /* (non-Javadoc) |
| 822 | * @see android.graphics.Canvas#drawRoundRect(android.graphics.RectF, float, float, android.graphics.Paint) |
| 823 | */ |
| 824 | @Override |
| 825 | public void drawRoundRect(RectF rect, float rx, float ry, Paint paint) { |
Xavier Ducrohet | 5ac8f40 | 2010-01-14 19:19:06 -0800 | [diff] [blame] | 826 | if (rect.width() > 0 && rect.height() > 0) { |
Xavier Ducrohet | 36ab128 | 2010-01-15 11:24:44 -0800 | [diff] [blame] | 827 | // get a Graphics2D object configured with the drawing parameters. |
| 828 | Graphics2D g = getCustomGraphics(paint); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 829 | |
Xavier Ducrohet | 89d538dc | 2010-01-14 18:37:21 -0800 | [diff] [blame] | 830 | Style style = paint.getStyle(); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 831 | |
Xavier Ducrohet | 89d538dc | 2010-01-14 18:37:21 -0800 | [diff] [blame] | 832 | // draw |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 833 | |
Xavier Ducrohet | 89d538dc | 2010-01-14 18:37:21 -0800 | [diff] [blame] | 834 | int arcWidth = (int)(rx * 2); |
| 835 | int arcHeight = (int)(ry * 2); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 836 | |
Xavier Ducrohet | 89d538dc | 2010-01-14 18:37:21 -0800 | [diff] [blame] | 837 | if (style == Style.FILL || style == Style.FILL_AND_STROKE) { |
| 838 | g.fillRoundRect((int)rect.left, (int)rect.top, (int)rect.width(), (int)rect.height(), |
| 839 | arcWidth, arcHeight); |
| 840 | } |
| 841 | |
| 842 | if (style == Style.STROKE || style == Style.FILL_AND_STROKE) { |
| 843 | g.drawRoundRect((int)rect.left, (int)rect.top, (int)rect.width(), (int)rect.height(), |
| 844 | arcWidth, arcHeight); |
| 845 | } |
| 846 | |
| 847 | // dispose Graphics2D object |
| 848 | g.dispose(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 849 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 850 | } |
| 851 | |
| 852 | |
| 853 | /* (non-Javadoc) |
| 854 | * @see android.graphics.Canvas#drawLine(float, float, float, float, android.graphics.Paint) |
| 855 | */ |
| 856 | @Override |
| 857 | public void drawLine(float startX, float startY, float stopX, float stopY, Paint paint) { |
Xavier Ducrohet | 36ab128 | 2010-01-15 11:24:44 -0800 | [diff] [blame] | 858 | // get a Graphics2D object configured with the drawing parameters. |
| 859 | Graphics2D g = getCustomGraphics(paint); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 860 | |
| 861 | g.drawLine((int)startX, (int)startY, (int)stopX, (int)stopY); |
| 862 | |
| 863 | // dispose Graphics2D object |
| 864 | g.dispose(); |
| 865 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 866 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 867 | /* (non-Javadoc) |
| 868 | * @see android.graphics.Canvas#drawLines(float[], int, int, android.graphics.Paint) |
| 869 | */ |
| 870 | @Override |
| 871 | public void drawLines(float[] pts, int offset, int count, Paint paint) { |
Xavier Ducrohet | 36ab128 | 2010-01-15 11:24:44 -0800 | [diff] [blame] | 872 | // get a Graphics2D object configured with the drawing parameters. |
| 873 | Graphics2D g = getCustomGraphics(paint); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 874 | |
| 875 | for (int i = 0 ; i < count ; i += 4) { |
| 876 | g.drawLine((int)pts[i + offset], (int)pts[i + offset + 1], |
| 877 | (int)pts[i + offset + 2], (int)pts[i + offset + 3]); |
| 878 | } |
| 879 | |
| 880 | // dispose Graphics2D object |
| 881 | g.dispose(); |
| 882 | } |
| 883 | |
| 884 | /* (non-Javadoc) |
| 885 | * @see android.graphics.Canvas#drawLines(float[], android.graphics.Paint) |
| 886 | */ |
| 887 | @Override |
| 888 | public void drawLines(float[] pts, Paint paint) { |
| 889 | drawLines(pts, 0, pts.length, paint); |
| 890 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 891 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 892 | /* (non-Javadoc) |
| 893 | * @see android.graphics.Canvas#drawCircle(float, float, float, android.graphics.Paint) |
| 894 | */ |
| 895 | @Override |
| 896 | public void drawCircle(float cx, float cy, float radius, Paint paint) { |
Xavier Ducrohet | 36ab128 | 2010-01-15 11:24:44 -0800 | [diff] [blame] | 897 | // get a Graphics2D object configured with the drawing parameters. |
| 898 | Graphics2D g = getCustomGraphics(paint); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 899 | |
| 900 | Style style = paint.getStyle(); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 901 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 902 | int size = (int)(radius * 2); |
| 903 | |
| 904 | // draw |
| 905 | if (style == Style.FILL || style == Style.FILL_AND_STROKE) { |
| 906 | g.fillOval((int)(cx - radius), (int)(cy - radius), size, size); |
| 907 | } |
| 908 | |
| 909 | if (style == Style.STROKE || style == Style.FILL_AND_STROKE) { |
| 910 | g.drawOval((int)(cx - radius), (int)(cy - radius), size, size); |
| 911 | } |
| 912 | |
| 913 | // dispose Graphics2D object |
| 914 | g.dispose(); |
| 915 | } |
| 916 | |
| 917 | /* (non-Javadoc) |
| 918 | * @see android.graphics.Canvas#drawOval(android.graphics.RectF, android.graphics.Paint) |
| 919 | */ |
| 920 | @Override |
| 921 | public void drawOval(RectF oval, Paint paint) { |
Xavier Ducrohet | 36ab128 | 2010-01-15 11:24:44 -0800 | [diff] [blame] | 922 | // get a Graphics2D object configured with the drawing parameters. |
| 923 | Graphics2D g = getCustomGraphics(paint); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 924 | |
| 925 | Style style = paint.getStyle(); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 926 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 927 | // draw |
| 928 | if (style == Style.FILL || style == Style.FILL_AND_STROKE) { |
| 929 | g.fillOval((int)oval.left, (int)oval.top, (int)oval.width(), (int)oval.height()); |
| 930 | } |
| 931 | |
| 932 | if (style == Style.STROKE || style == Style.FILL_AND_STROKE) { |
| 933 | g.drawOval((int)oval.left, (int)oval.top, (int)oval.width(), (int)oval.height()); |
| 934 | } |
| 935 | |
| 936 | // dispose Graphics2D object |
| 937 | g.dispose(); |
| 938 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 939 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 940 | /* (non-Javadoc) |
| 941 | * @see android.graphics.Canvas#drawPath(android.graphics.Path, android.graphics.Paint) |
| 942 | */ |
| 943 | @Override |
| 944 | public void drawPath(Path path, Paint paint) { |
Xavier Ducrohet | 36ab128 | 2010-01-15 11:24:44 -0800 | [diff] [blame] | 945 | // get a Graphics2D object configured with the drawing parameters. |
| 946 | Graphics2D g = getCustomGraphics(paint); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 947 | |
| 948 | Style style = paint.getStyle(); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 949 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 950 | // draw |
| 951 | if (style == Style.FILL || style == Style.FILL_AND_STROKE) { |
| 952 | g.fill(path.getAwtShape()); |
| 953 | } |
| 954 | |
| 955 | if (style == Style.STROKE || style == Style.FILL_AND_STROKE) { |
| 956 | g.draw(path.getAwtShape()); |
| 957 | } |
| 958 | |
| 959 | // dispose Graphics2D object |
| 960 | g.dispose(); |
| 961 | } |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 962 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 963 | /* (non-Javadoc) |
| 964 | * @see android.graphics.Canvas#setMatrix(android.graphics.Matrix) |
| 965 | */ |
| 966 | @Override |
| 967 | public void setMatrix(Matrix matrix) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 968 | // get the new current graphics |
| 969 | Graphics2D g = getGraphics2d(); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 970 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 971 | // and apply the matrix |
| 972 | g.setTransform(matrix.getTransform()); |
Xavier Ducrohet | 2473ef56 | 2009-08-14 20:47:50 -0700 | [diff] [blame] | 973 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 974 | if (mLogger != null && matrix.hasPerspective()) { |
| 975 | mLogger.warning("android.graphics.Canvas#setMatrix(android.graphics.Matrix) only supports affine transformations in the Layout Editor."); |
| 976 | } |
| 977 | } |
| 978 | |
Xavier Ducrohet | 608cd11 | 2010-01-13 18:06:00 -0800 | [diff] [blame] | 979 | /* (non-Javadoc) |
| 980 | * @see android.graphics.Canvas#concat(android.graphics.Matrix) |
| 981 | */ |
| 982 | @Override |
| 983 | public void concat(Matrix matrix) { |
| 984 | // get the current top graphics2D object. |
| 985 | Graphics2D g = getGraphics2d(); |
| 986 | |
| 987 | // get its current matrix |
| 988 | AffineTransform currentTx = g.getTransform(); |
| 989 | // get the AffineTransform of the given matrix |
| 990 | AffineTransform matrixTx = matrix.getTransform(); |
| 991 | |
| 992 | // combine them so that the given matrix is applied after. |
| 993 | currentTx.preConcatenate(matrixTx); |
| 994 | |
| 995 | // give it to the graphics2D as a new matrix replacing all previous transform |
| 996 | g.setTransform(currentTx); |
| 997 | } |
| 998 | |
| 999 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1000 | // -------------------- |
| 1001 | |
| 1002 | /* (non-Javadoc) |
| 1003 | * @see android.graphics.Canvas#clipPath(android.graphics.Path, android.graphics.Region.Op) |
| 1004 | */ |
| 1005 | @Override |
| 1006 | public boolean clipPath(Path path, Op op) { |
| 1007 | // TODO Auto-generated method stub |
| 1008 | return super.clipPath(path, op); |
| 1009 | } |
| 1010 | |
| 1011 | /* (non-Javadoc) |
| 1012 | * @see android.graphics.Canvas#clipPath(android.graphics.Path) |
| 1013 | */ |
| 1014 | @Override |
| 1015 | public boolean clipPath(Path path) { |
| 1016 | // TODO Auto-generated method stub |
| 1017 | return super.clipPath(path); |
| 1018 | } |
| 1019 | |
| 1020 | |
| 1021 | /* (non-Javadoc) |
| 1022 | * @see android.graphics.Canvas#clipRegion(android.graphics.Region, android.graphics.Region.Op) |
| 1023 | */ |
| 1024 | @Override |
| 1025 | public boolean clipRegion(Region region, Op op) { |
| 1026 | // TODO Auto-generated method stub |
| 1027 | return super.clipRegion(region, op); |
| 1028 | } |
| 1029 | |
| 1030 | /* (non-Javadoc) |
| 1031 | * @see android.graphics.Canvas#clipRegion(android.graphics.Region) |
| 1032 | */ |
| 1033 | @Override |
| 1034 | public boolean clipRegion(Region region) { |
| 1035 | // TODO Auto-generated method stub |
| 1036 | return super.clipRegion(region); |
| 1037 | } |
| 1038 | |
| 1039 | /* (non-Javadoc) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1040 | * @see android.graphics.Canvas#drawArc(android.graphics.RectF, float, float, boolean, android.graphics.Paint) |
| 1041 | */ |
| 1042 | @Override |
| 1043 | public void drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter, |
| 1044 | Paint paint) { |
| 1045 | // TODO Auto-generated method stub |
| 1046 | super.drawArc(oval, startAngle, sweepAngle, useCenter, paint); |
| 1047 | } |
| 1048 | |
| 1049 | /* (non-Javadoc) |
| 1050 | * @see android.graphics.Canvas#drawBitmapMesh(android.graphics.Bitmap, int, int, float[], int, int[], int, android.graphics.Paint) |
| 1051 | */ |
| 1052 | @Override |
| 1053 | public void drawBitmapMesh(Bitmap bitmap, int meshWidth, int meshHeight, float[] verts, |
| 1054 | int vertOffset, int[] colors, int colorOffset, Paint paint) { |
| 1055 | // TODO Auto-generated method stub |
| 1056 | super.drawBitmapMesh(bitmap, meshWidth, meshHeight, verts, vertOffset, colors, colorOffset, paint); |
| 1057 | } |
| 1058 | |
| 1059 | /* (non-Javadoc) |
| 1060 | * @see android.graphics.Canvas#drawPicture(android.graphics.Picture, android.graphics.Rect) |
| 1061 | */ |
| 1062 | @Override |
| 1063 | public void drawPicture(Picture picture, Rect dst) { |
| 1064 | // TODO Auto-generated method stub |
| 1065 | super.drawPicture(picture, dst); |
| 1066 | } |
| 1067 | |
| 1068 | /* (non-Javadoc) |
| 1069 | * @see android.graphics.Canvas#drawPicture(android.graphics.Picture, android.graphics.RectF) |
| 1070 | */ |
| 1071 | @Override |
| 1072 | public void drawPicture(Picture picture, RectF dst) { |
| 1073 | // TODO Auto-generated method stub |
| 1074 | super.drawPicture(picture, dst); |
| 1075 | } |
| 1076 | |
| 1077 | /* (non-Javadoc) |
| 1078 | * @see android.graphics.Canvas#drawPicture(android.graphics.Picture) |
| 1079 | */ |
| 1080 | @Override |
| 1081 | public void drawPicture(Picture picture) { |
| 1082 | // TODO Auto-generated method stub |
| 1083 | super.drawPicture(picture); |
| 1084 | } |
| 1085 | |
| 1086 | /* (non-Javadoc) |
| 1087 | * @see android.graphics.Canvas#drawPoint(float, float, android.graphics.Paint) |
| 1088 | */ |
| 1089 | @Override |
| 1090 | public void drawPoint(float x, float y, Paint paint) { |
| 1091 | // TODO Auto-generated method stub |
| 1092 | super.drawPoint(x, y, paint); |
| 1093 | } |
| 1094 | |
| 1095 | /* (non-Javadoc) |
| 1096 | * @see android.graphics.Canvas#drawPoints(float[], int, int, android.graphics.Paint) |
| 1097 | */ |
| 1098 | @Override |
| 1099 | public void drawPoints(float[] pts, int offset, int count, Paint paint) { |
| 1100 | // TODO Auto-generated method stub |
| 1101 | super.drawPoints(pts, offset, count, paint); |
| 1102 | } |
| 1103 | |
| 1104 | /* (non-Javadoc) |
| 1105 | * @see android.graphics.Canvas#drawPoints(float[], android.graphics.Paint) |
| 1106 | */ |
| 1107 | @Override |
| 1108 | public void drawPoints(float[] pts, Paint paint) { |
| 1109 | // TODO Auto-generated method stub |
| 1110 | super.drawPoints(pts, paint); |
| 1111 | } |
| 1112 | |
| 1113 | /* (non-Javadoc) |
| 1114 | * @see android.graphics.Canvas#drawPosText(char[], int, int, float[], android.graphics.Paint) |
| 1115 | */ |
| 1116 | @Override |
| 1117 | public void drawPosText(char[] text, int index, int count, float[] pos, Paint paint) { |
| 1118 | // TODO Auto-generated method stub |
| 1119 | super.drawPosText(text, index, count, pos, paint); |
| 1120 | } |
| 1121 | |
| 1122 | /* (non-Javadoc) |
| 1123 | * @see android.graphics.Canvas#drawPosText(java.lang.String, float[], android.graphics.Paint) |
| 1124 | */ |
| 1125 | @Override |
| 1126 | public void drawPosText(String text, float[] pos, Paint paint) { |
| 1127 | // TODO Auto-generated method stub |
| 1128 | super.drawPosText(text, pos, paint); |
| 1129 | } |
| 1130 | |
| 1131 | /* (non-Javadoc) |
| 1132 | * @see android.graphics.Canvas#drawTextOnPath(char[], int, int, android.graphics.Path, float, float, android.graphics.Paint) |
| 1133 | */ |
| 1134 | @Override |
| 1135 | public void drawTextOnPath(char[] text, int index, int count, Path path, float offset, |
| 1136 | float offset2, Paint paint) { |
| 1137 | // TODO Auto-generated method stub |
| 1138 | super.drawTextOnPath(text, index, count, path, offset, offset2, paint); |
| 1139 | } |
| 1140 | |
| 1141 | /* (non-Javadoc) |
| 1142 | * @see android.graphics.Canvas#drawTextOnPath(java.lang.String, android.graphics.Path, float, float, android.graphics.Paint) |
| 1143 | */ |
| 1144 | @Override |
| 1145 | public void drawTextOnPath(String text, Path path, float offset, float offset2, Paint paint) { |
| 1146 | // TODO Auto-generated method stub |
| 1147 | super.drawTextOnPath(text, path, offset, offset2, paint); |
| 1148 | } |
| 1149 | |
| 1150 | /* (non-Javadoc) |
| 1151 | * @see android.graphics.Canvas#drawVertices(android.graphics.Canvas.VertexMode, int, float[], int, float[], int, int[], int, short[], int, int, android.graphics.Paint) |
| 1152 | */ |
| 1153 | @Override |
| 1154 | public void drawVertices(VertexMode mode, int vertexCount, float[] verts, int vertOffset, |
| 1155 | float[] texs, int texOffset, int[] colors, int colorOffset, short[] indices, |
| 1156 | int indexOffset, int indexCount, Paint paint) { |
| 1157 | // TODO Auto-generated method stub |
| 1158 | super.drawVertices(mode, vertexCount, verts, vertOffset, texs, texOffset, colors, colorOffset, |
| 1159 | indices, indexOffset, indexCount, paint); |
| 1160 | } |
| 1161 | |
| 1162 | /* (non-Javadoc) |
| 1163 | * @see android.graphics.Canvas#getDrawFilter() |
| 1164 | */ |
| 1165 | @Override |
| 1166 | public DrawFilter getDrawFilter() { |
| 1167 | // TODO Auto-generated method stub |
| 1168 | return super.getDrawFilter(); |
| 1169 | } |
| 1170 | |
| 1171 | /* (non-Javadoc) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1172 | * @see android.graphics.Canvas#getMatrix() |
| 1173 | */ |
| 1174 | @Override |
| 1175 | public Matrix getMatrix() { |
| 1176 | // TODO Auto-generated method stub |
| 1177 | return super.getMatrix(); |
| 1178 | } |
| 1179 | |
| 1180 | /* (non-Javadoc) |
| 1181 | * @see android.graphics.Canvas#getMatrix(android.graphics.Matrix) |
| 1182 | */ |
| 1183 | @Override |
| 1184 | public void getMatrix(Matrix ctm) { |
| 1185 | // TODO Auto-generated method stub |
| 1186 | super.getMatrix(ctm); |
| 1187 | } |
| 1188 | |
| 1189 | /* (non-Javadoc) |
| 1190 | * @see android.graphics.Canvas#isOpaque() |
| 1191 | */ |
| 1192 | @Override |
| 1193 | public boolean isOpaque() { |
| 1194 | // TODO Auto-generated method stub |
| 1195 | return super.isOpaque(); |
| 1196 | } |
| 1197 | |
| 1198 | /* (non-Javadoc) |
| 1199 | * @see android.graphics.Canvas#saveLayer(float, float, float, float, android.graphics.Paint, int) |
| 1200 | */ |
| 1201 | @Override |
| 1202 | public int saveLayer(float left, float top, float right, float bottom, Paint paint, |
| 1203 | int saveFlags) { |
| 1204 | // TODO Auto-generated method stub |
| 1205 | return super.saveLayer(left, top, right, bottom, paint, saveFlags); |
| 1206 | } |
| 1207 | |
| 1208 | /* (non-Javadoc) |
| 1209 | * @see android.graphics.Canvas#saveLayer(android.graphics.RectF, android.graphics.Paint, int) |
| 1210 | */ |
| 1211 | @Override |
| 1212 | public int saveLayer(RectF bounds, Paint paint, int saveFlags) { |
| 1213 | // TODO Auto-generated method stub |
| 1214 | return super.saveLayer(bounds, paint, saveFlags); |
| 1215 | } |
| 1216 | |
| 1217 | /* (non-Javadoc) |
| 1218 | * @see android.graphics.Canvas#saveLayerAlpha(float, float, float, float, int, int) |
| 1219 | */ |
| 1220 | @Override |
| 1221 | public int saveLayerAlpha(float left, float top, float right, float bottom, int alpha, |
| 1222 | int saveFlags) { |
| 1223 | // TODO Auto-generated method stub |
| 1224 | return super.saveLayerAlpha(left, top, right, bottom, alpha, saveFlags); |
| 1225 | } |
| 1226 | |
| 1227 | /* (non-Javadoc) |
| 1228 | * @see android.graphics.Canvas#saveLayerAlpha(android.graphics.RectF, int, int) |
| 1229 | */ |
| 1230 | @Override |
| 1231 | public int saveLayerAlpha(RectF bounds, int alpha, int saveFlags) { |
| 1232 | // TODO Auto-generated method stub |
| 1233 | return super.saveLayerAlpha(bounds, alpha, saveFlags); |
| 1234 | } |
| 1235 | |
| 1236 | /* (non-Javadoc) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1237 | * @see android.graphics.Canvas#setDrawFilter(android.graphics.DrawFilter) |
| 1238 | */ |
| 1239 | @Override |
| 1240 | public void setDrawFilter(DrawFilter filter) { |
| 1241 | // TODO Auto-generated method stub |
| 1242 | super.setDrawFilter(filter); |
| 1243 | } |
| 1244 | |
| 1245 | /* (non-Javadoc) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1246 | * @see android.graphics.Canvas#skew(float, float) |
| 1247 | */ |
| 1248 | @Override |
| 1249 | public void skew(float sx, float sy) { |
| 1250 | // TODO Auto-generated method stub |
| 1251 | super.skew(sx, sy); |
| 1252 | } |
| 1253 | |
| 1254 | |
| 1255 | |
| 1256 | } |