⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bufferedimagebackgroundpainterstrategy.java

📁 具有不同语法高亮的编辑器实例
💻 JAVA
字号:
/* * 01/22/2005 * * BufferedImageBackgroundPainterStrategy.java - Renders an RTextAreaBase's * background as an image using a BufferedImage. * Copyright (C) 2005 Robert Futrell * email@address.com * www.website.com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. */package org.fife.ui.rtextarea;import java.awt.Graphics;import java.awt.Image;/** * A strategy for painting the background of an <code>RTextAreaBase</code> * as an image.  The image is always stretched to completely fill the * <code>RTextAreaBase</code>.<p> * * A <code>java.awt.image.BufferedImage</code> is used for rendering; * theoretically, for performance you should use * <code>java.awt.image.VolatileImage</code>; see * <code>org.fife.ui.RTextArea.VolatileImageBackgroundPainterStrategy</code> * for this.<p> * * You can set the scaling hint used when stretching/skewing the image * to fit in the <code>RTextAreaBase</code>'s background via the * <code>setScalingHint</code> method, but keep in mind the more * accurate the scaling hint, the less responsive your application will * be when stretching the window (as that's the only time the image's * size is recalculated). * * @author Robert Futrell * @version 0.1 * @see org.fife.ui.rtextarea.ImageBackgroundPainterStrategy * @see org.fife.ui.rtextarea.VolatileImageBackgroundPainterStrategy */public class BufferedImageBackgroundPainterStrategy					extends ImageBackgroundPainterStrategy {	private Image bgImage;/*****************************************************************************/	/**	 * Constructor.	 *	 * @param ta The text area whose background we'll be painting.	 */	public BufferedImageBackgroundPainterStrategy(RTextAreaBase ta) {		super(ta);	}/*****************************************************************************/	/**	 * Paints the image at the specified location.  This method assumes	 * scaling has already been done, and simply paints the background	 * image "as-is."	 *	 * @param g The graphics context.	 * @param x The x-coordinate at which to paint.	 * @param y The y-coordinate at which to paint.	 */	protected void paintImage(Graphics g, int x, int y) {		if (bgImage != null)			g.drawImage(bgImage, x,y, null);	}/*****************************************************************************/	/**	 * Rescales the displayed image to be the specified size.	 *	 * @param width The new width of the image.	 * @param height The new height of the image.	 * @param hint The scaling hint to use.	 */	protected void rescaleImage(int width, int height, int hint) {		Image master = getMasterImage();		if (master!=null) {			bgImage = master.getScaledInstance(width,height, hint);			tracker.addImage(bgImage, 1);			try {				tracker.waitForID(1);			} catch (InterruptedException e) {				e.printStackTrace();				bgImage = null;				return;			} finally {				tracker.removeImage(bgImage, 1);			}		}		else {			bgImage = null;		}	}/*****************************************************************************/}

⌨️ 快捷键说明

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