bugfixproxygraphics2d.java

来自「swing编写的库存管理程序。毕业设计类」· Java 代码 · 共 1,607 行 · 第 1/5 页

JAVA
1,607
字号
/**
 * ========================================
 * JFreeReport : a free Java report library
 * ========================================
 *
 * Project Info:  http://www.jfree.org/jfreereport/index.html
 * Project Lead:  Thomas Morgner (taquera@sherito.org);
 *
 * (C) Copyright 2000-2003, by Simba Management Limited and Contributors.
 *
 * This library is free software; you can redistribute it and/or modify it under the terms
 * of the GNU Lesser General Public License as published by the Free Software Foundation;
 * either version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with this
 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * ------------------------------
 * BugFixProxyGraphics2D.java
 * ------------------------------
 * (C)opyright 2003, by Thomas Morgner and Contributors.
 *
 * Original Author:  Thomas Morgner;
 * Contributor(s):   David Gilbert (for Simba Management Limited);
 *
 * $Id: BugFixProxyGraphics2D.java,v 1.5 2003/11/07 18:33:51 taqua Exp $
 *
 * Changes 
 * -------------------------
 * 31.08.2003 : Initial version
 *  
 */

package org.jfree.report.modules.gui.config;

import java.awt.Color;
import java.awt.Composite;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.Paint;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.geom.AffineTransform;
import java.awt.geom.Arc2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.awt.geom.RoundRectangle2D;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.awt.image.ImageObserver;
import java.awt.image.RenderedImage;
import java.awt.image.renderable.RenderableImage;
import java.text.AttributedCharacterIterator;
import java.util.Map;

/**
 * This documents another sad chapter in Sun's java implementation.
 * The tree cell renderer does not check the clipping of the painted
 * graphics correctly.
 * <p>
 * This bug seems to be related to the TreeCellRenderer's unability to
 * display the defined (and drawn) background of the CellRenderers render
 * component.
 * <p>
 * A first hint of that bug can be found at
 * <a href="http://www.cs.cf.ac.uk/Dave/HCI/HCI_Handout_CALLER/node155.html">
 * http://www.cs.cf.ac.uk/Dave/HCI/HCI_Handout_CALLER/node155.html</a>
 *
 * @author Thomas Morgner
 */
public class BugFixProxyGraphics2D extends Graphics2D
{
  /** The proxy parent. */
  private final Graphics2D parent;

  /**
   * Creates a new proxy to fix some of the Swing bugs.
   *
   * @param parent the original graphics object
   */
  public BugFixProxyGraphics2D(final Graphics2D parent)
  {
    this.parent = parent;
  }

  /**
   * Forwards the call to the parent.
   *
   * @param s the <code>Shape</code> to be rendered
   */
  public void draw(final Shape s)
  {
    parent.draw(s);
  }

  /**
   * Forwards the call to the parent.
   *
   * @param img the <code>Image</code> to be rendered
   * @param xform the transformation from image space into user space
   * @param obs the {@link ImageObserver}
   * to be notified as more of the <code>Image</code>
   * is converted
   * @return <code>true</code> if the <code>Image</code> is
   * fully loaded and completely rendered;
   * <code>false</code> if the <code>Image</code> is still being loaded.
   */
  public boolean drawImage(final Image img,
                           final AffineTransform xform,
                           final ImageObserver obs)
  {
    return parent.drawImage (img, xform, obs);
  }

  /**
   * Renders a <code>BufferedImage</code> that is
   * filtered with a
   * {@link BufferedImageOp}.
   * The rendering attributes applied include the <code>Clip</code>,
   * <code>Transform</code>
   * and <code>Composite</code> attributes.  This is equivalent to:
   * <pre>
   * img1 = op.filter(img, null);
   * drawImage(img1, new AffineTransform(1f,0f,0f,1f,x,y), null);
   * </pre>
   * @param op the filter to be applied to the image before rendering
   * @param img the <code>BufferedImage</code> to be rendered
   * @param x the painting location ...
   * @param y the location in user space where the upper left
   * corner of the image is rendered
   * @see #transform
   * @see #setTransform
   * @see #setComposite
   * @see #clip
   * @see #setClip
   */
  public void drawImage(final BufferedImage img,
                        final BufferedImageOp op,
                        final int x,
                        final int y)
  {
    parent.drawImage (img, op, x, y);
  }

