View Javadoc

1   // START LICENSE
2   // JSet - a Java JSet card board game implementation
3   // Copyright (C) 2004 Jerome Lacoste
4   //
5   // This program is free software; you can redistribute it and/or modify
6   // it under the terms of the GNU General Public License as published by
7   // the Free Software Foundation; either version 2 of the License, or (at
8   // your option) any later version.
9   //
10  // This program is distributed in the hope that it will be useful, but
11  // WITHOUT ANY WARRANTY; without even the implied warranty of
12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  // General Public License for more details.
14  //
15  // You should have received a copy of the GNU General Public License
16  // along with this program; if not, write to the Free Software
17  // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18  // END LICENSE
19  
20  package org.cb.cardboard;
21  
22  import javax.swing.*;
23  import javax.swing.event.EventListenerList;
24  
25  /***
26   * Default data model for board selections.
27   * <p>
28   * we shamely reuse the DefaultListSelectionModel interface & adapts its implementation.
29   *
30   * @author jerome@coffeebreaks.org - last modified by $LastModifiedBy$
31   * @version $Id: DefaultBoardSelectionModel.java 123 2004-04-14 23:45:53Z jerome $
32   */
33  public class DefaultBoardSelectionModel implements BoardSelectionModel
34  {
35    /*** the adapted <code>DefaultListSelectionModel</code> instance. */
36    private final DefaultListSelectionModel _adaptee = new DefaultListSelectionModel();
37    /*** the listener list. */
38    private final EventListenerList _listenerList = new EventListenerList();
39  
40    public void setSelectionInterval(final int index0, final int index1)
41    {
42      _adaptee.setSelectionInterval(index0, index1);
43    }
44  
45    public void addSelectionInterval(final int index0, final int index1)
46    {
47      _adaptee.addSelectionInterval(index0, index1);
48    }
49  
50    public void removeSelectionInterval(final int index0, final int index1)
51    {
52      _adaptee.removeSelectionInterval(index0, index1);
53    }
54  
55    public int getMinSelectionIndex()
56    {
57      return _adaptee.getMinSelectionIndex();
58    }
59  
60    public int getMaxSelectionIndex()
61    {
62      return _adaptee.getMaxSelectionIndex();
63    }
64  
65    public boolean isSelectedIndex(final int index)
66    {
67      return _adaptee.isSelectedIndex(index);
68    }
69  
70    public int getAnchorSelectionIndex()
71    {
72      return _adaptee.getAnchorSelectionIndex();
73    }
74  
75    public void setAnchorSelectionIndex(final int index)
76    {
77      _adaptee.setAnchorSelectionIndex(index);
78    }
79  
80    public int getLeadSelectionIndex()
81    {
82      return _adaptee.getLeadSelectionIndex();
83    }
84  
85    public void setLeadSelectionIndex(final int index)
86    {
87      _adaptee.setLeadSelectionIndex(index);
88    }
89  
90    public void clearSelection()
91    {
92      _adaptee.clearSelection();
93    }
94  
95    public boolean isSelectionEmpty()
96    {
97      return _adaptee.isSelectionEmpty();
98    }
99  
100   public void insertIndexInterval(final int index, final int length, final boolean before)
101   {
102     _adaptee.insertIndexInterval(index, length, before);
103   }
104 
105   public void removeIndexInterval(final int index0, final int index1)
106   {
107     _adaptee.removeIndexInterval(index0, index1);
108   }
109 
110   public void setValueIsAdjusting(final boolean valueIsAdjusting)
111   {
112     _adaptee.setValueIsAdjusting(valueIsAdjusting);
113   }
114 
115   public boolean getValueIsAdjusting()
116   {
117     return _adaptee.getValueIsAdjusting();
118   }
119 
120   public void setSelectionMode(final int selectionMode)
121   {
122     _adaptee.setSelectionMode(selectionMode);
123   }
124 
125   public int getSelectionMode()
126   {
127     return _adaptee.getSelectionMode();
128   }
129 
130   public void addBoardSelectionListener(final BoardSelectionListener x)
131   {
132     _listenerList.add(BoardSelectionListener.class, x);
133   }
134 
135   public void removeBoardSelectionListener(final BoardSelectionListener x)
136   {
137     _listenerList.remove(BoardSelectionListener.class, x);
138   }
139 }