001 /*
002 * $Id: DefaultTipOfTheDayModel.java,v 1.4 2005/10/10 18:03:13 rbair Exp $
003 *
004 * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
005 * Santa Clara, California 95054, U.S.A. All rights reserved.
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * You should have received a copy of the GNU Lesser General Public
018 * License along with this library; if not, write to the Free Software
019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
020 */
021 package org.jdesktop.swingx.tips;
022
023 import java.util.ArrayList;
024 import java.util.Arrays;
025 import java.util.Collection;
026 import java.util.List;
027
028 /**
029 * Default {@link org.jdesktop.swingx.tips.TipOfTheDayModel} implementation.<br>
030 *
031 * @author <a href="mailto:fred@L2FProd.com">Frederic Lavigne</a>
032 */
033 public class DefaultTipOfTheDayModel implements TipOfTheDayModel {
034
035 private List<Tip> tips = new ArrayList<Tip>();
036
037 public DefaultTipOfTheDayModel() {
038 }
039
040 public DefaultTipOfTheDayModel(Tip[] tips) {
041 this(Arrays.asList(tips));
042 }
043
044 public DefaultTipOfTheDayModel(Collection<Tip> tips) {
045 this.tips.addAll(tips);
046 }
047
048 public Tip getTipAt(int index) {
049 return tips.get(index);
050 }
051
052 public int getTipCount() {
053 return tips.size();
054 }
055
056 public void add(Tip tip) {
057 tips.add(tip);
058 }
059
060 public void remove(Tip tip) {
061 tips.remove(tip);
062 }
063
064 public Tip[] getTips() {
065 return tips.toArray(new Tip[tips.size()]);
066 }
067
068 public void setTips(Tip[] tips) {
069 this.tips.clear();
070 this.tips.addAll(Arrays.asList(tips));
071 }
072
073 }