diff --git a/howtos/pom.xml b/howtos/pom.xml
index 19830695..d46c16f5 100644
--- a/howtos/pom.xml
+++ b/howtos/pom.xml
@@ -8,7 +8,7 @@
org.scijava
pom-scijava
- 26.0.0
+ 29.2.1
diff --git a/howtos/src/main/java/howto/app/DisposeImageJ.java b/howtos/src/main/java/howto/app/DisposeImageJ.java
index 173984c8..14e337e4 100644
--- a/howtos/src/main/java/howto/app/DisposeImageJ.java
+++ b/howtos/src/main/java/howto/app/DisposeImageJ.java
@@ -25,7 +25,7 @@ public static void run() {
// do something with ImageJ
// dispose ImageJ
- ij.context().dispose();
+ ij.dispose();
}
public static void main(String...args) { run(); }
diff --git a/howtos/src/main/java/howto/images/SaveImageCompressed.java b/howtos/src/main/java/howto/images/SaveImageCompressed.java
index 86e95f16..2cdb5f91 100644
--- a/howtos/src/main/java/howto/images/SaveImageCompressed.java
+++ b/howtos/src/main/java/howto/images/SaveImageCompressed.java
@@ -11,14 +11,17 @@
import io.scif.config.SCIFIOConfig;
import io.scif.formats.TIFFFormat;
import io.scif.services.DatasetIOService;
+
+import java.io.IOException;
+import java.nio.file.Files;
+
import net.imagej.Dataset;
import net.imagej.DefaultDataset;
import net.imagej.ImageJ;
import net.imagej.ImgPlus;
import net.imglib2.img.Img;
-import java.io.IOException;
-import java.nio.file.Files;
+import org.scijava.io.location.FileLocation;
/**
* How to save an image as LZW compressed TIFF
@@ -35,7 +38,7 @@ public static void run() throws IOException {
Img img = (Img) ij.io().open(Object.class.getResource("/blobs.png").getPath());
// create temporary path to save image to
- String dest = Files.createTempFile("img", ".tif").toString();
+ FileLocation dest = new FileLocation(Files.createTempFile("img", ".tif").toFile());
System.out.println("Saving image to " + dest);
// create SCIFIO config to set compression algorithm
@@ -48,7 +51,7 @@ public static void run() throws IOException {
ij.get(DatasetIOService.class).save(dataset, dest, config);
// load and show saved image
- Object savedImg = ij.io().open(dest);
+ Object savedImg = ij.io().open(dest.getFile().getAbsolutePath());
ij.ui().show("saved image", savedImg);
}
diff --git a/howtos/src/main/java/howto/metadata/GetMetadata.java b/howtos/src/main/java/howto/metadata/GetMetadata.java
index 310e90c2..42f48b1d 100644
--- a/howtos/src/main/java/howto/metadata/GetMetadata.java
+++ b/howtos/src/main/java/howto/metadata/GetMetadata.java
@@ -7,22 +7,19 @@
*/
package howto.metadata;
-import java.io.IOException;
-
-import io.scif.services.FormatService;
+import io.scif.FieldPrinter;
import io.scif.Format;
-import io.scif.FormatException;
import io.scif.Metadata;
-import io.scif.FieldPrinter;
+import io.scif.services.FormatService;
-import net.imagej.ImageJ;
import net.imagej.Dataset;
+import net.imagej.ImageJ;
import org.scijava.ItemIO;
-import org.scijava.command.Command;
+import org.scijava.io.location.Location;
+import org.scijava.io.location.LocationService;
import org.scijava.log.LogService;
import org.scijava.plugin.Parameter;
-import org.scijava.plugin.Plugin;
/**
* This example illustrates how to access and display image metadata using the {@link FormatService} and
@@ -35,8 +32,7 @@
* An optional {@code formatMetadata} method is included to (hopefully) make the text more readable.
*
*/
-@Plugin(type = Command.class, menuPath = "Image>Show Metadata")
-public class GetMetadata implements Command {
+public class GetMetadata {
// -- Needed services --
@@ -44,44 +40,46 @@ public class GetMetadata implements Command {
@Parameter
private FormatService formatService;
+ @Parameter
+ private LocationService locationService;
+
// for logging errors
@Parameter
private LogService log;
// -- Inputs and outputs to the command --
- // input image
- @Parameter
- private Dataset img;
-
// output metadata string
@Parameter(label = "Metadata", type = ItemIO.OUTPUT)
private String mString;
- @Override
- public void run() {
- // we need the file path to determine the file format
- final String filePath = img.getSource();
+ public static void run() throws Exception {
+ ImageJ ij = new ImageJ();
- // catch any Format or IO exceptions
- try {
+ // open a sample image
+ final Dataset img = ij.scifio().datasetIO().open("http://imagej.net/images/FluorescentCells.jpg");
- // determine the Format based on the extension and, if necessary, the source data
- Format format = formatService.getFormat(filePath);
+ // we need the file path to determine the file format
+ Location source = ij.get(LocationService.class).resolve(img.getSource());
- // create an instance of the associated Parser and parse metadata from the image file
- Metadata metadata = format.createParser().parse(filePath);
+ // catch any Format or IO exceptions
+ // determine the Format based on the extension and, if necessary, the source data
+ Format format = ij.scifio().format().getFormat(source);
- // use FieldPrinter to traverse metadata tree and return as a String
- String metadataTree = new FieldPrinter(metadata).toString();
+ // create an instance of the associated Parser and parse metadata from the image file
+ Metadata metadata = format.createParser().parse(source);
- // (optional) remove some of the tree formatting to make the metadata easier to read
- mString = formatMetadata(metadataTree);
- }
- catch (final FormatException | IOException e) {
- log.error(e);
- }
+ // use FieldPrinter to traverse metadata tree and return as a String
+ String metadataTree = new FieldPrinter(metadata).toString();
+ // (optional) remove some of the tree formatting to make the metadata easier to read
+ String mString = formatMetadata(metadataTree);
+
+ // print out our precious metadata!
+ ij.log().info(mString);
+
+ // close out our ImageJ
+ ij.dispose();
}
/**
@@ -89,7 +87,7 @@ public void run() {
* @param metadataTree raw metadata string returned by FieldPrinter().toString()
* @return formatted version of metadataTree
*/
- private String formatMetadata(String metadataTree) {
+ private static String formatMetadata(String metadataTree) {
// remove ending braces | replace ", " between OME fields
String tmp = metadataTree.replaceAll("(\\t+}\\n)|(,\\s)", "\n");
@@ -98,28 +96,5 @@ private String formatMetadata(String metadataTree) {
return tmp.replaceAll("(\\t+\\{\\n)|(\\t+)", "");
}
- /**
- * This main function serves for development purposes.
- * It allows you to run the plugin immediately out of
- * your integrated development environment (IDE).
- *
- * @param args unused
- * @throws Exception
- */
- public static void main(final String... args) throws Exception {
- // create the ImageJ application context with all available services
- final ImageJ ij = new ImageJ();
- ij.launch(args);
-
- // open a sample image
- final Dataset img = ij.scifio().datasetIO().open("http://imagej.net/images/FluorescentCells.jpg");
-
- // show the image
- ij.ui().show(img);
-
- // invoke the plugin
- ij.command().run(GetMetadata.class, true);
-
- }
-
+ public static void main(String...args) throws Exception { run(); }
}
diff --git a/maven-projects/add-two-datasets/pom.xml b/maven-projects/add-two-datasets/pom.xml
index e9713a07..edc029b7 100644
--- a/maven-projects/add-two-datasets/pom.xml
+++ b/maven-projects/add-two-datasets/pom.xml
@@ -8,7 +8,7 @@
org.scijava
pom-scijava
- 26.0.0
+ 29.2.1
diff --git a/maven-projects/custom-preprocessor-plugin/pom.xml b/maven-projects/custom-preprocessor-plugin/pom.xml
index 3fa43873..713a03b0 100644
--- a/maven-projects/custom-preprocessor-plugin/pom.xml
+++ b/maven-projects/custom-preprocessor-plugin/pom.xml
@@ -8,7 +8,7 @@
org.scijava
pom-scijava
- 26.0.0
+ 29.2.1
diff --git a/maven-projects/dynamic-commands/pom.xml b/maven-projects/dynamic-commands/pom.xml
index 1ab7d552..f588f65b 100644
--- a/maven-projects/dynamic-commands/pom.xml
+++ b/maven-projects/dynamic-commands/pom.xml
@@ -8,7 +8,7 @@
org.scijava
pom-scijava
- 26.0.0
+ 29.2.1
diff --git a/maven-projects/execute-commands/pom.xml b/maven-projects/execute-commands/pom.xml
index 80c390e7..b75f722f 100644
--- a/maven-projects/execute-commands/pom.xml
+++ b/maven-projects/execute-commands/pom.xml
@@ -8,7 +8,7 @@
org.scijava
pom-scijava
- 26.0.0
+ 29.2.1
diff --git a/maven-projects/execute-commands/src/main/java/ExecuteCommands.java b/maven-projects/execute-commands/src/main/java/ExecuteCommands.java
index 4a2ac0a5..0253246d 100644
--- a/maven-projects/execute-commands/src/main/java/ExecuteCommands.java
+++ b/maven-projects/execute-commands/src/main/java/ExecuteCommands.java
@@ -158,7 +158,7 @@ public static Dataset invokeWithArgs(final ImageJ ij) {
*/
public static Dataset invokeWithMap(final ImageJ ij) {
// populate the map of input parameters
- final Map inputMap = new HashMap();
+ final Map inputMap = new HashMap<>();
inputMap.put("inputFile", new File("sample-image.fake"));
// execute asynchronously using the command service
final Future future =
diff --git a/maven-projects/ij2-image-plus/pom.xml b/maven-projects/ij2-image-plus/pom.xml
index d5842a5d..1b7c410a 100644
--- a/maven-projects/ij2-image-plus/pom.xml
+++ b/maven-projects/ij2-image-plus/pom.xml
@@ -8,7 +8,7 @@
org.scijava
pom-scijava
- 26.0.0
+ 29.2.1
diff --git a/maven-projects/listen-to-events/pom.xml b/maven-projects/listen-to-events/pom.xml
index 152e0bdb..bb78c6d2 100644
--- a/maven-projects/listen-to-events/pom.xml
+++ b/maven-projects/listen-to-events/pom.xml
@@ -8,7 +8,7 @@
org.scijava
pom-scijava
- 26.0.0
+ 29.2.1
diff --git a/maven-projects/simple-commands/pom.xml b/maven-projects/simple-commands/pom.xml
index 9f1f0811..f73ed673 100644
--- a/maven-projects/simple-commands/pom.xml
+++ b/maven-projects/simple-commands/pom.xml
@@ -8,7 +8,7 @@
org.scijava
pom-scijava
- 26.0.0
+ 29.2.1
diff --git a/maven-projects/swing-example/pom.xml b/maven-projects/swing-example/pom.xml
index ce76548f..204e50b0 100644
--- a/maven-projects/swing-example/pom.xml
+++ b/maven-projects/swing-example/pom.xml
@@ -8,7 +8,7 @@
org.scijava
pom-scijava
- 26.0.0
+ 29.2.1
diff --git a/maven-projects/swing-example/src/main/java/DeconvolutionCommand.java b/maven-projects/swing-example/src/main/java/DeconvolutionCommand.java
index 28bff73e..224dcfc9 100644
--- a/maven-projects/swing-example/src/main/java/DeconvolutionCommand.java
+++ b/maven-projects/swing-example/src/main/java/DeconvolutionCommand.java
@@ -66,7 +66,8 @@ public void run() {
}
log.info("starting deconvolution");
- deconvolved = ops.deconvolve().richardsonLucy(imgFloat, psf, numIterations);
+ final Img deconvolved = ops.create().img(imgFloat);
+ ops.deconvolve().richardsonLucy(deconvolved, imgFloat, psf, numIterations);
log.info("finished deconvolution");
}
diff --git a/maven-projects/swing-example/src/main/java/DeconvolutionCommandSwing.java b/maven-projects/swing-example/src/main/java/DeconvolutionCommandSwing.java
index e2cd17b7..0a975e5f 100644
--- a/maven-projects/swing-example/src/main/java/DeconvolutionCommandSwing.java
+++ b/maven-projects/swing-example/src/main/java/DeconvolutionCommandSwing.java
@@ -8,66 +8,37 @@
import javax.swing.SwingUtilities;
-import net.imagej.ops.OpService;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.type.numeric.real.FloatType;
+import org.scijava.Context;
import org.scijava.ItemIO;
-import org.scijava.app.StatusService;
import org.scijava.command.Command;
-import org.scijava.command.CommandService;
-import org.scijava.log.LogService;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;
-import org.scijava.thread.ThreadService;
-import org.scijava.ui.UIService;
@Plugin(type = Command.class, headless = true,
menuPath = "Deconvolution>Deconvolution Swing")
public class DeconvolutionCommandSwing implements Command {
@Parameter
- OpService ops;
+ private Context ctx;
- @Parameter
- LogService log;
-
- @Parameter
- UIService ui;
-
- @Parameter
- CommandService cmd;
-
- @Parameter
- StatusService status;
-
- @Parameter
- ThreadService thread;
+ @Parameter(type = ItemIO.OUTPUT)
+ private RandomAccessibleInterval deconvolved;
private static DeconvolutionDialog dialog = null;
- @Parameter(type = ItemIO.OUTPUT)
- RandomAccessibleInterval deconvolved;
-
/**
* show a dialog and give the dialog access to required IJ2 Services
*/
@Override
public void run() {
-
SwingUtilities.invokeLater(() -> {
if (dialog == null) {
- dialog = new DeconvolutionDialog();
+ dialog = new DeconvolutionDialog(ctx);
}
dialog.setVisible(true);
-
- dialog.setOps(ops);
- dialog.setLog(log);
- dialog.setStatus(status);
- dialog.setCommand(cmd);
- dialog.setThread(thread);
- dialog.setUi(ui);
-
});
}
}
diff --git a/maven-projects/swing-example/src/main/java/DeconvolutionDialog.java b/maven-projects/swing-example/src/main/java/DeconvolutionDialog.java
index 718bcf0e..01972a62 100644
--- a/maven-projects/swing-example/src/main/java/DeconvolutionDialog.java
+++ b/maven-projects/swing-example/src/main/java/DeconvolutionDialog.java
@@ -14,19 +14,19 @@
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
-import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder;
import net.imagej.ops.OpService;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.img.Img;
import net.imglib2.img.display.imagej.ImageJFunctions;
-import net.imglib2.type.numeric.RealType;
import net.imglib2.type.numeric.real.FloatType;
+import org.scijava.Context;
import org.scijava.app.StatusService;
import org.scijava.command.CommandService;
import org.scijava.log.LogService;
+import org.scijava.plugin.Parameter;
import org.scijava.thread.ThreadService;
import org.scijava.ui.UIService;
@@ -35,33 +35,31 @@
public class DeconvolutionDialog extends JDialog {
+ @Parameter
private OpService ops;
+
+ @Parameter
private LogService log;
+
+ @Parameter
private StatusService status;
+
+ @Parameter
private CommandService cmd;
+
+ @Parameter
private ThreadService thread;
+
+ @Parameter
private UIService ui;
private final JPanel contentPanel = new JPanel();
- /**
- * Launch the application.
- */
- public static void main(final String[] args) {
- try {
- final DeconvolutionDialog dialog = new DeconvolutionDialog();
- dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
- dialog.setVisible(true);
- }
- catch (final Exception e) {
- e.printStackTrace();
- }
- }
-
/**
* Create the dialog.
*/
- public DeconvolutionDialog() {
+ public DeconvolutionDialog(final Context ctx) {
+ ctx.inject(this);
setBounds(100, 100, 450, 300);
getContentPane().setLayout(new BorderLayout());
contentPanel.setLayout(new FlowLayout());
@@ -75,10 +73,7 @@ public DeconvolutionDialog() {
public void actionPerformed(final ActionEvent arg0) {
// start deconvolution with the scijava ThreadService
- thread.run(() -> {
- deconvolve();
- });
-
+ thread.run(() -> deconvolve());
}
});
contentPanel.add(btnDeconvolve);
@@ -95,28 +90,12 @@ public void actionPerformed(final ActionEvent arg0) {
});
contentPanel.add(btnDeconvolveViaCommand);
}
- {
- final JPanel buttonPane = new JPanel();
- buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
- getContentPane().add(buttonPane, BorderLayout.SOUTH);
- {
- final JButton okButton = new JButton("OK");
- okButton.setActionCommand("OK");
- buttonPane.add(okButton);
- getRootPane().setDefaultButton(okButton);
- }
- {
- final JButton cancelButton = new JButton("Cancel");
- cancelButton.setActionCommand("Cancel");
- buttonPane.add(cancelButton);
- }
- }
}
/**
* Perform deconvolution
*/
- public > void deconvolve() {
+ public void deconvolve() {
final ImagePlus imp = IJ.getImage();
final Img img = ImageJFunctions.wrap(imp);
@@ -133,8 +112,8 @@ public > void deconvolve() {
}
log.info("starting deconvolution with thread service");
- final RandomAccessibleInterval deconvolved = ops.deconvolve()
- .richardsonLucy(imgFloat, psf, 50);
+ final Img deconvolved = ops.create().img(imgFloat);
+ ops.deconvolve().richardsonLucy(deconvolved, imgFloat, psf, 50);
log.info("finished deconvolution");
ui.show(deconvolved);
@@ -144,61 +123,10 @@ public > void deconvolve() {
* perform deconvolution by calling a command
*/
public void deconvolveViaCommand() {
-
final ImagePlus imp = IJ.getImage();
final Img img = ImageJFunctions.wrap(imp);
cmd.run(DeconvolutionCommand.class, true, "img", img, "sxy", 3, "sz", 7,
"numIterations", 50);
-
}
-
- public OpService getOps() {
- return ops;
- }
-
- public void setOps(final OpService ops) {
- this.ops = ops;
- }
-
- public LogService getLog() {
- return log;
- }
-
- public void setLog(final LogService log) {
- this.log = log;
- }
-
- public StatusService getStatus() {
- return status;
- }
-
- public void setStatus(final StatusService status) {
- this.status = status;
- }
-
- public CommandService getCommand() {
- return cmd;
- }
-
- public void setCommand(final CommandService command) {
- this.cmd = command;
- }
-
- public ThreadService getThread() {
- return thread;
- }
-
- public void setThread(final ThreadService thread) {
- this.thread = thread;
- }
-
- public UIService getUi() {
- return ui;
- }
-
- public void setUi(final UIService ui) {
- this.ui = ui;
- }
-
}
diff --git a/maven-projects/swing-example/src/main/java/SwingExample.java b/maven-projects/swing-example/src/main/java/SwingExample.java
index 355cd08a..b672c097 100644
--- a/maven-projects/swing-example/src/main/java/SwingExample.java
+++ b/maven-projects/swing-example/src/main/java/SwingExample.java
@@ -6,6 +6,8 @@
* https://unlicense.org/
*/
+import javax.swing.WindowConstants;
+
import net.imagej.ImageJ;
public class SwingExample {
@@ -13,6 +15,15 @@ public class SwingExample {
public static void main(final String[] args) {
final ImageJ ij = new ImageJ();
ij.launch(args);
+
+ try {
+ final DeconvolutionDialog dialog = new DeconvolutionDialog(ij.context());
+ dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+ dialog.setVisible(true);
+ }
+ catch (final Exception e) {
+ e.printStackTrace();
+ }
}
}
diff --git a/maven-projects/working-with-modules/pom.xml b/maven-projects/working-with-modules/pom.xml
index 711a5e82..760215c6 100644
--- a/maven-projects/working-with-modules/pom.xml
+++ b/maven-projects/working-with-modules/pom.xml
@@ -8,7 +8,7 @@
org.scijava
pom-scijava
- 26.0.0
+ 29.2.1
diff --git a/maven-projects/working-with-modules/src/main/java/WorkingWithModules.java b/maven-projects/working-with-modules/src/main/java/WorkingWithModules.java
index 92eca2ea..7ddf3f69 100644
--- a/maven-projects/working-with-modules/src/main/java/WorkingWithModules.java
+++ b/maven-projects/working-with-modules/src/main/java/WorkingWithModules.java
@@ -95,7 +95,8 @@ public static void main(final String... args) {
// It may sometimes be the case that even with preprocessing, your module
// still requires additional input values. In such situations, you can pass
// the map of such input values explicitly as follows:
- final Map myInputs = new HashMap();
+ final Map myInputs = new HashMap<>();
+ /*
myInputs.put("requiredStringInput", "requiredStringValue");
myInputs.put("requiredDoubleInput", 5.6);
// etc.
@@ -105,6 +106,7 @@ public static void main(final String... args) {
ij.module().run(myInfo, true,
"requiredStringInput", "requiredStringValue",
"requiredDoubleInput", 5.6);
+ */
// If you desire more control over pre- and postprocessing, you can instead
// invoke the module with the process flag set to false.
@@ -117,7 +119,7 @@ public static void main(final String... args) {
// pre- and postprocessing, you can also pass an explicit list of module
// pre- and postprocessors.
- final List pre = new ArrayList();
+ final List pre = new ArrayList<>();
// The validity preprocessor ensures the module does not break the rules.
final ValidityPreprocessor validPre = new ValidityPreprocessor();
diff --git a/migration-notes/imagej_tutorial_howto_migration.md b/migration-notes/imagej_tutorial_howto_migration.md
index 124e3f8c..406b160c 100644
--- a/migration-notes/imagej_tutorial_howto_migration.md
+++ b/migration-notes/imagej_tutorial_howto_migration.md
@@ -25,13 +25,13 @@ ImageJ maven-projects > howto migration notes
| `DynamicCallbacks.java` | dynamic-commands | --- | **Y** | Opens UI. Selecting options either returns input letter (a, b or c) or returns only the first item in the `kindOfThing` list. | --- | **N** | Calls AWT UI. |
| `DynamicInitialization.java` | dynamic-commands | commands > dynamic | **Y** | --- | --- | **Y** | Calls AWT UI. |
| `DynamicNumberOfParameters.java` | dynamic-commands | commands > dynamic | **Y** | --- | --- | **Y** | Calls AWT UI. |
-| `ExecuteCommands.java` | execute-commands | --- | **N** | Broken import of `org.scijava.plugins.commands.io.OpenFile` | --- | **N** | --- |
+| `ExecuteCommands.java` | execute-commands | --- | **Y** | --- | --- | **N** | --- |
| `DatasetWrapping.java` | ij2-image-plus | --- | **Y** | Doesn't seem to do anything, opens blank image. | --- | **N** | Calls AWT UI. |
| `IntroToImageJAPI.java` | intro-to-imagej-api | adv | **Y** | --- | --- | **Y** | No UI. Opens imagej.net webpage and terminal output. |
| `ListenToEvents.java` | listen-to-events | --- | **Y** | AWT image window does not output events to the terminal, swing image window does. | Possible action: Request swing UI by calling `ij.ui().showUI("swing")`. | **N** | Calls AWT UI (image window only). |
| `LoadAndDisplayDataset.java` | load-and-display-dataset | datasets | **Y** | Input image drawn incorrectly (legacy bug). | --- | **Y** | Calls AWT UI (image window only). |
| `LowPassFilter.java` | low-pass-filter | images > filtering | **Y** | Input image drawn incorrectly (legacy bug). | --- | **Y** |Calls AWT UI. |
-| `GetMetadata.java` | metadata | metadata | **Y** | Input image drawn incorrectly (legacy bug) | --- | **Y** | Calls AWT UI. |
+| `GetMetadata.java` | metadata | metadata | **Y** | --- | --- | **Y** | --- |
| `CopyLabels.java` | mixed-world-command | commands > simple | **Y** | --- | --- | **Y** | Calls AWT UI. |.
| `GradientImage.java` | simple-commands | commands > simple | **Y** | --- | --- | **Y** | Calls AWT UI. |
| `HelloWorld.java` | simple-commands | commands > simple | **Y** | --- | --- | **Y** | Calls AWT UI. |
diff --git a/pom.xml b/pom.xml
index 3b6154de..afb30f07 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
org.scijava
pom-scijava
- 26.0.0
+ 29.2.1