Changeset 7212 for branches/maven


Ignore:
Timestamp:
11/16/10 20:28:53 (10 years ago)
Author:
aivar
Message:

Added new method to generate a color bar. Added javadoc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/maven/projects/slim-plugin/src/main/java/loci/slim/colorizer/FiveColorColorize.java

    r7130 r7212  
    3838 
    3939/** 
    40  * TODO 
     40 * Colorizes data based on a sequence of five colors. 
    4141 * 
    42  * <dl><dt><b>Source code:</b></dt> 
    43  * <dd><a href="http://dev.loci.wisc.edu/trac/java/browser/trunk/projects/slim-plugin/src/main/java/loci/colorizer/ThreeColorColorize.java">Trac</a>, 
    44  * <a href="http://dev.loci.wisc.edu/svn/java/trunk/projects/slim-plugin/src/main/java/loci/colorizer/ThreeColorColorize.java">SVN</a></dd></dl> 
    45  * 
    46  * @author Aivar Grislis grislis at wisc.edu 
     42 * @author Aivar Grislis 
    4743 */ 
    48 public class FiveColorColorize implements IColorize { 
     44public class FiveColorColorize extends MultiColorColorize implements IColorize { 
    4945    Color m_color1; 
    5046    Color m_color2; 
     
    5349    Color m_color5; 
    5450 
     51    /** 
     52     * Constructor.  Specifies the sequence of five colors. 
     53     * 
     54     * @param color1 
     55     * @param color2 
     56     * @param color3 
     57     * @param color4 
     58     * @param color5 
     59     */ 
    5560    public FiveColorColorize(Color color1, Color color2, Color color3, Color color4, Color color5) { 
    5661        m_color1 = color1; 
     
    6166    } 
    6267 
     68    /** 
     69     * Colorizes a data value. 
     70     * 
     71     * @param start value associated with starting color 
     72     * @param stop value associated with ending color 
     73     * @param value to be colorized 
     74     * @return interpolated color 
     75     */ 
    6376    public Color colorize(double start, double stop, double value) { 
    6477        Color returnColor = Color.BLACK; 
     
    8497        return returnColor; 
    8598    } 
    86  
    87     private Color interpolateColor(Color start, Color end, double blend) { 
    88         int startRed   = start.getRed(); 
    89         int startGreen = start.getGreen(); 
    90         int startBlue  = start.getBlue(); 
    91         int endRed   = end.getRed(); 
    92         int endGreen = end.getGreen(); 
    93         int endBlue  = end.getBlue(); 
    94         int red   = interpolateColorComponent(startRed, endRed, blend); 
    95         int green = interpolateColorComponent(startGreen, endGreen, blend); 
    96         int blue  = interpolateColorComponent(startBlue, endBlue, blend); 
    97         Color returnColor = Color.BLACK; 
    98         try { 
    99             returnColor = new Color(red, green, blue); 
    100         } 
    101         catch (Exception e) { 
    102             System.out.println("Exception " + e + " " + red + " " + green + " " + blue); 
    103         } 
    104         return returnColor; 
    105     } 
    106  
    107     private int interpolateColorComponent(int start, int end, double blend) { 
    108         return (int)(blend * (end - start) + start); 
    109     } 
    110  
    11199} 
Note: See TracChangeset for help on using the changeset viewer.