com.meltingice.caman
Class CamanFilter

java.lang.Object
  extended by com.meltingice.caman.CamanFilter
Direct Known Subclasses:
Brightness, Channels, Clip, Colorize, Contrast, Curves, Exposure, Gamma, GaussianBlur, Greyscale, Hue, Invert, Noise, Saturation, Sepia, Sharpen, Vibrance

public abstract class CamanFilter
extends java.lang.Object

Abstract class for all filters. Override only the methods you need, and the others will automatically throw an InvalidPluginException.

Version:
1.0
Author:
Ryan LeFevre

Constructor Summary
CamanFilter()
          Default constructor for the filter.
 
Method Summary
 double[] getKernel()
          If making a filter that requires image convolution, this returns the kernel that will be applied to the image.
 double getParamDouble(int num)
          Retrieves the specified param and forces it to be a double.
 int getParamInt(int num)
          Retrieves the specified param and forces it to be an integer.
 void precomputeParams()
          Allows the filter to precompute any required values before process(int[]) is executed.
 int[] process(int[] rgb)
          Processes the given pixel and returns the updated values.
 CamanFilter set(java.lang.Object param)
          Set a param for this filter.
 CamanFilter set(java.lang.Object[] paramArr)
          Set an array of params for easier readability/simplicity
 PluginType type()
          Reports the type of plugin this filter is
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CamanFilter

public CamanFilter()
Default constructor for the filter. This will probably never need to be overrode unless you're doing something really fancy.

Method Detail

set

public CamanFilter set(java.lang.Object param)
Set a param for this filter. Params are stored in the order that they're added.

Parameters:
param - The param to set
Returns:
This filter object for chainability reasons

set

public CamanFilter set(java.lang.Object[] paramArr)
Set an array of params for easier readability/simplicity

Parameters:
paramArr - An array of values to set
Returns:
This filter object for chainability reasons

getParamDouble

public double getParamDouble(int num)
Retrieves the specified param and forces it to be a double. This avoids confusing the user by making some filters requiring doubles with others requiring integers.

Parameters:
num - The index of the argument
Returns:
The specified argument as a double

getParamInt

public int getParamInt(int num)
Retrieves the specified param and forces it to be an integer. This avoids confusing the user by making some filters requiring doubles with others requiring integers.

Parameters:
num - The index of the argument
Returns:
The specified argument as an int

precomputeParams

public void precomputeParams()
                      throws InvalidArgumentsException
Allows the filter to precompute any required values before process(int[]) is executed. This helps with speed so that arguments don't have to be recomputed for every pixel.

Throws:
InvalidArgumentsException

type

public PluginType type()
Reports the type of plugin this filter is

Returns:
The type

process

public int[] process(int[] rgb)
              throws InvalidPluginException
Processes the given pixel and returns the updated values.

Parameters:
rgb - The current pixel's color values rgb[0] => red, rgb[1] => green, rgb[2] => blue
Returns:
The updated RGB color values
Throws:
InvalidPluginException

getKernel

public double[] getKernel()
                   throws InvalidPluginException
If making a filter that requires image convolution, this returns the kernel that will be applied to the image.

Returns:
The convolution matrix
Throws:
InvalidPluginException