Skip to content

Commit

Permalink
Merge pull request #549 from saalfeldlab/feat/1.5.0
Browse files Browse the repository at this point in the history
Feat/1.5.0
  • Loading branch information
cmhulbert authored Oct 11, 2024
2 parents eba5438 + 95f13c2 commit bba621f
Show file tree
Hide file tree
Showing 77 changed files with 1,830 additions and 1,161 deletions.
14 changes: 6 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>paintera</artifactId>
<version>1.4.4-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>

<name>Paintera</name>
<description>New Era Painting and annotation tool</description>
Expand Down Expand Up @@ -68,7 +68,7 @@
<main-class>org.janelia.saalfeldlab.paintera.Paintera</main-class>
<app.name>Paintera</app.name>
<app.package>paintera</app.package>
<app.version>1.4.1</app.version>
<app.version>1.5.0</app.version>

<jvm.modules>javafx.base,javafx.controls,javafx.fxml,javafx.media,javafx.swing,javafx.web,javafx.graphics,java.naming,java.management,java.sql</jvm.modules>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -81,7 +81,9 @@
<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.15.0</imglib2-label-multisets.version>
<imglib2-label-multisets.version>0.15.1</imglib2-label-multisets.version>
<imglib2.version>6.1.0</imglib2.version>
<imglib2-realtransform.version>4.0.1</imglib2-realtransform.version>

