Skip to content

Commit

Permalink
Merge pull request #96 from bigdataviewer/metadatabdv
Browse files Browse the repository at this point in the history
adds metadata to displays / bdv handle in the sourceandconverterdispl…
  • Loading branch information
Christian "Tischi" Tischer authored Mar 5, 2020
2 parents 9e773d7 + 7924f00 commit 64bee42
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ public void initialize() {
scriptService.addAlias(BdvHandle.class);
bdvHandleToSacs = new HashMap<>();
sacToBdvHandleRefs = new HashMap<>();
displayToMetadata = new HashMap<>();
bdvSourceAndConverterService.setDisplayService(this);
SourceAndConverterServices.setSourceAndConverterDisplayService(this);
log.accept("Service initialized.");
Expand Down Expand Up @@ -709,4 +710,32 @@ public Set< SourceAndConverter > getSourceAndConverters( BdvHandle bdv )
return bdvHandleToSacs.get( bdv ).stream().collect(Collectors.toSet());
}

/**
* Map containing objects that are 1 to 1 linked to a Display ( a BdvHandle object )
* TODO : ask if it should contain a WeakReference to BdvHandle keys (Potential Memory leak ?)
*/
Map<BdvHandle, Map<String, Object>> displayToMetadata;

public void setDisplayMetadata( BdvHandle bdvh, String key, Object data )
{
if (bdvh == null) {
System.err.println("Error : bdvh is null in setMetadata function! ");
//return;
}
if (displayToMetadata.get( bdvh ) == null) {
// Create Metadata
displayToMetadata.put(bdvh, new HashMap<>());
}
displayToMetadata.get( bdvh ).put( key, data );
}

public Object getDisplayMetadata( BdvHandle bdvh, String key )
{
if (displayToMetadata.containsKey(bdvh)) {
return displayToMetadata.get(bdvh).get(key);
} else {
return null;
}
}

}

0 comments on commit 64bee42

Please sign in to comment.