Class SelectiveClientListModel

  • All Implemented Interfaces:
    java.io.Serializable, javax.swing.ListModel
    Direct Known Subclasses:
    SubscribedClientListModel

    public abstract class SelectiveClientListModel
    extends javax.swing.AbstractListModel
    ListModel implementation which sits on top of an existing ListModel containing Clients, but only includes a subset of its elements.

    Concrete subclasses must

    1. implement the isIncluded(org.astrogrid.samp.Client) method to determine which clients from the base list appear in this one
    2. call init() before the class is used (for instance in their constructor)
      Since:
      1 Sep 2008
      Author:
      Mark Taylor
      See Also:
      Serialized Form
      • Field Summary

        Fields 
        Modifier and Type Field Description
        private javax.swing.ListModel baseModel_  
        private javax.swing.event.ListDataListener listDataListener_  
        private int[] map_  
        • Fields inherited from class javax.swing.AbstractListModel

          listenerList
      • Constructor Summary

        Constructors 
        Constructor Description
        SelectiveClientListModel​(javax.swing.ListModel clientListModel)
        Constructor.
      • Method Summary

        All Methods Instance Methods Abstract Methods Concrete Methods 
        Modifier and Type Method Description
        private int[] calculateMap()
        Recalculates the this list -> base list lookup table.
        void dispose()
        Releases any resources associated with this transmitter.
        java.lang.Object getElementAt​(int index)  
        int getSize()  
        protected void init()
        Must be called by subclass prior to use.
        protected abstract boolean isIncluded​(Client client)
        Implement this method to determine which clients are included in this list.
        protected void refresh()
        Recalculates the inclusions.
        • Methods inherited from class javax.swing.AbstractListModel

          addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
        • Methods inherited from class java.lang.Object

          clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Field Detail

        • baseModel_

          private final javax.swing.ListModel baseModel_
        • listDataListener_

          private final javax.swing.event.ListDataListener listDataListener_
        • map_

          private int[] map_
      • Constructor Detail

        • SelectiveClientListModel

          public SelectiveClientListModel​(javax.swing.ListModel clientListModel)
          Constructor.
          Parameters:
          clientListModel - base ListModel containing Client objects
      • Method Detail

        • isIncluded

          protected abstract boolean isIncluded​(Client client)
          Implement this method to determine which clients are included in this list.
          Parameters:
          client - client for consideration
          Returns:
          true iff client is to be included in this list
        • init

          protected void init()
          Must be called by subclass prior to use.
        • refresh

          protected void refresh()
          Recalculates the inclusions. This should be called if the return value from isIncluded(org.astrogrid.samp.Client) might have changed for some of the elements.
        • getSize

          public int getSize()
        • getElementAt

          public java.lang.Object getElementAt​(int index)
        • dispose

          public void dispose()
          Releases any resources associated with this transmitter.
        • calculateMap

          private int[] calculateMap()
          Recalculates the this list -> base list lookup table.
          Returns:
          array whose indices represent elements of this list, and values represent elements of the base list