001/*
002 * Copyright 2010-2015 Institut Pasteur.
003 * 
004 * This file is part of Icy.
005 * 
006 * Icy is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 * 
011 * Icy is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014 * GNU General Public License for more details.
015 * 
016 * You should have received a copy of the GNU General Public License
017 * along with Icy. If not, see <http://www.gnu.org/licenses/>.
018 */
019package icy.image.colormap;
020
021import java.awt.Color;
022
023/**
024 * @author Stephane
025 */
026public class IceColorMap extends IcyColorMap
027{
028    private static final short[] ice_red = {0, 0, 0, 0, 0, 0, 19, 29, 50, 48, 79, 112, 134, 158, 186, 201, 217, 229,
029            242, 250, 250, 250, 250, 251, 250, 250, 250, 250, 251, 251, 243, 230};
030    private static final short[] ice_green = {156, 165, 176, 184, 190, 196, 193, 184, 171, 162, 146, 125, 107, 93, 81,
031            87, 92, 97, 95, 93, 93, 90, 85, 69, 64, 54, 47, 35, 19, 0, 4, 0};
032    private static final short[] ice_blue = {140, 147, 158, 166, 170, 176, 209, 220, 234, 225, 236, 246, 250, 251, 250,
033            250, 245, 230, 230, 222, 202, 180, 163, 142, 123, 114, 106, 94, 84, 64, 26, 27};
034
035    public IceColorMap()
036    {
037        super("Ice");
038
039        beginUpdate();
040        try
041        {
042            final int nColors = ice_red.length;
043            final float scale = (float) IcyColorMap.MAX_INDEX / (nColors - 1);
044
045            for (int i = 0; i < nColors; i++)
046            {
047                final int index = Math.round(i * scale);
048                setRGBControlPoint(index, new Color(ice_red[i], ice_green[i], ice_blue[i]));
049            }
050        }
051        finally
052        {
053            endUpdate();
054        }
055    }
056}