Home » openjdk-7 » javax » swing » [javadoc | source]

    1   /*
    2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    3    *  contributor license agreements.  See the NOTICE file distributed with
    4    *  this work for additional information regarding copyright ownership.
    5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    6    *  (the "License"); you may not use this file except in compliance with
    7    *  the License.  You may obtain a copy of the License at
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    *  Unless required by applicable law or agreed to in writing, software
   12    *  distributed under the License is distributed on an "AS IS" BASIS,
   13    *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    *  See the License for the specific language governing permissions and
   15    *  limitations under the License.
   16    */
   17   
   18   /**
   19    * @author Anton Avtamonov
   20    */
   21   package javax.swing;
   22   
   23   import java.awt.Color;
   24   import java.awt.Component;
   25   import java.awt.Font;
   26   import java.awt.FontMetrics;
   27   import java.awt.Graphics;
   28   import java.awt.Image;
   29   import java.awt.Rectangle;
   30   import java.awt.Shape;
   31   import java.awt.image.ImageObserver;
   32   import java.text.AttributedCharacterIterator;
   33   
   34   class OffscreenGraphics extends Graphics {
   35       private final Graphics offscreenGraphics;
   36       private final Image offscreenImage;
   37   
   38       public OffscreenGraphics(final Image image) {
   39           offscreenImage = image;
   40           offscreenGraphics = offscreenImage.getGraphics();
   41       }
   42   
   43       public Image getImage() {
   44           return offscreenImage;
   45       }
   46   
   47       public void setColor(final Color color) {
   48           offscreenGraphics.setColor(color);
   49       }
   50   
   51       public Graphics create() {
   52           return new OffscreenGraphics(offscreenImage);
   53       }
   54   
   55       public void dispose() {
   56           offscreenGraphics.dispose();
   57       }
   58   
   59       public Shape getClip() {
   60           return offscreenGraphics.getClip();
   61       }
   62   
   63       public Font getFont() {
   64           return offscreenGraphics.getFont();
   65       }
   66   
   67       public FontMetrics getFontMetrics(final Font font) {
   68           return offscreenGraphics.getFontMetrics(font);
   69       }
   70   
   71       public void setClip(final Shape clip) {
   72           offscreenGraphics.setClip(clip);
   73       }
   74   
   75       public void setClip(final int x, final int y, final int width, final int height) {
   76           offscreenGraphics.setClip(x, y, width, height);
   77       }
   78   
   79       public void setFont(final Font font) {
   80           offscreenGraphics.setFont(font);
   81       }
   82   
   83       public void translate(final int x, final int y) {
   84           offscreenGraphics.translate(x, y);
   85       }
   86   
   87       public void clearRect(final int x, final int y, final int width, final int height) {
   88           offscreenGraphics.clearRect(x, y, width, height);
   89       }
   90   
   91       public boolean drawImage(final Image img, final int dx1, final int dy1, final int dx2, final int dy2, final int sx1, final int sy1, final int sx2, final int sy2, final Color bgcolor, final ImageObserver observer) {
   92           return offscreenGraphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer);
   93       }
   94   
   95       public boolean drawImage(final Image img, final int x, final int y, final ImageObserver observer) {
   96           return offscreenGraphics.drawImage(img, x, y, observer);
   97       }
   98   
   99       public boolean drawImage(final Image img, final int x, final int y, final int width, final int height, final ImageObserver observer) {
  100           return offscreenGraphics.drawImage(img, x, y, width, height, observer);
  101       }
  102   
  103       public boolean drawImage(final Image img, final int dx1, final int dy1, final int dx2, final int dy2, final int sx1, final int sy1, final int sx2, final int sy2, final ImageObserver observer) {
  104           return offscreenGraphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer);
  105       }
  106   
  107       public boolean drawImage(final Image img, final int x, final int y, final int width, final int height, final Color bgcolor, final ImageObserver observer) {
  108           return offscreenGraphics.drawImage(img, x, y, width, height, bgcolor, observer);
  109       }
  110   
  111       public boolean drawImage(final Image img, final int x, final int y, final Color bgcolor, final ImageObserver observer) {
  112           return offscreenGraphics.drawImage(img, x, y, bgcolor, observer);
  113       }
  114   
  115       public void fillRect(final int x, final int y, final int width, final int height) {
  116           offscreenGraphics.fillRect(x, y, width, height);
  117       }
  118   
  119       public void clipRect(final int x, final int y, final int width, final int height) {
  120           offscreenGraphics.clipRect(x, y, width, height);
  121       }
  122   
  123       public void copyArea(final int x, final int y, final int width, final int height, final int dx, final int dy) {
  124           offscreenGraphics.copyArea(x, y, width, height, dx, dy);
  125       }
  126   
  127       public void drawArc(final int x, final int y, final int width, final int height, final int startAngle, final int arcAngle) {
  128           offscreenGraphics.drawArc(x, y, width, height, startAngle, arcAngle);
  129       }
  130   
  131       public void drawLine(final int x1, final int y1, final int x2, final int y2) {
  132           offscreenGraphics.drawLine(x1, y1, x2, y2);
  133       }
  134   
  135       public void drawOval(final int x, final int y, final int width, final int height) {
  136           offscreenGraphics.drawOval(x, y, width, height);
  137       }
  138   
  139       public void drawPolygon(final int[] xPoints, final int[] yPoints, final int nPoints) {
  140           offscreenGraphics.drawPolygon(xPoints, yPoints, nPoints);
  141       }
  142   
  143       public void drawPolyline(final int[] xPoints, final int[] yPoints, final int nPoints) {
  144           offscreenGraphics.drawPolyline(xPoints, yPoints, nPoints);
  145       }
  146   
  147       public void drawRoundRect(final int x, final int y, final int width, final int height, final int arcWidth, final int arcHeight) {
  148           offscreenGraphics.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
  149       }
  150   
  151       public void drawString(final String str, final int x, final int y) {
  152           offscreenGraphics.drawString(str, x, y);
  153       }
  154   
  155       public void drawString(final AttributedCharacterIterator iterator, final int x, final int y) {
  156           offscreenGraphics.drawString(iterator, x, y);
  157       }
  158   
  159       public void fillArc(final int x, final int y, final int width, final int height, final int startAngle, final int arcAngle) {
  160           offscreenGraphics.fillArc(x, y, width, height, startAngle, arcAngle);
  161       }
  162   
  163       public void fillOval(final int x, final int y, final int width, final int height) {
  164           offscreenGraphics.fillOval(x, y, width, height);
  165       }
  166   
  167       public void fillPolygon(final int[] xPoints, final int[] yPoints, final int nPoints) {
  168           offscreenGraphics.fillPolygon(xPoints, yPoints, nPoints);
  169       }
  170   
  171       public void fillRoundRect(final int x, final int y, final int width, final int height, final int arcWidth, final int arcHeight) {
  172           offscreenGraphics.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
  173       }
  174   
  175       public Rectangle getClipBounds() {
  176           return offscreenGraphics.getClipBounds();
  177       }
  178   
  179       public Color getColor() {
  180           return offscreenGraphics.getColor();
  181       }
  182   
  183       public void setPaintMode() {
  184           offscreenGraphics.setPaintMode();
  185       }
  186   
  187       public void setXORMode(final Color color) {
  188           offscreenGraphics.setXORMode(color);
  189       }
  190   }

Home » openjdk-7 » javax » swing » [javadoc | source]