Skip to content

Commit

Permalink
Merge pull request #219 from bigdataviewer/refactor_display_options
Browse files Browse the repository at this point in the history
Refactor display options

Heaving refactoring. A lot of the display customization is removed from this repository and goes into https://github.com/NicoKiaru/bigdataviewer_playground_display. We get a better separation of tasks, the same functionalities as before, and an easier and more flexible to extend them.

This PR allows to solve, or provide an easier way to fix:

    #199 -> done in bigdataviewer_playground_display
    #196 -> done in bigdataviewer_playground_display with more flexibility
    #140
    #136
    #131
    #117
    #95
    #94

Two main mecahnisms used to separates concerns:
* using more scijava plugins extensibility mechanism
* using gson serialization, in combination with scijava plugins

This  allows in particular  the serialization of the suppliers of Bdv windows. User prefs (and dev prefs) are stored conveniently in the class that builds bdv windows, and is stored through serialization.

Another kind of plugin is added, which allows to handle any sourceandconverter operation based on a tag of xml of spimdata objects, when spimdata objects are loaded or saved ( think displaysettings, projection, and also custom converters for label images).
  • Loading branch information
NicoKiaru authored May 7, 2021
2 parents 89d232f + 0cee843 commit 359a143
Show file tree
Hide file tree
Showing 131 changed files with 2,537 additions and 4,043 deletions.
4 changes: 2 additions & 2 deletions bigdataviewer.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
#Fri Feb 05 10:33:13 CET 2021
#Fri Apr 30 16:10:12 CEST 2021
scale-bar-bg-color=-16724788
show-text-overlay=true
show-multibox-overlay=true
show-multibox-overlay=false
show-scale-bar-in-movie=true
show-scale-bar=true
scale-bar-color=-1
23 changes: 23 additions & 0 deletions plugins/bdvpgsettings/bdvpg.editor.actions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
"BDV - Set Number Of Timepoints",
"BDV - Show Sources (new Bdv window)",
"BDV - Screenshot",
"PopupLine",
"BDV - Remove Sources From BDV",
"Set Sources Color",
"Set Sources Brightness",
"Make Sources Invisible",
"Set Sources Projection Mode",
"PopupLine",
"Create New Source (Set LUT)",
"PopupLine",
"Manual Sources Transformation",
"Basic Transformation",
"Make Global Source Group",
"PopupLine",
"Inspect Sources",
"PopupLine",
"Add Metadata To Sources",
"PopupLine",
"Export Sources to XML/HDF5 Spimdataset"
]
1 change: 0 additions & 1 deletion plugins/bdvpgsettings/bdvpg.editor.actions.txt.default.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[
"BDV - Set Number Of Timepoints",
"BDV - Show Sources (new Bdv window)",
"BDV - Screenshot",
"PopupLine",
"BDV - Remove Sources From BDV",
"Set Sources Color",
Expand Down
37 changes: 37 additions & 0 deletions plugins/bdvpgsettings/bdvpg.tree.actions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[
"BDV - Show Sources",
"BDV - Show Sources (new Bdv window)",
"BDV - Zoom to source",
"BDV - Show Sources In Multiple BDV Windows",
"BDV - Set Number Of Timepoints",
"BDV - Create empty BDV window",
"BDV - Create Orthogonal Views",
"BDV - Screenshot",
"BDV - Synchronize Views",
"BDV - Remove Sources From BDV",
"PopupLine",
"Create Empty BVV Frame",
"Show Sources in BVV",
"PopupLine",
"Set Sources Color",
"Set Sources Brightness",
"Make Sources Invisible",
"Make Sources Visible",
"Set Sources Projection Mode",
"Create New Source (Set LUT)",
"Create New Source (Set Color)",
"PopupLine",
"Manual Sources Transformation",
"Basic Transformation",
"Make Global Source Group",
"PopupLine",
"Save BDVDataset",
"Inspect Sources",
"PopupLine",
"Add Metadata To Sources",
"Make Metadata Filter Node",
"PopupLine",
"Export Sources to XML/HDF5 Spimdataset",
"Delete Sources",
"PopupLine"
]
1 change: 0 additions & 1 deletion plugins/bdvpgsettings/bdvpg.tree.actions.txt.default.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"BDV - Set Number Of Timepoints",
"BDV - Create empty BDV window",
"BDV - Create Orthogonal Views",
"BDV - Screenshot",
"BDV - Synchronize Views",
"BDV - Remove Sources From BDV",
"PopupLine",
Expand Down
15 changes: 4 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>sc.fiji</groupId>
<artifactId>bigdataviewer-playground</artifactId>
<version>0.2.15-SNAPSHOT</version>
<version>0.3.0-SNAPSHOT</version>

<name>bigdataviewer-playground</name>
<description>BigDataViewer Actions and GUI</description>
Expand Down Expand Up @@ -92,7 +92,6 @@
<connection>scm:git:git://github.com/bigdataviewer/bigdataviewer-playground</connection>
<developerConnection>scm:git:[email protected]:bigdataviewer/bigdataviewer-playground</developerConnection>
<url>https://github.com/bigdataviewer/bigdataviewer-playground/</url>
<tag>bigdataviewer-playground-0.2.7</tag>
</scm>

<issueManagement>
Expand All @@ -118,12 +117,12 @@
<releaseProfiles>deploy-to-scijava</releaseProfiles>

<scijava.deleteOtherVersions>true</scijava.deleteOtherVersions>
<scijava.app.directory>C:/Users/nicol/Desktop/fiji-win64-bdv-playground/Fiji.app/</scijava.app.directory>
<!-- <scijava.app.directory>C:/Users/nicol/Desktop/fiji-win64-bdv-playground/Fiji.app/</scijava.app.directory> -->

<bigdataviewer-selector.version>0.1.8</bigdataviewer-selector.version>
<bigvolumeviewer.version>0.2.0</bigvolumeviewer.version>
<mastodon.version>1.0.0-beta-16</mastodon.version>
<bigdataviewer-spimdata-extras.version>0.1.0</bigdataviewer-spimdata-extras.version>
<mastodon.version>1.0.0-beta-17</mastodon.version>
<bigdataviewer-spimdata-extras.version>0.1.1</bigdataviewer-spimdata-extras.version>
<reflections.version>0.9.11</reflections.version>

<!-- package version below are determined by the parent pom but need to be upgraded -->
Expand Down Expand Up @@ -195,12 +194,6 @@
<artifactId>imglib2</artifactId>
</dependency>

<dependency>
<groupId>ch.epfl.biop</groupId>
<artifactId>bigdataviewer-spimdata-extras</artifactId>
<version>${bigdataviewer-spimdata-extras.version}</version>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
Expand Down
123 changes: 0 additions & 123 deletions src/main/java/bdv/util/ARGBColorConverterSetup.java

This file was deleted.

3 changes: 2 additions & 1 deletion src/main/java/bdv/util/EmptySource.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import net.imglib2.type.numeric.integer.UnsignedShortType;
import net.imglib2.view.ExtendedRandomAccessibleInterval;
import net.imglib2.view.Views;
import sc.fiji.bdvpg.scijava.adapter.source.EmptySourceAdapter;

import java.io.Serializable;
import java.util.function.BiConsumer;
Expand All @@ -48,7 +49,7 @@
* This source can be thus used to define a template in order to Resample another source
* with new bounds and voxel size, for instance as a model in {@link ResampledSource}
*
* Also this source can be serialized with the gson adapter {@link sc.fiji.bdvpg.services.serializers.plugins.EmptySourceAdapter}
* Also this source can be serialized with the gson adapter {@link EmptySourceAdapter}
* which is helpful to save such source easily.
*
*/
Expand Down
1 change: 1 addition & 0 deletions src/main/java/bdv/util/RAIHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import net.imglib2.util.Util;
import net.imglib2.view.Views;
import org.janelia.saalfeldlab.n5.imglib2.RandomAccessibleLoader;
//import org.janelia.saalfeldlab.n5.imglib2.RandomAccessibleLoader;

import static net.imglib2.img.basictypeaccess.AccessFlags.VOLATILE;
import static net.imglib2.type.PrimitiveType.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package sc.fiji.bdvpg.services.serializers;
package net.imglib2.realtransform;

import com.google.gson.*;
import net.imglib2.realtransform.AffineTransform3D;
import org.scijava.plugin.Plugin;
import sc.fiji.bdvpg.services.serializers.plugins.IClassAdapter;

import sc.fiji.persist.IClassAdapter;
import java.lang.reflect.Type;

/**
* Affine transform 3D adapter
*/
@Plugin(type = IClassAdapter.class)
public class AffineTransform3DAdapter implements IClassAdapter<AffineTransform3D> {

Expand All @@ -58,4 +59,5 @@ public JsonElement serialize(AffineTransform3D affineTransform3D, Type type, Jso
public Class<? extends AffineTransform3D> getAdapterClass() {
return AffineTransform3D.class;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,30 @@
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package sc.fiji.bdvpg.services.serializers.plugins;
package net.imglib2.realtransform;

import org.scijava.plugin.PTService;
import org.scijava.plugin.PluginInfo;
import org.scijava.service.SciJavaService;
import org.scijava.plugin.Plugin;
import sc.fiji.persist.IClassRuntimeAdapter;

import java.util.List;
/**
* Runtime adapter for RealTransform
*/
@Plugin(type = IClassRuntimeAdapter.class)
public class AffineTransform3DRunTimeAdapter implements IClassRuntimeAdapter<RealTransform, AffineTransform3D> {

@Override
public Class<? extends RealTransform> getBaseClass() {
return RealTransform.class;
}

public interface BdvPlaygroundObjectAdapterService extends PTService<IBdvPlaygroundObjectAdapter>, SciJavaService {
@Override
public Class<? extends AffineTransform3D> getRunTimeClass() {
return AffineTransform3D.class;
}

//List<PluginInfo<IBdvPlaygroundObjectAdapter>> getAdapters(Class<? extends IBdvPlaygroundObjectAdapter> adapterClass);
@Override
public boolean useCustomAdapter() {
return false;
}

<PT extends IBdvPlaygroundObjectAdapter> List<PluginInfo<PT>> getAdapters(Class<PT> adapterClass);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import com.google.gson.*;
import org.scijava.plugin.Plugin;
import sc.fiji.bdvpg.services.serializers.plugins.IClassRuntimeAdapter;
import sc.fiji.persist.IClassRuntimeAdapter;

import java.lang.reflect.Type;

Expand All @@ -57,6 +57,11 @@ public Class<? extends InvertibleRealTransformSequence> getRunTimeClass() {
return InvertibleRealTransformSequence.class;
}

@Override
public boolean useCustomAdapter() {
return true;
}

@Override
public InvertibleRealTransformSequence deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
JsonObject obj = jsonElement.getAsJsonObject();
Expand All @@ -77,7 +82,7 @@ public InvertibleRealTransformSequence deserialize(JsonElement jsonElement, Type
if (transform instanceof InvertibleRealTransform) {
irts.add((InvertibleRealTransform) transform);
} else {
System.err.println("Deserialization eroor: "+transform+" of class "+transform.getClass().getSimpleName()+" is not invertible!");
System.err.println("Deserialization error: "+transform+" of class "+transform.getClass().getSimpleName()+" is not invertible!");
return null;
}
}
Expand All @@ -89,15 +94,10 @@ public InvertibleRealTransformSequence deserialize(JsonElement jsonElement, Type
@Override
public JsonElement serialize(InvertibleRealTransformSequence irts, Type type, JsonSerializationContext jsonSerializationContext) {
JsonObject obj = new JsonObject();

obj.addProperty("type", InvertibleRealTransformSequence.class.getSimpleName());

obj.addProperty("size", irts.transforms.size());

for (int iTransform = 0; iTransform<irts.transforms.size(); iTransform++) {
obj.add("realTransform_"+iTransform, jsonSerializationContext.serialize(irts.transforms.get(iTransform)));
obj.add("realTransform_"+iTransform, jsonSerializationContext.serialize(irts.transforms.get(iTransform), RealTransform.class));
}

return obj;
}
}
Loading

0 comments on commit 359a143

Please sign in to comment.