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 icy.common.CollapsibleEvent;
022
023/**
024 * @author stephane
025 */
026public class IcyColorMapEvent implements CollapsibleEvent
027{
028    public enum IcyColorMapEventType
029    {
030        MAP_CHANGED, TYPE_CHANGED, ENABLED_CHANGED
031    }
032
033    private final IcyColorMap colormap;
034    private final IcyColorMapEventType type;
035
036    public IcyColorMapEvent(IcyColorMap colormap, IcyColorMapEventType type)
037    {
038        super();
039
040        this.colormap = colormap;
041        this.type = type;
042    }
043
044    /**
045     * @return the colormap
046     */
047    public IcyColorMap getColormap()
048    {
049        return colormap;
050    }
051
052    /**
053     * @return the type
054     */
055    public IcyColorMapEventType getType()
056    {
057        return type;
058    }
059
060    @Override
061    public boolean collapse(CollapsibleEvent event)
062    {
063        if (equals(event))
064        {
065            // nothing to change here
066            return true;
067        }
068
069        return false;
070    }
071
072    @Override
073    public int hashCode()
074    {
075        return colormap.hashCode() ^ type.hashCode();
076    }
077
078    @Override
079    public boolean equals(Object obj)
080    {
081        if (obj instanceof IcyColorMapEvent)
082        {
083            final IcyColorMapEvent e = (IcyColorMapEvent) obj;
084
085            return (colormap == e.getColormap()) && (type == e.getType());
086        }
087
088        return super.equals(obj);
089    }
090}