Frames | No Frames |
1: /* Copyright (C) 2000, 2002, 2004, 2006, Free Software Foundation 2: 3: This file is part of GNU Classpath. 4: 5: GNU Classpath is free software; you can redistribute it and/or modify 6: it under the terms of the GNU General Public License as published by 7: the Free Software Foundation; either version 2, or (at your option) 8: any later version. 9: 10: GNU Classpath is distributed in the hope that it will be useful, but 11: WITHOUT ANY WARRANTY; without even the implied warranty of 12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13: General Public License for more details. 14: 15: You should have received a copy of the GNU General Public License 16: along with GNU Classpath; see the file COPYING. If not, write to the 17: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 18: 02110-1301 USA. 19: 20: Linking this library statically or dynamically with other modules is 21: making a combined work based on this library. Thus, the terms and 22: conditions of the GNU General Public License cover the whole 23: combination. 24: 25: As a special exception, the copyright holders of this library give you 26: permission to link this library with independent modules to produce an 27: executable, regardless of the license terms of these independent 28: modules, and to copy and distribute the resulting executable under 29: terms of your choice, provided that you also meet, for each linked 30: independent module, the terms and conditions of the license of that 31: module. An independent module is a module which is not derived from 32: or based on this library. If you modify this library, you may extend 33: this exception to your version of the library, but you are not 34: obligated to do so. If you do not wish to do so, delete this 35: exception statement from your version. */ 36: 37: 38: package java.awt; 39: 40: import java.awt.font.FontRenderContext; 41: import java.awt.font.GlyphVector; 42: import java.awt.geom.AffineTransform; 43: import java.awt.image.BufferedImage; 44: import java.awt.image.BufferedImageOp; 45: import java.awt.image.ImageObserver; 46: import java.awt.image.RenderedImage; 47: import java.awt.image.renderable.RenderableImage; 48: import java.awt.print.PageFormat; 49: import java.awt.print.Printable; 50: import java.text.AttributedCharacterIterator; 51: import java.util.Map; 52: 53: /** 54: * An abstract class defining a device independent two-dimensional vector 55: * graphics API. Concrete subclasses implement this API for output of 56: * vector graphics to: (*) 57: * <p> 58: * <ul> 59: * <li>a {@link javax.swing.JComponent} - in the 60: * {@link javax.swing.JComponent#paint(Graphics)} method, the incoming 61: * {@link Graphics} should always be an instance of 62: * <code>Graphics2D</code> (*);</li> 63: * <li>a {@link BufferedImage} - see 64: * {@link BufferedImage#createGraphics()} (*);</li> 65: * <li>a {@link java.awt.print.PrinterJob} - in the 66: * {@link Printable#print(Graphics, PageFormat, int)} method, the incoming 67: * {@link Graphics} should always be an instance of <code>Graphics2D</code> 68: * (*).</li> 69: * </ul> 70: * <p> 71: * (*) Support for this API is not fully implemented in GNU Classpath yet. 72: * <p> 73: * Third party libraries provide support for output to other formats via this 74: * API, including encapsulated postscript (EPS), portable document format (PDF), 75: * and scalable vector graphics (SVG). 76: * 77: * @author Rolf W. Rasmussen (rolfwr@ii.uib.no) 78: */ 79: public abstract class Graphics2D extends Graphics 80: { 81: 82: protected Graphics2D() 83: { 84: } 85: 86: public void draw3DRect(int x, int y, int width, int height, 87: boolean raised) 88: { 89: super.draw3DRect(x, y, width, height, raised); 90: } 91: 92: public void fill3DRect(int x, int y, int width, int height, 93: boolean raised) 94: { 95: super.fill3DRect(x, y, width, height, raised); 96: } 97: 98: /** 99: * Draws an outline around a shape using the current stroke and paint. 100: * 101: * @param shape the shape (<code>null</code> not permitted). 102: * 103: * @see #getStroke() 104: * @see #getPaint() 105: */ 106: public abstract void draw(Shape shape); 107: 108: public abstract boolean drawImage(Image image, AffineTransform xform, 109: ImageObserver obs); 110: 111: public abstract void drawImage(BufferedImage image, 112: BufferedImageOp op, 113: int x, 114: int y); 115: 116: public abstract void drawRenderedImage(RenderedImage image, 117: AffineTransform xform); 118: 119: public abstract void drawRenderableImage(RenderableImage image, 120: AffineTransform xform); 121: 122: /** 123: * Draws a string at the specified location, using the current font. 124: * 125: * @param text the string to draw. 126: * @param x the x-coordinate. 127: * @param y the y-coordinate. 128: * 129: * @see Graphics#setFont(Font) 130: */ 131: public abstract void drawString(String text, int x, int y); 132: 133: /** 134: * Draws a string at the specified location, using the current font. 135: * 136: * @param text the string to draw. 137: * @param x the x-coordinate. 138: * @param y the y-coordinate. 139: * 140: * @see Graphics#setFont(Font) 141: */ 142: public abstract void drawString(String text, float x, float y); 143: 144: /** 145: * Draws an attributed string at the specified location. 146: * 147: * @param iterator the source of the attributed text. 148: * @param x the x-coordinate. 149: * @param y the y-coordinate. 150: */ 151: public abstract void drawString(AttributedCharacterIterator iterator, 152: int x, int y); 153: 154: /** 155: * Draws an attributed string at the specified location. 156: * 157: * @param iterator the source of the attributed text. 158: * @param x the x-coordinate. 159: * @param y the y-coordinate. 160: */ 161: public abstract void drawString(AttributedCharacterIterator iterator, 162: float x, float y); 163: 164: /** 165: * Fills the interior of the specified <code>shape</code> using the current 166: * paint. 167: * 168: * @param shape the shape to fill (<code>null</code> not permitted). 169: * 170: * @see #draw(Shape) 171: * @see #getPaint() 172: */ 173: public abstract void fill(Shape shape); 174: 175: public abstract boolean hit(Rectangle rect, Shape text, 176: boolean onStroke); 177: 178: public abstract GraphicsConfiguration getDeviceConfiguration(); 179: 180: /** 181: * Sets the current compositing rule. 182: * 183: * @param comp the composite. 184: * 185: * @see #getComposite() 186: */ 187: public abstract void setComposite(Composite comp); 188: 189: /** 190: * Sets the paint to be used for subsequent drawing operations. 191: * 192: * @param paint the paint (<code>null</code> not permitted). 193: * 194: * @see #getPaint() 195: */ 196: public abstract void setPaint(Paint paint); 197: 198: /** 199: * Sets the stroke to be used for subsequent drawing operations. 200: * 201: * @param stroke the stroke (<code>null</code> not permitted). 202: * 203: * @see #getStroke() 204: */ 205: public abstract void setStroke(Stroke stroke); 206: 207: /** 208: * Adds or updates a hint in the current rendering hints table. 209: * 210: * @param hintKey the hint key. 211: * @param hintValue the hint value. 212: */ 213: public abstract void setRenderingHint(RenderingHints.Key hintKey, 214: Object hintValue); 215: 216: /** 217: * Returns the current value of a rendering hint. 218: * 219: * @param hintKey the key for the hint. 220: * 221: * @return The value for the specified hint. 222: */ 223: public abstract Object getRenderingHint(RenderingHints.Key hintKey); 224: 225: /** 226: * Replaces the current rendering hints with the supplied hints. 227: * 228: * @param hints the hints. 229: * 230: * @see #addRenderingHints(Map) 231: */ 232: public abstract void setRenderingHints(Map hints); 233: 234: /** 235: * Adds/updates the rendering hint. 236: * 237: * @param hints the hints to add or update. 238: */ 239: public abstract void addRenderingHints(Map hints); 240: 241: /** 242: * Returns the current rendering hints. 243: * 244: * @return The current rendering hints. 245: */ 246: public abstract RenderingHints getRenderingHints(); 247: 248: public abstract void translate(int x, int y); 249: 250: public abstract void translate(double tx, double ty); 251: 252: public abstract void rotate(double theta); 253: 254: public abstract void rotate(double theta, double x, double y); 255: 256: public abstract void scale(double scaleX, double scaleY); 257: 258: public abstract void shear(double shearX, double shearY); 259: 260: /** 261: * Sets the current transform to a concatenation of <code>transform</code> 262: * and the existing transform. 263: * 264: * @param transform the transform. 265: */ 266: public abstract void transform(AffineTransform transform); 267: 268: /** 269: * Sets the current transform. If the caller specifies a <code>null</code> 270: * transform, this method should set the current transform to the 271: * identity transform. 272: * 273: * @param transform the transform (<code>null</code> permitted). 274: * 275: * @see #getTransform() 276: */ 277: public abstract void setTransform(AffineTransform transform); 278: 279: /** 280: * Returns the current transform. 281: * 282: * @return The current transform. 283: * 284: * @see #setTransform(AffineTransform) 285: */ 286: public abstract AffineTransform getTransform(); 287: 288: /** 289: * Returns the current paint. 290: * 291: * @return The current paint. 292: * 293: * @see #setPaint(Paint) 294: */ 295: public abstract Paint getPaint(); 296: 297: /** 298: * Returns the current compositing rule. 299: * 300: * @return The current compositing rule. 301: * 302: * @see #setComposite(Composite) 303: */ 304: public abstract Composite getComposite(); 305: 306: /** 307: * Sets the background color (used by the 308: * {@link Graphics#clearRect(int, int, int, int)} method). 309: * 310: * @param color the color. 311: * 312: * @see #getBackground() 313: */ 314: public abstract void setBackground(Color color); 315: 316: /** 317: * Returns the color used by the 318: * {@link Graphics#clearRect(int, int, int, int)} method. 319: * 320: * @return The background color. 321: * 322: * @see #setBackground(Color) 323: */ 324: public abstract Color getBackground(); 325: 326: /** 327: * Returns the current stroke. 328: * 329: * @return The current stroke. 330: * 331: * @see #setStroke(Stroke) 332: */ 333: public abstract Stroke getStroke(); 334: 335: /** 336: * Sets the clip region to the intersection of the current clipping region 337: * and <code>s</code>. 338: * 339: * @param s the shape to intersect with the current clipping region. 340: * 341: * @see Graphics#setClip(Shape) 342: */ 343: public abstract void clip(Shape s); 344: 345: /** 346: * Returns the font render context. 347: * 348: * @return The font render context. 349: */ 350: public abstract FontRenderContext getFontRenderContext(); 351: 352: /** 353: * Draws a glyph vector at the specified location. 354: * 355: * @param g the glyph vector. 356: * @param x the x-coordinate. 357: * @param y the y-coordinate. 358: */ 359: public abstract void drawGlyphVector(GlyphVector g, float x, float y); 360: }