- java.lang.Object
-
- bdv.viewer.SynchronizedViewerState
-
- All Implemented Interfaces:
ViewerState
public class SynchronizedViewerState extends Object implements ViewerState
Maintains the BigDataViewer state and implementsViewerStateto expose query and modification methods.ViewerStateChangeListeners can be registered and will be notified about variousstate changes.All methods of this class are
synchronized, so that every individual change to the viewer state is atomic.IllegalArgumentExceptions thrown by the wrappedBasicViewerStateare silently swallowed, under the assumption that they result from concurrent changes (for example another thread might have removed the source that you are trying to make current).To perform sequences of operations atomically explicit synchronization is required. In particular, this is true when using the collections returned by
getSources(),getActiveSources(),getGroups(),getActiveGroups(), andgetSourcesInGroup(SourceGroup). These collections are backed by the ViewerState, they reflect changes, and they are not thread-safe. It is possible to run intoConcurrentModificationExceptionwhen iterating them, etc.Example where explicit synchronization is required:
List<SourceGroup> groupsContainingCurrentSource; synchronized (state) { SourceAndConverter<?> currentSource = state.getCurrentSource(); groupsContainingCurrentSource = state.getGroups().stream() .filter(g -> state.getSourcesInGroup(g).contains(currentSource)) .collect(Collectors.toList()); }Alternatively, for read-only access, it is possible to (atomically) take an unmodifiable
snapshot()of the current state.- Author:
- Tobias Pietzsch
-
-
Constructor Summary
Constructors Constructor Description SynchronizedViewerState(ViewerState state)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddGroup(SourceGroup group)Addgroupto the state.booleanaddGroups(Collection<? extends SourceGroup> collection)Add all groups incollectionto the state.booleanaddSource(SourceAndConverter<?> source)Addsourceto the state.booleanaddSources(Collection<? extends SourceAndConverter<?>> collection)Add all sources incollectionto the state.booleanaddSourcesToGroup(Collection<? extends SourceAndConverter<?>> collection, SourceGroup group)Add all sources incollectiontogroup.booleanaddSourceToGroup(SourceAndConverter<?> source, SourceGroup group)Addsourcetogroup.org.scijava.listeners.Listeners<ViewerStateChangeListener>changeListeners()ViewerStateChangeListeners can be added/removed here, and will be notified about changes to this ViewerState.voidclearGroups()Remove all groups from the state.voidclearSources()Remove all sources from the state.booleancontainsGroup(SourceGroup group)Check whether the state contains thegroup.booleancontainsSource(SourceAndConverter<?> source)Check whether the state contains thesource.AccumulateProjectorFactory<net.imglib2.type.numeric.ARGBType>getAccumulateProjectorFactory()Get the currentAccumulateProjectorFactory.Set<SourceGroup>getActiveGroups()Get the set of active groups.Set<SourceAndConverter<?>>getActiveSources()Get the set of active sources.SourceGroupgetCurrentGroup()Get the current group.SourceAndConverter<?>getCurrentSource()Get the current source.intgetCurrentTimepoint()Get the current timepoint.DisplayModegetDisplayMode()Get the currentDisplayMode.StringgetGroupName(SourceGroup group)Get the name of agroup.List<SourceGroup>getGroups()Get the list of groups.InterpolationgetInterpolation()Get the interpolation method.intgetNumTimepoints()Get the number of timepoints.List<SourceAndConverter<?>>getSources()Get the list of sources.Set<SourceAndConverter<?>>getSourcesInGroup(SourceGroup group)Get the set sources ingroup.voidgetViewerTransform(net.imglib2.realtransform.AffineTransform3D transform)Get the viewer transform.Set<SourceAndConverter<?>>getVisibleAndPresentSources()Get the set of visible sources that also provide image data for the current timepoint.Set<SourceAndConverter<?>>getVisibleSources()Get the set of visible sources.ViewerStategetWrappedState()Returns the wrappedViewerState.Comparator<SourceGroup>groupOrder()Returns aComparatorthat compares groups according to the order in which they occur in the groups list.booleanisCurrentGroup(SourceGroup group)Returnstrueifgroupis the current group.booleanisCurrentSource(SourceAndConverter<?> source)Returnstrueifsourceis the current source.booleanisGroupActive(SourceGroup group)Check whether the givengroupis active.booleanisSourceActive(SourceAndConverter<?> source)Check whether the givensourceis active.booleanisSourceVisible(SourceAndConverter<?> source)Check whether the givensourceis visible.booleanisSourceVisibleAndPresent(SourceAndConverter<?> source)Check whether the givensourceis both visible and provides image data for the current timepoint.booleanremoveGroup(SourceGroup group)Removegroupfrom the state.booleanremoveGroups(Collection<? extends SourceGroup> collection)Remove all groups incollectionfrom the state.booleanremoveSource(SourceAndConverter<?> source)Removesourcefrom the state.booleanremoveSourceFromGroup(SourceAndConverter<?> source, SourceGroup group)Removesourcefromgroup.booleanremoveSources(Collection<? extends SourceAndConverter<?>> collection)Remove all sources incollectionfrom the state.booleanremoveSourcesFromGroup(Collection<? extends SourceAndConverter<?>> collection, SourceGroup group)Remove all sources incollectionfromgroup.voidsetAccumulateProjectorFactory(AccumulateProjectorFactory<net.imglib2.type.numeric.ARGBType> factory)Set theAccumulateProjectorFactory.booleansetCurrentGroup(SourceGroup group)Makegroupthe current group.booleansetCurrentSource(SourceAndConverter<?> source)Makesourcethe current source.voidsetCurrentTimepoint(int t)Set the current timepoint (optional operation).voidsetDisplayMode(DisplayMode mode)Set theDisplayMode(optional operation).booleansetGroupActive(SourceGroup group, boolean active)Setgroupactive or inactive.voidsetGroupName(SourceGroup group, String name)Set thenameof agroup.booleansetGroupsActive(Collection<? extends SourceGroup> collection, boolean active)Set all groups incollectionactive or inactive.voidsetInterpolation(Interpolation interpolation)Set the interpolation method (optional operation).voidsetNumTimepoints(int n)Set the number of timepoints (optional operation).booleansetSourceActive(SourceAndConverter<?> source, boolean active)Setsourceactive or inactive.booleansetSourcesActive(Collection<? extends SourceAndConverter<?>> collection, boolean active)Set all sources incollectionactive or inactive.voidsetViewerTransform(net.imglib2.realtransform.AffineTransform3D transform)Set the viewer transform (optional operation).ViewerStatesnapshot()Get a snapshot of this ViewerState.Comparator<SourceAndConverter<?>>sourceOrder()Returns aComparatorthat compares sources according to the order in which they occur in the sources list.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface bdv.viewer.ViewerState
getViewerTransform
-
-
-
-
Constructor Detail
-
SynchronizedViewerState
public SynchronizedViewerState(ViewerState state)
-
-
Method Detail
-
changeListeners
public org.scijava.listeners.Listeners<ViewerStateChangeListener> changeListeners()
Description copied from interface:ViewerStateViewerStateChangeListeners can be added/removed here, and will be notified about changes to this ViewerState.- Specified by:
changeListenersin interfaceViewerState
-
snapshot
public ViewerState snapshot()
Get a snapshot of this ViewerState.- Specified by:
snapshotin interfaceViewerState- Returns:
- unmodifiable copy of the current state
-
getInterpolation
public Interpolation getInterpolation()
Description copied from interface:ViewerStateGet the interpolation method.- Specified by:
getInterpolationin interfaceViewerState- Returns:
- interpolation method
-
setInterpolation
public void setInterpolation(Interpolation interpolation)
Description copied from interface:ViewerStateSet the interpolation method (optional operation).- Specified by:
setInterpolationin interfaceViewerState
-
getDisplayMode
public DisplayMode getDisplayMode()
Description copied from interface:ViewerStateGet the currentDisplayMode.- In
DisplayMode.SINGLEonly the current source is visible. - In
DisplayMode.GROUPthe sources in the current group are visible. - In
DisplayMode.FUSEDall active sources are visible. - In
DisplayMode.FUSEDROUPthe sources in all active groups are visible.
- Specified by:
getDisplayModein interfaceViewerState- Returns:
- the current display mode
- In
-
setDisplayMode
public void setDisplayMode(DisplayMode mode)
Description copied from interface:ViewerStateSet theDisplayMode(optional operation).- Specified by:
setDisplayModein interfaceViewerState
-
getAccumulateProjectorFactory
public AccumulateProjectorFactory<net.imglib2.type.numeric.ARGBType> getAccumulateProjectorFactory()
Description copied from interface:ViewerStateGet the currentAccumulateProjectorFactory.This factory provides AccumulateProjectors for blending rendered overlapping sources into the final screen image.
- Specified by:
getAccumulateProjectorFactoryin interfaceViewerState- Returns:
- current AccumulateProjector factory
-
setAccumulateProjectorFactory
public void setAccumulateProjectorFactory(AccumulateProjectorFactory<net.imglib2.type.numeric.ARGBType> factory)
Description copied from interface:ViewerStateSet theAccumulateProjectorFactory.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.
- Specified by:
setAccumulateProjectorFactoryin interfaceViewerState- Parameters:
factory- AccumulateProjector factory to set
-
getNumTimepoints
public int getNumTimepoints()
Description copied from interface:ViewerStateGet the number of timepoints.- Specified by:
getNumTimepointsin interfaceViewerState- Returns:
- the number of timepoints
-
setNumTimepoints
public void setNumTimepoints(int n)
Description copied from interface:ViewerStateSet the number of timepoints (optional operation).If
ViewerState.getCurrentTimepoint()current timepoint} is>= n, it will be adjusted ton-1.- Specified by:
setNumTimepointsin interfaceViewerState
-
getCurrentTimepoint
public int getCurrentTimepoint()
Description copied from interface:ViewerStateGet the current timepoint.- Specified by:
getCurrentTimepointin interfaceViewerState- Returns:
- current timepoint (index)
-
setCurrentTimepoint
public void setCurrentTimepoint(int t)
Description copied from interface:ViewerStateSet the current timepoint (optional operation).- Specified by:
setCurrentTimepointin interfaceViewerState
-
getViewerTransform
public void getViewerTransform(net.imglib2.realtransform.AffineTransform3D transform)
Description copied from interface:ViewerStateGet the viewer transform.- Specified by:
getViewerTransformin interfaceViewerState- Parameters:
transform- is set to the viewer transform
-
setViewerTransform
public void setViewerTransform(net.imglib2.realtransform.AffineTransform3D transform)
Description copied from interface:ViewerStateSet the viewer transform (optional operation).- Specified by:
setViewerTransformin interfaceViewerState
-
getSources
public List<SourceAndConverter<?>> getSources()
Get the list of sources. The returnedListreflects changes to the viewer state. It is unmodifiable and not thread-safe.The returned list is also a set, there are no duplicate entries.
- Specified by:
getSourcesin interfaceViewerState- Returns:
- the list of sources
-
getCurrentSource
public SourceAndConverter<?> getCurrentSource()
Get the current source. (May returnnullif there is no current source)- Specified by:
getCurrentSourcein interfaceViewerState- Returns:
- the current source
-
isCurrentSource
public boolean isCurrentSource(SourceAndConverter<?> source)
Returnstrueifsourceis the current source. Equivalent to(getCurrentSource() == source).- Specified by:
isCurrentSourcein interfaceViewerState- Parameters:
source- the source. Passingnullchecks whether no source is current.- Returns:
trueifsourceis the current source
-
setCurrentSource
public boolean setCurrentSource(SourceAndConverter<?> source)
Makesourcethe current source. Returnstrue, if current source changes as a result of the call. Returnsfalse, ifsourceis already the current source.Also returns
false, ifsourceis not valid (for example because it has been removed from the state by a different thread).- Specified by:
setCurrentSourcein interfaceViewerState- Parameters:
source- the source to make current. Passingnullclears the current source.- Returns:
true, if current source changed as a result of the call
-
getActiveSources
public Set<SourceAndConverter<?>> getActiveSources()
Get the set of active sources. The returnedSetreflects changes to the viewer state. It is unmodifiable and not thread-safe.- Specified by:
getActiveSourcesin interfaceViewerState- Returns:
- the set of active sources
-
isSourceActive
public boolean isSourceActive(SourceAndConverter<?> source)
Check whether the givensourceis active. Returnstrue, ifsourceis active. Returnsfalse, ifsourceis inactive or not valid (for example because it has been removed from the state by a different thread).- Specified by:
isSourceActivein interfaceViewerState- Returns:
true, ifsourceis active- Throws:
NullPointerException- ifsource == null
-
setSourceActive
public boolean setSourceActive(SourceAndConverter<?> source, boolean active)
Setsourceactive or inactive.Returns
true, if source activity changes as a result of the call. Returnsfalse, ifsourceis already in the desiredactivestate.Also returns
false, ifsourceis not valid (for example because it has been removed from the state by a different thread).- Specified by:
setSourceActivein interfaceViewerState- Returns:
true, if source activity changed as a result of the call- Throws:
NullPointerException- ifsource == null
-
setSourcesActive
public boolean setSourcesActive(Collection<? extends SourceAndConverter<?>> collection, boolean active)
Set all sources incollectionactive or inactive.Returns
true, if source activity changes as a result of the call. Returnsfalse, if all sources were already in the desiredactivestate.Does nothing and returns
false, if any source incollectionis not valid (for example because it was removed from the state by a different thread).- Specified by:
setSourcesActivein interfaceViewerState- Returns:
true, if source activity changed as a result of the call- Throws:
NullPointerException- ifcollection == nullor any element ofcollectionisnull.
-
isSourceVisible
public boolean isSourceVisible(SourceAndConverter<?> source)
Check whether the givensourceis visible.Returns
false, ifsourceis not valid (for example because it has been removed from the state by a different thread).Whether a source is visible depends on the
display mode:- In
DisplayMode.SINGLEonly the current source is visible. - In
DisplayMode.GROUPthe sources in the current group are visible. - In
DisplayMode.FUSEDall active sources are visible. - In
DisplayMode.FUSEDROUPthe sources in all active groups are visible.
- Specified by:
isSourceVisiblein interfaceViewerState- Returns:
true, ifsourceis visible- Throws:
NullPointerException- ifsource == nullIllegalArgumentException- ifsourceis not contained in the state (and notnull).
- In
-
isSourceVisibleAndPresent
public boolean isSourceVisibleAndPresent(SourceAndConverter<?> source)
Check whether the givensourceis both visible and provides image data for the current timepoint.Returns
false, ifsourceis not valid (for example because it has been removed from the state by a different thread). Whether a source is visible depends on thedisplay mode:- In
DisplayMode.SINGLEonly the current source is visible. - In
DisplayMode.GROUPthe sources in the current group are visible. - In
DisplayMode.FUSEDall active sources are visible. - In
DisplayMode.FUSEDROUPthe sources in all active groups are visible.
present, i.e., provide image data for thecurrent timepoint.- Specified by:
isSourceVisibleAndPresentin interfaceViewerState- Returns:
true, ifsourceis both visible and present- Throws:
NullPointerException- ifsource == null
- In
-
getVisibleSources
public Set<SourceAndConverter<?>> getVisibleSources()
Get the set of visible sources.The returned
Setis 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.SINGLEonly the current source is visible. - In
DisplayMode.GROUPthe sources in the current group are visible. - In
DisplayMode.FUSEDall active sources are visible. - In
DisplayMode.FUSEDROUPthe sources in all active groups are visible.
- Specified by:
getVisibleSourcesin interfaceViewerState- Returns:
- the set of visible sources
- In
-
getVisibleAndPresentSources
public Set<SourceAndConverter<?>> getVisibleAndPresentSources()
Get the set of visible sources that also provide image data for the current timepoint.The returned
Setis 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.SINGLEonly the current source is visible. - In
DisplayMode.GROUPthe sources in the current group are visible. - In
DisplayMode.FUSEDall active sources are visible. - In
DisplayMode.FUSEDROUPthe sources in all active groups are visible.
present, i.e., provide image data for thecurrent timepoint.- Specified by:
getVisibleAndPresentSourcesin interfaceViewerState- Returns:
- the set of sources that are both visible and present
- In
-
containsSource
public boolean containsSource(SourceAndConverter<?> source)
Check whether the state contains thesource.- Specified by:
containsSourcein interfaceViewerState- Returns:
true, ifsourceis in the list of sources.- Throws:
NullPointerException- ifsource == null
-
addSource
public boolean addSource(SourceAndConverter<?> source)
Addsourceto the state. Returnstrue, if the source is added. Returnsfalse, if the source is already present.If
sourceis added and no other source was current, thensourceis made current- Specified by:
addSourcein interfaceViewerState- Returns:
true, if list of sources changed as a result of the call.- Throws:
NullPointerException- ifsource == null
-
addSources
public boolean addSources(Collection<? extends SourceAndConverter<?>> collection)
Add all sources incollectionto the state. Returnstrue, if at least one source was added. Returnsfalse, 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.
- Specified by:
addSourcesin interfaceViewerState- Returns:
true, if list of sources changed as a result of the call.- Throws:
NullPointerException- ifcollection == nullor any element ofcollectionisnull.
-
removeSource
public boolean removeSource(SourceAndConverter<?> source)
Removesourcefrom the state.Returns
true, ifsourcewas removed from the state. Returnsfalse, ifsourcewas not contained in state.The
sourceis also removed from any groups that contained it. Ifsourcewas current, then the first source in the list of sources is made current (if it exists).- Specified by:
removeSourcein interfaceViewerState- Returns:
true, if list of sources changed as a result of the call- Throws:
NullPointerException- ifsource == null
-
removeSources
public boolean removeSources(Collection<? extends SourceAndConverter<?>> collection)
Remove all sources incollectionfrom the state. Returnstrue, if at least one source was removed. Returnsfalse, 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).
- Specified by:
removeSourcesin interfaceViewerState- Returns:
true, if list of sources changed as a result of the call.- Throws:
NullPointerException- ifcollection == nullor any element ofcollectionisnull.
-
clearSources
public void clearSources()
Remove all sources from the state.- Specified by:
clearSourcesin interfaceViewerState
-
sourceOrder
public Comparator<SourceAndConverter<?>> sourceOrder()
Returns aComparatorthat 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).- Specified by:
sourceOrderin interfaceViewerState
-
getGroups
public List<SourceGroup> getGroups()
Get the list of groups. The returnedListreflects changes to the viewer state. It is unmodifiable and not thread-safe.The returned list is also a set, there are no duplicate entries.
- Specified by:
getGroupsin interfaceViewerState- Returns:
- the list of groups
-
getCurrentGroup
public SourceGroup getCurrentGroup()
Get the current group. (May returnnullif there is no current group)- Specified by:
getCurrentGroupin interfaceViewerState- Returns:
- the current group
-
isCurrentGroup
public boolean isCurrentGroup(SourceGroup group)
Returnstrueifgroupis the current group. Equivalent to(getCurrentGroup() == group).- Specified by:
isCurrentGroupin interfaceViewerState- Parameters:
group- the group. Passingnullchecks whether no group is current.- Returns:
trueifgroupis the current group
-
setCurrentGroup
public boolean setCurrentGroup(SourceGroup group)
Makegroupthe current group. Returnstrue, if current group changes as a result of the call. Returnsfalse, ifgroupis already the current group.Also returns
false, ifgroupis not valid (for example because it has been removed from the state by a different thread).- Specified by:
setCurrentGroupin interfaceViewerState- Parameters:
group- the group to make current. Passingnullclears the current group.- Returns:
true, if current group changed as a result of the call.
-
getActiveGroups
public Set<SourceGroup> getActiveGroups()
Get the set of active groups. The returnedSetreflects changes to the viewer state. It is unmodifiable and not thread-safe.- Specified by:
getActiveGroupsin interfaceViewerState- Returns:
- the set of active groups
-
isGroupActive
public boolean isGroupActive(SourceGroup group)
Check whether the givengroupis active. Returnstrue, ifgroupis active. Returnsfalse, ifgroupis inactive or not valid (for example because it has been removed from the state by a different thread).- Specified by:
isGroupActivein interfaceViewerState- Returns:
true, ifgroupis active- Throws:
NullPointerException- ifgroup == nullIllegalArgumentException- ifgroupis not contained in the state (and notnull).
-
setGroupActive
public boolean setGroupActive(SourceGroup group, boolean active)
Setgroupactive or inactive.Returns
true, if group activity changes as a result of the call. Returnsfalse, ifgroupis already in the desiredactivestate.Also returns
false, ifgroupis not valid (for example because it has been removed from the state by a different thread).- Specified by:
setGroupActivein interfaceViewerState- Returns:
true, if group activity changed as a result of the call- Throws:
NullPointerException- ifgroup == null
-
setGroupsActive
public boolean setGroupsActive(Collection<? extends SourceGroup> collection, boolean active)
Set all groups incollectionactive or inactive.Returns
true, if group activity changes as a result of the call. Returnsfalse, if all groups were already in the desiredactivestate.Does nothing and returns
false, if any group incollectionis not valid (for example because it was removed from the state by a different thread).- Specified by:
setGroupsActivein interfaceViewerState- Returns:
true, if group activity changed as a result of the call- Throws:
NullPointerException- ifcollection == nullor any element ofcollectionisnull.
-
getGroupName
public String getGroupName(SourceGroup group)
Get the name of agroup.Returns
null, ifgroupis not valid (for example because it has been removed from the state by a different thread), an empty set is returned.- Specified by:
getGroupNamein interfaceViewerState- Returns:
- name of the group, may be
null - Throws:
NullPointerException- ifgroup == null
-
setGroupName
public void setGroupName(SourceGroup group, String name)
Set thenameof agroup.Does nothing, if
groupis not valid (for example because it has been removed from the state by a different thread), an empty set is returned.- Specified by:
setGroupNamein interfaceViewerState- Throws:
NullPointerException- ifgroup == null
-
containsGroup
public boolean containsGroup(SourceGroup group)
Check whether the state contains thegroup.- Specified by:
containsGroupin interfaceViewerState- Returns:
true, ifgroupis in the list of groups.- Throws:
NullPointerException- ifgroup == null
-
addGroup
public boolean addGroup(SourceGroup group)
Addgroupto the state. Returnstrue, if the group is added. Returnsfalse, if the group is already present.If
groupis added and no other group was current, thengroupis made current- Specified by:
addGroupin interfaceViewerState- Returns:
true, if list of groups changed as a result of the call.- Throws:
NullPointerException- ifgroup == null
-
addGroups
public boolean addGroups(Collection<? extends SourceGroup> collection)
Add all groups incollectionto the state. Returnstrue, if at least one group was added. Returnsfalse, 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.
- Specified by:
addGroupsin interfaceViewerState- Returns:
true, if list of groups changed as a result of the call.- Throws:
NullPointerException- ifcollection == nullor any element ofcollectionisnull.
-
removeGroup
public boolean removeGroup(SourceGroup group)
Removegroupfrom the state.Returns
true, ifgroupwas removed from the state. Returnsfalse, ifgroupwas not contained in state.If
groupwas current, then the first group in the list of groups is made current (if it exists).- Specified by:
removeGroupin interfaceViewerState- Returns:
true, if list of groups changed as a result of the call- Throws:
NullPointerException- ifgroup == null
-
removeGroups
public boolean removeGroups(Collection<? extends SourceGroup> collection)
Remove all groups incollectionfrom the state. Returnstrue, if at least one group was removed. Returnsfalse, 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).
- Specified by:
removeGroupsin interfaceViewerState- Returns:
true, if list of groups changed as a result of the call.- Throws:
NullPointerException- ifcollection == nullor any element ofcollectionisnull.
-
addSourceToGroup
public boolean addSourceToGroup(SourceAndConverter<?> source, SourceGroup group)
Addsourcetogroup.Returns
true, ifsourcewas added togroup. Returnsfalse, ifsourcewas already contained ingroup. or either ofsourceandgroupis not valid (not in the BDV sources/groups list).Does nothing and returns
false, ifsourceorgroupare not valid (for example because they were removed from the state by a different thread).- Specified by:
addSourceToGroupin interfaceViewerState- Returns:
true, if set of sources ingroupchanged as a result of the call- Throws:
NullPointerException- ifsource == nullorgroup == null
-
addSourcesToGroup
public boolean addSourcesToGroup(Collection<? extends SourceAndConverter<?>> collection, SourceGroup group)
Add all sources incollectiontogroup.Returns
true, if at least one source was added togroup. Returnsfalse, if all sources were already contained ingroup.Does nothing and returns
false, ifgroupor any source incollectionare not valid (for example because they were removed from the state by a different thread).- Specified by:
addSourcesToGroupin interfaceViewerState- Returns:
true, if set of sources ingroupchanged as a result of the call- Throws:
NullPointerException- ifgroup == nullorcollection == nullor any element ofcollectionisnull.
-
removeSourceFromGroup
public boolean removeSourceFromGroup(SourceAndConverter<?> source, SourceGroup group)
Removesourcefromgroup.Returns
true, ifsourcewas removed fromgroup. Returnsfalse, ifsourcewas not contained ingroup,Does nothing and returns
false, ifsourceorgroupare not valid (for example because they were removed from the state by a different thread).- Specified by:
removeSourceFromGroupin interfaceViewerState- Returns:
true, if set of sources ingroupchanged as a result of the call- Throws:
NullPointerException- ifsource == nullorgroup == null
-
removeSourcesFromGroup
public boolean removeSourcesFromGroup(Collection<? extends SourceAndConverter<?>> collection, SourceGroup group)
Remove all sources incollectionfromgroup.Returns
true, if at least one source was removed fromgroup. Returnsfalse, if none of the sources were contained ingroup.Does nothing and returns
false, ifgroupor any source incollectionare not valid (for example because they were removed from the state by a different thread).- Specified by:
removeSourcesFromGroupin interfaceViewerState- Returns:
true, if set of sources ingroupchanged as a result of the call- Throws:
NullPointerException- ifgroup == nullorcollection == nullor any element ofcollectionisnull.
-
getSourcesInGroup
public Set<SourceAndConverter<?>> getSourcesInGroup(SourceGroup group)
Get the set sources ingroup. The returnedSetreflects changes to the viewer state. It is unmodifiable and not thread-safe.If
groupis not valid (for example because it has been removed from the state by a different thread), an empty set is returned.- Specified by:
getSourcesInGroupin interfaceViewerState- Returns:
- the set of sources in
group - Throws:
NullPointerException- ifgroup == null
-
clearGroups
public void clearGroups()
Remove all groups from the state.- Specified by:
clearGroupsin interfaceViewerState
-
groupOrder
public Comparator<SourceGroup> groupOrder()
Returns aComparatorthat 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).- Specified by:
groupOrderin interfaceViewerState
-
getWrappedState
public ViewerState getWrappedState()
Returns the wrappedViewerState.When using this, explicit synchronization (on this
SynchronizedViewerState) is required. PLEASE BE CAREFUL!
-
-