<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
<enforcer.skip>true</enforcer.skip>
Expand Down Expand Up @@ -185,7 +187,6 @@
<dependency>
<groupId>net.imglib2</groupId>
<artifactId>imglib2</artifactId>
<version>6.1.0</version>
</dependency>
<dependency>
<groupId>net.imglib2</groupId>
Expand All @@ -194,7 +195,6 @@
<dependency>
<groupId>net.imglib2</groupId>
<artifactId>imglib2-realtransform</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>net.imglib2</groupId>
Expand Down Expand Up @@ -687,7 +687,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkCount>1</forkCount>
<argLine>-Dtestfx.robot=glass -Dglass.platform=Monocle -Dmonocle.platform=Headless -Dprism.order=sw --enable-preview</argLine>
<argLine>-Dtestfx.robot=glass -Dglass.platform=Monocle -Dmonocle.platform=Headless -Dprism.order=sw</argLine>
</configuration>
</plugin>
</plugins>
Expand All @@ -709,7 +709,6 @@
</annotationProcessors>
<source>21</source>
<target>21</target>
<compilerArgs>--enable-preview</compilerArgs>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -919,7 +918,6 @@
<version>${kotlin.version}</version>
<configuration>
<javacOptions>
<javacOption>--enable-preview</javacOption>
</javacOptions>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public interface ImageGenerator<T> {
/**
* @param display The canvas that will display the images we render.
* @param painterThread Thread that triggers repainting of the display. Requests for repainting are send there.
* @param screenScales Scale factors from the viewer canvas to screen images of different resolutions. A scale factor of 1 means 1
* @param initialScreenScales Scale factors from the viewer canvas to screen images of different resolutions. A scale factor of 1 means 1
* pixel in the screen image is displayed as 1 pixel on the canvas, a scale factor of 0.5 means 1 pixel in the
* screen image is displayed as 2 pixel on the canvas, etc.
* @param targetRenderNanos Target rendering time in nanoseconds. The rendering time for the coarsest rendered scale should be below
Expand All @@ -271,7 +271,7 @@ public interface ImageGenerator<T> {
MultiResolutionRendererGeneric(
final TransformAwareRenderTargetGeneric<T> display,
final PainterThreadFx painterThread,
final double[] screenScales,
final double[] initialScreenScales,
final long targetRenderNanos,
final boolean doubleBuffered,
final TaskExecutor renderingTaskExecutor,
Expand All @@ -287,7 +287,7 @@ public interface ImageGenerator<T> {
this.painterThread = painterThread;
projector = null;
currentScreenScaleIndex = -1;
this.screenScales = screenScales.clone();
this.screenScales = initialScreenScales.clone();
this.doubleBuffered = doubleBuffered;
createVariables();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ public void requestRepaint(final RealInterval intervalInGlobalSpace) {
this.applyToAll(v -> v.requestRepaint(intervalInGlobalSpace));
}

public void drawOverlays() {
applyToAll(it -> it.getDisplay().drawOverlays());
}

/**
* {@link ViewerPanelFX#setAllSources(Collection)}} for all {@link ViewerPanelFX viewer children} (top left, top right, bottom left)
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.janelia.saalfeldlab.paintera;

import com.pivovarit.function.ThrowingSupplier;
import org.janelia.saalfeldlab.paintera.config.PainteraDirectoriesConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.Yaml;
Expand All @@ -14,50 +15,63 @@
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Supplier;

public class PainteraConfigYaml {

private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

private static final String USER_HOME = System.getProperty("user.home");
private static final String PAINTERA_YAML = "paintera.yml";

private static final Path PAINTERA_YAML = Paths.get(USER_HOME, ".config", "paintera.yml");
public static <T> T getConfig(final Supplier<T> fallBack, final String... segments) {

public static Object getConfig(final Supplier<Object> fallBack, final String... segments) {

Object currentConfig = getConfig();
for (final String segment : segments) {
if (!(currentConfig instanceof Map<?, ?>))
return fallBack.get();
final Map<?, ?> map = (Map<?, ?>)currentConfig;
if (!map.containsKey(segment))
Map<?, ?> currentConfig = getConfig();

final Function<Object, T> getOrFallback = (config) -> {
try {
return (T) config;
} catch (ClassCastException e) {
return fallBack.get();
currentConfig = map.get(segment);
}
};

for (int i = 0; i < segments.length; i++) {
final String segment = segments[i];
if (currentConfig.containsKey(segment)) {
final Object config = currentConfig.get(segment);
if (i == segments.length - 1)
return getOrFallback.apply(config);
if (config instanceof Map<?, ?>)
currentConfig = (Map<?, ?>) config;
else
return fallBack.get();
}
}
return currentConfig;
return fallBack.get();
}

// TODO should this return copy?
public static Map<?, ?> getConfig() {

return CONFIG;
String appConfigDir;
try {
appConfigDir = Paintera.getPaintera().getProperties().getPainteraDirectoriesConfig().getAppConfigDir();
} catch (Exception e) {
appConfigDir = PainteraDirectoriesConfig.APPLICATION_DIRECTORIES.configDir;
}
return readConfigUnchecked(Paths.get(appConfigDir, PAINTERA_YAML));
}

private static final Map<?, ?> CONFIG = readConfigUnchecked();

private static Map<?, ?> readConfigUnchecked() {

return ThrowingSupplier.unchecked(PainteraConfigYaml::readConfig).get();
}
private static Map<?, ?> readConfigUnchecked(Path painteraYaml) {
return ThrowingSupplier.unchecked(() -> readConfig(painteraYaml)).get();
};

private static Map<?, ?> readConfig() throws IOException {
private static Map<?, ?> readConfig(Path painteraYaml) throws IOException {

final Yaml yaml = new Yaml();
try (final InputStream fis = new FileInputStream(PAINTERA_YAML.toFile())) {
// TODO is this cast always safe?
// TODO make this type safe, maybe create config class
final Map<?, ?> data = (Map<?, ?>)yaml.load(fis);
try (final InputStream fis = new FileInputStream(painteraYaml.toFile())) {
final Map<?, ?> data = yaml.load(fis);
LOG.debug("Loaded paintera info: {}", data);
return data;
} catch (final FileNotFoundException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public enum MenuActionType implements ActionType {
LoadProject,
DetachViewer,

OpenProject;
OpenProject,
ExportSource;

public static EnumSet<MenuActionType> of(final MenuActionType first, final MenuActionType... rest) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import java.util.function.Consumer;

import static java.util.FormatProcessor.FMT;

public class CoordinateDisplayListener {

private final ViewerPanelFX viewer;
Expand Down Expand Up @@ -93,7 +91,7 @@ public static String realPointToString(final RealPoint p) {
final double d0 = p.getDoublePosition(0);
final double d1 = p.getDoublePosition(1);
final double d2 = p.getDoublePosition(2);
return FMT."(%8.3f\{d0}, %8.3f\{d1}, %8.3f\{d2})";
return String.format("(%8.3f, %8.3f, %8.3f)", d0, d1, d2);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,32 @@ public void translate(final double dX, final double dY, final double dZ, final D

manager.getTransform(globalTransform);
globalToViewerTransformListener.getTransformCopy(globalToViewerTransform);
/* undo global transform, left with only scale, rotation, translation in viewer space */
globalToViewerTransform.concatenate(globalTransform.inverse());
globalToViewerTransform.setTranslation(0.0, 0.0, 0.0);


delta[0] = dX;
delta[1] = dY;
delta[2] = dZ;

globalToViewerTransform.applyInverse(delta, delta);
globalTransform.translate(delta);
translateFromViewer(globalTransform, globalToViewerTransform, delta);

manager.setTransform(globalTransform, duration != null ? duration : Duration.ZERO);
}

}

public static void translateFromViewer(
final AffineTransform3D globalTransform,
final AffineTransform3D globalToViewerTransform,
final double[] delta
) {

/* undo global transform, left with only scale, rotation, translation in viewer space */
globalToViewerTransform.concatenate(globalTransform.inverse());
globalToViewerTransform.setTranslation(0.0, 0.0, 0.0);

globalToViewerTransform.applyInverse(delta, delta);
globalTransform.translate(delta);
}

/*TODO: Move this to somewhere else*/
public static final class TransformTracker implements TransformListener<AffineTransform3D> {

Expand Down
Loading

0 comments on commit bba621f

Please sign in to comment.