Showing the changes to java/pkg/sun/java2d/pipe/ValidatePipe.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,241 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved. | ||
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| 4 | * | ||
| 5 | * This code is free software; you can redistribute it and/or modify it | ||
| 6 | * under the terms of the GNU General Public License version 2 only, as | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 10 | * | ||
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT | ||
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| 14 | * version 2 for more details (a copy is included in the LICENSE file that | ||
| 15 | * accompanied this code). | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License version | ||
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, | ||
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 20 | * | ||
| 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| 22 | * or visit www.oracle.com if you need additional information or have any | ||
| 23 | * questions. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package sun.java2d.pipe; | ||
| 27 | |||
| 28 | import java.awt.Color; | ||
| 29 | import java.awt.Image; | ||
| 30 | import java.awt.Shape; | ||
| 31 | import java.awt.geom.AffineTransform; | ||
| 32 | import java.awt.image.BufferedImage; | ||
| 33 | import java.awt.image.BufferedImageOp; | ||
| 34 | import java.awt.image.ImageObserver; | ||
| 35 | import sun.java2d.SunGraphics2D; | ||
| 36 | import java.awt.font.GlyphVector; | ||
| 37 | |||
| 38 | /** | ||
| 39 | * This class is used to force a revalidation of the pipelines of | ||
| 40 | * the indicated SunGraphics2D object before a draw command. | ||
| 41 | * After calling SunGraphics2D.validatePipe() to force the pipeline | ||
| 42 | * to be revalidated, this object redispatches the draw command to | ||
| 43 | * the new valid pipe object. | ||
| 44 | */ | ||
| 45 | public class ValidatePipe | ||
| 46 | implements PixelDrawPipe, PixelFillPipe, ShapeDrawPipe, TextPipe, | ||
| 47 | DrawImagePipe | ||
| 48 | { | ||
| 49 | /* | ||
| 50 | * Different subclasses may override this to do various | ||
| 51 | * other forms of validation and return a return code | ||
| 52 | * indicating whether or not the validation was successful. | ||
| 53 | */ | ||
| 54 | public boolean validate(SunGraphics2D sg) { | ||
| 55 | sg.validatePipe(); | ||
| 56 | return true; | ||
| 57 | } | ||
| 58 | |||
| 59 | public void drawLine(SunGraphics2D sg, | ||
| 60 | int x1, int y1, int x2, int y2) { | ||
| 61 | if (validate(sg)) { | ||
| 62 | sg.drawpipe.drawLine(sg, x1, y1, x2, y2); | ||
| 63 | } | ||
| 64 | } | ||
| 65 | |||
| 66 | public void drawRect(SunGraphics2D sg, | ||
| 67 | int x, int y, int width, int height) { | ||
| 68 | if (validate(sg)) { | ||
| 69 | sg.drawpipe.drawRect(sg, x, y, width, height); | ||
| 70 | } | ||
| 71 | } | ||
| 72 | |||
| 73 | public void fillRect(SunGraphics2D sg, | ||
| 74 | int x, int y, int width, int height) { | ||
| 75 | if (validate(sg)) { | ||
| 76 | sg.fillpipe.fillRect(sg, x, y, width, height); | ||
| 77 | } | ||
| 78 | } | ||
| 79 | |||
| 80 | public void drawRoundRect(SunGraphics2D sg, | ||
| 81 | int x, int y, int width, int height, | ||
| 82 | int arcWidth, int arcHeight) { | ||
| 83 | if (validate(sg)) { | ||
| 84 | sg.drawpipe.drawRoundRect(sg, x, y, width, height, | ||
| 85 | arcWidth, arcHeight); | ||
| 86 | } | ||
| 87 | } | ||
| 88 | |||
| 89 | public void fillRoundRect(SunGraphics2D sg, | ||
| 90 | int x, int y, int width, int height, | ||
| 91 | int arcWidth, int arcHeight) { | ||
| 92 | if (validate(sg)) { | ||
| 93 | sg.fillpipe.fillRoundRect(sg, x, y, width, height, | ||
| 94 | arcWidth, arcHeight); | ||
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 98 | public void drawOval(SunGraphics2D sg, | ||
| 99 | int x, int y, int width, int height) { | ||
| 100 | if (validate(sg)) { | ||
| 101 | sg.drawpipe.drawOval(sg, x, y, width, height); | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 | public void fillOval(SunGraphics2D sg, | ||
| 106 | int x, int y, int width, int height) { | ||
| 107 | if (validate(sg)) { | ||
| 108 | sg.fillpipe.fillOval(sg, x, y, width, height); | ||
| 109 | } | ||
| 110 | } | ||
| 111 | |||
| 112 | public void drawArc(SunGraphics2D sg, | ||
| 113 | int x, int y, int width, int height, | ||
| 114 | int startAngle, int arcAngle) { | ||
| 115 | if (validate(sg)) { | ||
| 116 | sg.drawpipe.drawArc(sg, x, y, width, height, startAngle, arcAngle); | ||
| 117 | } | ||
| 118 | } | ||
| 119 | |||
| 120 | public void fillArc(SunGraphics2D sg, | ||
| 121 | int x, int y, int width, int height, | ||
| 122 | int startAngle, int arcAngle) { | ||
| 123 | if (validate(sg)) { | ||
| 124 | sg.fillpipe.fillArc(sg, x, y, width, height, startAngle, arcAngle); | ||
| 125 | } | ||
| 126 | } | ||
| 127 | |||
| 128 | public void drawPolyline(SunGraphics2D sg, | ||
| 129 | int xPoints[], int yPoints[], | ||
| 130 | int nPoints) { | ||
| 131 | if (validate(sg)) { | ||
| 132 | sg.drawpipe.drawPolyline(sg, xPoints, yPoints, nPoints); | ||
| 133 | } | ||
| 134 | } | ||
| 135 | |||
| 136 | public void drawPolygon(SunGraphics2D sg, | ||
| 137 | int xPoints[], int yPoints[], | ||
| 138 | int nPoints) { | ||
| 139 | if (validate(sg)) { | ||
| 140 | sg.drawpipe.drawPolygon(sg, xPoints, yPoints, nPoints); | ||
| 141 | } | ||
| 142 | } | ||
| 143 | |||
| 144 | public void fillPolygon(SunGraphics2D sg, | ||
| 145 | int xPoints[], int yPoints[], | ||
| 146 | int nPoints) { | ||
| 147 | if (validate(sg)) { | ||
| 148 | sg.fillpipe.fillPolygon(sg, xPoints, yPoints, nPoints); | ||
| 149 | } | ||
| 150 | } | ||
| 151 | |||
| 152 | public void draw(SunGraphics2D sg, Shape s) { | ||
| 153 | if (validate(sg)) { | ||
| 154 | sg.shapepipe.draw(sg, s); | ||
| 155 | } | ||
| 156 | } | ||
| 157 | |||
| 158 | public void fill(SunGraphics2D sg, Shape s) { | ||
| 159 | if (validate(sg)) { | ||
| 160 | sg.shapepipe.fill(sg, s); | ||
| 161 | } | ||
| 162 | } | ||
| 163 | public void drawString(SunGraphics2D sg, String s, double x, double y) { | ||
| 164 | if (validate(sg)) { | ||
| 165 | sg.textpipe.drawString(sg, s, x, y); | ||
| 166 | } | ||
| 167 | } | ||
| 168 | public void drawGlyphVector(SunGraphics2D sg, GlyphVector g, | ||
| 169 | float x, float y) { | ||
| 170 | if (validate(sg)) { | ||
| 171 | sg.textpipe.drawGlyphVector(sg, g, x, y); | ||
| 172 | } | ||
| 173 | } | ||
| 174 | public void drawChars(SunGraphics2D sg, | ||
| 175 | char data[], int offset, int length, | ||
| 176 | int x, int y) { | ||
| 177 | if (validate(sg)) { | ||
| 178 | sg.textpipe.drawChars(sg, data, offset, length, x, y); | ||
| 179 | } | ||
| 180 | } | ||
| 181 | public boolean copyImage(SunGraphics2D sg, Image img, | ||
| 182 | int x, int y, | ||
| 183 | Color bgColor, | ||
| 184 | ImageObserver observer) { | ||
| 185 | if (validate(sg)) { | ||
| 186 | return sg.imagepipe.copyImage(sg, img, x, y, bgColor, observer); | ||
| 187 | } else { | ||
| 188 | return false; | ||
| 189 | } | ||
| 190 | } | ||
| 191 | public boolean copyImage(SunGraphics2D sg, Image img, | ||
| 192 | int dx, int dy, int sx, int sy, int w, int h, | ||
| 193 | Color bgColor, | ||
| 194 | ImageObserver observer) { | ||
| 195 | if (validate(sg)) { | ||
| 196 | return sg.imagepipe.copyImage(sg, img, dx, dy, sx, sy, w, h, | ||
| 197 | bgColor, observer); | ||
| 198 | } else { | ||
| 199 | return false; | ||
| 200 | } | ||
| 201 | } | ||
| 202 | public boolean scaleImage(SunGraphics2D sg, Image img, int x, int y, | ||
| 203 | int w, int h, | ||
| 204 | Color bgColor, | ||
| 205 | ImageObserver observer) { | ||
| 206 | if (validate(sg)) { | ||
| 207 | return sg.imagepipe.scaleImage(sg, img, x, y, w, h, bgColor, | ||
| 208 | observer); | ||
| 209 | } else { | ||
| 210 | return false; | ||
| 211 | } | ||
| 212 | } | ||
| 213 | public boolean scaleImage(SunGraphics2D sg, Image img, | ||
| 214 | int dx1, int dy1, int dx2, int dy2, | ||
| 215 | int sx1, int sy1, int sx2, int sy2, | ||
| 216 | Color bgColor, | ||
| 217 | ImageObserver observer) { | ||
| 218 | if (validate(sg)) { | ||
| 219 | return sg.imagepipe.scaleImage(sg, img, dx1, dy1, dx2, dy2, | ||
| 220 | sx1, sy1, sx2, sy2, bgColor, | ||
| 221 | observer); | ||
| 222 | } else { | ||
| 223 | return false; | ||
| 224 | } | ||
| 225 | } | ||
| 226 | public boolean transformImage(SunGraphics2D sg, Image img, | ||
| 227 | AffineTransform atfm, | ||
| 228 | ImageObserver observer) { | ||
| 229 | if (validate(sg)) { | ||
| 230 | return sg.imagepipe.transformImage(sg, img, atfm, observer); | ||
| 231 | } else { | ||
| 232 | return false; | ||
| 233 | } | ||
| 234 | } | ||
| 235 | public void transformImage(SunGraphics2D sg, BufferedImage img, | ||
| 236 | BufferedImageOp op, int x, int y) { | ||
| 237 | if (validate(sg)) { | ||
| 238 | sg.imagepipe.transformImage(sg, img, op, x, y); | ||
| 239 | } | ||
| 240 | } | ||
| 241 | } | ||