Skip to content

Commit

Permalink
Merge pull request #543 from saalfeldlab/perf/1.4.0
Browse files Browse the repository at this point in the history
Perf/1.4.0
  • Loading branch information
cmhulbert committed Jul 26, 2024
2 parents 93e59c0 + 538be00 commit b0459b3
Show file tree
Hide file tree
Showing 35 changed files with 1,002 additions and 1,563 deletions.
37 changes: 12 additions & 25 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.scijava</groupId>
<artifactId>pom-scijava</artifactId>
<version>37.0.0</version>
<version>38.0.1</version>
</parent>

<groupId>org.janelia.saalfeldlab</groupId>
Expand All @@ -29,7 +29,6 @@
<properties>
<!-- allows passing in command line argument to javafx:run via `-Dpaintera.commandline.args="....."`-->
<paintera.commandline.args />
<scijava.jvm.version>21</scijava.jvm.version>

<main-class>org.janelia.saalfeldlab.paintera.Paintera</main-class>
<license.licenseName>GNU General Public License v2.0</license.licenseName>
Expand All @@ -41,6 +40,8 @@

<package-name>org.janelia.saalfeldlab.paintera</package-name>

<!-- java -->
<scijava.jvm.version>21</scijava.jvm.version>
<!-- kotlin -->
<kotlin.version>1.9.24</kotlin.version>
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
Expand All @@ -51,14 +52,13 @@
<javadoc.skip>true</javadoc.skip>
<maven.javadoc.skip>${javadoc.skip}</maven.javadoc.skip>


<janino.version>3.0.7</janino.version>
<logback.version>1.4.12</logback.version>
<slf4j.version>2.0.0</slf4j.version>

<!-- JavaFx Version-->
<javafx.version>22.0.1</javafx.version>
<saalfx.version>1.4.2</saalfx.version>
<saalfx.version>2.0.0-SNAPSHOT</saalfx.version>
<testfx.version>4.0.16-alpha</testfx.version>

<alphanumeric-comparator.version>1.4.1</alphanumeric-comparator.version>
Expand All @@ -74,14 +74,12 @@
<macos.sign />
<macos.sign.identity />

<!--N5 versions. Should match with versions pinned by n5-universe -->
<n5.version>3.2.0</n5.version>
<n5-hdf5.version>2.2.0</n5-hdf5.version>
<n5-google-cloud.version>4.1.0</n5-google-cloud.version>
<n5-aws-s3.version>4.2.0</n5-aws-s3.version>
<n5-zarr.version>1.3.4</n5-zarr.version>
<n5-imglib2.version>7.0.0</n5-imglib2.version>
<n5-universe.version>1.6.0</n5-universe.version>
<!-- N5 (Only specify if newer versions available than in pom-scijava) -->
<n5.version>3.3.0</n5.version>
<n5-aws-s3.version>4.2.1</n5-aws-s3.version>
<n5-google-cloud>4.1.1</n5-google-cloud>
<n5-zarr.version>1.3.5</n5-zarr.version>

<imglib2-label-multisets.version>0.14.0</imglib2-label-multisets.version>

<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
Expand Down Expand Up @@ -319,17 +317,6 @@
<artifactId>commons-io</artifactId>
</dependency>

<dependency>
<groupId>io.reactivex.rxjava2</groupId>
<artifactId>rxjavafx</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>io.reactivex.rxjava2</groupId>
<artifactId>rxjava</artifactId>
<version>2.1.6</version>
</dependency>

<!-- scripting-->
<dependency>
<groupId>org.scijava</groupId>
Expand All @@ -351,7 +338,7 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>${groovy.version}</version>
</dependency>
Expand Down Expand Up @@ -568,7 +555,7 @@
<email>hanslovskyp@janelia.hhmi.org</email>
<url />
<organization>HHMI Janelia</organization>
<organizationUrl>http://janelia.org/</organizationUrl>
<organizationUrl>https://janelia.org/</organizationUrl>
<roles>
<role>founder</role>
<role>lead</role>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.janelia.saalfeldlab.bdv.fx.viewer.scalebar;

import org.janelia.saalfeldlab.bdv.fx.viewer.render.OverlayRendererGeneric;
import bdv.viewer.TransformListener;
import javafx.geometry.Bounds;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.text.Text;
import net.imglib2.realtransform.AffineTransform3D;
import net.imglib2.util.LinAlgHelpers;
import org.janelia.saalfeldlab.bdv.fx.viewer.render.OverlayRendererGeneric;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -25,8 +25,6 @@ public class ScaleBarOverlayRenderer implements OverlayRendererGeneric<GraphicsC

private final ScaleBarOverlayConfig config;

// private final DecimalFormat format = new DecimalFormat("0.####");

/**
* For finding the value to display on the scalebar: into how many parts is
* each power of ten divided? For example, 4 means the following are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,14 @@ public void close() {
private File inferActualDirectory(final File directory) throws IOException {

return directory == null
? Files.createTempDirectory("paintera-project-").toFile()
? temporaryN5PainteraProjectDirectory()
: directory;
}

private File temporaryN5PainteraProjectDirectory() throws IOException {
return new File(Files.createTempDirectory("paintera-project-").toString() + ".n5");
}

private void stateChanged() {

this.listeners.forEach(l -> l.accept(this));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package org.janelia.saalfeldlab.paintera.control.navigation;

import org.janelia.saalfeldlab.bdv.fx.viewer.ViewerPanelFX;
import org.janelia.saalfeldlab.bdv.fx.viewer.ViewerState;
import bdv.viewer.Interpolation;
import bdv.viewer.Source;
import bdv.viewer.TransformListener;
import javafx.application.Platform;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Task;
import javafx.event.EventHandler;
import javafx.scene.input.MouseEvent;
import kotlinx.coroutines.Deferred;
import net.imglib2.RealRandomAccess;
import net.imglib2.realtransform.AffineTransform3D;
import net.imglib2.realtransform.RealViews;
import net.imglib2.view.composite.Composite;
import org.janelia.saalfeldlab.bdv.fx.viewer.ViewerPanelFX;
import org.janelia.saalfeldlab.bdv.fx.viewer.ViewerState;
import org.janelia.saalfeldlab.fx.Tasks;
import org.janelia.saalfeldlab.paintera.data.ChannelDataSource;
import org.janelia.saalfeldlab.paintera.data.DataSource;
Expand Down Expand Up @@ -95,17 +96,17 @@ private static <D> D getVal(final RealRandomAccess<D> access, final ViewerPanelF
return access.get();
}

private final Map<DataSource<?, ?>, Task<?>> taskMap = new HashMap<>();
private final Map<DataSource<?, ?>, Deferred<?>> taskMap = new HashMap<>();

private final ExecutorService executor = Executors.newSingleThreadExecutor(new NamedThreadFactory("value-display-listener", true, 2));

private <D> void getInfo() {

final Optional<Source<?>> optionalSource = Optional.ofNullable(currentSource.getValue());
if (optionalSource.isPresent() && optionalSource.get() instanceof DataSource<?, ?>) {
final DataSource<D, ?> source = (DataSource<D, ?>) optionalSource.get();
final DataSource<D, ?> source = (DataSource<D, ?>)optionalSource.get();

final var taskObj = Tasks.<String>createTask(t -> {
final var job = Tasks.createTask(() -> {
final ViewerState state = viewer.getState();
final Interpolation interpolation = this.interpolation.apply(source);
final AffineTransform3D screenScaleTransform = new AffineTransform3D();
Expand All @@ -123,28 +124,29 @@ private <D> void getInfo() {
).realRandomAccess();
final var val = getVal(x, y, access, viewer);
return stringConverterFromSource(source).apply(val);
}).onSuccess((event, t) -> {
/* submit the value if the task is completed; remove from the map*/
submitValue.accept(t.getValue());
}).onSuccess(result -> {
Platform.runLater(() -> submitValue.accept(result));
taskMap.remove(source);
});



/* If we are creating a task for a source which has a running task, cancel the old task after removing. */
Optional.ofNullable(taskMap.put(source, taskObj)).ifPresent(Task::cancel);
Optional.ofNullable(taskMap.put(source, job)).ifPresent(it -> it.cancel(null));

taskObj.submit(executor);
job.start();

}
}

private static <D> Function<D, String> stringConverterFromSource(final DataSource<D, ?> source) {

if (source instanceof ChannelDataSource<?, ?>) {
final long numChannels = ((ChannelDataSource<?, ?>) source).numChannels();
final long numChannels = ((ChannelDataSource<?, ?>)source).numChannels();

// Cast not actually redundant
//noinspection unchecked,RedundantCast
return (Function<D, String>) (Function<? extends Composite<?>, String>) comp -> {
return (Function<D, String>)(Function<? extends Composite<?>, String>)comp -> {
StringBuilder sb = new StringBuilder("(");
if (numChannels > 0)
sb.append(comp.get(0).toString());
Expand Down
Loading

0 comments on commit b0459b3

Please sign in to comment.