Package bdv.viewer

Interface ViewerState

  • All Known Implementing Classes:
    BasicViewerState, SynchronizedViewerState

    public interface ViewerState
    Reading and writing the BigDataViewer state:
    • interpolation and display mode
    • contained sources and source groups
    • activeness / currentness of sources and groups
    • current timepoint and transformation
    Author:
    Tobias Pietzsch
    • Method Detail

      • snapshot

        ViewerState snapshot()
        Get a snapshot of this ViewerState.
        Returns:
        unmodifiable copy of the current state
      • changeListeners

        org.scijava.listeners.Listeners<ViewerStateChangeListener> changeListeners()
        ViewerStateChangeListeners can be added/removed here, and will be notified about changes to this ViewerState.
      • getInterpolation

        Interpolation getInterpolation()
        Get the interpolation method.
        Returns:
        interpolation method
      • setInterpolation

        void setInterpolation​(Interpolation interpolation)
        Set the interpolation method (optional operation).
        Throws:
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • getDisplayMode

        DisplayMode getDisplayMode()
        Get the current DisplayMode.
        • In DisplayMode.SINGLE only the current source is visible.
        • In DisplayMode.GROUP the sources in the current group are visible.
        • In DisplayMode.FUSED all active sources are visible.
        • In DisplayMode.FUSEDROUP the sources in all active groups are visible.
        Returns:
        the current display mode
      • getAccumulateProjectorFactory

        AccumulateProjectorFactory<net.imglib2.type.numeric.ARGBType> getAccumulateProjectorFactory()
        Get the current AccumulateProjectorFactory.

        This factory provides AccumulateProjectors for blending rendered overlapping sources into the final screen image.

        Returns:
        current AccumulateProjector factory
      • setAccumulateProjectorFactory

        void setAccumulateProjectorFactory​(AccumulateProjectorFactory<net.imglib2.type.numeric.ARGBType> factory)
        Set the AccumulateProjectorFactory.

        This factory provides AccumulateProjectors for blending rendered overlapping sources into the final screen image. This can be used for switching between "sum" and "average" blending mode for example.

        Parameters:
        factory - AccumulateProjector factory to set
      • getNumTimepoints

        int getNumTimepoints()
        Get the number of timepoints.
        Returns:
        the number of timepoints
      • getCurrentTimepoint

        int getCurrentTimepoint()
        Get the current timepoint.
        Returns:
        current timepoint (index)
      • getSources

        List<SourceAndConverter<?>> getSources()
        Get the list of sources. The returned List reflects changes to the viewer state. It is unmodifiable and not thread-safe.
        Returns:
        the list of sources
      • getCurrentSource

        SourceAndConverter<?> getCurrentSource()
        Get the current source. (May return null if there is no current source)
        Returns:
        the current source
      • isCurrentSource

        boolean isCurrentSource​(SourceAndConverter<?> source)
        Returns true if source is the current source. Equivalent to (getCurrentSource() == source).
        Parameters:
        source - the source. Passing null checks whether no source is current.
        Returns:
        true if source is the current source
      • setCurrentSource

        boolean setCurrentSource​(SourceAndConverter<?> source)
        Make source the current source (optional operation). Returns true, if current source changes as a result of the call. Returns false, if source is already the current source.
        Parameters:
        source - the source to make current. Passing null clears the current source.
        Returns:
        true, if current source changed as a result of the call
        Throws:
        IllegalArgumentException - if source is not contained in the state (and not null).
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • getActiveSources

        Set<SourceAndConverter<?>> getActiveSources()
        Get the set of active sources. The returned Set reflects changes to the viewer state. It is unmodifiable and not thread-safe.
        Returns:
        the set of active sources
      • setSourceActive

        boolean setSourceActive​(SourceAndConverter<?> source,
                                boolean active)
        Set source active or inactive (optional operation).

        Returns true, if source activity changes as a result of the call. Returns false, if source is already in the desired active state.

        Returns:
        true, if source activity changed as a result of the call
        Throws:
        NullPointerException - if source == null
        IllegalArgumentException - if source is not contained in the state (and not null).
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • setSourcesActive

        boolean setSourcesActive​(Collection<? extends SourceAndConverter<?>> collection,
                                 boolean active)
        Set all sources in collection active or inactive (optional operation).

        Returns true, if source activity changes as a result of the call. Returns false, if all sources were already in the desired active state.

        Returns:
        true, if source activity changed as a result of the call
        Throws:
        NullPointerException - if collection == null or any element of collection is null.
        IllegalArgumentException - if any element of collection is not contained in the state.
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • isSourceVisible

        boolean isSourceVisible​(SourceAndConverter<?> source)
        Check whether the given source is visible.

        Whether a source is visible depends on the display mode:

        • In DisplayMode.SINGLE only the current source is visible.
        • In DisplayMode.GROUP the sources in the current group are visible.
        • In DisplayMode.FUSED all active sources are visible.
        • In DisplayMode.FUSEDROUP the sources in all active groups are visible.
        Returns:
        true, if source is visible
        Throws:
        NullPointerException - if source == null
        IllegalArgumentException - if source is not contained in the state (and not null).
      • isSourceVisibleAndPresent

        boolean isSourceVisibleAndPresent​(SourceAndConverter<?> source)
        Check whether the given source is both visible and provides image data for the current timepoint.

        Whether a source is visible depends on the display mode:

        • In DisplayMode.SINGLE only the current source is visible.
        • In DisplayMode.GROUP the sources in the current group are visible.
        • In DisplayMode.FUSED all active sources are visible.
        • In DisplayMode.FUSEDROUP the sources in all active groups are visible.
        Additionally, the source must be present, i.e., provide image data for the current timepoint.
        Returns:
        true, if source is both visible and present
        Throws:
        NullPointerException - if source == null
        IllegalArgumentException - if source is not contained in the state (and not null).
      • getVisibleSources

        Set<SourceAndConverter<?>> getVisibleSources()
        Get the set of visible sources.

        The returned Set is a copy. Changes to the set will not be reflected in the viewer state, and vice versa.

        Whether a source is visible depends on the display mode:

        • In DisplayMode.SINGLE only the current source is visible.
        • In DisplayMode.GROUP the sources in the current group are visible.
        • In DisplayMode.FUSED all active sources are visible.
        • In DisplayMode.FUSEDROUP the sources in all active groups are visible.
        Returns:
        the set of visible sources
      • getVisibleAndPresentSources

        Set<SourceAndConverter<?>> getVisibleAndPresentSources()
        Get the set of visible sources that also provide image data for the current timepoint.

        The returned Set is a copy. Changes to the set will not be reflected in the viewer state, and vice versa.

        Whether a source is visible depends on the display mode:

        • In DisplayMode.SINGLE only the current source is visible.
        • In DisplayMode.GROUP the sources in the current group are visible.
        • In DisplayMode.FUSED all active sources are visible.
        • In DisplayMode.FUSEDROUP the sources in all active groups are visible.
        Additionally, the source must be present, i.e., provide image data for the current timepoint.
        Returns:
        the set of sources that are both visible and present
      • containsSource

        boolean containsSource​(SourceAndConverter<?> source)
        Check whether the state contains the source.
        Returns:
        true, if source is in the list of sources.
        Throws:
        NullPointerException - if source == null
      • addSource

        boolean addSource​(SourceAndConverter<?> source)
        Add source to the state (optional operation). Returns true, if the source is added. Returns false, if the source is already present.

        If source is added and no other source was current, then source is made current

        Returns:
        true, if list of sources changed as a result of the call.
        Throws:
        NullPointerException - if source == null
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • addSources

        boolean addSources​(Collection<? extends SourceAndConverter<?>> collection)
        Add all sources in collection to the state (optional operation). Returns true, if at least one source was added. Returns false, if all sources were already present.

        If any sources are added and no other source was current, then the first added sources will be made current.

        Returns:
        true, if list of sources changed as a result of the call.
        Throws:
        NullPointerException - if collection == null or any element of collection is null.
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • removeSource

        boolean removeSource​(SourceAndConverter<?> source)
        Remove source from the state (optional operation).

        Returns true, if source was removed from the state. Returns false, if source was not contained in state.

        The source is also removed from any groups that contained it. If source was current, then the first source in the list of sources is made current (if it exists).

        Returns:
        true, if list of sources changed as a result of the call
        Throws:
        NullPointerException - if source == null
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • removeSources

        boolean removeSources​(Collection<? extends SourceAndConverter<?>> collection)
        Remove all sources in collection from the state (optional operation). Returns true, if at least one source was removed. Returns false, if none of the sources was present.

        Removed sources are also removed from any groups containing them. If the current source was removed, then the first source in the remaining list of sources is made current (if it exists).

        Returns:
        true, if list of sources changed as a result of the call.
        Throws:
        NullPointerException - if collection == null or any element of collection is null.
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • clearSources

        void clearSources()
        Remove all sources from the state (optional operation).
        Throws:
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • sourceOrder

        Comparator<SourceAndConverter<?>> sourceOrder()
        Returns a Comparator that compares sources according to the order in which they occur in the sources list. (Sources that do not occur in the list are ordered before any source in the list).
      • getGroups

        List<SourceGroup> getGroups()
        Get the list of groups. The returned List reflects changes to the viewer state. It is unmodifiable and not thread-safe.
        Returns:
        the list of groups
      • getCurrentGroup

        SourceGroup getCurrentGroup()
        Get the current group. (May return null if there is no current group)
        Returns:
        the current group
      • isCurrentGroup

        boolean isCurrentGroup​(SourceGroup group)
        Returns true if group is the current group. Equivalent to (getCurrentGroup() == group).
        Returns:
        true if group is the current group
      • setCurrentGroup

        boolean setCurrentGroup​(SourceGroup group)
        Make group the current group (optional operation). Returns true, if current group changes as a result of the call. Returns false, if group is already the current group.
        Parameters:
        group - the group to make current
        Returns:
        true, if current group changed as a result of the call.
        Throws:
        IllegalArgumentException - if group is not contained in the state (and not null).
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • getActiveGroups

        Set<SourceGroup> getActiveGroups()
        Get the set of active groups. The returned Set reflects changes to the viewer state. It is unmodifiable and not thread-safe.
        Returns:
        the set of active groups
      • setGroupActive

        boolean setGroupActive​(SourceGroup group,
                               boolean active)
        Set group active or inactive (optional operation).

        Returns true, if group activity changes as a result of the call. Returns false, if group is already in the desired active state.

        Returns:
        true, if group activity changed as a result of the call
        Throws:
        NullPointerException - if group == null
        IllegalArgumentException - if group is not contained in the state (and not null).
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • setGroupsActive

        boolean setGroupsActive​(Collection<? extends SourceGroup> collection,
                                boolean active)
        Set all groups in collection active or inactive (optional operation).

        Returns true, if group activity changes as a result of the call. Returns false, if all groups were already in the desired active state.

        Returns:
        true, if group activity changed as a result of the call
        Throws:
        NullPointerException - if collection == null or any element of collection is null.
        IllegalArgumentException - if any element of collection is not contained in the state.
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • containsGroup

        boolean containsGroup​(SourceGroup group)
        Check whether the state contains the group.
        Returns:
        true, if group is in the list of groups.
        Throws:
        NullPointerException - if group == null
      • addGroup

        boolean addGroup​(SourceGroup group)
        Add group to the state (optional operation). Returns true, if the group is added. Returns false, if the group is already present.

        If group is added and no other group was current, then group is made current

        Returns:
        true, if list of groups changed as a result of the call.
        Throws:
        NullPointerException - if group == null
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • addGroups

        boolean addGroups​(Collection<? extends SourceGroup> collection)
        Add all groups in collection to the state (optional operation). Returns true, if at least one group was added. Returns false, if all groups were already present.

        If any groups are added and no other group was current, then the first added groups will be made current.

        Returns:
        true, if list of groups changed as a result of the call.
        Throws:
        NullPointerException - if collection == null or any element of collection is null.
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • removeGroup

        boolean removeGroup​(SourceGroup group)
        Remove group from the state (optional operation).

        Returns true, if group was removed from the state. Returns false, if group was not contained in state.

        If group was current, then the first group in the list of groups is made current (if it exists).

        Returns:
        true, if list of groups changed as a result of the call
        Throws:
        NullPointerException - if group == null
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • removeGroups

        boolean removeGroups​(Collection<? extends SourceGroup> collection)
        Remove all groups in collection from the state (optional operation). Returns true, if at least one group was removed. Returns false, if none of the groups was present.

        If the current group was removed, then the first group in the remaining list of groups is made current (if it exists).

        Returns:
        true, if list of groups changed as a result of the call.
        Throws:
        NullPointerException - if collection == null or any element of collection is null.
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • addSourceToGroup

        boolean addSourceToGroup​(SourceAndConverter<?> source,
                                 SourceGroup group)
        Add source to group (optional operation).

        Returns true, if source was added to group. Returns false, if source was already contained in group. or either of source and group is not valid (not in the BDV sources/groups list).

        Returns:
        true, if set of sources in group changed as a result of the call
        Throws:
        NullPointerException - if source == null or group == null
        IllegalArgumentException - if either of source and group is not contained in the state (and not null).
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • addSourcesToGroup

        boolean addSourcesToGroup​(Collection<? extends SourceAndConverter<?>> collection,
                                  SourceGroup group)
        Add all sources in collection to group (optional operation).

        Returns true, if at least one source was added to group. Returns false, if all sources were already contained in group.

        Returns:
        true, if set of sources in group changed as a result of the call
        Throws:
        NullPointerException - if group == null or collection == null or any element of collection is null.
        IllegalArgumentException - if group or any element of collection is is not contained in the state (and not null).
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • removeSourceFromGroup

        boolean removeSourceFromGroup​(SourceAndConverter<?> source,
                                      SourceGroup group)
        Remove source from group (optional operation).

        Returns true, if source was removed from group. Returns false, if source was not contained in group,

        Returns:
        true, if set of sources in group changed as a result of the call
        Throws:
        NullPointerException - if source == null or group == null
        IllegalArgumentException - if either of source and group is not contained in the state (and not null).
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • removeSourcesFromGroup

        boolean removeSourcesFromGroup​(Collection<? extends SourceAndConverter<?>> collection,
                                       SourceGroup group)
        Remove all sources in collection from group (optional operation).

        Returns true, if at least one source was removed from group. Returns false, if none of the sources were contained in group.

        Returns:
        true, if set of sources in group changed as a result of the call
        Throws:
        NullPointerException - if group == null or collection == null or any element of collection is null.
        IllegalArgumentException - if group or any element of collection is is not contained in the state (and not null).
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • getSourcesInGroup

        Set<SourceAndConverter<?>> getSourcesInGroup​(SourceGroup group)
        Get the set sources in group. The returned Set reflects changes to the viewer state. It is unmodifiable and not thread-safe.
        Returns:
        the set of sources in group
        Throws:
        NullPointerException - if group == null
        IllegalArgumentException - if group is not contained in the state (and not null).
      • clearGroups

        void clearGroups()
        Remove all groups from the state (optional operation).
        Throws:
        UnsupportedOperationException - if the operation is not supported by this ViewerState
      • groupOrder

        Comparator<SourceGroup> groupOrder()
        Returns a Comparator that compares groups according to the order in which they occur in the groups list. (Groups that do not occur in the list are ordered before any group in the list).