📄 colorbackgroundpainterstrategy.java
字号:
/* * 01/22/2005 * * ColorBackgroundPainterStrategy.java - Renders an RTextAreaBase's background * as a single color. * 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.Color;import java.awt.Graphics;import java.awt.Rectangle;/** * A strategy for painting the background of an <code>RTextAreaBase</code> * as a solid color. The default background for <code>RTextAreaBase</code>s * is this strategy using the color white. * * @author Robert Futrell * @version 0.1 * @see org.fife.ui.rtextarea.ImageBackgroundPainterStrategy */public class ColorBackgroundPainterStrategy implements BackgroundPainterStrategy { private Color color;/*****************************************************************************/ /** * Constructor. * * @param color The color to use when painting the background. */ public ColorBackgroundPainterStrategy(Color color) { setColor(color); }/*****************************************************************************/ /** * Returns whether or not the specified object is equivalent to * this one. * * @param o2 The object to which to compare. * @return Whether <code>o2</code> is another * <code>ColorBackgroundPainterStrategy</code> representing * the same color as this one. */ public boolean equals(Object o2) { return o2!=null && (o2 instanceof ColorBackgroundPainterStrategy) && this.color.equals( ((ColorBackgroundPainterStrategy)o2).getColor()); }/*****************************************************************************/ /** * Returns the color used to paint the background. * * @return The color. * @see #setColor */ public Color getColor() { return color; }/*****************************************************************************/ /** * Paints the background. * * @param g The graphics context. * @param bounds The bounds of the object whose backgrouns we're * painting. */ public void paint(Graphics g, Rectangle bounds) { Color temp = g.getColor(); g.setColor(color); g.fillRect(bounds.x,bounds.y, bounds.width,bounds.height); g.setColor(temp); }/*****************************************************************************/ /** * Sets the color used to paint the background. * * @param color The color to use. * @see #getColor */ public void setColor(Color color) { this.color = color; }/*****************************************************************************/}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -