com.meltingice.caman
Class CamanUtil

java.lang.Object
  extended by com.meltingice.caman.CamanUtil

public class CamanUtil
extends java.lang.Object

Utility class of static methods

Version:
1.0
Author:
Ryan LeFevre

Constructor Summary
CamanUtil()
           
 
Method Summary
static int[] clampRGB(double[] drgb)
          Clamps an array of doubles and returns an array of integers.
static int clampRGB(int val)
          Clamps an integer value between 0 and 255
static int[] clampRGB(int[] rgb)
          Clamps an array of integers between 0 and 255.
static java.lang.String getFilterName(java.lang.String input)
          Given an input string, format it to produce the class name for a filter.
static double randomRange(double min, double max)
           
static int randomRange(int min, int max)
           
static double[] toDouble(int[] rgb)
          Converts an integer array to a double array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CamanUtil

public CamanUtil()
Method Detail

clampRGB

public static int clampRGB(int val)
Clamps an integer value between 0 and 255

Parameters:
val - The value to clamp
Returns:
The clamped integer

clampRGB

public static int[] clampRGB(int[] rgb)
Clamps an array of integers between 0 and 255. Useful when returning an integer array from CamanFilter.process(int[])

Parameters:
rgb - The array of integers to clamp
Returns:
The array of clamped integers

clampRGB

public static int[] clampRGB(double[] drgb)
Clamps an array of doubles and returns an array of integers. The reason it doesn't return an array of doubles is because this is designed to be returned from CamanFilter.process(int[]), and the return must be an int array. Doubles are converted to ints by simple casting, so the decimal portion of the double is dropped without rounding.

Parameters:
drgb - The array of doubles to clamp
Returns:
The array of clamped integers

toDouble

public static double[] toDouble(int[] rgb)
Converts an integer array to a double array.

Parameters:
rgb - The integer array to convert
Returns:
The array of doubles

getFilterName

public static java.lang.String getFilterName(java.lang.String input)
Given an input string, format it to produce the class name for a filter. All it does is capitolize the first letter of the name.

Parameters:
input - The filter name
Returns:
The formatted filter name

randomRange

public static double randomRange(double min,
                                 double max)

randomRange

public static int randomRange(int min,
                              int max)