1 /* Copyright (C) 2000, 2001 Free Software Foundation 2 3 This file is part of libgcj. 4 5 This software is copyrighted work licensed under the terms of the 6 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for 7 details. */ 8 9 package gnu.awt.j2d; 10 11 import java.awt.Color; 12 import java.awt.Image; 13 import java.awt.Shape; 14 import java.awt.Rectangle; 15 import java.awt.Graphics; 16 import java.awt.Graphics2D; 17 import java.awt.GraphicsConfiguration; 18 import java.awt.Font; 19 import java.awt.FontMetrics; 20 import java.awt.image.ImageObserver; 21 22 /** 23 * Base class for graphics state objects (State pattern, GOF book) 24 * that represents the current pipeline configuration. The Graphics2D 25 * object forwards most of the requests to the state object. The 26 * Graphics2D object itself only administers properties that are not 27 * specific for a certain state. 28 */ 29 public abstract class AbstractGraphicsState implements Cloneable 30 { 31 Graphics2DImpl frontend; 32 setFrontend(Graphics2DImpl frontend)33 public void setFrontend(Graphics2DImpl frontend) 34 { 35 this.frontend = frontend; 36 } 37 dispose()38 public void dispose() 39 { 40 frontend = null; 41 } 42 43 // -------- Graphics methods: 44 setColor(Color color)45 public abstract void setColor(Color color); 46 setPaintMode()47 public abstract void setPaintMode(); 48 setXORMode(Color altColor)49 public abstract void setXORMode(Color altColor); 50 setFont(Font font)51 public abstract void setFont(Font font); 52 getFontMetrics(Font font)53 public abstract FontMetrics getFontMetrics(Font font); 54 setClip(Shape clip)55 public abstract void setClip(Shape clip); 56 getClip()57 public abstract Shape getClip(); getClipBounds()58 public abstract Rectangle getClipBounds(); 59 copyArea(int x, int y, int width, int height, int dx, int dy)60 public abstract void copyArea(int x, int y, 61 int width, int height, 62 int dx, int dy); 63 drawLine(int x1, int y1, int x2, int y2)64 public abstract void drawLine(int x1, int y1, 65 int x2, int y2); 66 fillRect(int x, int y, int width, int height)67 public abstract void fillRect(int x, int y, 68 int width, int height); 69 clearRect(int x, int y, int width, int height)70 public abstract void clearRect(int x, int y, 71 int width, int height); 72 drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)73 public abstract void drawRoundRect(int x, int y, 74 int width, int height, 75 int arcWidth, int arcHeight); 76 fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)77 public abstract void fillRoundRect(int x, int y, 78 int width, int height, 79 int arcWidth, int arcHeight); 80 drawOval(int x, int y, int width, int height)81 public abstract void drawOval(int x, int y, 82 int width, int height); 83 fillOval(int x, int y, int width, int height)84 public abstract void fillOval(int x, int y, 85 int width, int height); 86 drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)87 public abstract void drawArc(int x, int y, 88 int width, int height, 89 int startAngle, int arcAngle); 90 fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)91 public abstract void fillArc(int x, int y, 92 int width, int height, 93 int startAngle, int arcAngle); 94 drawPolyline(int[] xPoints, int[] yPoints,int nPoints)95 public abstract void drawPolyline(int[] xPoints, int[] yPoints,int nPoints); 96 drawPolygon(int[] xPoints, int[] yPoints, int nPoints)97 public abstract void drawPolygon(int[] xPoints, int[] yPoints, int nPoints); 98 fillPolygon(int[] xPoints, int[] yPoints, int nPoints)99 public abstract void fillPolygon(int[] xPoints, int[] yPoints, int nPoints); 100 drawImage(Image image, int x, int y, ImageObserver observer)101 public abstract boolean drawImage(Image image, int x, int y, 102 ImageObserver observer); 103 104 105 // -------- Graphics2D methods: 106 draw(Shape shape)107 public abstract void draw(Shape shape); 108 fill(Shape shape)109 public abstract void fill(Shape shape); 110 hit(Rectangle rect, Shape text, boolean onStroke)111 public abstract boolean hit(Rectangle rect, Shape text, boolean onStroke); 112 drawString(String text, int x, int y)113 public abstract void drawString(String text, int x, int y); 114 drawString(String text, float x, float y)115 public abstract void drawString(String text, float x, float y); 116 translate(int x, int y)117 public abstract void translate(int x, int y); 118 translate(double tx, double ty)119 public abstract void translate(double tx, double ty); 120 rotate(double theta)121 public abstract void rotate(double theta); 122 rotate(double theta, double x, double y)123 public abstract void rotate(double theta, double x, double y); 124 scale(double scaleX, double scaleY)125 public abstract void scale(double scaleX, double scaleY); 126 shear(double shearX, double shearY)127 public abstract void shear(double shearX, double shearY); 128 clone()129 public Object clone () 130 { 131 try 132 { 133 return super.clone (); 134 } 135 catch (CloneNotSupportedException ex) 136 { 137 // This should never happen. 138 throw new InternalError (); 139 } 140 } 141 } 142