Class ChannelMap

Object
ChannelMap

public class ChannelMap extends Object
A mapping of assigned channel-names to particular indices.

This can be useful for opening an image file that contains many Channels and mapping all, or some subset, of the channels to semantically-meaningful identifiers.

The class preserves insertion order (via add(org.anchoranalysis.image.io.bean.channel.IndexedChannel) by internally using a LinkedHashMap.

Author:
Owen Feehan
  • Constructor Details

    • ChannelMap

      public ChannelMap()
  • Method Details

    • add

      public void add(IndexedChannel channel)
      Adds a IndexedChannel into the map.
      Parameters:
      channel - the channel to add.
    • get

      public int get(String name)
      Gets the index corresponding to a particular channel-name.
      Parameters:
      name - the channel name to find a corresponding index for.
      Returns:
      the index (beginning at 0) for the channel-name, or -1 if no such name exists in the map.
    • getException

      public int getException(String name)
      Like get(java.lang.String) but throws an exception if a particular channel-name does not exist in the map.
      Parameters:
      name - the channel name to find a corresponding index for.
      Returns:
      the index (beginning at 0) for the channel-name.
      Throws:
      IndexOutOfBoundsException - if the channel doesn't exist in the map.
    • names

      public Set<String> names()
      The names of the Channels in the map.
      Returns:
      a Set view on the names of the Channels in the map.
    • values

      public Collection<IndexedChannel> values()
      All IndexedChannels that exist in the map.
      Returns:
      a view on the IndexedChannels in the map.