diff --git a/.gitignore b/.gitignore index 6bf55a6e726d00e9470abd5220a69e2226dcafab..d4c3a6c5e5d37c1d2e1b9bcdddf30fb1530593bd 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ bin/ *.jar .classpath .project -export.jardesc \ No newline at end of file +export.jardesc +**/.DS_Store \ No newline at end of file diff --git a/pom.xml b/pom.xml index c5c56e217d6de7d54744491fbcb45bdc0e01843b..1ac5ed60cf6b5586bb20c3aac3bb9a853c90be83 100644 --- a/pom.xml +++ b/pom.xml @@ -1,42 +1,32 @@ <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.bioimageanalysis.icy</groupId> - <artifactId>pom-icy</artifactId> - <version>2.0.0</version> - </parent> + <artifactId>pom-icy</artifactId> + <version>2.2.0</version> + </parent> <artifactId>micromanager-block</artifactId> - <version>1.0.4</version> - - <packaging>jar</packaging> + <version>2.0.0</version> <name>Micro-Manager Block</name> <description> Blocks (protocols) for Micro-Manager (Icy plugin). </description> - - <profiles> - <profile> - <id>icy-plugin</id> - <activation> - <activeByDefault>true</activeByDefault> - </activation> - </profile> - </profiles> <dependencies> <dependency> <groupId>org.bioimageanalysis.icy</groupId> <artifactId>micromanager</artifactId> </dependency> + <dependency> <groupId>org.bioimageanalysis.icy</groupId> - <artifactId>blocks</artifactId> + <artifactId>protocols</artifactId> </dependency> </dependencies> diff --git a/src/main/java/plugins/stef/micromanager/block/AbstractMicroscopeBlock.java b/src/main/java/plugins/stef/micromanager/block/AbstractMicroscopeBlock.java index 4ae8f4bed2e0c6c146149ea9a20ad752a5cffbf3..24ba799a9cf2cb5d7ec6726050b7dc47288f1492 100644 --- a/src/main/java/plugins/stef/micromanager/block/AbstractMicroscopeBlock.java +++ b/src/main/java/plugins/stef/micromanager/block/AbstractMicroscopeBlock.java @@ -1,6 +1,21 @@ -/** - * +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. */ + package plugins.stef.micromanager.block; import icy.gui.dialog.MessageDialog; @@ -8,9 +23,7 @@ import icy.plugin.abstract_.Plugin; import icy.plugin.interface_.PluginBundled; import icy.plugin.interface_.PluginLibrary; import mmcorej.CMMCore; - import org.micromanager.utils.ReportingUtils; - import plugins.adufour.blocks.lang.Block; import plugins.tprovoost.Microscopy.MicroManager.MicroManager; import plugins.tprovoost.Microscopy.MicroManagerForIcy.MicromanagerPlugin; @@ -18,10 +31,8 @@ import plugins.tprovoost.Microscopy.MicroManagerForIcy.MicromanagerPlugin; /** * @author Stephane */ -public abstract class AbstractMicroscopeBlock extends Plugin implements Block, PluginLibrary, PluginBundled -{ - public AbstractMicroscopeBlock() - { +public abstract class AbstractMicroscopeBlock extends Plugin implements Block, PluginLibrary, PluginBundled { + public AbstractMicroscopeBlock() { super(); MicromanagerPlugin.init(); @@ -31,19 +42,15 @@ public abstract class AbstractMicroscopeBlock extends Plugin implements Block, P } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return MicroscopyBlocks.class.getName(); } - public static CMMCore getMMCore(boolean throwException) - { - try - { + public static CMMCore getMMCore(final boolean throwException) { + try { return MicroManager.getCore(); } - catch (Throwable e) - { + catch (final Throwable e) { ReportingUtils.logError(e); if (throwException) throw new RuntimeException("Cannot retrieve Micro-Manager core !", e); diff --git a/src/main/java/plugins/stef/micromanager/block/MicroscopyBlocks.java b/src/main/java/plugins/stef/micromanager/block/MicroscopyBlocks.java index 72b350059b2d8eca903f2d7eac8602bf073849fc..a61fa1725b396379c44e8068577e721b0cecad97 100644 --- a/src/main/java/plugins/stef/micromanager/block/MicroscopyBlocks.java +++ b/src/main/java/plugins/stef/micromanager/block/MicroscopyBlocks.java @@ -1,12 +1,28 @@ +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. + */ + package plugins.stef.micromanager.block; import icy.plugin.abstract_.Plugin; import icy.plugin.interface_.PluginLibrary; -public class MicroscopyBlocks extends Plugin implements PluginLibrary -{ - public MicroscopyBlocks() - { +public class MicroscopyBlocks extends Plugin implements PluginLibrary { + public MicroscopyBlocks() { super(); } } diff --git a/src/main/java/plugins/stef/micromanager/block/capture/MicroscopeGetMetadata.java b/src/main/java/plugins/stef/micromanager/block/capture/MicroscopeGetMetadata.java index 3f98172515c6d4825643d87172f5aae4504c9518..bd0f6c2ed13695dbb5f4b7519de54b9f3b174a49 100644 --- a/src/main/java/plugins/stef/micromanager/block/capture/MicroscopeGetMetadata.java +++ b/src/main/java/plugins/stef/micromanager/block/capture/MicroscopeGetMetadata.java @@ -1,10 +1,24 @@ -/** - * +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. */ + package plugins.stef.micromanager.block.capture; import org.json.JSONObject; - import plugins.adufour.blocks.util.VarList; import plugins.adufour.vars.lang.Var; import plugins.adufour.vars.lang.VarInteger; @@ -13,38 +27,33 @@ import plugins.tprovoost.Microscopy.MicroManager.MicroManager; /** * Retrieve global acquisition metadata and last acquired image metadata (Micro-Manager) - * + * * @author Stephane */ -public class MicroscopeGetMetadata extends AbstractMicroscopeBlock -{ +public class MicroscopeGetMetadata extends AbstractMicroscopeBlock { VarInteger channel = new VarInteger("Channel", 0); - Var<JSONObject> metadata = new Var<JSONObject>("Image metadata", JSONObject.class); - Var<JSONObject> acqMetadata = new Var<JSONObject>("Acquisition metadata", JSONObject.class); + Var<JSONObject> metadata = new Var<>("Image metadata", JSONObject.class); + Var<JSONObject> acqMetadata = new Var<>("Acquisition metadata", JSONObject.class); @Override - public void run() - { - metadata.setValue(MicroManager.getMetadata(channel.getValue().intValue())); + public void run() { + metadata.setValue(MicroManager.getMetadata(channel.getValue())); acqMetadata.setValue(MicroManager.getAcquisitionMetaData()); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("channel", channel); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("imageMetadata", metadata); outputMap.add("acqMetadata", acqMetadata); } @Override - public String getName() - { + public String getName() { return "Get Micro-Manager Metadata"; } } diff --git a/src/main/java/plugins/stef/micromanager/block/capture/MicroscopeSetTaggedImage.java b/src/main/java/plugins/stef/micromanager/block/capture/MicroscopeSetTaggedImage.java index a118be785210d6b2af4da307058cd137cf0178e7..a6b988253dd3d21afa8df4d37ee23f9111a9bb16 100644 --- a/src/main/java/plugins/stef/micromanager/block/capture/MicroscopeSetTaggedImage.java +++ b/src/main/java/plugins/stef/micromanager/block/capture/MicroscopeSetTaggedImage.java @@ -1,6 +1,21 @@ -/** - * +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. */ + package plugins.stef.micromanager.block.capture; import mmcorej.TaggedImage; @@ -14,13 +29,11 @@ import plugins.tprovoost.Microscopy.MicroManager.tools.MMUtils; /** * Set a TaggedImage into a Sequence (Micro-Manager) - * + * * @author Stephane Dallongeville */ -public class MicroscopeSetTaggedImage extends AbstractMicroscopeBlock -{ - VarArray<TaggedImage> taggedImages = new VarArray<TaggedImage>("Tagged image(s)", TaggedImage[].class, - new TaggedImage[0]); +public class MicroscopeSetTaggedImage extends AbstractMicroscopeBlock { + VarArray<TaggedImage> taggedImages = new VarArray<>("Tagged image(s)", TaggedImage[].class, new TaggedImage[0]); VarSequence seq = new VarSequence("Sequence", null); VarInteger posT = new VarInteger("T", -1); VarInteger posZ = new VarInteger("Z", -1); @@ -30,28 +43,30 @@ public class MicroscopeSetTaggedImage extends AbstractMicroscopeBlock VarInteger sizeC = new VarInteger("Size C", -1); @Override - public void run() - { - try - { - for (TaggedImage image : taggedImages.getValue()) - { + public void run() { + try { + for (final TaggedImage image : taggedImages.getValue()) { // set image position metadata - MMUtils.setImageMetadata(image, posT.getValue().intValue(), posZ.getValue().intValue(), posC - .getValue().intValue(), sizeT.getValue().intValue(), sizeZ.getValue().intValue(), sizeC.getValue().intValue()); + MMUtils.setImageMetadata( + image, + posT.getValue(), + posZ.getValue(), + posC.getValue(), + sizeT.getValue(), + sizeZ.getValue(), + sizeC.getValue() + ); // store image in sequence MMUtils.setImage(seq.getValue(), image); } } - catch (Throwable t) - { + catch (final Throwable t) { throw new VarException(taggedImages, t.getMessage()); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("taggedImage", taggedImages); inputMap.add("seq", seq); inputMap.add("t", posT); @@ -63,15 +78,12 @@ public class MicroscopeSetTaggedImage extends AbstractMicroscopeBlock } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // - } @Override - public String getName() - { + public String getName() { return "Set Tagged Image(s)"; } } diff --git a/src/main/java/plugins/stef/micromanager/block/capture/MicroscopeSnapChannels.java b/src/main/java/plugins/stef/micromanager/block/capture/MicroscopeSnapChannels.java index e0f6b298f8cc853cb5a490b9c9d13668cb6aeedd..05c7845fb8001282c1013b2356e56bed0f519ba4 100644 --- a/src/main/java/plugins/stef/micromanager/block/capture/MicroscopeSnapChannels.java +++ b/src/main/java/plugins/stef/micromanager/block/capture/MicroscopeSnapChannels.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. + */ + package plugins.stef.micromanager.block.capture; import java.util.ArrayList; @@ -25,55 +43,48 @@ import plugins.tprovoost.Microscopy.MicroManager.tools.StageMover; * * @author Stephane */ -public class MicroscopeSnapChannels extends AbstractMicroscopeBlock -{ +public class MicroscopeSnapChannels extends AbstractMicroscopeBlock { VarObject trigger; VarMMGroup group; VarChannels channels; VarArray<TaggedImage> out; - public MicroscopeSnapChannels() - { + public MicroscopeSnapChannels() { super(); trigger = new VarObject("Trigger", null); group = new VarMMGroup(); channels = new VarChannels(group); - out = new VarArray<TaggedImage>("Tagged image(s)", TaggedImage[].class, new TaggedImage[0]); + out = new VarArray<>("Tagged image(s)", TaggedImage[].class, new TaggedImage[0]); } @Override - public void run() - { + public void run() { // default out.setValue(new TaggedImage[0]); final ChannelSpec[] specs = channels.getValue(); // no channel to process - if (specs.length <= 0) + if (specs.length == 0) return; - try - { + try { MicroManager.setChannelGroup(group.getValue()); } - catch (Exception e) - { + catch (final Exception e) { throw new VarException(group, "Group value is not valid."); } - final List<TaggedImage> result = new ArrayList<TaggedImage>(); + final List<TaggedImage> result = new ArrayList<>(); - for (int ch = 0; ch < specs.length; ch++) - { + for (int ch = 0; ch < specs.length; ch++) { final ChannelSpec cs = specs[ch]; // channel not used --> skip if (!cs.useChannel) continue; - try - { + try { final String configName = cs.config; // set config @@ -82,7 +93,7 @@ public class MicroscopeSnapChannels extends AbstractMicroscopeBlock // set exposure MicroManager.setExposure(cs.exposure); // doing Z-Stack ? --> apply Z-offset - if (cs.doZStack.booleanValue() && (cs.zOffset != 0d)) + if (cs.doZStack && (cs.zOffset != 0d)) StageMover.moveZRelative(cs.zOffset, true); // do image acquisition @@ -90,7 +101,7 @@ public class MicroscopeSnapChannels extends AbstractMicroscopeBlock final List<TaggedImage> images = MicroManager.snapTaggedImage(); // restore Z position if needed - if (cs.doZStack.booleanValue() && (cs.zOffset != 0d)) + if (cs.doZStack && (cs.zOffset != 0d)) StageMover.moveZRelative(-cs.zOffset, true); // no image ? --> error @@ -98,8 +109,7 @@ public class MicroscopeSnapChannels extends AbstractMicroscopeBlock throw new Exception("Cannot snap image from Micro-Manager !"); // set metadata - for (TaggedImage image : images) - { + for (final TaggedImage image : images) { final JSONObject tags = image.tags; MDUtils.setNumChannels(tags, specs.length); @@ -110,33 +120,29 @@ public class MicroscopeSnapChannels extends AbstractMicroscopeBlock // add to result result.addAll(images); } - catch (Throwable t) - { + catch (final Throwable t) { throw new VarException(out, t.getMessage()); } } // set result - out.setValue(result.toArray(new TaggedImage[result.size()])); + out.setValue(result.toArray(new TaggedImage[0])); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("trigger", trigger); inputMap.add("group", group); inputMap.add("channels", channels); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("out", out); } @Override - public String getName() - { + public String getName() { return "Snap Channel(s)"; } } diff --git a/src/main/java/plugins/stef/micromanager/block/capture/MicroscopeSnapImage.java b/src/main/java/plugins/stef/micromanager/block/capture/MicroscopeSnapImage.java index baf19d0cda1bc450ab623a170332e930b06b72ff..7105ac8bd0e039ebe3a7c810ce706b932c2778c3 100644 --- a/src/main/java/plugins/stef/micromanager/block/capture/MicroscopeSnapImage.java +++ b/src/main/java/plugins/stef/micromanager/block/capture/MicroscopeSnapImage.java @@ -1,6 +1,22 @@ -package plugins.stef.micromanager.block.capture; +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. + */ -import java.util.List; +package plugins.stef.micromanager.block.capture; import mmcorej.TaggedImage; import plugins.adufour.blocks.util.VarList; @@ -10,48 +26,43 @@ import plugins.adufour.vars.util.VarException; import plugins.stef.micromanager.block.AbstractMicroscopeBlock; import plugins.tprovoost.Microscopy.MicroManager.MicroManager; +import java.util.List; + /** * Snap single channel image (Micro-Manager) - * + * * @author Stephane Dallongeville */ -public class MicroscopeSnapImage extends AbstractMicroscopeBlock -{ - VarArray<TaggedImage> out = new VarArray<TaggedImage>("Tagged image(s)", TaggedImage[].class, new TaggedImage[0]); +public class MicroscopeSnapImage extends AbstractMicroscopeBlock { + VarArray<TaggedImage> out = new VarArray<>("Tagged image(s)", TaggedImage[].class, new TaggedImage[0]); VarObject trigger = new VarObject("Trigger", null); @Override - public void run() - { - try - { + public void run() { + try { final List<TaggedImage> images = MicroManager.snapTaggedImage(); if (images.isEmpty()) throw new Exception("Cannot snap image from Micro-Manager !"); - out.setValue(images.toArray(new TaggedImage[images.size()])); + out.setValue(images.toArray(new TaggedImage[0])); } - catch (Throwable t) - { + catch (final Throwable t) { throw new VarException(out, t.getMessage()); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("trigger", trigger); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("out", out); } @Override - public String getName() - { + public String getName() { return "Snap Image"; } } diff --git a/src/main/java/plugins/stef/micromanager/block/lang/VarChannels.java b/src/main/java/plugins/stef/micromanager/block/lang/VarChannels.java index ee0aca09eb0ce813604d3ea008cba4597982b0c0..005b165619417e9164e1c0ece5f42c99c78c3977 100644 --- a/src/main/java/plugins/stef/micromanager/block/lang/VarChannels.java +++ b/src/main/java/plugins/stef/micromanager/block/lang/VarChannels.java @@ -1,8 +1,25 @@ -package plugins.stef.micromanager.block.lang; +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. + */ -import org.micromanager.utils.ChannelSpec; +package plugins.stef.micromanager.block.lang; import icy.type.collection.CollectionUtil; +import org.micromanager.utils.ChannelSpec; import plugins.adufour.vars.gui.VarEditor; import plugins.adufour.vars.lang.Var; import plugins.adufour.vars.lang.VarArray; @@ -11,12 +28,10 @@ import plugins.adufour.vars.util.VarListener; /** * Class in standby until an EzPlug fix */ -public class VarChannels extends VarArray<ChannelSpec> -{ +public class VarChannels extends VarArray<ChannelSpec> { VarChannelsEditor editor; - public VarChannels(String name, VarMMGroup groupVar) - { + public VarChannels(final String name, final VarMMGroup groupVar) { super(name, ChannelSpec[].class, null); // can be initialized by super constructor @@ -25,31 +40,25 @@ public class VarChannels extends VarArray<ChannelSpec> setGroup(groupVar.getValue()); - groupVar.addListener(new VarListener<String>() - { + groupVar.addListener(new VarListener<>() { @Override - public void valueChanged(Var<String> source, String oldValue, String newValue) - { + public void valueChanged(final Var<String> source, final String oldValue, final String newValue) { setGroup(newValue); } @Override - public void referenceChanged(Var<String> source, Var<? extends String> oldReference, - Var<? extends String> newReference) - { + public void referenceChanged(final Var<String> source, final Var<? extends String> oldReference, final Var<? extends String> newReference) { // } }); } - public VarChannels(VarMMGroup groupVar) - { + public VarChannels(final VarMMGroup groupVar) { this("Channels", groupVar); } @Override - public VarEditor<ChannelSpec[]> createVarEditor() - { + public VarEditor<ChannelSpec[]> createVarEditor() { if (editor == null) editor = new VarChannelsEditor(this); @@ -57,59 +66,16 @@ public class VarChannels extends VarArray<ChannelSpec> } @Override - public ChannelSpec[] getValue() - { + public ChannelSpec[] getValue() { return editor.table.getChannels().toArray(new ChannelSpec[0]); } @Override - public void setValue(ChannelSpec[] value) - { + public void setValue(final ChannelSpec[] value) { editor.table.setChannels(CollectionUtil.asArrayList(value)); } - public void setGroup(String groupName) - { + public void setGroup(final String groupName) { editor.setGroup(groupName); } - - // public static List<ChannelSpec> generateChannels(String groupName) - // { - // final List<ChannelSpec> toReturn = new ArrayList<ChannelSpec>(); - // if (groupName == null) - // return toReturn; - // - // final List<String> presets = MicroManager.getConfigs(groupName); - // - // if (presets != null) - // { - // try - // { - // final String cam = MicroManager.getCamera(); - // - // for (String s : presets) - // { - // ChannelSpec cs = new ChannelSpec(); - // - // cs.config = s; - // cs.camera = cam; - // cs.color = Color.WHITE; - // cs.doZStack = true; - // cs.skipFactorFrame = 0; - // cs.zOffset = 0D; - // cs.exposure = 10; - // cs.useChannel = true; - // - // toReturn.add(cs); - // } - // } - // catch (Throwable t) - // { - // ReportingUtils.logError(t); - // } - // } - // - // return toReturn; - // } - } diff --git a/src/main/java/plugins/stef/micromanager/block/lang/VarChannelsEditor.java b/src/main/java/plugins/stef/micromanager/block/lang/VarChannelsEditor.java index 7137301767e26dbde87efa55fc06c95f4508abc5..67d70d78501e4ea21cf160b4fac482848c739278 100644 --- a/src/main/java/plugins/stef/micromanager/block/lang/VarChannelsEditor.java +++ b/src/main/java/plugins/stef/micromanager/block/lang/VarChannelsEditor.java @@ -1,34 +1,41 @@ -package plugins.stef.micromanager.block.lang; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. + */ -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.ScrollPaneConstants; +package plugins.stef.micromanager.block.lang; import org.micromanager.dialogs.ChannelTableModel; import org.micromanager.utils.ChannelSpec; import org.micromanager.utils.TooltipTextMaker; - import plugins.adufour.vars.gui.VarEditor; import plugins.adufour.vars.lang.Var; import plugins.tprovoost.Microscopy.MicroManager.gui.ChannelTable; +import javax.swing.*; +import java.awt.*; + /** * Class in standby until an EzPlug fix */ -public class VarChannelsEditor extends VarEditor<ChannelSpec[]> -{ +public class VarChannelsEditor extends VarEditor<ChannelSpec[]> { protected JPanel mainPanel; protected ChannelTable table; - public VarChannelsEditor(Var<ChannelSpec[]> variable) - { + public VarChannelsEditor(final Var<ChannelSpec[]> variable) { super(variable); // can be done by super constructor @@ -39,8 +46,7 @@ public class VarChannelsEditor extends VarEditor<ChannelSpec[]> } @Override - protected JPanel createEditorComponent() - { + protected JPanel createEditorComponent() { // initialize if needed if (mainPanel == null) initialize(); @@ -48,91 +54,65 @@ public class VarChannelsEditor extends VarEditor<ChannelSpec[]> return mainPanel; } - private void initialize() - { + private void initialize() { table = new ChannelTable(); - JScrollPane scroll = new JScrollPane(table); + final JScrollPane scroll = new JScrollPane(table); scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); // better to give it a very small size scroll.setMinimumSize(new Dimension(240, 60)); scroll.setPreferredSize(new Dimension(240, 100)); - JButton btnAddChannel = new JButton("Add Channel"); + final JButton btnAddChannel = new JButton("Add Channel"); btnAddChannel.setToolTipText("Create new channel for currently selected channel group"); - btnAddChannel.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - final ChannelTableModel model = (ChannelTableModel) table.getModel(); - model.addNewChannel(); - model.fireTableDataChanged(); - } + btnAddChannel.addActionListener(e -> { + final ChannelTableModel model = (ChannelTableModel) table.getModel(); + model.addNewChannel(); + model.fireTableDataChanged(); }); - JButton btnRemoveChannel = new JButton("Remove Channel"); + final JButton btnRemoveChannel = new JButton("Remove Channel"); btnRemoveChannel.setToolTipText("Remove currently selected channel"); - btnRemoveChannel.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - int sel = table.getSelectedRow(); - - if (sel > -1) - { - final ChannelTableModel model = (ChannelTableModel) table.getModel(); - model.removeChannel(sel); - model.fireTableDataChanged(); - if (table.getRowCount() > sel) - table.setRowSelectionInterval(sel, sel); - } + btnRemoveChannel.addActionListener(e -> { + final int sel = table.getSelectedRow(); + + if (sel > -1) { + final ChannelTableModel model = (ChannelTableModel) table.getModel(); + model.removeChannel(sel); + model.fireTableDataChanged(); + if (table.getRowCount() > sel) + table.setRowSelectionInterval(sel, sel); } }); final JButton upButton = new JButton("Up"); upButton.setToolTipText(TooltipTextMaker .addHTMLBreaksForTooltip("Move currently selected channel up (Channels higher on list are acquired first)")); - upButton.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - int sel = table.getSelectedRow(); - - if (sel > -1) - { - final ChannelTableModel model = (ChannelTableModel) table.getModel(); - int newSel = model.rowUp(sel); - model.fireTableDataChanged(); - table.setRowSelectionInterval(newSel, newSel); - } + upButton.addActionListener(e -> { + final int sel = table.getSelectedRow(); + + if (sel > -1) { + final ChannelTableModel model = (ChannelTableModel) table.getModel(); + final int newSel = model.rowUp(sel); + model.fireTableDataChanged(); + table.setRowSelectionInterval(newSel, newSel); } }); final JButton downButton = new JButton("Down"); - downButton - .setToolTipText(TooltipTextMaker - .addHTMLBreaksForTooltip("Move currently selected channel down (Channels lower on list are acquired later)")); - downButton.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - int sel = table.getSelectedRow(); - - if (sel > -1) - { - final ChannelTableModel model = (ChannelTableModel) table.getModel(); - int newSel = model.rowDown(sel); - model.fireTableDataChanged(); - table.setRowSelectionInterval(newSel, newSel); - } + downButton.setToolTipText(TooltipTextMaker.addHTMLBreaksForTooltip("Move currently selected channel down (Channels lower on list are acquired later)")); + downButton.addActionListener(e -> { + final int sel = table.getSelectedRow(); + + if (sel > -1) { + final ChannelTableModel model = (ChannelTableModel) table.getModel(); + final int newSel = model.rowDown(sel); + model.fireTableDataChanged(); + table.setRowSelectionInterval(newSel, newSel); } }); - JPanel panelButtons = new JPanel(); + final JPanel panelButtons = new JPanel(); panelButtons.setLayout(new BoxLayout(panelButtons, BoxLayout.X_AXIS)); panelButtons.add(btnAddChannel); panelButtons.add(btnRemoveChannel); @@ -146,31 +126,26 @@ public class VarChannelsEditor extends VarEditor<ChannelSpec[]> } @Override - protected void activateListeners() - { + protected void activateListeners() { // } @Override - protected void deactivateListeners() - { + protected void deactivateListeners() { // } @Override - protected void updateInterfaceValue() - { + protected void updateInterfaceValue() { // } - public void setGroup(String group) - { + public void setGroup(final String group) { table.setGroup(group); } @Override - public Dimension getPreferredSize() - { + public Dimension getPreferredSize() { if (mainPanel != null) return mainPanel.getPreferredSize(); @@ -178,15 +153,13 @@ public class VarChannelsEditor extends VarEditor<ChannelSpec[]> } @Override - public void setComponentToolTipText(String s) - { + public void setComponentToolTipText(final String s) { if (mainPanel != null) mainPanel.setToolTipText(s); } @Override - protected void setEditorEnabled(boolean enabled) - { + protected void setEditorEnabled(final boolean enabled) { if (mainPanel != null) mainPanel.setEnabled(enabled); } diff --git a/src/main/java/plugins/stef/micromanager/block/lang/VarMMGroup.java b/src/main/java/plugins/stef/micromanager/block/lang/VarMMGroup.java index b94129e403ec351babafdf6b88ac15897831378f..ecf62f70255c452ec7944330378474461af54471 100644 --- a/src/main/java/plugins/stef/micromanager/block/lang/VarMMGroup.java +++ b/src/main/java/plugins/stef/micromanager/block/lang/VarMMGroup.java @@ -1,33 +1,45 @@ -/** - * +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. */ -package plugins.stef.micromanager.block.lang; -import java.util.List; +package plugins.stef.micromanager.block.lang; import plugins.adufour.vars.gui.model.ValueSelectionModel; import plugins.adufour.vars.lang.VarString; import plugins.tprovoost.Microscopy.MicroManager.MicroManager; +import java.util.List; + /** * EzVar representing Micro-Manager config group. - * + * * @author Stephane */ -public class VarMMGroup extends VarString -{ - public VarMMGroup(String name) - { +public class VarMMGroup extends VarString { + public VarMMGroup(final String name) { super(name, ""); - + final List<String> groups = MicroManager.getConfigGroups(); - - if (groups.size() > 0) - setDefaultEditorModel(new ValueSelectionModel<String>(groups.toArray(new String[groups.size()]), groups.get(0), false)); + + if (!groups.isEmpty()) + setDefaultEditorModel(new ValueSelectionModel<>(groups.toArray(new String[0]), groups.get(0), false)); } - public VarMMGroup() - { + public VarMMGroup() { this("Group"); } } diff --git a/src/main/java/plugins/stef/micromanager/block/lang/VarMMPreset.java b/src/main/java/plugins/stef/micromanager/block/lang/VarMMPreset.java index 5fbbee36e0c7e34010039f39fb5311f48ff99a2c..f6952b4d81c101788ddc6e0b0c5fcfc95af30e8a 100644 --- a/src/main/java/plugins/stef/micromanager/block/lang/VarMMPreset.java +++ b/src/main/java/plugins/stef/micromanager/block/lang/VarMMPreset.java @@ -1,9 +1,22 @@ -/** - * +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. */ -package plugins.stef.micromanager.block.lang; -import java.util.List; +package plugins.stef.micromanager.block.lang; import plugins.adufour.vars.gui.model.ValueSelectionModel; import plugins.adufour.vars.lang.Var; @@ -11,51 +24,44 @@ import plugins.adufour.vars.lang.VarString; import plugins.adufour.vars.util.VarListener; import plugins.tprovoost.Microscopy.MicroManager.MicroManager; +import java.util.List; + /** * EzVar representing Micro-Manager config preset. - * + * * @author Stephane */ -public class VarMMPreset extends VarString -{ - public VarMMPreset(String name, VarMMGroup groupVar) - { +public class VarMMPreset extends VarString { + public VarMMPreset(final String name, final VarMMGroup groupVar) { super(name, ""); // set values refreshPresets(groupVar.getValue()); // listen group var change - groupVar.addListener(new VarListener<String>() - { + groupVar.addListener(new VarListener<>() { @Override - public void valueChanged(Var<String> source, String oldValue, String newValue) - { + public void valueChanged(final Var<String> source, final String oldValue, final String newValue) { refreshPresets(newValue); } @Override - public void referenceChanged(Var<String> source, Var<? extends String> oldReference, - Var<? extends String> newReference) - { + public void referenceChanged(final Var<String> source, final Var<? extends String> oldReference, final Var<? extends String> newReference) { // } }); } - public VarMMPreset(VarMMGroup groupVar) - { + public VarMMPreset(final VarMMGroup groupVar) { this("Preset", groupVar); } - public void refreshPresets(String group) - { + public void refreshPresets(final String group) { final List<String> presets = MicroManager.getConfigs(group); - if (presets.size() > 0) - setDefaultEditorModel(new ValueSelectionModel<String>(presets.toArray(new String[presets.size()]), - presets.get(0), false)); - else - setDefaultEditorModel(new ValueSelectionModel<String>(new String[] {""}, "", false)); + if (!presets.isEmpty()) + setDefaultEditorModel(new ValueSelectionModel<>(presets.toArray(new String[0]), presets.get(0), false)); + else + setDefaultEditorModel(new ValueSelectionModel<>(new String[]{""}, "", false)); } } diff --git a/src/main/java/plugins/stef/micromanager/block/lang/VarMultiStagePosition.java b/src/main/java/plugins/stef/micromanager/block/lang/VarMultiStagePosition.java index 92f0982dd25eb315c252e6433bbf11566aeb7055..656ff7d2633993be4d31e19e1c03ee490f7ab2aa 100644 --- a/src/main/java/plugins/stef/micromanager/block/lang/VarMultiStagePosition.java +++ b/src/main/java/plugins/stef/micromanager/block/lang/VarMultiStagePosition.java @@ -1,25 +1,36 @@ -package plugins.stef.micromanager.block.lang; - -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. + */ -import javax.swing.JButton; -import javax.swing.JComponent; +package plugins.stef.micromanager.block.lang; import org.micromanager.api.MultiStagePosition; - import plugins.adufour.vars.gui.VarEditor; import plugins.adufour.vars.lang.Var; import plugins.adufour.vars.lang.VarArray; import plugins.tprovoost.Microscopy.MicroManager.MicroManager; -public class VarMultiStagePosition extends VarArray<MultiStagePosition> -{ +import javax.swing.*; +import java.awt.*; + +public class VarMultiStagePosition extends VarArray<MultiStagePosition> { VarEditorMultiStagePositions pos; - public VarMultiStagePosition(String name, MultiStagePosition[] defaultValue) - { + public VarMultiStagePosition(final String name, final MultiStagePosition[] defaultValue) { super(name, MultiStagePosition[].class, defaultValue); // can be initialized with super constructor @@ -28,57 +39,42 @@ public class VarMultiStagePosition extends VarArray<MultiStagePosition> } @Override - public VarEditor<MultiStagePosition[]> createVarEditor() - { + public VarEditor<MultiStagePosition[]> createVarEditor() { if (pos == null) pos = new VarEditorMultiStagePositions(this); return pos; } - private class VarEditorMultiStagePositions extends VarEditor<MultiStagePosition[]> - { + private static class VarEditorMultiStagePositions extends VarEditor<MultiStagePosition[]> { JButton btnOpen; - public VarEditorMultiStagePositions(Var<MultiStagePosition[]> variable) - { + public VarEditorMultiStagePositions(final Var<MultiStagePosition[]> variable) { super(variable); } @Override - protected JComponent createEditorComponent() - { + protected JComponent createEditorComponent() { btnOpen = new JButton("Open"); - btnOpen.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - MicroManager.getMMStudio().showXYPositionList(); - } - }); + btnOpen.addActionListener(e -> MicroManager.getMMStudio().showXYPositionList()); return btnOpen; } @Override - protected void activateListeners() - { + protected void activateListeners() { } @Override - protected void deactivateListeners() - { + protected void deactivateListeners() { } @Override - protected void updateInterfaceValue() - { + protected void updateInterfaceValue() { } @Override - public Dimension getPreferredSize() - { + public Dimension getPreferredSize() { if (btnOpen != null) return btnOpen.getPreferredSize(); @@ -86,15 +82,13 @@ public class VarMultiStagePosition extends VarArray<MultiStagePosition> } @Override - public void setComponentToolTipText(String s) - { + public void setComponentToolTipText(final String s) { if (btnOpen != null) btnOpen.setToolTipText(s); } @Override - protected void setEditorEnabled(boolean enabled) - { + protected void setEditorEnabled(final boolean enabled) { if (btnOpen != null) btnOpen.setEnabled(enabled); } diff --git a/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeChannels.java b/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeChannels.java index 6f51e6893b6ac5dc32a84884ff0589e27c0ad5b2..ece292cd08fb9aae1af85a574695e2ed7e0b45ca 100644 --- a/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeChannels.java +++ b/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeChannels.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. + */ + package plugins.stef.micromanager.block.setting; import plugins.adufour.blocks.tools.input.InputBlock; @@ -9,29 +27,25 @@ import plugins.stef.micromanager.block.lang.VarMMGroup; /** * Define a list of channel (Micro-Manager) * Class in standby until an EzPlug fix - * + * * @author Stephane Dallongeville */ -public class MicroscopeChannels extends AbstractMicroscopeBlock implements InputBlock -{ +public class MicroscopeChannels extends AbstractMicroscopeBlock implements InputBlock { VarMMGroup group; VarChannels channels; - public MicroscopeChannels() - { + public MicroscopeChannels() { group = new VarMMGroup(); channels = new VarChannels(group); } @Override - public void run() - { + public void run() { // } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { if (group != null) inputMap.add("groups", group); if (channels != null) @@ -39,8 +53,7 @@ public class MicroscopeChannels extends AbstractMicroscopeBlock implements Input } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } } diff --git a/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeGetBinning.java b/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeGetBinning.java index fd9384fe16b11a41ec56528d495a45e882181390..59c90868601b970be45ec0107f3d806e74f301ab 100644 --- a/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeGetBinning.java +++ b/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeGetBinning.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. + */ + package plugins.stef.micromanager.block.setting; import plugins.adufour.blocks.util.VarList; @@ -9,35 +27,29 @@ import plugins.tprovoost.Microscopy.MicroManager.MicroManager; /** * Return camera binning value (Micro-Manager) - * + * * @author Stephane Dallongeville */ -public class MicroscopeGetBinning extends AbstractMicroscopeBlock -{ +public class MicroscopeGetBinning extends AbstractMicroscopeBlock { VarObject trigger = new VarObject("Trigger", null); VarInteger binning = new VarInteger("Binning", 1); @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("trigger", trigger); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("binning", binning); } @Override - public void run() - { - try - { - binning.setValue(Integer.valueOf(MicroManager.getBinning())); + public void run() { + try { + binning.setValue(MicroManager.getBinning()); } - catch (Throwable t) - { + catch (final Throwable t) { throw new VarException(binning, t.getMessage()); } } diff --git a/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeGetExposure.java b/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeGetExposure.java index 3701e04014a5e78b000e39bd69c737ec92e00eec..52157d65b52469910a3b1539e755d294c35e6ada 100644 --- a/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeGetExposure.java +++ b/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeGetExposure.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. + */ + package plugins.stef.micromanager.block.setting; import plugins.adufour.blocks.util.VarList; @@ -9,35 +27,29 @@ import plugins.tprovoost.Microscopy.MicroManager.MicroManager; /** * Return camera exposure value in ms (Micro-Manager) - * + * * @author Stephane Dallongeville */ -public class MicroscopeGetExposure extends AbstractMicroscopeBlock -{ +public class MicroscopeGetExposure extends AbstractMicroscopeBlock { VarObject trigger = new VarObject("Trigger", null); VarDouble exposure = new VarDouble("Exposure (ms)", 50d); @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("trigger", trigger); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("exposure", exposure); } @Override - public void run() - { - try - { - exposure.setValue(Double.valueOf(MicroManager.getExposure())); + public void run() { + try { + exposure.setValue(MicroManager.getExposure()); } - catch (Throwable t) - { + catch (final Throwable t) { throw new VarException(exposure, t.getMessage()); } } diff --git a/src/main/java/plugins/stef/micromanager/block/setting/MicroscopePositions.java b/src/main/java/plugins/stef/micromanager/block/setting/MicroscopePositions.java index dc87ec8f97df95d198fa5d6858f331be39052980..e4814215097777108cabea81c5b64b4c7366875c 100644 --- a/src/main/java/plugins/stef/micromanager/block/setting/MicroscopePositions.java +++ b/src/main/java/plugins/stef/micromanager/block/setting/MicroscopePositions.java @@ -1,9 +1,26 @@ +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. + */ + package plugins.stef.micromanager.block.setting; import org.micromanager.MMStudio; import org.micromanager.api.MultiStagePosition; import org.micromanager.api.PositionList; - import plugins.adufour.blocks.tools.input.InputBlock; import plugins.adufour.blocks.util.VarList; import plugins.adufour.vars.lang.VarArray; @@ -14,42 +31,35 @@ import plugins.tprovoost.Microscopy.MicroManager.MicroManager; /** * Define a list of stage positions (Micro-Manager) - * + * * @author Stephane Dallongeville */ -public class MicroscopePositions extends AbstractMicroscopeBlock implements InputBlock -{ +public class MicroscopePositions extends AbstractMicroscopeBlock implements InputBlock { VarArray<MultiStagePosition> varPositions; - public MicroscopePositions() - { + public MicroscopePositions() { super(); varPositions = new VarMultiStagePosition("Positions", null); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("positions", varPositions); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public void run() - { + public void run() { final MMStudio mstudio = MicroManager.getMMStudio(); if (mstudio == null) - throw new VarException(null, - "Cannot retrieve Micro-Manager core...\nBe sure you started Micro-Manager plugin before using Micro-Manager blocks !"); + throw new VarException(null, "Cannot retrieve Micro-Manager core...\nBe sure you started Micro-Manager plugin before using Micro-Manager blocks !"); - try - { + try { final PositionList list = mstudio.getPositionList(); if (list.getPositions() == null) @@ -57,8 +67,7 @@ public class MicroscopePositions extends AbstractMicroscopeBlock implements Inpu varPositions.setValue(list.getPositions()); } - catch (Exception e) - { + catch (final Exception e) { throw new VarException(varPositions, e.getMessage()); } } diff --git a/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeSetBinning.java b/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeSetBinning.java index f7929ee4e5cac81cf25df061413d39f0f9cd3180..19ce2c474ced75fc9915381e183517302a8cdc70 100644 --- a/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeSetBinning.java +++ b/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeSetBinning.java @@ -1,6 +1,21 @@ -/** - * +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. */ + package plugins.stef.micromanager.block.setting; import plugins.adufour.blocks.util.VarList; @@ -13,40 +28,34 @@ import plugins.tprovoost.Microscopy.MicroManager.MicroManager; /** * Set the camera binning value (Micro-Manager) - * + * * @author Stephane Dallongeville */ -public class MicroscopeSetBinning extends AbstractMicroscopeBlock -{ +public class MicroscopeSetBinning extends AbstractMicroscopeBlock { VarObject trigger = new VarObject("Trigger", null); VarInteger binning = new VarInteger("Binning", 1); VarBoolean done = new VarBoolean("Done", false); @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("trigger", trigger); inputMap.add("binning", binning); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("done", done); } @Override - public void run() - { + public void run() { done.setValue(Boolean.FALSE); - try - { - MicroManager.setBinning(binning.getValue().intValue()); + try { + MicroManager.setBinning(binning.getValue()); done.setValue(Boolean.TRUE); } - catch (Throwable t) - { + catch (final Throwable t) { throw new VarException(binning, t.getMessage()); } } diff --git a/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeSetConfig.java b/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeSetConfig.java index 4ab9a964f23dac0ed9006a08ac5d4e2a4bcd8859..fbb0c2bea2e7843248dd65ce710dc06dc9eb35fe 100644 --- a/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeSetConfig.java +++ b/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeSetConfig.java @@ -1,6 +1,22 @@ -package plugins.stef.micromanager.block.setting; +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. + */ -import java.util.List; +package plugins.stef.micromanager.block.setting; import plugins.adufour.blocks.lang.BlockDescriptor; import plugins.adufour.blocks.lang.WorkFlow; @@ -22,21 +38,21 @@ import plugins.stef.micromanager.block.lang.VarMMGroup; import plugins.stef.micromanager.block.lang.VarMMPreset; import plugins.tprovoost.Microscopy.MicroManager.MicroManager; +import java.util.List; + /** * Set a preset for a specified group (Micro-Manager) - * + * * @author Stephane Dallongeville */ -public class MicroscopeSetConfig extends AbstractMicroscopeBlock -{ +public class MicroscopeSetConfig extends AbstractMicroscopeBlock { VarObject trigger; VarMMGroup group; VarMMPreset preset; VarBoolean wait; VarBoolean done; - public MicroscopeSetConfig() - { + public MicroscopeSetConfig() { super(); trigger = new VarObject("Trigger", null); @@ -46,42 +62,34 @@ public class MicroscopeSetConfig extends AbstractMicroscopeBlock done = new VarBoolean("Done", false); // listen group var to refresh the preset GUI which is disconnected from preset var - group.addListener(new VarListener<String>() - { + group.addListener(new VarListener<>() { @Override - public void valueChanged(Var<String> source, String oldValue, String newValue) - { + public void valueChanged(final Var<String> source, final String oldValue, final String newValue) { refreshPresetsGUI(newValue); } @Override - public void referenceChanged(Var<String> source, Var<? extends String> oldReference, - Var<? extends String> newReference) - { + public void referenceChanged(final Var<String> source, final Var<? extends String> oldReference, final Var<? extends String> newReference) { // } }); } @Override - public void run() - { + public void run() { done.setValue(Boolean.FALSE); - try - { - MicroManager.setConfigForGroup(group.getValue(), preset.getValue(), wait.getValue().booleanValue()); + try { + MicroManager.setConfigForGroup(group.getValue(), preset.getValue(), wait.getValue()); done.setValue(Boolean.TRUE); } - catch (Throwable t) - { + catch (final Throwable t) { throw new VarException(group, t.getMessage()); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("trigger", trigger); inputMap.add("group", group); inputMap.add("preset", preset); @@ -89,42 +97,34 @@ public class MicroscopeSetConfig extends AbstractMicroscopeBlock } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { if (done != null) outputMap.add("done", done); } - @SuppressWarnings("unchecked") - public void refreshPresetsGUI(String group) - { + public void refreshPresetsGUI(final String group) { final MainFrame protocols = Protocols.getInstance(); - if (protocols != null) - { + if (protocols != null) { final ProtocolPanel protocolPanel = protocols.getActiveProtocol(); - if (protocolPanel != null) - { + if (protocolPanel != null) { final WorkFlowContainer wfc = protocolPanel.getWorkFlowContainer(); final WorkFlow wf = protocolPanel.getWorkFlow(); // get our block descriptor final BlockDescriptor bd = wf.getInputOwner(preset); - if (bd != null) - { + if (bd != null) { // get our block panel final BlockPanel bp = wfc.getBlockPanel(bd); - if (bp != null) - { + if (bp != null) { // get GUI component for preset var final VarEditor<?> editor = bp.getVarEditor(preset); // should be a combo box - if (editor instanceof ComboBox<?>) - { - final ComboBox<String> combo = (ComboBox<String>) editor; + if (editor instanceof ComboBox<?>) { + @SuppressWarnings("unchecked") final ComboBox<String> combo = (ComboBox<String>) editor; final List<String> presets = MicroManager.getConfigs(group); - if (presets.size() > 0) - combo.setDefaultValues(presets.toArray(new String[presets.size()]), 0, false); + if (!presets.isEmpty()) + combo.setDefaultValues(presets.toArray(new String[0]), 0, false); } } } diff --git a/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeSetExposure.java b/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeSetExposure.java index 3f177e7b61a01b7ecbe514d5e0672be2796f0be0..803e6e75f4c81d07b566c88757b7cbc27b39a61a 100644 --- a/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeSetExposure.java +++ b/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeSetExposure.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. + */ + package plugins.stef.micromanager.block.setting; import plugins.adufour.blocks.util.VarList; @@ -10,40 +28,34 @@ import plugins.tprovoost.Microscopy.MicroManager.MicroManager; /** * Set the camera exposure value (Micro-Manager) - * + * * @author Stephane Dallongeville */ -public class MicroscopeSetExposure extends AbstractMicroscopeBlock -{ +public class MicroscopeSetExposure extends AbstractMicroscopeBlock { VarObject trigger = new VarObject("Trigger", null); VarDouble exposure = new VarDouble("Exposure", 10d); VarBoolean done = new VarBoolean("Done", false); @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("trigger", trigger); inputMap.add("exposure", exposure); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("done", done); } @Override - public void run() - { + public void run() { done.setValue(Boolean.FALSE); - try - { - MicroManager.setExposure(exposure.getValue().doubleValue()); + try { + MicroManager.setExposure(exposure.getValue()); done.setValue(Boolean.TRUE); } - catch (Throwable t) - { + catch (final Throwable t) { throw new VarException(exposure, t.getMessage()); } } diff --git a/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeSetShutter.java b/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeSetShutter.java index 84e1e7e011aed04a79a7d281d54b4a556332c377..82b13e0a5a8cdc2cd9ffefb6ba1248dca58086f8 100644 --- a/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeSetShutter.java +++ b/src/main/java/plugins/stef/micromanager/block/setting/MicroscopeSetShutter.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. + */ + package plugins.stef.micromanager.block.setting; import plugins.adufour.blocks.util.VarList; @@ -9,41 +27,35 @@ import plugins.tprovoost.Microscopy.MicroManager.MicroManager; /** * Set the shutter position: open / close (Micro-Manager) - * + * * @author Stephane Dallongeville */ -public class MicroscopeSetShutter extends AbstractMicroscopeBlock -{ +public class MicroscopeSetShutter extends AbstractMicroscopeBlock { VarObject trigger = new VarObject("Trigger", null); VarBoolean open = new VarBoolean("Open", true); VarBoolean done = new VarBoolean("Done", false); @Override - public void run() - { + public void run() { done.setValue(Boolean.FALSE); - try - { - MicroManager.setShutterOpen(open.getValue().booleanValue()); + try { + MicroManager.setShutterOpen(open.getValue()); done.setValue(Boolean.TRUE); } - catch (Throwable t) - { + catch (final Throwable t) { throw new VarException(open, t.getMessage()); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("trigger", trigger); inputMap.add("open", open); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("done", done); } } diff --git a/src/main/java/plugins/stef/micromanager/block/stage/MicroscopeGetStageXYZ.java b/src/main/java/plugins/stef/micromanager/block/stage/MicroscopeGetStageXYZ.java index a67874c466651de9e70936cbd0bc8e814980e716..9f91b3403ff42cf824516e62cacf5aeb87403fee 100644 --- a/src/main/java/plugins/stef/micromanager/block/stage/MicroscopeGetStageXYZ.java +++ b/src/main/java/plugins/stef/micromanager/block/stage/MicroscopeGetStageXYZ.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. + */ + package plugins.stef.micromanager.block.stage; import icy.type.point.Point3D; @@ -11,11 +29,10 @@ import plugins.tprovoost.Microscopy.MicroManager.tools.StageMover; /** * Return the stage XYZ position (Micro-Manager) - * + * * @author Stephane Dallongeville */ -public class MicroscopeGetStageXYZ extends AbstractMicroscopeBlock -{ +public class MicroscopeGetStageXYZ extends AbstractMicroscopeBlock { VarObject trigger = new VarObject("Trigger", null); VarBoolean wait = new VarBoolean("Wait stage", true); VarDouble outX = new VarDouble("X", 0d); @@ -23,32 +40,27 @@ public class MicroscopeGetStageXYZ extends AbstractMicroscopeBlock VarDouble outZ = new VarDouble("Z", 0d); @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("trigger", trigger); inputMap.add("wait", wait); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("x", outX); outputMap.add("y", outY); outputMap.add("z", outZ); } @Override - public void run() - { - try - { - Point3D.Double pos = StageMover.getXYZ(); + public void run() { + try { + final Point3D.Double pos = StageMover.getXYZ(); outX.setValue(Double.valueOf(pos.x)); outY.setValue(Double.valueOf(pos.y)); outZ.setValue(Double.valueOf(pos.z)); } - catch (Throwable t) - { + catch (final Throwable t) { throw new VarException(outX, t.getMessage()); } } diff --git a/src/main/java/plugins/stef/micromanager/block/stage/MicroscopeSetStagePosition.java b/src/main/java/plugins/stef/micromanager/block/stage/MicroscopeSetStagePosition.java index 4e85038c75734b04a938d823722941a867c8bef9..8b08e76c81cad640dfa237945fae51808e5925bd 100644 --- a/src/main/java/plugins/stef/micromanager/block/stage/MicroscopeSetStagePosition.java +++ b/src/main/java/plugins/stef/micromanager/block/stage/MicroscopeSetStagePosition.java @@ -1,9 +1,26 @@ -package plugins.stef.micromanager.block.stage; +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. + */ -import org.micromanager.api.MultiStagePosition; +package plugins.stef.micromanager.block.stage; import icy.system.thread.ThreadUtil; import mmcorej.CMMCore; +import org.micromanager.api.MultiStagePosition; import plugins.adufour.blocks.util.VarList; import plugins.adufour.vars.lang.Var; import plugins.adufour.vars.lang.VarBoolean; @@ -15,59 +32,45 @@ import plugins.stef.micromanager.block.setting.MicroscopePositions; * Set the stage to given position (Micro-Manager).<br> * This block should be used in conjunction with {@link MicroscopePositions} block and an indexer * so we can move to each position. - * + * * @author Stephane Dallongeville */ -public class MicroscopeSetStagePosition extends AbstractMicroscopeBlock -{ +public class MicroscopeSetStagePosition extends AbstractMicroscopeBlock { Var<MultiStagePosition> input; VarBoolean waitForStage; VarBoolean done; - public MicroscopeSetStagePosition() - { + public MicroscopeSetStagePosition() { super(); - input = new Var<MultiStagePosition>("Position", MultiStagePosition.class); + input = new Var<>("Position", MultiStagePosition.class); waitForStage = new VarBoolean("Wait stage", true); done = new VarBoolean("Done", false); } @Override - public void run() - { + public void run() { done.setValue(Boolean.FALSE); final CMMCore core = getMMCore(true); - if (waitForStage.getValue().booleanValue()) - { - try - { + if (waitForStage.getValue()) { + try { MultiStagePosition.goToPosition(input.getValue(), core); done.setValue(Boolean.TRUE); } - catch (Throwable t) - { + catch (final Throwable t) { throw new VarException(input, t.getMessage()); } } - else - { + else { // do it in background - ThreadUtil.bgRun(new Runnable() - { - @Override - public void run() - { - try - { - MultiStagePosition.goToPosition(input.getValue(), core); - } - catch (Throwable t) - { - throw new VarException(input, t.getMessage()); - } + ThreadUtil.bgRun(() -> { + try { + MultiStagePosition.goToPosition(input.getValue(), core); + } + catch (final Throwable t) { + throw new VarException(input, t.getMessage()); } }); @@ -76,8 +79,7 @@ public class MicroscopeSetStagePosition extends AbstractMicroscopeBlock } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { if (input != null) inputMap.add("position", input); if (waitForStage != null) @@ -85,8 +87,7 @@ public class MicroscopeSetStagePosition extends AbstractMicroscopeBlock } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { if (done != null) outputMap.add("done", done); } diff --git a/src/main/java/plugins/stef/micromanager/block/stage/MicroscopeSetStageXY.java b/src/main/java/plugins/stef/micromanager/block/stage/MicroscopeSetStageXY.java index 0d180fcb1e57917dca86b05f3ebffdd703122dda..97db9cc131badf2003a9099b42457247045bc6ab 100644 --- a/src/main/java/plugins/stef/micromanager/block/stage/MicroscopeSetStageXY.java +++ b/src/main/java/plugins/stef/micromanager/block/stage/MicroscopeSetStageXY.java @@ -1,6 +1,22 @@ -package plugins.stef.micromanager.block.stage; +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. + */ -import java.awt.geom.Point2D; +package plugins.stef.micromanager.block.stage; import plugins.adufour.blocks.util.VarList; import plugins.adufour.vars.lang.VarBoolean; @@ -10,13 +26,14 @@ import plugins.adufour.vars.util.VarException; import plugins.stef.micromanager.block.AbstractMicroscopeBlock; import plugins.tprovoost.Microscopy.MicroManager.tools.StageMover; +import java.awt.geom.Point2D; + /** * Set the stage to given XY position (Micro-Manager). - * + * * @author Stephane Dallongeville */ -public class MicroscopeSetStageXY extends AbstractMicroscopeBlock -{ +public class MicroscopeSetStageXY extends AbstractMicroscopeBlock { VarDouble inX; VarDouble inY; VarObject trigger = new VarObject("Trigger", null); @@ -24,48 +41,39 @@ public class MicroscopeSetStageXY extends AbstractMicroscopeBlock VarBoolean relative = new VarBoolean("Relative", true); VarBoolean done = new VarBoolean("Done", false); - public MicroscopeSetStageXY() - { + public MicroscopeSetStageXY() { super(); - try - { - Point2D.Double pos = StageMover.getXY(); + try { + final Point2D.Double pos = StageMover.getXY(); inX = new VarDouble("X", pos.x); inY = new VarDouble("Y", pos.y); } - catch (Throwable t) - { + catch (final Throwable t) { inX = new VarDouble("X", 0d); inY = new VarDouble("Y", 0d); } } @Override - public void run() - { + public void run() { done.setValue(Boolean.FALSE); - try - { - if (relative.getValue().booleanValue()) - StageMover.moveXYRelative(inX.getValue().doubleValue(), inY.getValue().doubleValue(), wait.getValue() - .booleanValue()); + try { + if (relative.getValue()) + StageMover.moveXYRelative(inX.getValue(), inY.getValue(), wait.getValue()); else - StageMover.moveXYAbsolute(inX.getValue().doubleValue(), inY.getValue().doubleValue(), wait.getValue() - .booleanValue()); + StageMover.moveXYAbsolute(inX.getValue(), inY.getValue(), wait.getValue()); done.setValue(Boolean.TRUE); } - catch (Throwable t) - { + catch (final Throwable t) { throw new VarException(relative, t.getMessage()); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("trigger", trigger); inputMap.add("x", inX); inputMap.add("y", inY); @@ -74,8 +82,7 @@ public class MicroscopeSetStageXY extends AbstractMicroscopeBlock } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("done", done); } } diff --git a/src/main/java/plugins/stef/micromanager/block/stage/MicroscopeSetStageZ.java b/src/main/java/plugins/stef/micromanager/block/stage/MicroscopeSetStageZ.java index c0f8d84609cc1de5fecb515ae25cd1fad8c8868f..71084a044c126b5906e54ebdfa7a51bf82eddf3f 100644 --- a/src/main/java/plugins/stef/micromanager/block/stage/MicroscopeSetStageZ.java +++ b/src/main/java/plugins/stef/micromanager/block/stage/MicroscopeSetStageZ.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. + */ + package plugins.stef.micromanager.block.stage; import plugins.adufour.blocks.util.VarList; @@ -10,52 +28,44 @@ import plugins.tprovoost.Microscopy.MicroManager.tools.StageMover; /** * Set the Z stage to given Z position (Micro-Manager). - * + * * @author Stephane Dallongeville */ -public class MicroscopeSetStageZ extends AbstractMicroscopeBlock -{ +public class MicroscopeSetStageZ extends AbstractMicroscopeBlock { VarDouble inZ; VarObject trigger = new VarObject("Trigger", null); VarBoolean varWait = new VarBoolean("Wait stage", true); VarBoolean varRelative = new VarBoolean("Relative", true); VarBoolean varDone = new VarBoolean("Done", false); - public MicroscopeSetStageZ() - { - try - { - double z = StageMover.getZ(); + public MicroscopeSetStageZ() { + try { + final double z = StageMover.getZ(); inZ = new VarDouble("Z", z); } - catch (Throwable t) - { + catch (final Throwable t) { inZ = new VarDouble("Z", 0d); } } @Override - public void run() - { + public void run() { varDone.setValue(Boolean.FALSE); - try - { - if (varRelative.getValue().booleanValue()) - StageMover.moveZRelative(inZ.getValue().doubleValue(), varWait.getValue().booleanValue()); + try { + if (varRelative.getValue()) + StageMover.moveZRelative(inZ.getValue(), varWait.getValue()); else - StageMover.moveZAbsolute(inZ.getValue().doubleValue(), varWait.getValue().booleanValue()); + StageMover.moveZAbsolute(inZ.getValue(), varWait.getValue()); varDone.setValue(Boolean.TRUE); } - catch (Throwable t) - { + catch (final Throwable t) { throw new VarException(varRelative, t.getMessage()); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("trigger", trigger); inputMap.add("z", inZ); inputMap.add("relative", varRelative); @@ -63,8 +73,7 @@ public class MicroscopeSetStageZ extends AbstractMicroscopeBlock } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("done", varDone); } } diff --git a/src/main/java/plugins/stef/micromanager/block/tool/TaggedImageToIcyImage.java b/src/main/java/plugins/stef/micromanager/block/tool/TaggedImageToIcyImage.java index 8dd0a27d96e197cedceecaf90f9a7e6044fd9604..7574f55a0c8a3c2b75c2fbddf5d685c9571c4b24 100644 --- a/src/main/java/plugins/stef/micromanager/block/tool/TaggedImageToIcyImage.java +++ b/src/main/java/plugins/stef/micromanager/block/tool/TaggedImageToIcyImage.java @@ -1,6 +1,21 @@ -/** - * +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. */ + package plugins.stef.micromanager.block.tool; import icy.image.IcyBufferedImage; @@ -15,42 +30,35 @@ import plugins.tprovoost.Microscopy.MicroManager.tools.MMUtils; /** * Block to convert a TaggedImage to an IcyBufferedImage (Micro-Manager) - * + * * @author Stephane */ -public class TaggedImageToIcyImage extends AbstractMicroscopeBlock -{ - VarArray<TaggedImage> in = new VarArray<TaggedImage>("Tagged Image", TaggedImage[].class, new TaggedImage[0]); - Var<IcyBufferedImage> out = new Var<IcyBufferedImage>("Icy Image", IcyBufferedImage.class); +public class TaggedImageToIcyImage extends AbstractMicroscopeBlock { + VarArray<TaggedImage> in = new VarArray<>("Tagged Image", TaggedImage[].class, new TaggedImage[0]); + Var<IcyBufferedImage> out = new Var<>("Icy Image", IcyBufferedImage.class); @Override - public void run() - { - try - { + public void run() { + try { out.setValue(MMUtils.convertToIcyImage(CollectionUtil.asList(in.getValue()))); } - catch (Throwable t) - { + catch (final Throwable t) { throw new VarException(out, t.getMessage()); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("taggedImage", in); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("icyImage", out); } @Override - public String getName() - { + public String getName() { return "TaggedImage to IcyBufferedImage"; } } \ No newline at end of file