Source for gnu.awt.j2d.AbstractGraphicsState

   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: 
  33:   public void setFrontend(Graphics2DImpl frontend)
  34:   {
  35:     this.frontend = frontend;
  36:   }
  37:   
  38:   public void dispose()
  39:   {
  40:     frontend = null;
  41:   }
  42: 
  43:   // -------- Graphics methods:
  44:   
  45:   public abstract void setColor(Color color);
  46: 
  47:   public abstract void setPaintMode();
  48: 
  49:   public abstract void setXORMode(Color altColor);
  50: 
  51:   public abstract void setFont(Font font);
  52: 
  53:   public abstract FontMetrics getFontMetrics(Font font);
  54: 
  55:   public abstract void setClip(Shape clip);
  56: 
  57:   public abstract Shape getClip();
  58:   public abstract Rectangle getClipBounds();
  59: 
  60:   public abstract void copyArea(int x, int y, 
  61:                 int width, int height,
  62:                 int dx, int dy);
  63: 
  64:   public abstract void drawLine(int x1, int y1,
  65:                 int x2, int y2);
  66:   
  67:   public abstract void fillRect(int x, int y,
  68:                 int width, int height);
  69:   
  70:   public abstract void clearRect(int x, int y,
  71:                  int width, int height);
  72:   
  73:   public abstract void drawRoundRect(int x, int y,
  74:                      int width, int height,
  75:                      int arcWidth, int arcHeight);
  76:   
  77:   public abstract void fillRoundRect(int x, int y,
  78:                      int width, int height,
  79:                      int arcWidth, int arcHeight);
  80:   
  81:   public abstract void drawOval(int x, int y,
  82:                 int width, int height);
  83:   
  84:   public abstract void fillOval(int x, int y,
  85:                 int width, int height);
  86:   
  87:   public abstract void drawArc(int x, int y,
  88:                    int width, int height,
  89:                    int startAngle, int arcAngle);
  90:   
  91:   public abstract void fillArc(int x, int y,
  92:                    int width, int height,
  93:                    int startAngle, int arcAngle);
  94:   
  95:   public abstract void drawPolyline(int[] xPoints, int[] yPoints,int nPoints);
  96: 
  97:   public abstract void drawPolygon(int[] xPoints, int[] yPoints, int nPoints);
  98:     
  99:   public abstract void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
 100: 
 101:   public abstract boolean drawImage(Image image, int x, int y,
 102:                     ImageObserver observer);
 103:     
 104: 
 105:   // -------- Graphics2D methods:
 106: 
 107:   public abstract void draw(Shape shape);
 108: 
 109:   public abstract void fill(Shape shape);
 110:     
 111:   public abstract boolean hit(Rectangle rect, Shape text, boolean onStroke);
 112:   
 113:   public abstract void drawString(String text, int x, int y);
 114:   
 115:   public abstract void drawString(String text, float x, float y);
 116:   
 117:   public abstract void translate(int x, int y);
 118:   
 119:   public abstract void translate(double tx, double ty);
 120:   
 121:   public abstract void rotate(double theta);
 122:   
 123:   public abstract void rotate(double theta, double x, double y);
 124:   
 125:   public abstract void scale(double scaleX, double scaleY);
 126:   
 127:   public abstract void shear(double shearX, double shearY);
 128: 
 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: }