Class TapServiceTreeModel

  • All Implemented Interfaces:
    javax.swing.tree.TreeModel

    public class TapServiceTreeModel
    extends java.lang.Object
    implements javax.swing.tree.TreeModel
    TreeModel implementation representing a particular set of tables contained in a list of known TAP services.
    Since:
    30 Jun 2015
    Author:
    Mark Taylor
    • Constructor Detail

      • TapServiceTreeModel

        protected TapServiceTreeModel​(java.lang.String rootLabel,
                                      TapServiceFinder.Service[] services,
                                      java.util.Map<TapServiceFinder.Service,​TapServiceFinder.Table[]> tableMap)
        Constructor.
        Parameters:
        rootLabel - text label for root element (may be null)
        services - list of services nodes in tree
        tableMap - array of tables providing child nodes for each service; may be null if no table children are required, but if not null must contain an entry for each service
      • TapServiceTreeModel

        public TapServiceTreeModel​(java.lang.String rootLabel)
        Constructs an instance with no entries.
        Parameters:
        rootLabel - text label for root element (may be null)
    • Method Detail

      • getRoot

        public java.lang.Object getRoot()
        Specified by:
        getRoot in interface javax.swing.tree.TreeModel
      • isLeaf

        public boolean isLeaf​(java.lang.Object node)
        Specified by:
        isLeaf in interface javax.swing.tree.TreeModel
      • getChildCount

        public int getChildCount​(java.lang.Object parent)
        Specified by:
        getChildCount in interface javax.swing.tree.TreeModel
      • getChild

        public java.lang.Object getChild​(java.lang.Object parent,
                                         int index)
        Specified by:
        getChild in interface javax.swing.tree.TreeModel
      • getIndexOfChild

        public int getIndexOfChild​(java.lang.Object parent,
                                   java.lang.Object child)
        Specified by:
        getIndexOfChild in interface javax.swing.tree.TreeModel
      • valueForPathChanged

        public void valueForPathChanged​(javax.swing.tree.TreePath path,
                                        java.lang.Object newValue)
        Specified by:
        valueForPathChanged in interface javax.swing.tree.TreeModel
      • addTreeModelListener

        public void addTreeModelListener​(javax.swing.event.TreeModelListener lnr)
        Specified by:
        addTreeModelListener in interface javax.swing.tree.TreeModel
      • removeTreeModelListener

        public void removeTreeModelListener​(javax.swing.event.TreeModelListener lnr)
        Specified by:
        removeTreeModelListener in interface javax.swing.tree.TreeModel
      • getServicePath

        public static javax.swing.tree.TreePath getServicePath​(javax.swing.tree.TreePath path)
        Returns a tree path which correponds to a TAP service, and which is an ancestor of the supplied path. The supplied path counts as its own ancestor for these purposes.
        Parameters:
        path - path to examine
        Returns:
        path corresponding to a sub-path of the supplied one, for which the terminal element is a TapServiceFinder.Service, or null if no service appears in the ancestry
      • getService

        public static TapServiceFinder.Service getService​(javax.swing.tree.TreePath path)
        Returns a service in the ancestry of a supplied path. The supplied path counts as its own ancestor for these purposes.
        Parameters:
        path - path to examine
        Returns:
        service owning the path, or null if no service appears in the ancestry
      • readTreeModel

        public static TapServiceTreeModel readTreeModel​(TapServiceFinder.Service[] allServices,
                                                        TapServiceFinder finder,
                                                        TapServiceFinder.Constraint constraint)
                                                 throws java.io.IOException
        Constructs a tree model based on some given constraints. May require a read of service data, hence should not be executed on the Event Dispatch Thread.
        Parameters:
        allServices - list of all services that may be relevant
        finder - object that can search for TAP services
        constraint - defines the services of interest; if null, all are used
        Returns:
        tree model
        Throws:
        java.io.IOException
      • createCellRenderer

        public static javax.swing.tree.TreeCellRenderer createCellRenderer()
        Returns a cell renderer suitable for rendering nodes of a JTree using a model of this class.
        Returns:
        tree cell renderer