# Class TapServiceTreeModel

java.lang.Object
uk.ac.starlink.vo.TapServiceTreeModel

All Implemented Interfaces:
  `TreeModel`

public class TapServiceTreeModel extends Object implements 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 Summary

Constructors
Modifier
Constructor
Description
``
`TapServiceTreeModel(String rootLabel)`
Constructs an instance with no entries.
`protected`
`TapServiceTreeModel(String rootLabel, TapServiceFinder.Service[] services, Map<TapServiceFinder.Service, TapServiceFinder.Table[]> tableMap)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`addTreeModelListener(TreeModelListener lnr)`
`static TreeCellRenderer`
`createCellRenderer()`
Returns a cell renderer suitable for rendering nodes of a JTree using a model of this class.
`Object`
`getChild(Object parent, int index)`
`int`
`getChildCount(Object parent)`
`int`
`getIndexOfChild(Object parent, Object child)`
`Object`
`getRoot()`
`static TapServiceFinder.Service`
`getService(TreePath path)`
Returns a service in the ancestry of a supplied path.
`static TreePath`
`getServicePath(TreePath path)`
Returns a tree path which correponds to a TAP service, and which is an ancestor of the supplied path.
`static TapServiceFinder.Table`
`getTable(TreePath path)`
Returns a table that forms part of a supplied path.
`boolean`
`isLeaf(Object node)`
`static TapServiceTreeModel`
`readTreeModel(TapServiceFinder.Service[] allServices, TapServiceFinder finder, TapServiceFinder.Constraint constraint)`
Constructs a tree model based on some given constraints.
`void`
`removeTreeModelListener(TreeModelListener lnr)`
`void`
`valueForPathChanged(TreePath path, Object newValue)`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### TapServiceTreeModel

protected TapServiceTreeModel(String rootLabel, TapServiceFinder.Service[] services, 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(String rootLabel)
Constructs an instance with no entries.

Parameters:
  `rootLabel` - text label for root element (may be null)

## Method Details

### getRoot

public Object getRoot()

Specified by:
  `getRoot` in interface `TreeModel`

### isLeaf

public boolean isLeaf(Object node)

Specified by:
  `isLeaf` in interface `TreeModel`

### getChildCount

public int getChildCount(Object parent)

Specified by:
  `getChildCount` in interface `TreeModel`

### getChild

public Object getChild(Object parent, int index)

Specified by:
  `getChild` in interface `TreeModel`

### getIndexOfChild

public int getIndexOfChild(Object parent, Object child)

Specified by:
  `getIndexOfChild` in interface `TreeModel`

### valueForPathChanged

public void valueForPathChanged(TreePath path, Object newValue)

Specified by:
  `valueForPathChanged` in interface `TreeModel`

### addTreeModelListener

public void addTreeModelListener(TreeModelListener lnr)

Specified by:
  `addTreeModelListener` in interface `TreeModel`

### removeTreeModelListener

public void removeTreeModelListener(TreeModelListener lnr)

Specified by:
  `removeTreeModelListener` in interface `TreeModel`

### getServicePath

public static TreePath getServicePath(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(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

### getTable

public static TapServiceFinder.Table getTable(TreePath path)
Returns a table that forms part of a supplied path.

Parameters:
  `path` - path to examine
Returns:
  table at the end of the path, or null if there isn't one

### readTreeModel

public static TapServiceTreeModel readTreeModel(TapServiceFinder.Service[] allServices, TapServiceFinder finder, TapServiceFinder.Constraint constraint) throws 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:
  `IOException`

### createCellRenderer

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

Returns:
  tree cell renderer