001package com.hfg.ui;
002
003import java.util.Arrays;
004import java.util.HashSet;
005import java.util.Set;
006
007//------------------------------------------------------------------------------
008/**
009 Click event encapsulation.
010 <div>
011 @author J. Alex Taylor, hairyfatguy.com
012 </div>
013 */
014//------------------------------------------------------------------------------
015// com.hfg Library
016//
017// This library is free software; you can redistribute it and/or
018// modify it under the terms of the GNU Lesser General Public
019// License as published by the Free Software Foundation; either
020// version 2.1 of the License, or (at your option) any later version.
021//
022// This library is distributed in the hope that it will be useful,
023// but WITHOUT ANY WARRANTY; without even the implied warranty of
024// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
025// Lesser General Public License for more details.
026//
027// You should have received a copy of the GNU Lesser General Public
028// License along with this library; if not, write to the Free Software
029// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
030//
031// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
032// jataylor@hairyfatguy.com
033//------------------------------------------------------------------------------
034
035public class ClickEvent
036{  
037   public enum Modifier
038   {
039      DOUBLE_CLICK,
040      CONTROL_KEY,
041      META_KEY,
042      SHIFT_KEY
043   }
044
045   private Set<Modifier> mModifiers;
046
047   //###########################################################################
048   // CONSTRUCTORS
049   //###########################################################################
050
051   //---------------------------------------------------------------------------
052   public ClickEvent(Modifier... inModifiers)
053   {
054      if (inModifiers.length > 0)
055      {
056         mModifiers = new HashSet<>(inModifiers.length);
057         for (Modifier modifier : inModifiers)
058         {
059            mModifiers.add(modifier);
060         }
061      }
062   }
063
064   //###########################################################################
065   // PUBLIC METHODS
066   //###########################################################################
067
068   //---------------------------------------------------------------------------
069   public Set<Modifier> getModifiers()
070   {
071      return mModifiers;
072   }
073
074   //---------------------------------------------------------------------------
075   public boolean hasModifiers(Modifier... inModifiers)
076   {
077      return mModifiers != null && mModifiers.containsAll(Arrays.asList(inModifiers));
078   }
079
080   
081}