-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change location of demos (unfinished)
Adds tests for command and macros Fix #274 by adding a StringToSourceAndConverter.java converter
- Loading branch information
Showing
19 changed files
with
430 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/java/sc/fiji/bdvpg/scijava/command/bdv/MultiBdvCloseCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/*- | ||
* #%L | ||
* BigDataViewer-Playground | ||
* %% | ||
* Copyright (C) 2019 - 2024 Nicolas Chiaruttini, EPFL - Robert Haase, MPI CBG - Christian Tischer, EMBL | ||
* %% | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
* #L% | ||
*/ | ||
|
||
package sc.fiji.bdvpg.scijava.command.bdv; | ||
|
||
import bdv.util.BdvHandle; | ||
import ij.IJ; | ||
import org.scijava.plugin.Parameter; | ||
import org.scijava.plugin.Plugin; | ||
import sc.fiji.bdvpg.scijava.ScijavaBdvDefaults; | ||
import sc.fiji.bdvpg.scijava.command.BdvPlaygroundActionCommand; | ||
import sc.fiji.bdvpg.scijava.services.SourceAndConverterBdvDisplayService; | ||
|
||
@SuppressWarnings({ "CanBeFinal", "unused" }) // Because SciJava command fields | ||
// are set by SciJava | ||
// pre-processors | ||
|
||
@Plugin(type = BdvPlaygroundActionCommand.class, | ||
menuPath = ScijavaBdvDefaults.RootMenu + | ||
"BDV>BDV - Close bdv windows", | ||
description = "Closes one or several bdv windows.") | ||
public class MultiBdvCloseCommand implements BdvPlaygroundActionCommand { | ||
|
||
@Parameter(label = "Select BDV Windows", persist = false) | ||
BdvHandle[] bdvhs; | ||
|
||
@Parameter | ||
SourceAndConverterBdvDisplayService bdvDisplayService; | ||
|
||
@Override | ||
public void run() { | ||
if (bdvhs.length == 0) IJ.log("Please make sure to select a Bdv window."); | ||
for (BdvHandle bdvh : bdvhs) { | ||
bdvh.close(); | ||
} | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
src/main/java/sc/fiji/bdvpg/scijava/converters/StringToSourceAndConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/*- | ||
* #%L | ||
* BigDataViewer-Playground | ||
* %% | ||
* Copyright (C) 2019 - 2024 Nicolas Chiaruttini, EPFL - Robert Haase, MPI CBG - Christian Tischer, EMBL | ||
* %% | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
* #L% | ||
*/ | ||
|
||
package sc.fiji.bdvpg.scijava.converters; | ||
|
||
import bdv.viewer.SourceAndConverter; | ||
import org.scijava.convert.AbstractConverter; | ||
import org.scijava.plugin.Parameter; | ||
import org.scijava.plugin.Plugin; | ||
import sc.fiji.bdvpg.scijava.services.SourceAndConverterService; | ||
|
||
import javax.swing.tree.TreePath; | ||
import java.util.List; | ||
|
||
/** | ||
* @param <I> String class | ||
*/ | ||
|
||
@SuppressWarnings("unused") | ||
@Plugin(type = org.scijava.convert.Converter.class) | ||
public class StringToSourceAndConverter<I extends String> extends | ||
AbstractConverter<I, SourceAndConverter<?>> | ||
{ | ||
|
||
@Parameter | ||
SourceAndConverterService sacsService; | ||
|
||
@Override | ||
public <T> T convert(Object src, Class<T> dest) { | ||
String str = (String) src; | ||
TreePath tp = sacsService.getUI().getTreePathFromString(str); | ||
if (tp != null) { | ||
List<SourceAndConverter<?>> potentialSources = sacsService.getUI().getSourceAndConvertersFromTreePath(tp); | ||
if (potentialSources.size()!=1) { | ||
log().warn("The specified parameters refers no either no source or too many sources"); | ||
return null; | ||
} else { | ||
return (T) potentialSources.get(0); | ||
} | ||
} | ||
else { | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public Class getOutputType() { | ||
return SourceAndConverter.class; | ||
} | ||
|
||
@Override | ||
public Class<I> getInputType() { | ||
return (Class<I>) String.class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.