  /**
   * Forwards the call to the parent.
   *
   * @param img the image to be rendered
   * @param xform the transformation from image space into user space
   */
  public void drawRenderedImage(final RenderedImage img,
                                final AffineTransform xform)
  {
    parent.drawRenderedImage(img, xform);
  }

  /**
   * Forwards the call to the parent.
   *
   * @param img the image to be rendered
   * @param xform the transformation from image space into user space
   */
  public void drawRenderableImage(final RenderableImage img,
                                  final AffineTransform xform)
  {
    parent.drawRenderableImage(img, xform);
  }

  /**
   * Forwards the call to the parent.
   *
   * @param str the string to be rendered
   * @param x coordinates
   * @param y the coordinates where the <code>String</code>
   * should be rendered
   * @throws NullPointerException if <code>str</code> is
   *         <code>null</code>
   * @since       JDK1.0
   */
  public void drawString(final String str, final int x, final int y)
  {
    parent.drawString (str, x, y);
  }

  /**
   * Forwards the call to the parent.
   *
   * @param s the <code>String</code> to be rendered
   * @param x coordinates.
   * @param y the coordinates where the <code>String</code>
   * should be rendered
   * @throws NullPointerException if <code>str</code> is
   *         <code>null</code>
   */
  public void drawString(final String s, final float x, final float y)
  {
    parent.drawString (s, x, y);
  }

  /**
   * Forwards the call to the parent.
   *
   * @param iterator the iterator whose text is to be rendered
   * @param x coords.
   * @param y the coordinates where the iterator's text is to be
   * rendered
   */
  public void drawString(final AttributedCharacterIterator iterator,
                         final int x, final int y)
  {
    parent.drawString (iterator, x, y);
  }

  /**
   * Forwards the call to the parent.
   *
   * @param iterator the iterator whose text is to be rendered
   * @param x coords
   * @param y the coordinates where the iterator's text is to be
   * rendered
   */
  public void drawString(final AttributedCharacterIterator iterator,
                         final float x, final float y)
  {
    parent.drawString (iterator, x, y);
  }

  /**
   * Forwards the call to the parent.
   *
   * @param g the <code>GlyphVector</code> to be rendered
   * @param x coordinates.
   * @param y the position in User Space where the glyphs should
   * be rendered
   */
  public void drawGlyphVector(final GlyphVector g, final float x, final float y)
  {
    parent.drawGlyphVector(g, x, y);
  }

  /**
   * Forwards the call to the parent.
   *
   * @param s the <code>Shape</code> to be filled
   */
  public void fill(final Shape s)
  {
    parent.fill (s);
  }

  /**
   * Forwards the call to the parent.
   *
   * @param rect the area in device space to check for a hit
   * @param s the <code>Shape</code> to check for a hit
   * @param onStroke flag used to choose between testing the
   * stroked or the filled shape.  If the flag is <code>true</code>, the
   * <code>Stroke</code> oultine is tested.  If the flag is
   * <code>false</code>, the filled <code>Shape</code> is tested.
   * @return <code>true</code> if there is a hit; <code>false</code>
   * otherwise.
   */
  public boolean hit(final Rectangle rect,
                     final Shape s,
                     final boolean onStroke)
  {
    return parent.hit (rect, s, onStroke);
  }

  /**
   * Returns the device configuration associated with this
   * <code>Graphics2D</code>.
   * @return the device configuration of this <code>Graphics2D</code>.
   */
  public GraphicsConfiguration getDeviceConfiguration()
  {
    return parent.getDeviceConfiguration();
  }

  /**
   * Forwards the call to the parent.
   *
   * @throws SecurityException
   *         if a custom <code>Composite</code> object is being
   *         used to render to the screen and a security manager
   *         is set and its <code>checkPermission</code> method
   *         does not allow the operation.
   * @param comp the <code>Composite</code> object to be used for rendering
   */
  public void setComposite(final Composite comp)
  {
    parent.setComposite(comp);
  }

  /**
   * Forwards the call to the parent.
   *
   * @param paint the <code>Paint</code> object to be used to generate
   * color during the rendering process, or <code>null</code>
   */
  public void setPaint(final Paint paint)
  {
    parent.setPaint(paint);
  }

  /**
   * Sets the <code>Stroke</code> for the <code>Graphics2D</code> context.
   * @param s the <code>Stroke</code> object to be used to stroke a

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?