001/*
002Copyright 2006 Jerry Huxtable
003
004Licensed under the Apache License, Version 2.0 (the "License");
005you may not use this file except in compliance with the License.
006You may obtain a copy of the License at
007
008   http://www.apache.org/licenses/LICENSE-2.0
009
010Unless required by applicable law or agreed to in writing, software
011distributed under the License is distributed on an "AS IS" BASIS,
012WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013See the License for the specific language governing permissions and
014limitations under the License.
015*/
016
017package com.jhlabs.image;
018
019import java.awt.*;
020import java.awt.image.*;
021
022/**
023 * A filter which fills an image with a given color. Normally you would just call Graphics.fillRect but it can sometimes be useful
024 * to go via a filter to fit in with an existing API.
025 */
026public class FillFilter extends PointFilter {
027
028        private int fillColor;
029
030    /**
031     * Construct a FillFilter.
032     */
033        public FillFilter() {
034                this(0xff000000);
035        }
036
037    /**
038     * Construct a FillFilter.
039     * @param color the fill color
040     */
041        public FillFilter(int color) {
042                this.fillColor = color;
043        }
044
045    /**
046     * Set the fill color.
047     * @param fillColor the fill color
048     * @see #getFillColor
049     */
050        public void setFillColor(int fillColor) {
051                this.fillColor = fillColor;
052        }
053
054    /**
055     * Get the fill color.
056     * @return the fill color
057     * @see #setFillColor
058     */
059        public int getFillColor() {
060                return fillColor;
061        }
062
063        public int filterRGB(int x, int y, int rgb) {
064                return fillColor;
065        }
066}
067