org.sunflow.image
Class ColorFactory

java.lang.Object
  extended by org.sunflow.image.ColorFactory

public final class ColorFactory
extends java.lang.Object


Nested Class Summary
static class ColorFactory.ColorSpecificationException
           
 
Constructor Summary
ColorFactory()
           
 
Method Summary
static Color createColor(java.lang.String colorspace, float... data)
          Creates a color value in the renderer's internal color space from a string (representing the color space name) and an array of floating point values.
static java.lang.String getInternalColorspace()
          Return the name of the internal color space.
static int getRequiredDataValues(java.lang.String colorspace)
          Checks to see how many values are required to specify a color using the given colorspace.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorFactory

public ColorFactory()
Method Detail

getInternalColorspace

public static java.lang.String getInternalColorspace()
Return the name of the internal color space. This string can be used interchangeably with null in the following methods.

Returns:
internal colorspace name

getRequiredDataValues

public static int getRequiredDataValues(java.lang.String colorspace)
Checks to see how many values are required to specify a color using the given colorspace. This number can be variable for spectrum colors, in which case the returned value is -1. If the colorspace name is invalid, this method returns -2. No exception is thrown. This method is intended for parsers that want to know how many floating values to retrieve from a file.

Parameters:
colorspace -
Returns:
number of floating point numbers expected, -1 for any, -2 on error

createColor

public static Color createColor(java.lang.String colorspace,
                                float... data)
                         throws ColorFactory.ColorSpecificationException
Creates a color value in the renderer's internal color space from a string (representing the color space name) and an array of floating point values. If the colorspace string is null, we assume the data was supplied in internal space. This method does much error checking and may throw a RuntimeException if its parameters are not consistent. Here are the currently supported color spaces:

Parameters:
colorspace - color space name
data - data describing this color
Returns:
a valid color in the renderer's color space
Throws:
ColorFactory.ColorSpecificationException