//
// $Id: Colorization.java,v 1.2 2002/03/08 21:16:07 mdb Exp $

package com.threerings.cast;

import java.awt.Color;
import com.threerings.media.util.ImageUtil;

/**
 * Used to support colorization of character component images.
 */
public class Colorization
{
    /** Every colorization must have a unique name that can be used to
     * compare a particular colorization record with another. */
    public String name;

    /** The root color for the colorization. */
    public Color rootColor;

    /** The range around the root color that will be colorized (in
     * delta-hue, delta-saturation, delta-value. */
    public float[] range;

    /** The adjustments to make to hue, saturation and value. */
    public float[] offsets;

    /**
     * Constructs a colorization record with the specified name.
     */
    public Colorization (String name, Color rootColor,
                         float[] range, float[] offsets)
    {
        this.name = name;
        this.rootColor = rootColor;
        this.range = range;
        this.offsets = offsets;
    }

    /**
     * Returns the root color adjusted by the colorization.
     */
    public Color getColorizedRoot ()
    {
        float[] hsv = Color.RGBtoHSB(rootColor.getRed(), rootColor.getGreen(),
                                     rootColor.getBlue(), null);
        return new Color(ImageUtil.recolorColor(hsv, offsets));
    }

    /**
     * Compares this colorization to another based on name.
     */
    public boolean equals (Object other)
    {
        if (other instanceof Colorization) {
            return ((Colorization)other).name.equals(name);
        } else {
            return false;
        }
    }

    /**
     * Returns a string representation of this colorization.
     */
    public String toString ()
    {
        return name;
    }
}

@@ -26,17 +26,17 @@
 ava,v 1.
-2
+3
  2002/03
@@ -40,19 +40,19 @@
 /03/
-08 21:16:07
+10 22:30:46
  mdb
@@ -112,16 +112,55 @@
 .Color;%0A
+import com.samskivert.util.StringUtil;%0A
 import c
@@ -341,20 +341,18 @@
  unique 
-name
+id
  that ca
@@ -440,27 +440,34 @@
  public 
-String name
+int colorizationId
 ;%0A%0A    /
@@ -845,20 +845,26 @@
 ecified 
-name
+identifier
 .%0A     *
@@ -894,19 +894,26 @@
 on (
-String name
+int colorizationId
 , Co
@@ -1007,19 +1007,39 @@
 his.
-name = name
+colorizationId = colorizationId
 ;%0A  
@@ -1535,20 +1535,18 @@
 ased on 
-name
+id
 .%0A     *
@@ -1684,25 +1684,40 @@
 er).
-name.equals(name)
+colorizationId == colorizationId
 ;%0A  
@@ -1906,12 +1906,218 @@
 urn 
-name
+String.valueOf(colorizationId);%0A    %7D%0A%0A    /**%0A     * Returns a long string representation of this colorization.%0A     */%0A    public String toVerboseString ()%0A    %7B%0A        return StringUtil.fieldsToString(this)
 ;%0A  

Use integer ids rather than names.