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.*;
021import com.jhlabs.math.*;
022
023/**
024 * The superclass for some of the filters which work on binary images.
025 */
026public abstract class BinaryFilter extends WholeImageFilter {
027
028        protected int newColor = 0xff000000;
029        protected BinaryFunction blackFunction = new BlackFunction();
030        protected int iterations = 1;
031        protected Colormap colormap;
032
033        /**
034         * Set the number of iterations the effect is performed.
035         * @param iterations the number of iterations
036     * @min-value 0
037     * @see #getIterations
038         */
039        public void setIterations(int iterations) {
040                this.iterations = iterations;
041        }
042
043        /**
044         * Get the number of iterations the effect is performed.
045         * @return the number of iterations
046     * @see #setIterations
047         */
048        public int getIterations() {
049                return iterations;
050        }
051
052    /**
053     * Set the colormap to be used for the filter.
054     * @param colormap the colormap
055     * @see #getColormap
056     */
057        public void setColormap(Colormap colormap) {
058                this.colormap = colormap;
059        }
060
061    /**
062     * Get the colormap to be used for the filter.
063     * @return the colormap
064     * @see #setColormap
065     */
066        public Colormap getColormap() {
067                return colormap;
068        }
069
070        public void setNewColor(int newColor) {
071                this.newColor = newColor;
072        }
073
074        public int getNewColor() {
075                return newColor;
076        }
077
078        public void setBlackFunction(BinaryFunction blackFunction) {
079                this.blackFunction = blackFunction;
080        }
081
082        public BinaryFunction getBlackFunction() {
083                return blackFunction;
084        }
085
086}
087