diff --git a/.gitignore b/.gitignore index 80a5e13f65e119335d55a18274f23a4ee3cbff8c..198c988f98a0c7ee3299438321adf75b8ad024e6 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ target/ .project .classpath export.jardesc +**/.DS_Store diff --git a/pom.xml b/pom.xml index d1ad26a89bba1bac6c8bed478fb2d87b5f160952..381634a34153e4839055a5349777669955b40444 100644 --- a/pom.xml +++ b/pom.xml @@ -1,29 +1,24 @@ <?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>parent-pom-plugin</artifactId> - <version>1.0.8</version> + <artifactId>pom-icy</artifactId> + <version>2.2.0</version> </parent> <artifactId>sequence-blocks</artifactId> - <version>2.1.1</version> + <version>3.0.0</version> <name>SequenceBlocks</name> <dependencies> <dependency> <groupId>org.bioimageanalysis.icy</groupId> - <artifactId>icy-kernel</artifactId> - </dependency> - - <dependency> - <groupId>org.bioimageanalysis.icy</groupId> - <artifactId>blocks</artifactId> + <artifactId>protocols</artifactId> </dependency> </dependencies> diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/SequenceBlocks.java b/src/main/java/plugins/tprovoost/sequenceblocks/SequenceBlocks.java index 2a194ff3f2e713996cbec739d8681a9f72cc710c..e99b35cb9a4b5140f71ac1ec059557457eb5c14b 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/SequenceBlocks.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/SequenceBlocks.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.tprovoost.sequenceblocks; import icy.plugin.abstract_.Plugin; @@ -7,10 +25,9 @@ import icy.plugin.interface_.PluginLibrary; * This class is used as a main class for all the blocks contained in this * package. Each Block has a specified dedicated purpose. More documentation on * the concerned files. - * + * * @author thomasprovoost */ -public class SequenceBlocks extends Plugin implements PluginLibrary -{ +public class SequenceBlocks extends Plugin implements PluginLibrary { // } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/add/AddOverlays.java b/src/main/java/plugins/tprovoost/sequenceblocks/add/AddOverlays.java index 4251b970849bbe310e71ff4160b4fbf00e20e712..a6702c064fb465c45f6afc879bcdd11bfb982363 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/add/AddOverlays.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/add/AddOverlays.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.tprovoost.sequenceblocks.add; import icy.painter.Overlay; @@ -14,17 +32,14 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Block to add one or several {@link Overlay} to a Sequence - * + * * @author Stephane */ -public class AddOverlays extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class AddOverlays extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { final protected VarSequence inputSequence = new VarSequence("Sequence", null); - final protected VarArray<Overlay> overlays = new VarArray<Overlay>("Overlay(s)", Overlay[].class, new Overlay[0]) - { + final protected VarArray<Overlay> overlays = new VarArray<>("Overlay(s)", Overlay[].class, new Overlay[0]) { @Override - public String getValueAsString() - { + public String getValueAsString() { final Overlay[] value = getValue(); if (value == null || value.length == 0) @@ -35,23 +50,19 @@ public class AddOverlays extends Plugin implements SequenceBlock, PluginLibrary, }; @Override - public void run() - { + public void run() { final Sequence s = inputSequence.getValue(); if (s == null) throw new VarException(inputSequence, "Input sequence is null."); final Overlay[] o = overlays.getValue(); - if (o != null) - { + if (o != null) { s.beginUpdate(); - try - { - for (Overlay overlay : o) + try { + for (final Overlay overlay : o) s.addOverlay(overlay); } - finally - { + finally { s.endUpdate(); } } @@ -59,21 +70,18 @@ public class AddOverlays extends Plugin implements SequenceBlock, PluginLibrary, } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", inputSequence); inputMap.add("overlay(s)", overlays); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/add/AddRois.java b/src/main/java/plugins/tprovoost/sequenceblocks/add/AddRois.java index cbf26c84a61aa965af654edd9d7f4973873a6d8e..6e3417fb24cf7e849dd03835fef024888cd0c4d3 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/add/AddRois.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/add/AddRois.java @@ -1,6 +1,22 @@ -package plugins.tprovoost.sequenceblocks.add; +/* + * 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.Arrays; +package plugins.tprovoost.sequenceblocks.add; import icy.plugin.abstract_.Plugin; import icy.plugin.interface_.PluginBundled; @@ -15,25 +31,25 @@ import plugins.adufour.vars.lang.VarSequence; import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.SequenceBlocks; +import java.util.Arrays; + /** * Block to add one or several {@link ROI} to a Sequence - * + * * @author Stephane */ -public class AddRois extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class AddRois extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { final protected VarSequence inputSequence = new VarSequence("Sequence", null); final protected VarROIArray rois = new VarROIArray("Roi(s)"); final protected VarBoolean removePrevious = new VarBoolean("Remove previous", Boolean.FALSE); @Override - public void run() - { + public void run() { final Sequence s = inputSequence.getValue(); if (s == null) throw new VarException(inputSequence, "Input sequence is null."); - if (removePrevious.getValue().booleanValue()) + if (removePrevious.getValue()) s.removeAllROI(); final ROI[] r = rois.getValue(); @@ -42,22 +58,19 @@ public class AddRois extends Plugin implements SequenceBlock, PluginLibrary, Plu } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", inputSequence); inputMap.add("rois(s)", rois); inputMap.add("remove", removePrevious); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/convert/ConvertColor.java b/src/main/java/plugins/tprovoost/sequenceblocks/convert/ConvertColor.java index 1e4cf5b0c13fdad0aba8fe99c43e190f15057255..a145a4e3743123fc6487226138048129fbef88a3 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/convert/ConvertColor.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/convert/ConvertColor.java @@ -1,6 +1,22 @@ -package plugins.tprovoost.sequenceblocks.convert; +/* + * 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.image.BufferedImage; +package plugins.tprovoost.sequenceblocks.convert; import icy.image.IcyBufferedImageUtil; import icy.image.lut.LUT; @@ -16,68 +32,60 @@ import plugins.adufour.vars.lang.VarSequence; import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.SequenceBlocks; +import java.awt.image.BufferedImage; + /** * Block to render a given Sequence using a specific LUT.<br> * The result can be provided ARGB, RGB or GRAY sequence. - * + * * @author Stephane */ -public class ConvertColor extends Plugin implements SequenceBlock, PluginBundled -{ - public static enum ColorConversion - { - GRAY, RGB, ARGB; - }; +public class ConvertColor extends Plugin implements SequenceBlock, PluginBundled { + public enum ColorConversion { + GRAY, RGB, ARGB + } final protected VarSequence EZseq = new VarSequence("Sequence", null); - final protected VarEnum<ColorConversion> EZtype = new VarEnum<ColorConversion>("Conversion", ColorConversion.ARGB); - final protected Var<LUT> EZlut = new Var<LUT>("Lut", LUT.class); + final protected VarEnum<ColorConversion> EZtype = new VarEnum<>("Conversion", ColorConversion.ARGB); + final protected Var<LUT> EZlut = new Var<>("Lut", LUT.class); final protected VarSequence varOut = new VarSequence("Out", null); @Override - public void run() - { - Sequence s; + public void run() { + final Sequence s; // EZ PLUG s = EZseq.getValue(); if (s == null) throw new VarException(EZseq, "Input sequence is null."); - try - { + try { varOut.setValue(convertColor(s, getImageType(EZtype.getValue()), EZlut.getValue())); } - catch (InterruptedException e) - { + catch (final InterruptedException e) { // nothing to do } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("Sequence", EZseq); inputMap.add("Conversion", EZtype); inputMap.add("Lut", EZlut); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("Out", varOut); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } - public static int getImageType(ColorConversion value) - { - switch (value) - { + public static int getImageType(final ColorConversion value) { + switch (value) { default: case ARGB: return BufferedImage.TYPE_INT_ARGB; @@ -90,22 +98,19 @@ public class ConvertColor extends Plugin implements SequenceBlock, PluginBundled } } - public static Sequence convertColor(Sequence source, int imageType, LUT lut) throws IllegalArgumentException, InterruptedException - { + public static Sequence convertColor(final Sequence source, final int imageType, final LUT lut) throws IllegalArgumentException, InterruptedException { final Sequence result = new Sequence(OMEUtil.createOMEXMLMetadata(source.getOMEXMLMetadata())); // image receiver final BufferedImage imgOut = new BufferedImage(source.getSizeX(), source.getSizeY(), imageType); result.beginUpdate(); - try - { + try { for (int t = 0; t < source.getSizeT(); t++) for (int z = 0; z < source.getSizeZ(); z++) result.setImage(t, z, IcyBufferedImageUtil.toBufferedImage(source.getImage(t, z), imgOut, lut)); // rename channels and set final name - switch (imageType) - { + switch (imageType) { default: case BufferedImage.TYPE_INT_ARGB: result.setChannelName(0, "red"); @@ -128,8 +133,7 @@ public class ConvertColor extends Plugin implements SequenceBlock, PluginBundled break; } } - finally - { + finally { result.endUpdate(); } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/convert/ConvertStack.java b/src/main/java/plugins/tprovoost/sequenceblocks/convert/ConvertStack.java index 7eae544ad6eb2f68596852a2e2574f99c4a5518c..cc457d0eb71c867c17b38a1074fa28cc34d2a856 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/convert/ConvertStack.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/convert/ConvertStack.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.tprovoost.sequenceblocks.convert; import icy.plugin.abstract_.Plugin; @@ -5,7 +23,6 @@ import icy.plugin.interface_.PluginBundled; import icy.sequence.Sequence; import icy.sequence.SequenceUtil; import plugins.adufour.blocks.tools.sequence.SequenceBlock; -import plugins.adufour.blocks.util.BlocksException; import plugins.adufour.blocks.util.VarList; import plugins.adufour.vars.lang.VarEnum; import plugins.adufour.vars.lang.VarSequence; @@ -15,56 +32,48 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * @author thomasprovoost */ -public class ConvertStack extends Plugin implements SequenceBlock, PluginBundled -{ - public static enum TypeConversion - { +public class ConvertStack extends Plugin implements SequenceBlock, PluginBundled { + public enum TypeConversion { STACK, TIME - }; + } - final protected VarEnum<TypeConversion> type = new VarEnum<TypeConversion>("Type Wanted", TypeConversion.STACK); + final protected VarEnum<TypeConversion> type = new VarEnum<>("Type Wanted", TypeConversion.STACK); final protected VarSequence inputSequence = new VarSequence("Sequence", null); final protected VarSequence outputSequence = new VarSequence("Out", null); @Override - public void run() - { - Sequence in = inputSequence.getValue(); + public void run() { + final Sequence in = inputSequence.getValue(); if (in == null) throw new VarException(inputSequence, "Input sequence is null."); - try - { + try { // create a copy as we don't want to modify input - Sequence out = SequenceUtil.getCopy(in); + final Sequence out = SequenceUtil.getCopy(in); if (type.getValue() == TypeConversion.TIME) SequenceUtil.convertToTime(out); else SequenceUtil.convertToStack(out); outputSequence.setValue(out); } - catch (InterruptedException e) - { + catch (final InterruptedException e) { // nothing to do } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", inputSequence); inputMap.add("Type Wanted", type); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("out", outputSequence); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/convert/ConvertType.java b/src/main/java/plugins/tprovoost/sequenceblocks/convert/ConvertType.java index 48a11a4eba8e5bfc9afbdd330f2f279334eb2d80..a6afe8a65d9eab3f2cc699af1343351662affa0d 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/convert/ConvertType.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/convert/ConvertType.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.tprovoost.sequenceblocks.convert; import icy.plugin.abstract_.Plugin; @@ -17,48 +35,40 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * @author thomasprovoost */ -public class ConvertType extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ - final protected VarEnum<DataType> type = new VarEnum<DataType>("Type Wanted", DataType.UBYTE); +public class ConvertType extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { + final protected VarEnum<DataType> type = new VarEnum<>("Type Wanted", DataType.UBYTE); final protected VarSequence inputSequence = new VarSequence("sequence", null); final protected VarSequence outputSequence = new VarSequence("converted", null); final protected VarBoolean rescale = new VarBoolean("Rescale", Boolean.TRUE); @Override - public void run() - { - Sequence s = inputSequence.getValue(); + public void run() { + final Sequence s = inputSequence.getValue(); if (s == null) throw new VarException(inputSequence, "Input sequence is null."); - try - { - outputSequence.setValue(SequenceUtil.convertToType(s, type.getValue(), rescale.getValue().booleanValue())); + try { + outputSequence.setValue(SequenceUtil.convertToType(s, type.getValue(), rescale.getValue())); } - catch (InterruptedException e) - { + catch (final InterruptedException e) { // nothing to do } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", inputSequence); inputMap.add("Type Wanted", type); inputMap.add("Rescale", rescale); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("converted", outputSequence); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } - } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/convert/Resize.java b/src/main/java/plugins/tprovoost/sequenceblocks/convert/Resize.java index b222d0f51980e8838a83101c485c9a8b8ae8a1a2..5613a6b87d41927f05940149e01bdc25e92d25c5 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/convert/Resize.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/convert/Resize.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.tprovoost.sequenceblocks.convert; import icy.image.IcyBufferedImageUtil.FilterType; @@ -5,9 +23,6 @@ import icy.plugin.abstract_.Plugin; import icy.plugin.interface_.PluginBundled; import icy.sequence.Sequence; import icy.sequence.SequenceUtil; - -import javax.swing.SwingConstants; - import plugins.adufour.blocks.tools.sequence.SequenceBlock; import plugins.adufour.blocks.util.VarList; import plugins.adufour.vars.lang.VarBoolean; @@ -17,40 +32,38 @@ import plugins.adufour.vars.lang.VarSequence; import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.SequenceBlocks; -public class Resize extends Plugin implements SequenceBlock, PluginBundled -{ - protected enum Proportional - { +import javax.swing.*; + +public class Resize extends Plugin implements SequenceBlock, PluginBundled { + protected enum Proportional { NO, TO_WIDTH, TO_HEIGHT - }; + } - final protected VarSequence EZseq = new VarSequence("Sequence", null); - final protected VarInteger EZsizew = new VarInteger("Width", 320); - final protected VarInteger EZsizeh = new VarInteger("Height", 200); - final protected VarEnum<Proportional> EZproportional = new VarEnum<Proportional>("Proportional", Proportional.NO); - final protected VarBoolean EZscale = new VarBoolean("Scale content", Boolean.TRUE); - final protected VarEnum<FilterType> EZtype = new VarEnum<FilterType>("Filter", FilterType.BICUBIC); - final protected VarSequence varOut = new VarSequence("Out", null); + final protected VarSequence EZseq = new VarSequence("Sequence", null); + final protected VarInteger EZsizew = new VarInteger("Width", 320); + final protected VarInteger EZsizeh = new VarInteger("Height", 200); + final protected VarEnum<Proportional> EZproportional = new VarEnum<>("Proportional", Proportional.NO); + final protected VarBoolean EZscale = new VarBoolean("Scale content", Boolean.TRUE); + final protected VarEnum<FilterType> EZtype = new VarEnum<>("Filter", FilterType.BICUBIC); + final protected VarSequence varOut = new VarSequence("Out", null); @Override - public void run() - { - Sequence s; + public void run() { + final Sequence s; int w, h; - FilterType type; + final FilterType type; // EZ PLUG s = EZseq.getValue(); - w = EZsizew.getValue().intValue(); - h = EZsizeh.getValue().intValue(); + w = EZsizew.getValue(); + h = EZsizeh.getValue(); type = EZtype.getValue(); if (s == null || w <= 0 || h <= 0) throw new VarException(null, "No sequence chosen for resize, or wrong size."); - double scale = 1d * s.getWidth() / s.getHeight(); - switch (EZproportional.getValue()) - { + final double scale = 1d * s.getWidth() / s.getHeight(); + switch (EZproportional.getValue()) { case NO: break; case TO_WIDTH: @@ -61,15 +74,14 @@ public class Resize extends Plugin implements SequenceBlock, PluginBundled break; } - if (EZscale.getValue().booleanValue()) + if (EZscale.getValue()) varOut.setValue(SequenceUtil.scale(s, w, h, type)); else varOut.setValue(SequenceUtil.scale(s, w, h, false, SwingConstants.CENTER, SwingConstants.CENTER, type)); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("Sequence", EZseq); inputMap.add("Width", EZsizew); inputMap.add("Height", EZsizeh); @@ -79,14 +91,12 @@ public class Resize extends Plugin implements SequenceBlock, PluginBundled } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("Out", varOut); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/creation/CombineChannels.java b/src/main/java/plugins/tprovoost/sequenceblocks/creation/CombineChannels.java index b1fc9e1f6ab9986312da533bd14eb6995e3d58a7..68d5107b731ffd00e4611f26b053b1b2a57db45b 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/creation/CombineChannels.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/creation/CombineChannels.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.tprovoost.sequenceblocks.creation; import icy.plugin.abstract_.Plugin; @@ -16,57 +34,51 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * @author thomasprovoost */ -public class CombineChannels extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class CombineChannels extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { final protected VarSequence inputSequence = new VarSequence("Sequence 1", null); final protected VarSequence inputSequence2 = new VarSequence("Sequence 2", null); final protected VarSequence outputSequence = new VarSequence("Merged", null); - final protected VarIntegerArrayNative channelIdx = new VarIntegerArrayNative("Channel(s) 1", new int[] {0}); - final protected VarIntegerArrayNative channelIdx2 = new VarIntegerArrayNative("Channel(s) 2", new int[] {0}); + final protected VarIntegerArrayNative channelIdx = new VarIntegerArrayNative("Channel(s) 1", new int[]{0}); + final protected VarIntegerArrayNative channelIdx2 = new VarIntegerArrayNative("Channel(s) 2", new int[]{0}); final protected VarBoolean fillStackHole = new VarBoolean("Fill stack hole", Boolean.TRUE); final protected VarBoolean fitToMaxSize = new VarBoolean("Fit to max size", Boolean.TRUE); @Override - public void run() - { - Sequence s = inputSequence.getValue(); - Sequence s2 = inputSequence2.getValue(); + public void run() { + final Sequence s = inputSequence.getValue(); + final Sequence s2 = inputSequence2.getValue(); if (s == null) throw new VarException(inputSequence, "Input sequence 1 is null."); if (s2 == null) throw new VarException(inputSequence2, "Input sequence 2 is null."); - int[] channels1 = channelIdx.getValue(); - int[] channels2 = channelIdx2.getValue(); - int sizeC1 = channels1.length; - int sizeC2 = channels2.length; + final int[] channels1 = channelIdx.getValue(); + final int[] channels2 = channelIdx2.getValue(); + final int sizeC1 = channels1.length; + final int sizeC2 = channels2.length; // Because of concatC, it is necessary to create a sequence[] and int[] of the same size, // and duplicate the sequence as many times in the first as necessary. - Sequence[] sequences = new Sequence[sizeC1 + sizeC2]; - int channels[] = new int[sizeC1 + sizeC2]; + final Sequence[] sequences = new Sequence[sizeC1 + sizeC2]; + final int[] channels = new int[sizeC1 + sizeC2]; - for (int i = 0; i < sizeC1; ++i) - { + for (int i = 0; i < sizeC1; ++i) { sequences[i] = s; channels[i] = channels1[i]; } - for (int i = 0; i < sizeC2; ++i) - { + for (int i = 0; i < sizeC2; ++i) { sequences[sizeC1 + i] = s2; channels[sizeC1 + i] = channels2[i]; } - final Sequence res = SequenceUtil.concatC(sequences, channels, fillStackHole.getValue().booleanValue(), - fitToMaxSize.getValue().booleanValue(), null); + final Sequence res = SequenceUtil.concatC(sequences, channels, fillStackHole.getValue(), fitToMaxSize.getValue(), null); outputSequence.setValue(res); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence 1", inputSequence); inputMap.add("Channel 1", channelIdx); inputMap.add("sequence 2", inputSequence2); @@ -76,14 +88,12 @@ public class CombineChannels extends Plugin implements SequenceBlock, PluginLibr } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("out", outputSequence); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/creation/CreateSequence.java b/src/main/java/plugins/tprovoost/sequenceblocks/creation/CreateSequence.java index a133b94e6c608e5d912586d90084bed0b526f516..c99e181eae0d9c71fa812934e57e7238c883bba6 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/creation/CreateSequence.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/creation/CreateSequence.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.tprovoost.sequenceblocks.creation; import icy.image.IcyBufferedImage; @@ -14,32 +32,27 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * @author thomasprovoost */ -public class CreateSequence extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ - final protected Var<IcyBufferedImage> in = new Var<IcyBufferedImage>("image (optional)", IcyBufferedImage.class); +public class CreateSequence extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { + final protected Var<IcyBufferedImage> in = new Var<>("image (optional)", IcyBufferedImage.class); final protected VarSequence out = new VarSequence("sequence", null); @Override - public void run() - { + public void run() { out.setValue(new Sequence(in.getValue())); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("image (optional)", in); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("sequence", out); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/creation/DuplicateSequence.java b/src/main/java/plugins/tprovoost/sequenceblocks/creation/DuplicateSequence.java index dec05da26bbdd55487d7c58ee7227eb40d420e5f..e91fea73ac1471725464ca20aeb7c211b708a3ba 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/creation/DuplicateSequence.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/creation/DuplicateSequence.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.tprovoost.sequenceblocks.creation; import icy.plugin.abstract_.Plugin; @@ -14,43 +32,36 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * @author thomasprovoost */ -public class DuplicateSequence extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class DuplicateSequence extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { final protected VarSequence in = new VarSequence("sequence", null); final protected VarSequence out = new VarSequence("duplicated", null); @Override - public void run() - { - Sequence s = in.getValue(); + public void run() { + final Sequence s = in.getValue(); if (s == null) throw new VarException(in, "Input Sequence is null."); - try - { + try { out.setValue(SequenceUtil.getCopy(s)); } - catch (InterruptedException e) - { + catch (final InterruptedException e) { // nothing to do } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", in); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("duplicated", out); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/extract/CropCZT.java b/src/main/java/plugins/tprovoost/sequenceblocks/extract/CropCZT.java index 4ffa86cedabf80fd2f6c2df656f67a8e267010bb..24aceb5b74a18342f92f628c57649b5535540182 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/extract/CropCZT.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/extract/CropCZT.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.tprovoost.sequenceblocks.extract; import icy.plugin.abstract_.Plugin; @@ -12,8 +30,7 @@ import plugins.adufour.vars.lang.VarSequence; import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.SequenceBlocks; -public class CropCZT extends Plugin implements SequenceBlock, PluginBundled -{ +public class CropCZT extends Plugin implements SequenceBlock, PluginBundled { final protected VarSequence varSeq = new VarSequence("Sequence", null); final protected VarInteger varStartC = new VarInteger("Start index C", 0); final protected VarInteger varSizeC = new VarInteger("Size C", 1); @@ -24,8 +41,7 @@ public class CropCZT extends Plugin implements SequenceBlock, PluginBundled final protected VarSequence varOut = new VarSequence("Out", null); @Override - public void run() - { + public void run() { final Sequence seq; final int startX, sizeX; final int startY, sizeY; @@ -39,12 +55,12 @@ public class CropCZT extends Plugin implements SequenceBlock, PluginBundled if (seq == null) throw new VarException(varSeq, "No sequence chosen !"); - startC = Math.min(varStartC.getValue().intValue(), seq.getSizeC() - 1); - sizeC = Math.min(varSizeC.getValue().intValue(), seq.getSizeC() - startC); - startZ = Math.min(varStartZ.getValue().intValue(), seq.getSizeZ() - 1); - sizeZ = Math.min(varSizeZ.getValue().intValue(), seq.getSizeZ() - startZ); - startT = Math.min(varStartT.getValue().intValue(), seq.getSizeT() - 1); - sizeT = Math.min(varSizeT.getValue().intValue(), seq.getSizeT() - startT); + startC = Math.min(varStartC.getValue(), seq.getSizeC() - 1); + sizeC = Math.min(varSizeC.getValue(), seq.getSizeC() - startC); + startZ = Math.min(varStartZ.getValue(), seq.getSizeZ() - 1); + sizeZ = Math.min(varSizeZ.getValue(), seq.getSizeZ() - startZ); + startT = Math.min(varStartT.getValue(), seq.getSizeT() - 1); + sizeT = Math.min(varSizeT.getValue(), seq.getSizeT() - startT); startX = 0; sizeX = seq.getSizeX(); @@ -59,8 +75,7 @@ public class CropCZT extends Plugin implements SequenceBlock, PluginBundled } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("Sequence", varSeq); inputMap.add("Start index C", varStartC); inputMap.add("Size C", varSizeC); @@ -71,14 +86,12 @@ public class CropCZT extends Plugin implements SequenceBlock, PluginBundled } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("Out", varOut); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/extract/CropSequence.java b/src/main/java/plugins/tprovoost/sequenceblocks/extract/CropSequence.java index 334444f25fd17bcae0c3f62418077fbfb0d6bd5e..af08430983c98356fd5982f850ee64db17a3061a 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/extract/CropSequence.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/extract/CropSequence.java @@ -1,7 +1,22 @@ -package plugins.tprovoost.sequenceblocks.extract; +/* + * 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.ArrayList; -import java.util.List; +package plugins.tprovoost.sequenceblocks.extract; import icy.plugin.abstract_.Plugin; import icy.plugin.interface_.PluginBundled; @@ -19,25 +34,24 @@ import plugins.adufour.vars.lang.VarMutable; import plugins.adufour.vars.lang.VarSequence; import plugins.tprovoost.sequenceblocks.SequenceBlocks; +import java.util.ArrayList; +import java.util.List; + /** * @author thomasprovoost */ -public class CropSequence extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class CropSequence extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { final protected VarSequence inputSequence = new VarSequence("Sequence", null); - VarMutable inputROIs = new VarMutable("ROI(s)", null) - { + VarMutable inputROIs = new VarMutable("ROI(s)", null) { @Override - public boolean isAssignableFrom(@SuppressWarnings("rawtypes") Var source) - { + public boolean isAssignableFrom(final Var source) { return (ROI.class == source.getType()) || (ROI[].class == source.getType()); } }; final protected VarSequence outputSequence = new VarSequence("Cropped", null); @Override - public void run() - { + public void run() { outputSequence.setValue(null); final Sequence s = inputSequence.getValue(); @@ -50,42 +64,36 @@ public class CropSequence extends Plugin implements SequenceBlock, PluginLibrary final List<ROI> rois; - if (obj instanceof ROI) - { - rois = new ArrayList<ROI>(); + if (obj instanceof ROI) { + rois = new ArrayList<>(); rois.add((ROI) obj); } else rois = CollectionUtil.asList((ROI[]) obj); - try - { + try { final ROI roi = ROIUtil.merge(rois, BooleanOperator.OR); outputSequence.setValue(SequenceUtil.getSubSequence(s, roi)); } - catch (InterruptedException e) - { + catch (final InterruptedException e) { // nothing to do } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", inputSequence); inputMap.add("roi", inputROIs); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("cropped", outputSequence); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/extract/ExtractChannel.java b/src/main/java/plugins/tprovoost/sequenceblocks/extract/ExtractChannel.java index e977e82b733422edd3c95fb6a90dbe06c8065290..0ec592d60b89d86dc05d2ce687ba2a5a208cf730 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/extract/ExtractChannel.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/extract/ExtractChannel.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.tprovoost.sequenceblocks.extract; import icy.plugin.abstract_.Plugin; @@ -15,52 +33,45 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * @author thomasprovoost */ -public class ExtractChannel extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class ExtractChannel extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { final protected VarSequence inputSequence = new VarSequence("Sequence", null); final protected VarSequence outputSequence = new VarSequence("Extracted", null); final protected VarInteger channelIdx = new VarInteger("Channel", 0); @Override - public void run() - { + public void run() { final Sequence s = inputSequence.getValue(); - final int channel = channelIdx.getValue().intValue(); + final int channel = channelIdx.getValue(); if (s == null) throw new VarException(inputSequence, "Input sequence is null."); if (channel < 0 || channel >= s.getSizeC()) throw new VarException(channelIdx, "Channel index must be between 0 and " + (s.getSizeC() - 1)); - try - { - final Sequence res = SequenceUtil.extractChannel(s, channelIdx.getValue().intValue()); + try { + final Sequence res = SequenceUtil.extractChannel(s, channelIdx.getValue()); res.setName(s.getName() + " - channel: " + channelIdx.getValue()); outputSequence.setValue(res); } - catch (InterruptedException e) - { + catch (final InterruptedException e) { // nothing to do } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", inputSequence); inputMap.add("channel", channelIdx); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("extracted", outputSequence); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/extract/ExtractMultiChannels.java b/src/main/java/plugins/tprovoost/sequenceblocks/extract/ExtractMultiChannels.java index 79d6acaef733c9c608929b79a6ff6a73299820fe..b17f34bade25983da1cc6f36871417e05c6a47d4 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/extract/ExtractMultiChannels.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/extract/ExtractMultiChannels.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.tprovoost.sequenceblocks.extract; import icy.plugin.abstract_.Plugin; @@ -12,50 +30,45 @@ import plugins.adufour.vars.lang.VarSequence; import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.SequenceBlocks; +import java.util.Arrays; + /** * @author thomasprovoost */ -public class ExtractMultiChannels extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class ExtractMultiChannels extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { final protected VarSequence inputSequence = new VarSequence("Sequence", null); final protected VarSequence outputSequence = new VarSequence("Extracted", null); - final protected VarIntegerArrayNative channelIdx = new VarIntegerArrayNative("Channel(s)", new int[] {0}); + final protected VarIntegerArrayNative channelIdx = new VarIntegerArrayNative("Channel(s)", new int[]{0}); @Override - public void run() - { - Sequence s = inputSequence.getValue(); + public void run() { + final Sequence s = inputSequence.getValue(); if (s == null) throw new VarException(inputSequence, "Input sequence is null."); - try - { - Sequence res = SequenceUtil.extractChannels(s, channelIdx.getValue()); - res.setName(s.getName() + " - channel: " + channelIdx.getValue()); + try { + final Sequence res = SequenceUtil.extractChannels(s, channelIdx.getValue()); + res.setName(s.getName() + " - channel: " + Arrays.toString(channelIdx.getValue())); outputSequence.setValue(res); } - catch (InterruptedException e) - { + catch (final InterruptedException e) { // nothing to do } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", inputSequence); inputMap.add("Channel", channelIdx); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("extracted", outputSequence); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/extract/ExtractSlice.java b/src/main/java/plugins/tprovoost/sequenceblocks/extract/ExtractSlice.java index d579387491349753cca9cd09c52da5f1251b42ff..789aec49b0089f5694006f966567b0ed27a394b4 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/extract/ExtractSlice.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/extract/ExtractSlice.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.tprovoost.sequenceblocks.extract; import icy.plugin.abstract_.Plugin; @@ -15,38 +33,33 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * @author thomasprovoost */ -public class ExtractSlice extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class ExtractSlice extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { final protected VarSequence inputSequence = new VarSequence("Sequence", null); final protected VarSequence outputSequence = new VarSequence("Extracted", null); final protected VarInteger chosenZ = new VarInteger("Z", 0); @Override - public void run() - { - Sequence s = inputSequence.getValue(); + public void run() { + final Sequence s = inputSequence.getValue(); if (s == null) throw new VarException(inputSequence, "Input sequence is null."); - Sequence extracted = SequenceUtil.extractSlice(s, chosenZ.getValue().intValue()); + final Sequence extracted = SequenceUtil.extractSlice(s, chosenZ.getValue()); outputSequence.setValue(extracted); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", inputSequence); inputMap.add("Z pos", chosenZ); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("extracted", outputSequence); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/extract/ExtractTime.java b/src/main/java/plugins/tprovoost/sequenceblocks/extract/ExtractTime.java index 67004582a278dc3e3a131b459f585dd3240ee3d9..06f3aaeff561fe9b088a8565720459e7d93afe71 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/extract/ExtractTime.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/extract/ExtractTime.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.tprovoost.sequenceblocks.extract; import icy.plugin.abstract_.Plugin; @@ -15,38 +33,33 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * @author thomasprovoost */ -public class ExtractTime extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class ExtractTime extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { final protected VarSequence inputSequence = new VarSequence("Sequence", null); final protected VarSequence outputSequence = new VarSequence("Extracted", null); final protected VarInteger chosenT = new VarInteger("T", 0); @Override - public void run() - { - Sequence s = inputSequence.getValue(); + public void run() { + final Sequence s = inputSequence.getValue(); if (s == null) throw new VarException(inputSequence, "Input sequence is null."); - Sequence extracted = SequenceUtil.extractFrame(s, chosenT.getValue().intValue()); + final Sequence extracted = SequenceUtil.extractFrame(s, chosenT.getValue()); outputSequence.setValue(extracted); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", inputSequence); inputMap.add("T pos", chosenT); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("extracted", outputSequence); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/files/IsFileValid.java b/src/main/java/plugins/tprovoost/sequenceblocks/files/IsFileValid.java index 7b250ea63ee1f64ff2098b761f9ae3420856928f..c4a4b5d2d0ee11e06d59bc267c9c5279ff39ad24 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/files/IsFileValid.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/files/IsFileValid.java @@ -1,6 +1,22 @@ -package plugins.tprovoost.sequenceblocks.files; +/* + * 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.io.File; +package plugins.tprovoost.sequenceblocks.files; import icy.file.Loader; import icy.plugin.abstract_.Plugin; @@ -13,29 +29,26 @@ import plugins.adufour.vars.lang.VarBoolean; import plugins.adufour.vars.lang.VarMutable; import plugins.tprovoost.sequenceblocks.SequenceBlocks; +import java.io.File; + /** * Block to know if a file represents an image file - * + * * @author Stephane */ -public class IsFileValid extends Plugin implements PluginLibrary, SequenceBlock, PluginBundled -{ - final protected VarMutable f_in = new VarMutable("File", null) - { +public class IsFileValid extends Plugin implements PluginLibrary, SequenceBlock, PluginBundled { + final protected VarMutable f_in = new VarMutable("File", null) { @Override - public boolean isAssignableFrom(@SuppressWarnings("rawtypes") Var source) - { + public boolean isAssignableFrom(final Var source) { return String.class == source.getType() || File.class == source.getType(); } }; final protected VarBoolean result = new VarBoolean("Valid", Boolean.FALSE); @Override - public void run() - { + public void run() { final Object obj = f_in.getValue(); - if (obj != null) - { + if (obj != null) { final File f; if (obj instanceof String) @@ -43,25 +56,22 @@ public class IsFileValid extends Plugin implements PluginLibrary, SequenceBlock, else f = (File) obj; - result.setValue(Boolean.valueOf(Loader.isSupportedImageFile(f.getAbsolutePath()))); + result.setValue(Loader.isSupportedImageFile(f.getAbsolutePath())); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("file", f_in); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("valid", result); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/files/LoadMetadata.java b/src/main/java/plugins/tprovoost/sequenceblocks/files/LoadMetadata.java index 18d6f4f772b5345e9bc3a93cac28576b594cf0eb..3a513a68fde962471c5d3bb481b08069cefc280a 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/files/LoadMetadata.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/files/LoadMetadata.java @@ -1,6 +1,22 @@ -package plugins.tprovoost.sequenceblocks.files; +/* + * 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.io.File; +package plugins.tprovoost.sequenceblocks.files; import icy.file.Loader; import icy.plugin.abstract_.Plugin; @@ -16,30 +32,27 @@ import plugins.adufour.vars.lang.VarMutable; import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.SequenceBlocks; +import java.io.File; + /** * Block to load Sequence metadata from a file - * + * * @author Stephane */ -public class LoadMetadata extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ - final protected VarMutable f_in = new VarMutable("File", null) - { +public class LoadMetadata extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { + final protected VarMutable f_in = new VarMutable("File", null) { @Override - public boolean isAssignableFrom(@SuppressWarnings("rawtypes") Var source) - { + public boolean isAssignableFrom(final Var source) { return (String.class == source.getType()) || (File.class == source.getType()); } }; - final protected Var<OMEXMLMetadata> output = new Var<OMEXMLMetadata>("Metadata", OMEXMLMetadata.class); + final protected Var<OMEXMLMetadata> output = new Var<>("Metadata", OMEXMLMetadata.class); final protected VarInteger numSerie = new VarInteger("Series number", 1); @Override - public void run() - { + public void run() { final Object obj = f_in.getValue(); - if (obj != null) - { + if (obj != null) { final File f; if (obj instanceof String) @@ -47,39 +60,33 @@ public class LoadMetadata extends Plugin implements SequenceBlock, PluginLibrary else f = (File) obj; - try - { + try { final OMEXMLMetadata meta = Loader.getOMEXMLMetaData(f.getAbsolutePath()); - if (meta != null) - { + if (meta != null) { output.setValue(meta); - numSerie.setValue(Integer.valueOf(MetaDataUtil.getNumSeries(meta))); + numSerie.setValue(MetaDataUtil.getNumSeries(meta)); } } - catch (Exception e) - { + catch (final Exception e) { throw new VarException(null, e.getMessage()); } } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("file", f_in); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("Metadata", output); outputMap.add("Serie number", numSerie); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/files/LoadSequence.java b/src/main/java/plugins/tprovoost/sequenceblocks/files/LoadSequence.java index a0135c26ff104affc10665ff975f57d31dca0090..44acd9b50582daaffa5438432be1a4e76c84b5aa 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/files/LoadSequence.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/files/LoadSequence.java @@ -1,6 +1,22 @@ -package plugins.tprovoost.sequenceblocks.files; +/* + * 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.io.File; +package plugins.tprovoost.sequenceblocks.files; import icy.file.Loader; import icy.plugin.abstract_.Plugin; @@ -14,18 +30,17 @@ import plugins.adufour.vars.lang.VarMutable; import plugins.adufour.vars.lang.VarSequence; import plugins.tprovoost.sequenceblocks.SequenceBlocks; +import java.io.File; + /** * Block to load a Sequence from a file - * + * * @author Stephane */ -public class LoadSequence extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ - final protected VarMutable f_in = new VarMutable("File", null) - { +public class LoadSequence extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { + final protected VarMutable f_in = new VarMutable("File", null) { @Override - public boolean isAssignableFrom(@SuppressWarnings("rawtypes") Var source) - { + public boolean isAssignableFrom(final Var source) { return (String.class == source.getType()) || (File.class == source.getType()); } }; @@ -33,11 +48,9 @@ public class LoadSequence extends Plugin implements SequenceBlock, PluginLibrary final protected VarSequence outputSequence = new VarSequence("Sequence", null); @Override - public void run() - { + public void run() { final Object obj = f_in.getValue(); - if (obj != null) - { + if (obj != null) { final File f; if (obj instanceof String) @@ -48,27 +61,24 @@ public class LoadSequence extends Plugin implements SequenceBlock, PluginLibrary // if (f.isDirectory()) // throw new VarException("file should not be a directory."); - outputSequence.setValue(Loader.loadSequence(f.getAbsolutePath(), serie_in.getValue().intValue(), false)); + outputSequence.setValue(Loader.loadSequence(f.getAbsolutePath(), serie_in.getValue(), false)); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("file", f_in); inputMap.add("serie", serie_in); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("sequence", outputSequence); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/files/LoadSubSequence.java b/src/main/java/plugins/tprovoost/sequenceblocks/files/LoadSubSequence.java index 27861d6e9ba7ff4355f2378d207eef31e5495789..4e0ed0ff9350c4b12b3e168c00f8672d636cee10 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/files/LoadSubSequence.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/files/LoadSubSequence.java @@ -1,6 +1,22 @@ -package plugins.tprovoost.sequenceblocks.files; +/* + * 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.io.File; +package plugins.tprovoost.sequenceblocks.files; import icy.file.Loader; import icy.file.SequenceFileImporter; @@ -10,22 +26,18 @@ import icy.plugin.interface_.PluginLibrary; import icy.roi.ROI; import plugins.adufour.blocks.tools.io.IOBlock; import plugins.adufour.blocks.util.VarList; -import plugins.adufour.vars.lang.Var; -import plugins.adufour.vars.lang.VarBoolean; -import plugins.adufour.vars.lang.VarInteger; -import plugins.adufour.vars.lang.VarMutable; -import plugins.adufour.vars.lang.VarROIArray; -import plugins.adufour.vars.lang.VarSequence; +import plugins.adufour.vars.lang.*; import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.SequenceBlocks; +import java.io.File; + /** * Block to returns a Sequence with the given parameters from the specified closed) SequenceFileImporter. - * + * * @author Stephane */ -public class LoadSubSequence extends Plugin implements IOBlock, PluginLibrary, PluginBundled -{ +public class LoadSubSequence extends Plugin implements IOBlock, PluginLibrary, PluginBundled { final protected Var<SequenceFileImporter> importer; final protected VarMutable file; final protected VarInteger series; @@ -40,16 +52,13 @@ public class LoadSubSequence extends Plugin implements IOBlock, PluginLibrary, P final protected VarSequence sequence; - public LoadSubSequence() - { + public LoadSubSequence() { super(); - importer = new Var<SequenceFileImporter>("Importer", SequenceFileImporter.class); - file = new VarMutable("File", null) - { + importer = new Var<>("Importer", SequenceFileImporter.class); + file = new VarMutable("File", null) { @Override - public boolean isAssignableFrom(@SuppressWarnings("rawtypes") Var source) - { + public boolean isAssignableFrom(final Var source) { return (String.class == source.getType()) || (File.class == source.getType()); } }; @@ -67,13 +76,11 @@ public class LoadSubSequence extends Plugin implements IOBlock, PluginLibrary, P } @Override - public void run() - { + public void run() { final String path; final Object obj = file.getValue(); - if (obj != null) - { + if (obj != null) { if (obj instanceof String) path = (String) obj; else @@ -84,32 +91,42 @@ public class LoadSubSequence extends Plugin implements IOBlock, PluginLibrary, P // here importer can be null so we don't test for it final SequenceFileImporter imp = importer.getValue(); - final int s = series.getValue().intValue(); - final int r = resolution.getValue().intValue(); + final int s = series.getValue(); + final int r = resolution.getValue(); final ROI[] rois = region.getValue(); final ROI roi = ((rois != null) && (rois.length > 0)) ? rois[0] : null; - final int minZ = minZIndex.getValue().intValue(); - final int maxZ = maxZIndex.getValue().intValue(); - final int minT = minTIndex.getValue().intValue(); - final int maxT = maxTIndex.getValue().intValue(); - final int c = cIndex.getValue().intValue(); - final boolean progress = showProgress.getValue().booleanValue(); + final int minZ = minZIndex.getValue(); + final int maxZ = maxZIndex.getValue(); + final int minT = minTIndex.getValue(); + final int maxT = maxTIndex.getValue(); + final int c = cIndex.getValue(); + final boolean progress = showProgress.getValue(); - try - { - sequence.setValue(Loader.loadSequence(imp, path, s, r, - (roi != null) ? roi.getBounds5D().toRectangle2D().getBounds() : null, minZ, maxZ, minT, maxT, c, - false, progress)); + try { + sequence.setValue( + Loader.loadSequence( + imp, + path, + s, + r, + (roi != null) ? roi.getBounds5D().toRectangle2D().getBounds() : null, + minZ, + maxZ, + minT, + maxT, + c, + false, + progress + ) + ); } - catch (Exception e) - { + catch (final Exception e) { throw new VarException(importer, e.getMessage()); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("file", file); inputMap.add("importer", importer); inputMap.add("series", series); @@ -124,14 +141,12 @@ public class LoadSubSequence extends Plugin implements IOBlock, PluginLibrary, P } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("sequence", sequence); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/files/SaveMetadata.java b/src/main/java/plugins/tprovoost/sequenceblocks/files/SaveMetadata.java index da349443a7c1a076f753fa90ce8357d351de78aa..7fadf75aedd5bd3442e3a2c6e1a39db6f16f1f89 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/files/SaveMetadata.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/files/SaveMetadata.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.tprovoost.sequenceblocks.files; import icy.plugin.abstract_.Plugin; @@ -13,39 +31,34 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Block to save Sequence metadata - * + * * @author Stephane */ -public class SaveMetadata extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class SaveMetadata extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { final protected VarSequence sequence = new VarSequence("Sequence", null); final protected VarBoolean success = new VarBoolean("Success", Boolean.FALSE); @Override - public void run() - { - Sequence s = sequence.getValue(); + public void run() { + final Sequence s = sequence.getValue(); if (s == null) throw new VarException(sequence, "Sequence is null"); - success.setValue(Boolean.valueOf(s.saveXMLData())); + success.setValue(s.saveXMLData()); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", sequence); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("success", success); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/files/SaveSequence.java b/src/main/java/plugins/tprovoost/sequenceblocks/files/SaveSequence.java index 98e0a217d376abab46e8ca183f7d8d76f60cf758..5946db43ad0538bb0b6dab9eec6b5e45bfb895cb 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/files/SaveSequence.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/files/SaveSequence.java @@ -1,6 +1,22 @@ -package plugins.tprovoost.sequenceblocks.files; +/* + * 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.io.File; +package plugins.tprovoost.sequenceblocks.files; import icy.file.FileUtil; import icy.file.ImageFileFormat; @@ -11,45 +27,37 @@ import icy.plugin.interface_.PluginLibrary; import icy.sequence.Sequence; import plugins.adufour.blocks.tools.sequence.SequenceBlock; import plugins.adufour.blocks.util.VarList; -import plugins.adufour.vars.lang.Var; -import plugins.adufour.vars.lang.VarBoolean; -import plugins.adufour.vars.lang.VarEnum; -import plugins.adufour.vars.lang.VarMutable; -import plugins.adufour.vars.lang.VarSequence; +import plugins.adufour.vars.lang.*; import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.SequenceBlocks; +import java.io.File; + /** * Block to save a Sequence into a file - * + * * @author Stephane */ -public class SaveSequence extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ - final protected VarMutable f_in = new VarMutable("File", null) - { +public class SaveSequence extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { + final protected VarMutable f_in = new VarMutable("File", null) { @Override - public boolean isAssignableFrom(@SuppressWarnings("rawtypes") Var source) - { + public boolean isAssignableFrom(final Var source) { return String.class == source.getType() || File.class == source.getType(); } }; final protected VarBoolean overwriteForce = new VarBoolean("Overwrite", Boolean.TRUE); final protected VarBoolean multipleFile = new VarBoolean("Multiple file", Boolean.FALSE); final protected VarSequence sequence = new VarSequence("Sequence", null); - final protected VarEnum<ImageFileFormat> format = new VarEnum<ImageFileFormat>("Format", ImageFileFormat.TIFF); + final protected VarEnum<ImageFileFormat> format = new VarEnum<>("Format", ImageFileFormat.TIFF); @Override - public void run() - { + public void run() { final Sequence seq = sequence.getValue(); - if (seq != null) - { + if (seq != null) { final Object obj = f_in.getValue(); - if (obj != null) - { + if (obj != null) { String path; if (obj instanceof String) @@ -64,19 +72,18 @@ public class SaveSequence extends Plugin implements SequenceBlock, PluginLibrary path = FileUtil.setExtension(path, "." + format.getValue().getExtensions()[0]); // cannot overwrite ?? - if (FileUtil.exists(path) && !overwriteForce.getValue().booleanValue()) + if (FileUtil.exists(path) && !overwriteForce.getValue()) throw new VarException(f_in, "File already exists. If you want to overwrite, please check the \"overwrite\" field."); // save sequence - Saver.save(seq, new File(path), multipleFile.getValue().booleanValue(), false); + Saver.save(seq, new File(path), multipleFile.getValue(), false); } } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("file", f_in); inputMap.add("sequence", sequence); inputMap.add("format", format); @@ -85,14 +92,12 @@ public class SaveSequence extends Plugin implements SequenceBlock, PluginLibrary } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/images/AddImage.java b/src/main/java/plugins/tprovoost/sequenceblocks/images/AddImage.java index 35c88c4382df3f77107de3bb9941afcc29644ffd..bddbd90da03b32b6ab13e0eb32a32a7c07997dbe 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/images/AddImage.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/images/AddImage.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.tprovoost.sequenceblocks.images; import icy.image.IcyBufferedImage; @@ -14,39 +32,34 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Add an image to the Sequence. - * + * * @author thomasprovoost */ -public class AddImage extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ - final protected Var<IcyBufferedImage> in = new Var<IcyBufferedImage>("Image", IcyBufferedImage.class); +public class AddImage extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { + final protected Var<IcyBufferedImage> in = new Var<>("Image", IcyBufferedImage.class); final protected VarSequence varSeq = new VarSequence("Sequence", null); @Override - public void run() - { - Sequence s = varSeq.getValue(); + public void run() { + final Sequence s = varSeq.getValue(); if (s == null) throw new VarException(varSeq, "Input sequence is null."); s.addImage(in.getValue()); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", varSeq); inputMap.add("image", in); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/images/AsImageArray.java b/src/main/java/plugins/tprovoost/sequenceblocks/images/AsImageArray.java index 6179b1a66f700887799fc1cf7dab0f8cc0468865..a9d5193aa7784864c368c4a323aa60f01a992e52 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/images/AsImageArray.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/images/AsImageArray.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.tprovoost.sequenceblocks.images; import icy.image.IcyBufferedImage; @@ -14,38 +32,33 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Returns all images from the Sequence as an image array. - * + * * @author thomasprovoost */ -public class AsImageArray extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ - final protected VarArray<IcyBufferedImage> out = new VarArray<IcyBufferedImage>("Image array", IcyBufferedImage[].class, null); +public class AsImageArray extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { + final protected VarArray<IcyBufferedImage> out = new VarArray<>("Image array", IcyBufferedImage[].class, null); final protected VarSequence varSeq = new VarSequence("Sequence", null); @Override - public void run() - { - Sequence s = varSeq.getValue(); + public void run() { + final Sequence s = varSeq.getValue(); if (s == null) throw new VarException(varSeq, "Input sequence is null."); out.setValue(s.getAllImage().toArray(new IcyBufferedImage[0])); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", varSeq); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("image array", out); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/images/GetImage.java b/src/main/java/plugins/tprovoost/sequenceblocks/images/GetImage.java index 748afec03790b1bf400c205071f10a4999cf8aea..71c07759cd20599ca777efb502a1c307b3d215cf 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/images/GetImage.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/images/GetImage.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.tprovoost.sequenceblocks.images; import icy.image.IcyBufferedImage; @@ -15,42 +33,37 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Get the image at the given [T,Z] position from the Sequence. - * + * * @author thomasprovoost */ -public class GetImage extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class GetImage extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { final protected VarSequence varSeq = new VarSequence("Sequence", null); final protected VarInteger imgIdxT = new VarInteger("T", -1); final protected VarInteger imgIdxZ = new VarInteger("Z", -1); - final protected Var<IcyBufferedImage> out = new Var<IcyBufferedImage>("out", IcyBufferedImage.class); + final protected Var<IcyBufferedImage> out = new Var<>("out", IcyBufferedImage.class); @Override - public void run() - { - Sequence s = varSeq.getValue(); + public void run() { + final Sequence s = varSeq.getValue(); if (s == null) throw new VarException(varSeq, "Input sequence is null."); - out.setValue(s.getImage(imgIdxT.getValue().intValue(), imgIdxZ.getValue().intValue())); + out.setValue(s.getImage(imgIdxT.getValue(), imgIdxZ.getValue())); } @Override - public void declareInput(final VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", varSeq); inputMap.add("Idx T", imgIdxT); inputMap.add("Idx Z", imgIdxZ); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("out", out); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/images/RemoveImage.java b/src/main/java/plugins/tprovoost/sequenceblocks/images/RemoveImage.java index 1380a864c2f5bab815ef5cb69c66b4ff11c2d6a9..ff67393be862744516d71d4a47021d7fde6b3bf1 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/images/RemoveImage.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/images/RemoveImage.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.tprovoost.sequenceblocks.images; import icy.plugin.abstract_.Plugin; @@ -13,42 +31,37 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Remove an image from the Sequence. - * + * * @author thomasprovoost */ -public class RemoveImage extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class RemoveImage extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { VarSequence varSeq = new VarSequence("Sequence", null); VarInteger imgIdxT = new VarInteger("T", 0); VarInteger imgIdxZ = new VarInteger("Z", 0); @Override - public void run() - { - Sequence s = varSeq.getValue(); + public void run() { + final Sequence s = varSeq.getValue(); if (s == null) throw new VarException(varSeq, "Input sequence is null !"); - s.removeImage(imgIdxT.getValue().intValue(), imgIdxZ.getValue().intValue()); + s.removeImage(imgIdxT.getValue(), imgIdxZ.getValue()); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", varSeq); inputMap.add("Idx T", imgIdxT); inputMap.add("Idx Z", imgIdxZ); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/images/SetImage.java b/src/main/java/plugins/tprovoost/sequenceblocks/images/SetImage.java index b185d7d1c243fcdf156c856ddf008bf5968a3ee0..433321bcaf043c5737a74f683bd9e80e3353f47c 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/images/SetImage.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/images/SetImage.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.tprovoost.sequenceblocks.images; import icy.image.IcyBufferedImage; @@ -15,28 +33,25 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Set an image at the given [T,Z] position from the Sequence. - * + * * @author thomasprovoost */ -public class SetImage extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ - Var<IcyBufferedImage> in = new Var<IcyBufferedImage>("Image", IcyBufferedImage.class); +public class SetImage extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { + Var<IcyBufferedImage> in = new Var<>("Image", IcyBufferedImage.class); VarSequence varSeq = new VarSequence("Sequence", null); VarInteger imgIdxT = new VarInteger("T", 0); VarInteger imgIdxZ = new VarInteger("Z", 0); @Override - public void run() - { - Sequence s = varSeq.getValue(); + public void run() { + final Sequence s = varSeq.getValue(); if (s == null) throw new VarException(varSeq, "Input sequence is null."); - s.setImage(imgIdxT.getValue().intValue(), imgIdxZ.getValue().intValue(), in.getValue()); + s.setImage(imgIdxT.getValue(), imgIdxZ.getValue(), in.getValue()); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", varSeq); inputMap.add("image", in); inputMap.add("Idx T", imgIdxT); @@ -44,14 +59,12 @@ public class SetImage extends Plugin implements SequenceBlock, PluginLibrary, Pl } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/importer/PositionedSequenceFileImporter.java b/src/main/java/plugins/tprovoost/sequenceblocks/importer/PositionedSequenceFileImporter.java index 946af7486e324c2f8213daf9b19143097fc10af7..3485794953ec3dde2d557d494811df2474abe805 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/importer/PositionedSequenceFileImporter.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/importer/PositionedSequenceFileImporter.java @@ -1,24 +1,38 @@ -/** - * +/* + * 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.tprovoost.sequenceblocks.importer; -import java.awt.Rectangle; -import java.io.IOException; +package plugins.tprovoost.sequenceblocks.importer; import icy.common.exception.UnsupportedFormatException; import icy.file.SequenceFileImporter; import icy.sequence.MetaDataUtil; import ome.xml.meta.OMEXMLMetadata; +import java.awt.*; +import java.io.IOException; + /** * This class allow to use a {@link SequenceFileImporter} while storing a current position information to make its usage * more convenient with Protocols. - * + * * @author Stephane */ -public class PositionedSequenceFileImporter -{ +public class PositionedSequenceFileImporter { public SequenceFileImporter importer; protected OMEXMLMetadata metadata; public int s; @@ -27,9 +41,7 @@ public class PositionedSequenceFileImporter public int c; public Rectangle xyRegion; - public PositionedSequenceFileImporter(SequenceFileImporter importer, OMEXMLMetadata metadata, int s, int t, int z, - int c, Rectangle xyRegion) - { + public PositionedSequenceFileImporter(final SequenceFileImporter importer, final OMEXMLMetadata metadata, final int s, final int t, final int z, final int c, final Rectangle xyRegion) { super(); this.importer = importer; @@ -41,22 +53,25 @@ public class PositionedSequenceFileImporter this.c = c; } - public PositionedSequenceFileImporter(SequenceFileImporter importer) - { + public PositionedSequenceFileImporter(final SequenceFileImporter importer) { this(importer, null, -1, -1, -1, -1, null); } - public PositionedSequenceFileImporter(PositionedSequenceFileImporter positionedImporter) - { - this(positionedImporter.importer, positionedImporter.metadata, positionedImporter.s, positionedImporter.t, - positionedImporter.z, positionedImporter.c, positionedImporter.xyRegion); + public PositionedSequenceFileImporter(final PositionedSequenceFileImporter positionedImporter) { + this( + positionedImporter.importer, + positionedImporter.metadata, + positionedImporter.s, + positionedImporter.t, + positionedImporter.z, + positionedImporter.c, + positionedImporter.xyRegion + ); } - public OMEXMLMetadata getMetadata() throws UnsupportedFormatException, IOException, InterruptedException - { + public OMEXMLMetadata getMetadata() throws UnsupportedFormatException, IOException, InterruptedException { // not yet defined --> take it from importer if possible - if ((metadata == null) && (importer.getOpened() != null)) - { + if ((metadata == null) && (importer.getOpened() != null)) { metadata = importer.getOMEXMLMetaData(); // clean the metadata MetaDataUtil.clean(metadata); @@ -66,8 +81,7 @@ public class PositionedSequenceFileImporter } @Override - public String toString() - { + public String toString() { String result; if (importer != null) diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterClose.java b/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterClose.java index ccaa55b117d14f8adc510e572f5945f6e7bae6e3..57ef46635c29707112c2dea82b01f6e1e0c3fc85 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterClose.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterClose.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.tprovoost.sequenceblocks.importer; import icy.plugin.abstract_.Plugin; @@ -11,53 +29,45 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Block to close currently opened SequenceFileImporter. - * + * * @author Stephane */ -public class SequenceFileImporterClose extends Plugin implements IOBlock, PluginLibrary, PluginBundled -{ +public class SequenceFileImporterClose extends Plugin implements IOBlock, PluginLibrary, PluginBundled { final protected Var<PositionedSequenceFileImporter> importer; - public SequenceFileImporterClose() - { + public SequenceFileImporterClose() { super(); - importer = new Var<PositionedSequenceFileImporter>("Importer", PositionedSequenceFileImporter.class); + importer = new Var<>("Importer", PositionedSequenceFileImporter.class); } @Override - public void run() - { + public void run() { final PositionedSequenceFileImporter pi = importer.getValue(); if (pi == null) throw new VarException(importer, "Importer is null !"); - try - { + try { pi.importer.close(); } - catch (Exception e) - { + catch (final Exception e) { throw new VarException(importer, e.getMessage()); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("importer", importer); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterGetImage.java b/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterGetImage.java index 20f07dcdf0813d4c0bed50f408b7d4c04bb1a61d..dbfbc9bb48bb6efc835de65c121e05625511a120 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterGetImage.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterGetImage.java @@ -1,6 +1,22 @@ -package plugins.tprovoost.sequenceblocks.importer; +/* + * 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.Rectangle; +package plugins.tprovoost.sequenceblocks.importer; import icy.file.SequenceFileImporter; import icy.image.IcyBufferedImage; @@ -16,13 +32,14 @@ import plugins.adufour.vars.lang.VarROIArray; import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.SequenceBlocks; +import java.awt.*; + /** * Block to returns an image from the given parameters and opened SequenceFileImporter. - * + * * @author Stephane */ -public class SequenceFileImporterGetImage extends Plugin implements IOBlock, PluginLibrary, PluginBundled -{ +public class SequenceFileImporterGetImage extends Plugin implements IOBlock, PluginLibrary, PluginBundled { final protected Var<PositionedSequenceFileImporter> importer; final protected VarInteger series; final protected VarInteger resolution; @@ -33,11 +50,10 @@ public class SequenceFileImporterGetImage extends Plugin implements IOBlock, Plu final protected Var<IcyBufferedImage> image; - public SequenceFileImporterGetImage() - { + public SequenceFileImporterGetImage() { super(); - importer = new Var<PositionedSequenceFileImporter>("Importer", PositionedSequenceFileImporter.class); + importer = new Var<>("Importer", PositionedSequenceFileImporter.class); series = new VarInteger("Series", -1); resolution = new VarInteger("Resolution (0=full, 1=1/2, ..)", 0); region = new VarROIArray("XY region (ROI)", null); @@ -45,12 +61,11 @@ public class SequenceFileImporterGetImage extends Plugin implements IOBlock, Plu tIndex = new VarInteger("T (frame) index", -1); cIndex = new VarInteger("C (channel) index", -1); - image = new Var<IcyBufferedImage>("Image", IcyBufferedImage.class); + image = new Var<>("Image", IcyBufferedImage.class); } @Override - public void run() - { + public void run() { final PositionedSequenceFileImporter pi = importer.getValue(); if (pi == null) @@ -61,13 +76,13 @@ public class SequenceFileImporterGetImage extends Plugin implements IOBlock, Plu if (imp.getOpened() == null) throw new VarException(importer, "Importer is not opened !"); - final int res = resolution.getValue().intValue(); + final int res = resolution.getValue(); final ROI[] rois = region.getValue(); - int s = series.getValue().intValue(); - int z = zIndex.getValue().intValue(); - int t = tIndex.getValue().intValue(); - int c = cIndex.getValue().intValue(); + int s = series.getValue(); + int z = zIndex.getValue(); + int t = tIndex.getValue(); + int c = cIndex.getValue(); Rectangle rect = ((rois != null) && (rois.length > 0)) ? rois[0].getBounds5D().toRectangle2D().getBounds() : null; @@ -82,24 +97,21 @@ public class SequenceFileImporterGetImage extends Plugin implements IOBlock, Plu c = pi.c; if ((rect == null) && (pi.xyRegion != null)) rect = pi.xyRegion; - + // still undefined ? --> set default value for series if (s == -1) - s = 0; + s = 0; - try - { + try { image.setValue(imp.getImage(s, res, rect, z, t, c)); } - catch (Exception e) - { + catch (final Exception e) { throw new VarException(importer, e.getMessage()); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("importer", importer); inputMap.add("series", series); inputMap.add("resolution", resolution); @@ -110,14 +122,12 @@ public class SequenceFileImporterGetImage extends Plugin implements IOBlock, Plu } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("image", image); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterGetMetadata.java b/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterGetMetadata.java index cb20523d043a5223b1b18d31e160d73aad35d1f7..06f928046d26fd45a97402fc70520609dd6e6f31 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterGetMetadata.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterGetMetadata.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.tprovoost.sequenceblocks.importer; import icy.file.SequenceFileImporter; @@ -16,28 +34,25 @@ import plugins.tprovoost.sequenceblocks.infos.ReadMetadata; /** * Block to returns the metadata from the specified opened SequenceFileImporter. - * - * @see ReadMetadata + * * @author Stephane + * @see ReadMetadata */ -public class SequenceFileImporterGetMetadata extends Plugin implements IOBlock, PluginLibrary, PluginBundled -{ +public class SequenceFileImporterGetMetadata extends Plugin implements IOBlock, PluginLibrary, PluginBundled { final protected Var<PositionedSequenceFileImporter> importer; final protected Var<OMEXMLMetadata> metadata; final protected VarInteger numSeries; - public SequenceFileImporterGetMetadata() - { + public SequenceFileImporterGetMetadata() { super(); - - importer = new Var<PositionedSequenceFileImporter>("Importer", PositionedSequenceFileImporter.class); - metadata = new Var<OMEXMLMetadata>("Metadata", OMEXMLMetadata.class); + + importer = new Var<>("Importer", PositionedSequenceFileImporter.class); + metadata = new Var<>("Metadata", OMEXMLMetadata.class); numSeries = new VarInteger("Series number", 1); } @Override - public void run() - { + public void run() { final PositionedSequenceFileImporter pi = importer.getValue(); if (pi == null) @@ -48,37 +63,32 @@ public class SequenceFileImporterGetMetadata extends Plugin implements IOBlock, if (imp.getOpened() == null) throw new VarException(importer, "Importer is not opened !"); - try - { + try { final OMEXMLMetadata meta = imp.getOMEXMLMetaData(); metadata.setValue(meta); if (meta != null) - numSeries.setValue(Integer.valueOf(MetaDataUtil.getNumSeries(meta))); + numSeries.setValue(MetaDataUtil.getNumSeries(meta)); } - catch (Exception e) - { + catch (final Exception e) { throw new VarException(importer, e.getMessage()); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("importer", importer); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("metadata", metadata); outputMap.add("numSerie", numSeries); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterGetThumbnail.java b/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterGetThumbnail.java index 7303276842548ded54afe8d661314495a7c26825..a8057ce53dc0ef1745b106109e7bf341c507841e 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterGetThumbnail.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterGetThumbnail.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.tprovoost.sequenceblocks.importer; import icy.file.SequenceFileImporter; @@ -14,27 +32,24 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Block to returns a thumbnail from the specified opened SequenceFileImporter. - * + * * @author Stephane */ -public class SequenceFileImporterGetThumbnail extends Plugin implements IOBlock, PluginLibrary, PluginBundled -{ +public class SequenceFileImporterGetThumbnail extends Plugin implements IOBlock, PluginLibrary, PluginBundled { final protected Var<PositionedSequenceFileImporter> importer; final protected VarInteger series; final protected Var<IcyBufferedImage> thumbnail; - public SequenceFileImporterGetThumbnail() - { + public SequenceFileImporterGetThumbnail() { super(); - importer = new Var<PositionedSequenceFileImporter>("Importer", PositionedSequenceFileImporter.class); + importer = new Var<>("Importer", PositionedSequenceFileImporter.class); series = new VarInteger("Series", 0); - thumbnail = new Var<IcyBufferedImage>("Thumbnail", IcyBufferedImage.class); + thumbnail = new Var<>("Thumbnail", IcyBufferedImage.class); } @Override - public void run() - { + public void run() { final PositionedSequenceFileImporter pi = importer.getValue(); if (pi == null) @@ -45,34 +60,29 @@ public class SequenceFileImporterGetThumbnail extends Plugin implements IOBlock, if (imp.getOpened() == null) throw new VarException(importer, "Importer is not opened !"); - final int s = series.getValue().intValue(); + final int s = series.getValue(); - try - { + try { thumbnail.setValue(imp.getThumbnail(s)); } - catch (Exception e) - { + catch (final Exception e) { throw new VarException(importer, e.getMessage()); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("importer", importer); inputMap.add("series", series); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("thumbnail", thumbnail); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterGetTileSize.java b/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterGetTileSize.java index 7fa5e34a9b7ac14f519ce2b3e907c26fe8879d71..3d7f3c9f9a0f8ef754d8e367f6230b433dfc4955 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterGetTileSize.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterGetTileSize.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.tprovoost.sequenceblocks.importer; import icy.file.SequenceFileImporter; @@ -12,30 +30,27 @@ import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** - * Block to returns the optimal tile size for region reading from the specified opened SequenceFileImporter. - * + * Block to returns the optimal tile size for region reading from the specified opened SequenceFileImporter. + * * @author Stephane */ -public class SequenceFileImporterGetTileSize extends Plugin implements IOBlock, PluginLibrary, PluginBundled -{ +public class SequenceFileImporterGetTileSize extends Plugin implements IOBlock, PluginLibrary, PluginBundled { final protected Var<PositionedSequenceFileImporter> importer; final protected VarInteger series; final protected VarInteger tileW; final protected VarInteger tileH; - public SequenceFileImporterGetTileSize() - { + public SequenceFileImporterGetTileSize() { super(); - importer = new Var<PositionedSequenceFileImporter>("Importer", PositionedSequenceFileImporter.class); + importer = new Var<>("Importer", PositionedSequenceFileImporter.class); series = new VarInteger("Series", 0); tileW = new VarInteger("Tile width", 0); tileH = new VarInteger("Tile height", 0); } @Override - public void run() - { + public void run() { final PositionedSequenceFileImporter pi = importer.getValue(); if (pi == null) @@ -45,37 +60,32 @@ public class SequenceFileImporterGetTileSize extends Plugin implements IOBlock, if (imp.getOpened() == null) throw new VarException(importer, "Importer is not opened !"); - - final int s = series.getValue().intValue(); - try - { - tileW.setValue(Integer.valueOf(imp.getTileWidth(s))); - tileH.setValue(Integer.valueOf(imp.getTileHeight(s))); + final int s = series.getValue(); + + try { + tileW.setValue(imp.getTileWidth(s)); + tileH.setValue(imp.getTileHeight(s)); } - catch (Exception e) - { + catch (final Exception e) { throw new VarException(importer, e.getMessage()); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("importer", importer); inputMap.add("series", series); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("tileW", tileW); outputMap.add("tileH", tileH); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterLoadSequence.java b/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterLoadSequence.java index 666f65cc710b68cabe97b37fd1ecaaf4b2c604b5..9a8b57e45fdb435c67c88cac34b2169c989dde9b 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterLoadSequence.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterLoadSequence.java @@ -1,6 +1,22 @@ -package plugins.tprovoost.sequenceblocks.importer; +/* + * 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.Rectangle; +package plugins.tprovoost.sequenceblocks.importer; import icy.file.Loader; import icy.file.SequenceFileImporter; @@ -18,13 +34,14 @@ import plugins.adufour.vars.lang.VarSequence; import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.SequenceBlocks; +import java.awt.*; + /** * Block to returns a Sequence from the given parameters and opened SequenceFileImporter. - * + * * @author Stephane */ -public class SequenceFileImporterLoadSequence extends Plugin implements IOBlock, PluginLibrary, PluginBundled -{ +public class SequenceFileImporterLoadSequence extends Plugin implements IOBlock, PluginLibrary, PluginBundled { final protected Var<PositionedSequenceFileImporter> importer; final protected VarInteger series; final protected VarInteger resolution; @@ -37,11 +54,10 @@ public class SequenceFileImporterLoadSequence extends Plugin implements IOBlock, final protected VarSequence sequence; - public SequenceFileImporterLoadSequence() - { + public SequenceFileImporterLoadSequence() { super(); - importer = new Var<PositionedSequenceFileImporter>("Importer", PositionedSequenceFileImporter.class); + importer = new Var<>("Importer", PositionedSequenceFileImporter.class); series = new VarInteger("Series", -1); resolution = new VarInteger("Resolution (0=full, 1=1/2, ..)", 0); @@ -56,8 +72,7 @@ public class SequenceFileImporterLoadSequence extends Plugin implements IOBlock, } @Override - public void run() - { + public void run() { final PositionedSequenceFileImporter pi = importer.getValue(); if (pi == null) @@ -68,28 +83,25 @@ public class SequenceFileImporterLoadSequence extends Plugin implements IOBlock, if (imp.getOpened() == null) throw new VarException(importer, "Importer is not opened !"); - final int res = resolution.getValue().intValue(); + final int res = resolution.getValue(); final ROI[] rois = region.getValue(); - int s = series.getValue().intValue(); - int minZ = minZIndex.getValue().intValue(); - int maxZ = maxZIndex.getValue().intValue(); - int minT = minTIndex.getValue().intValue(); - int maxT = maxTIndex.getValue().intValue(); - int c = cIndex.getValue().intValue(); - Rectangle rect = ((rois != null) && (rois.length > 0)) ? rois[0].getBounds5D().toRectangle2D().getBounds() - : null; + int s = series.getValue(); + int minZ = minZIndex.getValue(); + int maxZ = maxZIndex.getValue(); + int minT = minTIndex.getValue(); + int maxT = maxTIndex.getValue(); + int c = cIndex.getValue(); + Rectangle rect = ((rois != null) && (rois.length > 0)) ? rois[0].getBounds5D().toRectangle2D().getBounds() : null; // undefined values ? use internal position if any defined if ((s == -1) && (pi.s != -1)) s = pi.s; - if ((minZ == -1) && (maxZ == -1) && (pi.z != -1)) - { + if ((minZ == -1) && (maxZ == -1) && (pi.z != -1)) { minZ = pi.z; maxZ = pi.z; } - if ((minT == -1) && (maxT == -1) && (pi.t != -1)) - { + if ((minT == -1) && (maxT == -1) && (pi.t != -1)) { minT = pi.t; maxT = pi.t; } @@ -97,28 +109,24 @@ public class SequenceFileImporterLoadSequence extends Plugin implements IOBlock, c = pi.c; if ((rect == null) && (pi.xyRegion != null)) rect = pi.xyRegion; - + // still undefined ? --> set default value for series if (s == -1) s = 0; - try - { - + try { // get metadata final OMEXMLMetadata meta = pi.getMetadata(); sequence.setValue(Loader.internalLoadSingle(imp, meta, s, res, rect, minZ, maxZ, minT, maxT, c, false, null)); } - catch (Exception e) - { + catch (final Exception e) { throw new VarException(importer, e.getMessage()); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("importer", importer); inputMap.add("series", series); inputMap.add("resolution", resolution); @@ -131,14 +139,12 @@ public class SequenceFileImporterLoadSequence extends Plugin implements IOBlock, } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("sequence", sequence); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterOpen.java b/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterOpen.java index 720b9c63b4d5c097cfbe28a86e91cb24b2bb62cf..374b4af5d78c1e0f970a4a13502f9700edea8ce7 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterOpen.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/importer/SequenceFileImporterOpen.java @@ -1,10 +1,22 @@ -package plugins.tprovoost.sequenceblocks.importer; +/* + * 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.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +package plugins.tprovoost.sequenceblocks.importer; import icy.file.Loader; import icy.file.SequenceFileImporter; @@ -22,13 +34,18 @@ import plugins.adufour.vars.lang.VarString; import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.SequenceBlocks; +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * Block to open a file with a given SequenceFileImporter. - * + * * @author Stephane */ -public class SequenceFileImporterOpen extends Plugin implements IOBlock, PluginLibrary, PluginBundled -{ +public class SequenceFileImporterOpen extends Plugin implements IOBlock, PluginLibrary, PluginBundled { final static String ID_AUTO = "Automatic"; final protected VarString importerName; @@ -39,59 +56,50 @@ public class SequenceFileImporterOpen extends Plugin implements IOBlock, PluginL // internal final protected Map<String, SequenceFileImporter> importersMap; - public SequenceFileImporterOpen() - { + public SequenceFileImporterOpen() { super(); - final List<String> importersName = new ArrayList<String>(); + final List<String> importersName = new ArrayList<>(); final List<SequenceFileImporter> importers = Loader.getSequenceFileImporters(); importerName = new VarString("Select importer", "", 1 + importers.size()); // build importer map - importersMap = new HashMap<String, SequenceFileImporter>(); + importersMap = new HashMap<>(); // automatic selection importersName.add(ID_AUTO); importersMap.put(ID_AUTO, null); - for (SequenceFileImporter importer : importers) - { + for (final SequenceFileImporter importer : importers) { String className = ClassUtil.getBaseClassName(importer.getClass().getName()); final int ind = className.lastIndexOf('.'); // just get final class name without package name if (ind > -1) - className = className.substring(ind + 1, className.length()); + className = className.substring(ind + 1); importersName.add(className); importersMap.put(className, importer); } // initialize importer selector field - importerName.setDefaultEditorModel(new ValueSelectionModel<String>( - importersName.toArray(new String[importersName.size()]), importersName.get(0), false)); + importerName.setDefaultEditorModel(new ValueSelectionModel<>(importersName.toArray(new String[0]), importersName.get(0), false)); - importer = new Var<PositionedSequenceFileImporter>("Importer", PositionedSequenceFileImporter.class); - file = new VarMutable("File", null) - { - @SuppressWarnings("rawtypes") + importer = new Var<>("Importer", PositionedSequenceFileImporter.class); + file = new VarMutable("File", null) { @Override - public boolean isAssignableFrom(Var source) - { + public boolean isAssignableFrom(final Var source) { return (String.class == source.getType()) || (File.class == source.getType()); } }; flag = new VarInteger("Flag", 0); } - @SuppressWarnings("resource") @Override - public void run() - { + public void run() { final String path; final Object obj = file.getValue(); - if (obj != null) - { + if (obj != null) { if (obj instanceof String) path = (String) obj; else @@ -114,34 +122,29 @@ public class SequenceFileImporterOpen extends Plugin implements IOBlock, PluginL // set importer importer.setValue(new PositionedSequenceFileImporter(imp)); - try - { + try { // try to open the importer - imp.open(path, flag.getValue().intValue()); + imp.open(path, flag.getValue()); } - catch (Exception e) - { + catch (final Exception e) { throw new VarException(importer, e.getMessage()); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("name", importerName); inputMap.add("file", file); inputMap.add("flag", flag); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("importer", importer); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/CreateLinearColormap.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/CreateLinearColormap.java index 7616d670b2551fcd5204130fdfdbf22202e0562b..5251a07d237039e146d41278e8453cbefad2d089 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/CreateLinearColormap.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/CreateLinearColormap.java @@ -1,48 +1,60 @@ +/* + * 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.tprovoost.sequenceblocks.infos; import icy.image.colormap.LinearColorMap; import icy.plugin.abstract_.Plugin; import icy.plugin.interface_.PluginBundled; - -import java.awt.Color; - import plugins.adufour.blocks.tools.sequence.SequenceBlock; import plugins.adufour.blocks.util.VarList; import plugins.adufour.vars.lang.VarColor; import plugins.tprovoost.sequenceblocks.SequenceBlocks; +import java.awt.*; + /** * Block to create a linear colormap from a color value - * + * * @author Stephane * @see SetColormap */ -public class CreateLinearColormap extends Plugin implements SequenceBlock, PluginBundled -{ - private VarColor color = new VarColor("Color", Color.white); - private VarColormap colormap = new VarColormap("Color map", LinearColorMap.gray_); +public class CreateLinearColormap extends Plugin implements SequenceBlock, PluginBundled { + private final VarColor color = new VarColor("Color", Color.white); + private final VarColormap colormap = new VarColormap("Color map", LinearColorMap.gray_); @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("input", color); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("output", colormap); } @Override - public void run() - { + public void run() { colormap.setValue(new LinearColorMap("color", color.getValue())); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/Dimensions.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/Dimensions.java index 3dbc2dff82153ccc62d3547281d0e248b8168d99..97d49b19c0df68cabe1e4dde513312dd3f64d10f 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/Dimensions.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/Dimensions.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.tprovoost.sequenceblocks.infos; import icy.plugin.abstract_.Plugin; @@ -14,8 +32,7 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * @author thomasprovoost */ -public class Dimensions extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class Dimensions extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { VarSequence varSeq = new VarSequence("Sequence", null); VarInteger sizeZ = new VarInteger("Size Z", 1); VarInteger sizeT = new VarInteger("Size T", 1); @@ -24,28 +41,25 @@ public class Dimensions extends Plugin implements SequenceBlock, PluginLibrary, VarInteger height = new VarInteger("Height", 1); @Override - public void run() - { - Sequence s = varSeq.getValue(); + public void run() { + final Sequence s = varSeq.getValue(); if (s == null) throw new VarException(varSeq, "Input sequence is null."); - - width.setValue(Integer.valueOf(s.getWidth())); - height.setValue(Integer.valueOf(s.getHeight())); - sizeC.setValue(Integer.valueOf(s.getSizeC())); - sizeZ.setValue(Integer.valueOf(s.getSizeZ())); - sizeT.setValue(Integer.valueOf(s.getSizeT())); + + width.setValue(s.getWidth()); + height.setValue(s.getHeight()); + sizeC.setValue(s.getSizeC()); + sizeZ.setValue(s.getSizeZ()); + sizeT.setValue(s.getSizeT()); } @Override - public void declareInput(final VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", varSeq); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("width", width); outputMap.add("height", height); outputMap.add("size C", sizeC); @@ -54,8 +68,7 @@ public class Dimensions extends Plugin implements SequenceBlock, PluginLibrary, } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/EzVarColormap.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/EzVarColormap.java index a810bec3715498df8d8c358c9a45be7192538256..99c314b1060eff0592e298ee4a717141f6c18730 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/EzVarColormap.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/EzVarColormap.java @@ -1,20 +1,35 @@ +/* + * 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.tprovoost.sequenceblocks.infos; import icy.image.colormap.IcyColorMap; import plugins.adufour.ezplug.EzVar; import plugins.tprovoost.sequenceblocks.infos.VarColormap.ColormapSelectionModel; -public class EzVarColormap extends EzVar<IcyColorMap> -{ +public class EzVarColormap extends EzVar<IcyColorMap> { /** * Constructs a new variable that handles colormap data. - * - * @param varName - * the parameter name + * + * @param varName the parameter name * @param defaultValue IcyColorMap */ - public EzVarColormap(String varName, IcyColorMap defaultValue) - { + public EzVarColormap(final String varName, final IcyColorMap defaultValue) { super(new VarColormap(varName, defaultValue), new ColormapSelectionModel()); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetChannelName.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetChannelName.java index ba5f734027cccd8e2ab694f83b4c793d471de962..322a46f9bba281001b4c0b4b30df6cc7b0f9d39e 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetChannelName.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetChannelName.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.tprovoost.sequenceblocks.infos; import icy.plugin.abstract_.Plugin; @@ -14,20 +32,18 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * @author thomasprovoost */ -public class GetChannelName extends Plugin implements SequenceBlock, PluginBundled -{ - private VarSequence varSequence = new VarSequence("Sequence", null); - private VarInteger varIdx = new VarInteger("Channel", 0); - private VarString varName = new VarString("Name", ""); +public class GetChannelName extends Plugin implements SequenceBlock, PluginBundled { + private final VarSequence varSequence = new VarSequence("Sequence", null); + private final VarInteger varIdx = new VarInteger("Channel", 0); + private final VarString varName = new VarString("Name", ""); @Override - public void run() - { - Sequence s = varSequence.getValue(); + public void run() { + final Sequence s = varSequence.getValue(); if (s == null) throw new VarException(varSequence, "Sequence is null"); - int index = varIdx.getValue().intValue(); + final int index = varIdx.getValue(); if (index < 0 || index >= s.getSizeC()) throw new VarException(varIdx, "Wrong channel index."); @@ -35,21 +51,18 @@ public class GetChannelName extends Plugin implements SequenceBlock, PluginBundl } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", varSequence); inputMap.add("index", varIdx); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("name", varName); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetChannelsName.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetChannelsName.java index 5506b01bcf956881edec07454d70287f18e01ab8..2daceba14d5823cd8e6b4a4afeb6cb4c437bcb42 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetChannelsName.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetChannelsName.java @@ -1,12 +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.tprovoost.sequenceblocks.infos; import icy.plugin.abstract_.Plugin; import icy.plugin.interface_.PluginBundled; import icy.sequence.Sequence; - -import java.util.ArrayList; -import java.util.List; - import plugins.adufour.blocks.tools.sequence.SequenceBlock; import plugins.adufour.blocks.util.VarList; import plugins.adufour.vars.lang.VarArray; @@ -14,48 +28,46 @@ import plugins.adufour.vars.lang.VarSequence; import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.SequenceBlocks; +import java.util.ArrayList; +import java.util.List; + /** * Block to retrieve all channels name from a given sequence - * + * * @author Stephane * @see GetChannelName * @see SetChannelsName */ -public class GetChannelsName extends Plugin implements SequenceBlock, PluginBundled -{ - private VarSequence varSequence = new VarSequence("Sequence", null); - private VarArray<String> varNames = new VarArray<String>("Names", String[].class, new String[0]); +public class GetChannelsName extends Plugin implements SequenceBlock, PluginBundled { + private final VarSequence varSequence = new VarSequence("Sequence", null); + private final VarArray<String> varNames = new VarArray<>("Names", String[].class, new String[0]); @Override - public void run() - { + public void run() { final Sequence s = varSequence.getValue(); if (s == null) throw new VarException(varSequence, "Sequence is null"); - final List<String> names = new ArrayList<String>(); + final List<String> names = new ArrayList<>(); for (int c = 0; c < s.getSizeC(); c++) names.add(s.getChannelName(c)); - varNames.setValue(names.toArray(new String[names.size()])); + varNames.setValue(names.toArray(new String[0])); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", varSequence); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("names", varNames); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetColormap.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetColormap.java index 98a564d4f6d2b9ffe6071199647b7e6ed2a6c67e..95b76ad7fb71d51b4eea03da494657fb39431b56 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetColormap.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetColormap.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.tprovoost.sequenceblocks.infos; import icy.image.colormap.LinearColorMap; @@ -13,37 +31,32 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Block to retrieve a channel colormap from a given sequence - * + * * @author Stephane * @see SetColormap */ -public class GetColormap extends Plugin implements SequenceBlock, PluginBundled -{ - private VarSequence sequenceIn = new VarSequence("Sequence", null); - private VarInteger numChannel = new VarInteger("Channel", 0); - private VarColormap colormap = new VarColormap("Color map", LinearColorMap.gray_); +public class GetColormap extends Plugin implements SequenceBlock, PluginBundled { + private final VarSequence sequenceIn = new VarSequence("Sequence", null); + private final VarInteger numChannel = new VarInteger("Channel", 0); + private final VarColormap colormap = new VarColormap("Color map", LinearColorMap.gray_); @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("input", sequenceIn); inputMap.add("numChannel", numChannel); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("output", colormap); } @Override - public void run() - { + public void run() { final Sequence seq = sequenceIn.getValue(); - if (seq != null) - { - final int ch = numChannel.getValue().intValue(); + if (seq != null) { + final int ch = numChannel.getValue(); if (ch < seq.getSizeC()) colormap.setValue(seq.getColorMap(ch)); @@ -53,8 +66,7 @@ public class GetColormap extends Plugin implements SequenceBlock, PluginBundled } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetColormaps.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetColormaps.java index dcc86d74a15cb9efbce5cb6c060bcce80c2976af..3654a058032f8c28e4f9a13e3c9237f8660b1bec 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetColormaps.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetColormaps.java @@ -1,13 +1,27 @@ +/* + * 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.tprovoost.sequenceblocks.infos; import icy.image.colormap.IcyColorMap; import icy.plugin.abstract_.Plugin; import icy.plugin.interface_.PluginBundled; import icy.sequence.Sequence; - -import java.util.ArrayList; -import java.util.List; - import plugins.adufour.blocks.tools.sequence.SequenceBlock; import plugins.adufour.blocks.util.VarList; import plugins.adufour.vars.lang.VarArray; @@ -15,48 +29,45 @@ import plugins.adufour.vars.lang.VarSequence; import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.SequenceBlocks; +import java.util.ArrayList; +import java.util.List; + /** * Block to retrieve all channels colormap from a given sequence - * + * * @author Stephane * @see SetColormaps */ -public class GetColormaps extends Plugin implements SequenceBlock, PluginBundled -{ - private VarSequence sequenceIn = new VarSequence("Sequence", null); - private VarArray<IcyColorMap> colormaps = new VarArray<IcyColorMap>("Color maps", IcyColorMap[].class, - new IcyColorMap[0]); +public class GetColormaps extends Plugin implements SequenceBlock, PluginBundled { + private final VarSequence sequenceIn = new VarSequence("Sequence", null); + private final VarArray<IcyColorMap> colormaps = new VarArray<>("Color maps", IcyColorMap[].class, new IcyColorMap[0]); @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("input", sequenceIn); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("Colormaps", colormaps); } @Override - public void run() - { + public void run() { final Sequence seq = sequenceIn.getValue(); if (seq == null) throw new VarException(sequenceIn, "Sequence is null"); - final List<IcyColorMap> cms = new ArrayList<IcyColorMap>(); + final List<IcyColorMap> cms = new ArrayList<>(); for (int c = 0; c < seq.getSizeC(); c++) cms.add(seq.getColorMap(c)); - colormaps.setValue(cms.toArray(new IcyColorMap[cms.size()])); + colormaps.setValue(cms.toArray(new IcyColorMap[0])); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetDataType.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetDataType.java index d47fe2d536199705304b10a7d7c95529846b3040..283b7592f5ffe125af5634151284e7035a2196a1 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetDataType.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetDataType.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.tprovoost.sequenceblocks.infos; import icy.plugin.abstract_.Plugin; @@ -16,38 +31,33 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Returns the DataType of the Sequence object - * + * * @author Stephane */ -public class GetDataType extends Plugin implements SequenceBlock, PluginBundled -{ +public class GetDataType extends Plugin implements SequenceBlock, PluginBundled { final protected VarSequence varSequence = new VarSequence("Sequence", null); - final protected VarEnum<DataType> type = new VarEnum<DataType>("Data type", DataType.UBYTE); + final protected VarEnum<DataType> type = new VarEnum<>("Data type", DataType.UBYTE); @Override - public void run() - { - Sequence s = varSequence.getValue(); + public void run() { + final Sequence s = varSequence.getValue(); if (s == null) throw new VarException(varSequence, "Sequence is null"); type.setValue(s.getDataType_()); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", varSequence); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("type", type); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetFileName.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetFileName.java index 2bf3699ee50a8651b20df613489457db5bc6e286..0bc1e12b5ed4d49c48556bfb69c324b1156df1bb 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetFileName.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetFileName.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.tprovoost.sequenceblocks.infos; import icy.file.FileUtil; @@ -17,20 +32,18 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Returns the origin filename (from where the sequence has been loaded / saved) - * + * * @author Stephane */ -public class GetFileName extends Plugin implements SequenceBlock, PluginBundled -{ +public class GetFileName extends Plugin implements SequenceBlock, PluginBundled { final protected VarSequence varSequence = new VarSequence("Sequence", null); final protected VarString filename = new VarString("Filename", ""); final protected VarBoolean withFolder = new VarBoolean("Folder", Boolean.TRUE); final protected VarBoolean withExtension = new VarBoolean("Extension", Boolean.TRUE); @Override - public void run() - { - Sequence s = varSequence.getValue(); + public void run() { + final Sequence s = varSequence.getValue(); if (s == null) throw new VarException(varSequence, "Sequence is null"); @@ -38,32 +51,29 @@ public class GetFileName extends Plugin implements SequenceBlock, PluginBundled String result = s.getFilename(); // remove folder information ? - if (!withFolder.getValue().booleanValue()) + if (!withFolder.getValue()) result = FileUtil.getFileName(result); // remove extension ? - if (!withExtension.getValue().booleanValue()) + if (!withExtension.getValue()) result = FileUtil.setExtension(result, ""); filename.setValue(result); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", varSequence); inputMap.add("folder", withFolder); inputMap.add("extension", withExtension); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("name", filename); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } \ No newline at end of file diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetMetaData.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetMetaData.java index db267be68c5143e9f693d977ff9c822ec81b0ba7..4f51fdf9c7507ebd7f873dd42b2339ae8c53612a 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetMetaData.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetMetaData.java @@ -1,6 +1,22 @@ -package plugins.tprovoost.sequenceblocks.infos; +/* + * 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.Rectangle; +package plugins.tprovoost.sequenceblocks.infos; import icy.math.UnitUtil; import icy.plugin.abstract_.Plugin; @@ -9,24 +25,21 @@ import icy.sequence.Sequence; import ome.xml.meta.OMEXMLMetadata; import plugins.adufour.blocks.tools.sequence.SequenceBlock; import plugins.adufour.blocks.util.VarList; -import plugins.adufour.vars.lang.Var; -import plugins.adufour.vars.lang.VarDouble; -import plugins.adufour.vars.lang.VarInteger; -import plugins.adufour.vars.lang.VarSequence; -import plugins.adufour.vars.lang.VarString; +import plugins.adufour.vars.lang.*; import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.SequenceBlocks; +import java.awt.*; + /** * Block to return metadata information from a Sequence object. * - * @see ReadMetadata * @author Stephane + * @see ReadMetadata */ -public class GetMetaData extends Plugin implements SequenceBlock, PluginBundled -{ +public class GetMetaData extends Plugin implements SequenceBlock, PluginBundled { final protected VarSequence varSequence = new VarSequence("Sequence", null); - final protected Var<OMEXMLMetadata> metaData = new Var<OMEXMLMetadata>("Metadata", OMEXMLMetadata.class); + final protected Var<OMEXMLMetadata> metaData = new Var<>("Metadata", OMEXMLMetadata.class); final protected VarString name = new VarString("Name", ""); final protected VarInteger seriesIndex = new VarInteger("Series index", 0); final protected VarDouble pxSizeX = new VarDouble("Pixel Size X (" + UnitUtil.MICRO_STRING + "m)", 1d); @@ -37,7 +50,7 @@ public class GetMetaData extends Plugin implements SequenceBlock, PluginBundled final protected VarDouble positionY = new VarDouble("Position Y (" + UnitUtil.MICRO_STRING + "m)", 0d); final protected VarDouble positionZ = new VarDouble("Position Z (" + UnitUtil.MICRO_STRING + "m)", 0d); final protected VarInteger originResolution = new VarInteger("Resolution", 0); - final protected Var<Rectangle> originRegion = new Var<Rectangle>("Region", new Rectangle()); + final protected Var<Rectangle> originRegion = new Var<>("Region", new Rectangle()); final protected VarInteger originZMin = new VarInteger("Z min", -1); final protected VarInteger originZMax = new VarInteger("Z max", -1); final protected VarInteger originTMin = new VarInteger("T min", -1); @@ -45,41 +58,38 @@ public class GetMetaData extends Plugin implements SequenceBlock, PluginBundled final protected VarInteger originChannel = new VarInteger("Channel", -1); @Override - public void run() - { - Sequence s = varSequence.getValue(); + public void run() { + final Sequence s = varSequence.getValue(); if (s == null) throw new VarException(varSequence, "Sequence is null"); metaData.setValue(s.getOMEXMLMetadata()); name.setValue(s.getName()); - seriesIndex.setValue(Integer.valueOf(s.getSeries())); - pxSizeX.setValue(Double.valueOf(s.getPixelSizeX())); - pxSizeY.setValue(Double.valueOf(s.getPixelSizeY())); - pxSizeZ.setValue(Double.valueOf(s.getPixelSizeZ())); - timeIntT.setValue(Double.valueOf(s.getTimeInterval())); - positionX.setValue(Double.valueOf(s.getPositionX())); - positionY.setValue(Double.valueOf(s.getPositionY())); - positionZ.setValue(Double.valueOf(s.getPositionZ())); - originResolution.setValue(Integer.valueOf(s.getOriginResolution())); + seriesIndex.setValue(s.getSeries()); + pxSizeX.setValue(s.getPixelSizeX()); + pxSizeY.setValue(s.getPixelSizeY()); + pxSizeZ.setValue(s.getPixelSizeZ()); + timeIntT.setValue(s.getTimeInterval()); + positionX.setValue(s.getPositionX()); + positionY.setValue(s.getPositionY()); + positionZ.setValue(s.getPositionZ()); + originResolution.setValue(s.getOriginResolution()); originRegion.setValue(s.getOriginXYRegion()); - originZMin.setValue(Integer.valueOf(s.getOriginZMin())); - originZMax.setValue(Integer.valueOf(s.getOriginZMax())); - originTMin.setValue(Integer.valueOf(s.getOriginTMin())); - originTMax.setValue(Integer.valueOf(s.getOriginTMax())); - originChannel.setValue(Integer.valueOf(s.getOriginChannel())); + originZMin.setValue(s.getOriginZMin()); + originZMax.setValue(s.getOriginZMax()); + originTMin.setValue(s.getOriginTMin()); + originTMax.setValue(s.getOriginTMax()); + originChannel.setValue(s.getOriginChannel()); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", varSequence); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("metadata", metaData); outputMap.add("name", name); outputMap.add("seriesIndex", seriesIndex); @@ -100,8 +110,7 @@ public class GetMetaData extends Plugin implements SequenceBlock, PluginBundled } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetName.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetName.java index c102a40c24970e75a1bdf82c514f1955de652010..46a6ed668a47d02c3f0e82758bba2ca9e29d78dc 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetName.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetName.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.tprovoost.sequenceblocks.infos; import icy.plugin.abstract_.Plugin; @@ -12,38 +30,33 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Returns the name of the Sequence object - * + * * @author Stephane */ -public class GetName extends Plugin implements SequenceBlock, PluginBundled -{ +public class GetName extends Plugin implements SequenceBlock, PluginBundled { final protected VarSequence varSequence = new VarSequence("Sequence", null); final protected VarString name = new VarString("Name", ""); @Override - public void run() - { - Sequence s = varSequence.getValue(); + public void run() { + final Sequence s = varSequence.getValue(); if (s == null) throw new VarException(varSequence, "Sequence is null"); name.setValue(s.getName()); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", varSequence); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("name", name); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetOutputFilename.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetOutputFilename.java index 3e9deece814f71e8189f2a742ad60f668014b4b2..55e7085bb5b8d57a6eb6cf0f614dde3f5d5da1d3 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetOutputFilename.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetOutputFilename.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.tprovoost.sequenceblocks.infos; import icy.file.FileUtil; @@ -17,48 +32,43 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Returns the output filename generated from origin filename and internal partitioning information - * + * * @author Stephane */ -public class GetOutputFilename extends Plugin implements SequenceBlock, PluginBundled -{ +public class GetOutputFilename extends Plugin implements SequenceBlock, PluginBundled { final protected VarSequence varSequence = new VarSequence("Sequence", null); final protected VarString outFilename = new VarString("Output filename", ""); final protected VarBoolean withFolder = new VarBoolean("Folder", Boolean.TRUE); final protected VarBoolean withExtension = new VarBoolean("Extension", Boolean.TRUE); @Override - public void run() - { - Sequence s = varSequence.getValue(); + public void run() { + final Sequence s = varSequence.getValue(); if (s == null) throw new VarException(varSequence, "Sequence is null"); - String result = s.getOutputFilename(withExtension.getValue().booleanValue()); + String result = s.getOutputFilename(withExtension.getValue()); - if (!withFolder.getValue().booleanValue()) + if (!withFolder.getValue()) result = FileUtil.getFileName(result); outFilename.setValue(result); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", varSequence); inputMap.add("folder", withFolder); inputMap.add("extension", withExtension); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("outFilename", outFilename); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } \ No newline at end of file diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetResolution.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetResolution.java index 053d5731b8822496af7a9c34cc1ed21536f5cafc..0323af89a1984f2959f516714191c195208d60f4 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetResolution.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetResolution.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.tprovoost.sequenceblocks.infos; import icy.math.UnitUtil; @@ -14,12 +32,11 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Block to return pixel size and time interval information from a Sequence object. * + * @author Stephane * @see ReadMetadata * @see GetMetaData - * @author Stephane */ -public class GetResolution extends Plugin implements SequenceBlock, PluginBundled -{ +public class GetResolution extends Plugin implements SequenceBlock, PluginBundled { final protected VarSequence varSequence = new VarSequence("Sequence", null); final protected VarDouble pxSizeX = new VarDouble("Pixel Size X (" + UnitUtil.MICRO_STRING + "m)", 1d); final protected VarDouble pxSizeY = new VarDouble("Pixel Size Y (" + UnitUtil.MICRO_STRING + "m)", 1d); @@ -27,31 +44,26 @@ public class GetResolution extends Plugin implements SequenceBlock, PluginBundle final protected VarDouble timeIntT = new VarDouble("Time interval T (s)", 0.1d); @Override - public void run() - { - Sequence s = varSequence.getValue(); - if (s != null) - { - pxSizeX.setValue(Double.valueOf(s.getPixelSizeX())); - pxSizeY.setValue(Double.valueOf(s.getPixelSizeY())); - pxSizeZ.setValue(Double.valueOf(s.getPixelSizeZ())); - timeIntT.setValue(Double.valueOf(s.getTimeInterval())); + public void run() { + final Sequence s = varSequence.getValue(); + if (s != null) { + pxSizeX.setValue(s.getPixelSizeX()); + pxSizeY.setValue(s.getPixelSizeY()); + pxSizeZ.setValue(s.getPixelSizeZ()); + timeIntT.setValue(s.getTimeInterval()); } - else - { + else { throw new VarException(varSequence, "Sequence is null"); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", varSequence); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("Pixel Size X (" + UnitUtil.MICRO_STRING + "m)", pxSizeX); outputMap.add("Pixel Size Y (" + UnitUtil.MICRO_STRING + "m)", pxSizeY); outputMap.add("Pixel Size Z (" + UnitUtil.MICRO_STRING + "m)", pxSizeZ); @@ -59,8 +71,7 @@ public class GetResolution extends Plugin implements SequenceBlock, PluginBundle } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetRoisAsRegion.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetRoisAsRegion.java index 2ddd6e77724d7081410026336469affdf294b105..bc4a279828946ccb5d89d0c854c242a0bd7350d4 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetRoisAsRegion.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetRoisAsRegion.java @@ -1,8 +1,22 @@ -package plugins.tprovoost.sequenceblocks.infos; +/* + * 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.Rectangle; -import java.util.ArrayList; -import java.util.List; +package plugins.tprovoost.sequenceblocks.infos; import icy.plugin.abstract_.Plugin; import icy.plugin.interface_.PluginBundled; @@ -20,38 +34,39 @@ import plugins.adufour.vars.util.VarException; import plugins.kernel.roi.roi2d.ROI2DRectangle; import plugins.tprovoost.sequenceblocks.SequenceBlocks; +import java.awt.*; +import java.util.ArrayList; +import java.util.List; + /** * Block to retrieve ROI(s) from a Sequence as 2D Rectangular regions.<br> * The <i>origin resolution</i> parameter indicate if we want to rescale ROI to the original image resolution in case we * have a Sequence which represents a sub resolution of the original image. - * + * * @author Stephane */ -public class GetRoisAsRegion extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ - public static enum TypeSelection - { +public class GetRoisAsRegion extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { + public enum TypeSelection { ALL, SELECTED - }; + } final protected VarSequence inputSequence = new VarSequence("Sequence", null); - final protected VarEnum<TypeSelection> type = new VarEnum<TypeSelection>("ROI(s) to get", TypeSelection.ALL); + final protected VarEnum<TypeSelection> type = new VarEnum<>("ROI(s) to get", TypeSelection.ALL); final protected VarBoolean originResolution = new VarBoolean("Origin resolution", Boolean.TRUE); final protected VarROIArray regionsRois = new VarROIArray("Region ROI(s)", null); @Override - public void run() - { + public void run() { final Sequence sequence = inputSequence.getValue(); if (sequence == null) throw new VarException(inputSequence, "Input sequence is null."); final List<ROI> rois; - final List<ROI2DRectangle> result = new ArrayList<ROI2DRectangle>(); + final List<ROI2DRectangle> result = new ArrayList<>(); - switch (type.getValue()) - { + switch (type.getValue()) { default: + case ALL: rois = sequence.getROIs(); break; case SELECTED: @@ -59,11 +74,10 @@ public class GetRoisAsRegion extends Plugin implements SequenceBlock, PluginLibr break; } - final boolean scale = originResolution.getValue().booleanValue(); + final boolean scale = originResolution.getValue(); // build rectangular ROI(s) - for (ROI roi : rois) - { + for (final ROI roi : rois) { // get ROI 2D bounds Rectangle rect = roi.getBounds5D().toRectangle2D().getBounds(); @@ -75,26 +89,23 @@ public class GetRoisAsRegion extends Plugin implements SequenceBlock, PluginLibr result.add(new ROI2DRectangle(rect)); } - regionsRois.setValue(result.toArray(new ROI[result.size()])); + regionsRois.setValue(result.toArray(new ROI[0])); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", inputSequence); inputMap.add("type", type); inputMap.add("originResolution", originResolution); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("regionsRois", regionsRois); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetSequenceProperty.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetSequenceProperty.java index 278ae202f5ead8935f48ab0d9be658ad1b4893e7..65a6838243de31877df4f35ecb5db608d8e92c56 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetSequenceProperty.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/GetSequenceProperty.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.tprovoost.sequenceblocks.infos; import icy.plugin.abstract_.Plugin; @@ -29,18 +47,16 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; * <li><i>userName</i> = user who generated / acquired the dataset</li> * <li><i>virtual</i> = virtual mode enabled on the dataset</li> * </ul> - * + * * @author Stephane */ -public class GetSequenceProperty extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class GetSequenceProperty extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { protected VarSequence sequence = new VarSequence("Sequence", null); protected VarString propertyName = new VarString("Property", "name"); protected VarString value = new VarString("Value", ""); @Override - public void run() - { + public void run() { final Sequence seq = sequence.getValue(); if (seq != null) @@ -48,21 +64,18 @@ public class GetSequenceProperty extends Plugin implements SequenceBlock, Plugin } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", sequence); inputMap.add("property", propertyName); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("value", value); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/ReadMetadata.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/ReadMetadata.java index 1abdef6e9384fa2bddceb01e196bd3c8f41073f4..2ac3d0be007c6cf1ca41df853d9bb7813f934f78 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/ReadMetadata.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/ReadMetadata.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.tprovoost.sequenceblocks.infos; import icy.math.UnitUtil; @@ -18,13 +36,12 @@ import plugins.tprovoost.sequenceblocks.files.LoadMetadata; /** * Block to return main informations from a metadata object. - * - * @see LoadMetadata + * * @author Stephane + * @see LoadMetadata */ -public class ReadMetadata extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ - final protected Var<OMEXMLMetadata> metadata = new Var<OMEXMLMetadata>("Metadata", OMEXMLMetadata.class); +public class ReadMetadata extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { + final protected Var<OMEXMLMetadata> metadata = new Var<>("Metadata", OMEXMLMetadata.class); final protected VarInteger serie = new VarInteger("Series", 0); final protected VarInteger numSerie = new VarInteger("Num serie", 1); @@ -43,47 +60,43 @@ public class ReadMetadata extends Plugin implements SequenceBlock, PluginLibrary final protected VarDouble positionZ = new VarDouble("Position Z (" + UnitUtil.MICRO_STRING + "m)", 0d); @Override - public void run() - { + public void run() { final OMEXMLMetadata meta = metadata.getValue(); if (meta == null) throw new VarException(metadata, "Metadata is null !"); - final int s = serie.getValue().intValue(); + final int s = serie.getValue(); final int numS = MetaDataUtil.getNumSeries(meta); - numSerie.setValue(Integer.valueOf(numS)); + numSerie.setValue(numS); if (s >= numS) throw new VarException(serie, "Serie index must be between 0 and " + (numS - 1)); name.setValue(MetaDataUtil.getName(meta, s)); - sizeX.setValue(Integer.valueOf(MetaDataUtil.getSizeX(meta, s))); - sizeY.setValue(Integer.valueOf(MetaDataUtil.getSizeY(meta, s))); - sizeZ.setValue(Integer.valueOf(MetaDataUtil.getSizeZ(meta, s))); - sizeT.setValue(Integer.valueOf(MetaDataUtil.getSizeT(meta, s))); - sizeC.setValue(Integer.valueOf(MetaDataUtil.getSizeC(meta, s))); - pxSizeX.setValue(Double.valueOf(MetaDataUtil.getPixelSizeX(meta, s, pxSizeX.getDefaultValue().doubleValue()))); - pxSizeY.setValue(Double.valueOf(MetaDataUtil.getPixelSizeY(meta, s, pxSizeY.getDefaultValue().doubleValue()))); - pxSizeZ.setValue(Double.valueOf(MetaDataUtil.getPixelSizeZ(meta, s, pxSizeZ.getDefaultValue().doubleValue()))); - timeIntT.setValue( - Double.valueOf(MetaDataUtil.getTimeInterval(meta, s, timeIntT.getDefaultValue().doubleValue()))); + sizeX.setValue(MetaDataUtil.getSizeX(meta, s)); + sizeY.setValue(MetaDataUtil.getSizeY(meta, s)); + sizeZ.setValue(MetaDataUtil.getSizeZ(meta, s)); + sizeT.setValue(MetaDataUtil.getSizeT(meta, s)); + sizeC.setValue(MetaDataUtil.getSizeC(meta, s)); + pxSizeX.setValue(MetaDataUtil.getPixelSizeX(meta, s, pxSizeX.getDefaultValue())); + pxSizeY.setValue(MetaDataUtil.getPixelSizeY(meta, s, pxSizeY.getDefaultValue())); + pxSizeZ.setValue(MetaDataUtil.getPixelSizeZ(meta, s, pxSizeZ.getDefaultValue())); + timeIntT.setValue(MetaDataUtil.getTimeInterval(meta, s, timeIntT.getDefaultValue())); // get position of first plane only for now - positionX.setValue(Double.valueOf(MetaDataUtil.getPositionX(meta, s, 0, 0, 0, 0d))); - positionY.setValue(Double.valueOf(MetaDataUtil.getPositionY(meta, s, 0, 0, 0, 0d))); - positionZ.setValue(Double.valueOf(MetaDataUtil.getPositionZ(meta, s, 0, 0, 0, 0d))); + positionX.setValue(MetaDataUtil.getPositionX(meta, s, 0, 0, 0, 0d)); + positionY.setValue(MetaDataUtil.getPositionY(meta, s, 0, 0, 0, 0d)); + positionZ.setValue(MetaDataUtil.getPositionZ(meta, s, 0, 0, 0, 0d)); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("Metadata", metadata); inputMap.add("Serie", serie); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { outputMap.add("numSerie", numSerie); outputMap.add("Name", name); outputMap.add("Size X", sizeX); @@ -101,8 +114,7 @@ public class ReadMetadata extends Plugin implements SequenceBlock, PluginLibrary } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } \ No newline at end of file diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetChannelName.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetChannelName.java index 2b94357b2ac6bb9d4efe7325543df343145e5d61..336b7f64c851d3b373bf297db3c00dcc3057121e 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetChannelName.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetChannelName.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.tprovoost.sequenceblocks.infos; import icy.plugin.abstract_.Plugin; @@ -14,29 +32,27 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Block to set channel name of the specified sequence - * + * * @author Stephane * @see GetChannelsName * @see SetChannelName */ -public class SetChannelName extends Plugin implements SequenceBlock, PluginBundled -{ +public class SetChannelName extends Plugin implements SequenceBlock, PluginBundled { final protected VarSequence varSequence = new VarSequence("Sequence", null); final protected VarString varName = new VarString("Name", ""); final protected VarInteger idx = new VarInteger("Channel", 0); @Override - public void run() - { - Sequence s = varSequence.getValue(); + public void run() { + final Sequence s = varSequence.getValue(); if (s == null) throw new VarException(varSequence, "Sequence is null"); - int index = idx.getValue().intValue(); + final int index = idx.getValue(); if (index < 0 || index >= s.getSizeC()) throw new VarException(idx, "Wrong channel index."); - String name = varName.getName(); + final String name = varName.getName(); if (StringUtil.isEmpty(name)) throw new VarException(varName, "Name cannot be empty"); @@ -44,22 +60,19 @@ public class SetChannelName extends Plugin implements SequenceBlock, PluginBundl } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", varSequence); inputMap.add("index", idx); inputMap.add("name", varName); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetChannelsName.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetChannelsName.java index ce421ee89527de3d6832dc3c34518688f9ec77f7..d73549934a813fcec2d81dbc294bbb6f8cf64ca3 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetChannelsName.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetChannelsName.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.tprovoost.sequenceblocks.infos; import icy.plugin.abstract_.Plugin; @@ -12,19 +30,17 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Block to set all channels name of the specified sequence - * + * * @author Stephane * @see GetChannelsName * @see SetChannelName */ -public class SetChannelsName extends Plugin implements SequenceBlock, PluginBundled -{ +public class SetChannelsName extends Plugin implements SequenceBlock, PluginBundled { final protected VarSequence varSequence = new VarSequence("Sequence", null); - final protected VarArray<String> varNames = new VarArray<String>("Names", String[].class, new String[0]); + final protected VarArray<String> varNames = new VarArray<>("Names", String[].class, new String[0]); @Override - public void run() - { + public void run() { final Sequence s = varSequence.getValue(); if (s == null) throw new VarException(varSequence, "Sequence is null"); @@ -38,21 +54,18 @@ public class SetChannelsName extends Plugin implements SequenceBlock, PluginBund } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", varSequence); inputMap.add("names", varNames); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetColormap.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetColormap.java index 3a7e57c1cd7786371b07acf5e884e00fec5858a7..5abab03999f1b07ad3d2999e0426b601a49cc48a 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetColormap.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetColormap.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.tprovoost.sequenceblocks.infos; import icy.image.colormap.IcyColorMap; @@ -12,34 +30,29 @@ import plugins.adufour.vars.lang.VarInteger; import plugins.adufour.vars.lang.VarSequence; import plugins.tprovoost.sequenceblocks.SequenceBlocks; -public class SetColormap extends Plugin implements SequenceBlock, PluginBundled -{ +public class SetColormap extends Plugin implements SequenceBlock, PluginBundled { final protected VarSequence sequenceIn = new VarSequence("Sequence", null); final protected VarInteger numChannel = new VarInteger("Channel", 0); final protected VarColormap colormap = new VarColormap("Color map", LinearColorMap.gray_); @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("input", sequenceIn); inputMap.add("numChannel", numChannel); inputMap.add("colormap", colormap); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // no output here } @Override - public void run() - { + public void run() { final Sequence seq = sequenceIn.getValue(); - if (seq != null) - { - final int ch = numChannel.getValue().intValue(); + if (seq != null) { + final int ch = numChannel.getValue(); final IcyColorMap map = colormap.getValue(); if ((ch < seq.getSizeC()) && (map != null)) @@ -50,8 +63,7 @@ public class SetColormap extends Plugin implements SequenceBlock, PluginBundled } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetColormaps.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetColormaps.java index 9e0d9e548fb48112eaf9a319d8b32c0d7919ed78..09c5873f6289f4c705f778f6bb2b113a49779b17 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetColormaps.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetColormaps.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.tprovoost.sequenceblocks.infos; import icy.image.colormap.IcyColorMap; @@ -11,28 +29,23 @@ import plugins.adufour.vars.lang.VarSequence; import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.SequenceBlocks; -public class SetColormaps extends Plugin implements SequenceBlock, PluginBundled -{ +public class SetColormaps extends Plugin implements SequenceBlock, PluginBundled { final protected VarSequence sequenceIn = new VarSequence("Input", null); - final protected VarArray<IcyColorMap> colormaps = new VarArray<IcyColorMap>("Color maps", IcyColorMap[].class, - new IcyColorMap[0]); + final protected VarArray<IcyColorMap> colormaps = new VarArray<>("Color maps", IcyColorMap[].class, new IcyColorMap[0]); @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("input", sequenceIn); inputMap.add("colormaps", colormaps); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // no output here } @Override - public void run() - { + public void run() { final Sequence seq = sequenceIn.getValue(); if (seq == null) throw new VarException(sequenceIn, "Sequence is null"); @@ -46,8 +59,7 @@ public class SetColormaps extends Plugin implements SequenceBlock, PluginBundled } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetName.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetName.java index 2cf4be88bac22d6ae353bc140d801201eb931d4f..82085ef19daff9f08eb36d202dc35fed97e05cf2 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetName.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetName.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.tprovoost.sequenceblocks.infos; import icy.plugin.abstract_.Plugin; @@ -13,41 +31,34 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * @author thomasprovoost */ -public class SetName extends Plugin implements SequenceBlock, PluginBundled -{ +public class SetName extends Plugin implements SequenceBlock, PluginBundled { final protected VarSequence varSequence = new VarSequence("Sequence", null); final protected VarString name = new VarString("Name", ""); @Override - public void run() - { - Sequence s = varSequence.getValue(); - if (s != null) - { + public void run() { + final Sequence s = varSequence.getValue(); + if (s != null) { s.setName(name.getValue()); } - else - { + else { throw new VarException(varSequence, "Sequence is null"); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", varSequence); inputMap.add("name", name); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetResolution.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetResolution.java index 2fb2bbcc1d3601c643ff723f38fb0321052c4ab2..669aa86136b0b722db0bd79725156d62281cb1be 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetResolution.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetResolution.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.tprovoost.sequenceblocks.infos; import icy.math.UnitUtil; @@ -14,58 +32,52 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * @author thomasprovoost */ -public class SetResolution extends Plugin implements SequenceBlock, PluginBundled -{ - final protected VarSequence varSequence = new VarSequence("Sequence", null); - final protected VarDouble pxSizeX = new VarDouble("Pixel Size X (" + UnitUtil.MICRO_STRING + "m)", 1d); - final protected VarDouble pxSizeY = new VarDouble("Pixel Size Y (" + UnitUtil.MICRO_STRING + "m)", 1d); - final protected VarDouble pxSizeZ = new VarDouble("Pixel Size Z (" + UnitUtil.MICRO_STRING + "m)", 1d); - final protected VarDouble timeIntT = new VarDouble("Time interval T (s)", 100d); +public class SetResolution extends Plugin implements SequenceBlock, PluginBundled { + final protected VarSequence varSequence = new VarSequence("Sequence", null); + final protected VarDouble pxSizeX = new VarDouble("Pixel Size X (" + UnitUtil.MICRO_STRING + "m)", 1d); + final protected VarDouble pxSizeY = new VarDouble("Pixel Size Y (" + UnitUtil.MICRO_STRING + "m)", 1d); + final protected VarDouble pxSizeZ = new VarDouble("Pixel Size Z (" + UnitUtil.MICRO_STRING + "m)", 1d); + final protected VarDouble timeIntT = new VarDouble("Time interval T (s)", 100d); - @Override - public void run() - { - Sequence s = varSequence.getValue(); + @Override + public void run() { + final Sequence s = varSequence.getValue(); - if (s != null) - { - double x = pxSizeX.getValue().doubleValue(); - double y = pxSizeY.getValue().doubleValue(); - double z = pxSizeZ.getValue().doubleValue(); - double ti = timeIntT.getValue().doubleValue(); - if (x != -1) - s.setPixelSizeX(x); - if (y != -1) - s.setPixelSizeY(y); - if (z != -1) - s.setPixelSizeZ(z); - if (ti != -1) - s.setTimeInterval(ti); - } else - { - throw new VarException(varSequence, "Sequence is null"); - } - } + if (s != null) { + final double x = pxSizeX.getValue(); + final double y = pxSizeY.getValue(); + final double z = pxSizeZ.getValue(); + final double ti = timeIntT.getValue(); + if (x != -1) + s.setPixelSizeX(x); + if (y != -1) + s.setPixelSizeY(y); + if (z != -1) + s.setPixelSizeZ(z); + if (ti != -1) + s.setTimeInterval(ti); + } + else { + throw new VarException(varSequence, "Sequence is null"); + } + } - @Override - public void declareInput(VarList inputMap) - { - inputMap.add("sequence", varSequence); - inputMap.add("PxSize X (" + UnitUtil.MICRO_STRING + "m)", pxSizeX); - inputMap.add("PxSize Y (" + UnitUtil.MICRO_STRING + "m)", pxSizeY); - inputMap.add("PxSize Z (" + UnitUtil.MICRO_STRING + "m)", pxSizeZ); - inputMap.add("Time interval T (s)", timeIntT); - } + @Override + public void declareInput(final VarList inputMap) { + inputMap.add("sequence", varSequence); + inputMap.add("PxSize X (" + UnitUtil.MICRO_STRING + "m)", pxSizeX); + inputMap.add("PxSize Y (" + UnitUtil.MICRO_STRING + "m)", pxSizeY); + inputMap.add("PxSize Z (" + UnitUtil.MICRO_STRING + "m)", pxSizeZ); + inputMap.add("Time interval T (s)", timeIntT); + } - @Override - public void declareOutput(VarList outputMap) - { - // - } + @Override + public void declareOutput(final VarList outputMap) { + // + } - @Override - public String getMainPluginClassName() - { - return SequenceBlocks.class.getName(); - } + @Override + public String getMainPluginClassName() { + return SequenceBlocks.class.getName(); + } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetSequenceProperty.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetSequenceProperty.java index 21aa719924b636cd4069d65919fd72778304cf57..a1ac68a0ea2aa3e5901697f0fdb035046e39efe1 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetSequenceProperty.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/SetSequenceProperty.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.tprovoost.sequenceblocks.infos; import icy.plugin.abstract_.Plugin; @@ -29,18 +47,16 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; * <li><i>userName</i> = user who generated / acquired the dataset</li> * <li><i>virtual</i> = virtual mode enabled on the dataset</li> * </ul> - * + * * @author Stephane */ -public class SetSequenceProperty extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class SetSequenceProperty extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { protected VarSequence sequence = new VarSequence("Sequence", null); protected VarString propertyName = new VarString("Property", "name"); protected VarString value = new VarString("Value", ""); @Override - public void run() - { + public void run() { final Sequence seq = sequence.getValue(); if (seq != null) @@ -48,22 +64,19 @@ public class SetSequenceProperty extends Plugin implements SequenceBlock, Plugin } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", sequence); inputMap.add("property", propertyName); inputMap.add("value", value); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/infos/VarColormap.java b/src/main/java/plugins/tprovoost/sequenceblocks/infos/VarColormap.java index bd81d7b9b16fe3e89551ee2c7f15df4e326d1491..41ac1526a2a92c84f040358796dcec3333067342 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/infos/VarColormap.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/infos/VarColormap.java @@ -1,35 +1,48 @@ -package plugins.tprovoost.sequenceblocks.infos; - -import javax.swing.JComboBox; +/* + * 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.w3c.dom.Node; +package plugins.tprovoost.sequenceblocks.infos; import icy.gui.component.renderer.ColormapComboBoxRenderer; import icy.image.colormap.IcyColorMap; import icy.image.colormap.LinearColorMap; import icy.util.XMLUtil; +import org.w3c.dom.Node; import plugins.adufour.vars.gui.VarEditor; import plugins.adufour.vars.gui.model.ValueSelectionModel; import plugins.adufour.vars.gui.swing.ComboBox; import plugins.adufour.vars.lang.Var; +import javax.swing.*; + /** * Define a specific Var type for ColorMap object - * + * * @author emilie */ -public class VarColormap extends Var<IcyColorMap> -{ - public static class ColormapSelectionModel extends ValueSelectionModel<IcyColorMap> - { - public ColormapSelectionModel() - { +public class VarColormap extends Var<IcyColorMap> { + public static class ColormapSelectionModel extends ValueSelectionModel<IcyColorMap> { + public ColormapSelectionModel() { super(IcyColorMap.getAllColorMaps(true, true).toArray(new IcyColorMap[0]), LinearColorMap.gray_, false); } @Override - public boolean isValid(IcyColorMap value) - { + public boolean isValid(final IcyColorMap value) { return true; } } @@ -38,21 +51,20 @@ public class VarColormap extends Var<IcyColorMap> /** * Create a new VarColormap with given name and default value - * @param name String + * + * @param name String * @param defaultValue IcyColorMap */ - public VarColormap(String name, IcyColorMap defaultValue) - { + public VarColormap(final String name, final IcyColorMap defaultValue) { super(name, new ColormapSelectionModel()); } @Override - public VarEditor<IcyColorMap> createVarEditor() - { + public VarEditor<IcyColorMap> createVarEditor() { // create the var editor (combo box type here) - final ComboBox<IcyColorMap> result = new ComboBox<IcyColorMap>(this); + final ComboBox<IcyColorMap> result = new ComboBox<>(this); // get the editor component - final JComboBox combo = result.getEditorComponent(); + final JComboBox<IcyColorMap> combo = result.getEditorComponent(); // and set a specific renderer combo.setRenderer(new ColormapComboBoxRenderer(combo)); @@ -60,32 +72,26 @@ public class VarColormap extends Var<IcyColorMap> } @Override - public boolean loadFromXML(Node node) - { - try - { + public boolean loadFromXML(final Node node) { + try { final IcyColorMap map = new IcyColorMap(); map.loadFromXML(XMLUtil.setElement(node, ID_NODE)); setValue(map); return true; } - catch (Exception e) - { + catch (final Exception e) { return false; } } @Override - public boolean saveToXML(Node node) throws UnsupportedOperationException - { - try - { + public boolean saveToXML(final Node node) throws UnsupportedOperationException { + try { getValue().saveToXML(XMLUtil.setElement(node, ID_NODE)); return true; } - catch (Exception e) - { + catch (final Exception e) { return false; } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceChannelBatch.java b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceChannelBatch.java index ed0dbe83e0cd7f0438646f08fe78cc824c2804b2..14c7b67aab08d3b861507ed953facb542add3e3a 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceChannelBatch.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceChannelBatch.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.tprovoost.sequenceblocks.loop; import icy.plugin.interface_.PluginBundled; @@ -12,18 +30,16 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Simple batch loop to iterate over all C channel from an input Sequence. - * + * * @author Stephane */ -public class SequenceChannelBatch extends Batch implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class SequenceChannelBatch extends Batch implements SequenceBlock, PluginLibrary, PluginBundled { // important to not initialize here (even with null) and create them in getBatchSource() and getBatchElement() protected VarSequence inputSequence; protected VarSequence element; @Override - public VarSequence getBatchSource() - { + public VarSequence getBatchSource() { // initialize variable if needed if (inputSequence == null) inputSequence = new VarSequence("Sequence", null); @@ -32,8 +48,7 @@ public class SequenceChannelBatch extends Batch implements SequenceBlock, Plugin } @Override - public VarSequence getBatchElement() - { + public VarSequence getBatchElement() { // initialize element if needed if (element == null) element = new VarSequence("Channel Sequence", null); @@ -42,8 +57,7 @@ public class SequenceChannelBatch extends Batch implements SequenceBlock, Plugin } @Override - public void initializeLoop() - { + public void initializeLoop() { final Sequence value = inputSequence.getValue(); if (value == null) @@ -51,28 +65,23 @@ public class SequenceChannelBatch extends Batch implements SequenceBlock, Plugin } @Override - public void beforeIteration() - { - try - { + public void beforeIteration() { + try { // set result in element - element.setValue(SequenceUtil.extractChannel(inputSequence.getValue(), getIterationCounter().getValue().intValue())); + element.setValue(SequenceUtil.extractChannel(inputSequence.getValue(), getIterationCounter().getValue())); } - catch (InterruptedException e) - { + catch (final InterruptedException e) { // nothing to do } } @Override - public boolean isStopConditionReached() - { - return getIterationCounter().getValue().intValue() >= inputSequence.getValue().getSizeC(); + public boolean isStopConditionReached() { + return getIterationCounter().getValue() >= inputSequence.getValue().getSizeC(); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterBatch.java b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterBatch.java index d4877311b4626934294186115f9f460181d56117..63439624f988c00aa39af233eca8ffcd7cc67f5c 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterBatch.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterBatch.java @@ -1,6 +1,22 @@ -package plugins.tprovoost.sequenceblocks.loop; +/* + * 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.tprovoost.sequenceblocks.loop; import icy.file.SequenceFileImporter; import icy.plugin.interface_.PluginBundled; @@ -14,13 +30,14 @@ import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.SequenceBlocks; import plugins.tprovoost.sequenceblocks.importer.PositionedSequenceFileImporter; +import java.util.List; + /** * Base abstract class for {@link SequenceFileImporter} batch loop. - * + * * @author Stephane */ -public abstract class SequenceFileImporterBatch extends Batch implements SequenceBlock, PluginLibrary, PluginBundled -{ +public abstract class SequenceFileImporterBatch extends Batch implements SequenceBlock, PluginLibrary, PluginBundled { // important to not initialize and create them in getBatchSource() and getBatchElement() protected Var<PositionedSequenceFileImporter> positionedImporter; protected Var<PositionedSequenceFileImporter> element; @@ -30,29 +47,26 @@ public abstract class SequenceFileImporterBatch extends Batch implements Sequenc protected int limit; @Override - public Var<PositionedSequenceFileImporter> getBatchSource() - { + public Var<PositionedSequenceFileImporter> getBatchSource() { // initialize variable if needed if (positionedImporter == null) - positionedImporter = new Var<PositionedSequenceFileImporter>("Importer", + positionedImporter = new Var<>("Importer", PositionedSequenceFileImporter.class); return positionedImporter; } @Override - public Var<PositionedSequenceFileImporter> getBatchElement() - { + public Var<PositionedSequenceFileImporter> getBatchElement() { // initialize element if needed if (element == null) - element = new Var<PositionedSequenceFileImporter>("Loop importer", PositionedSequenceFileImporter.class); + element = new Var<>("Loop importer", PositionedSequenceFileImporter.class); return element; } @Override - public void initializeLoop() - { + public void initializeLoop() { final PositionedSequenceFileImporter value = positionedImporter.getValue(); if (value == null) @@ -66,7 +80,7 @@ public abstract class SequenceFileImporterBatch extends Batch implements Sequenc // create new positioned importer for element initialization final PositionedSequenceFileImporter pi = new PositionedSequenceFileImporter(value); - final int s = series.getValue().intValue(); + final int s = series.getValue(); // defined series ? --> set series position if (s != -1) @@ -77,8 +91,7 @@ public abstract class SequenceFileImporterBatch extends Batch implements Sequenc } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { super.declareInput(inputMap); // lazy creation @@ -89,8 +102,7 @@ public abstract class SequenceFileImporterBatch extends Batch implements Sequenc } @Override - public void declareLoopVariables(List<Var<?>> loopVariables) - { + public void declareLoopVariables(final List<Var<?>> loopVariables) { // need to be called after super.declareLoopVariables(loopVariables); @@ -102,8 +114,7 @@ public abstract class SequenceFileImporterBatch extends Batch implements Sequenc } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterChannelBatch.java b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterChannelBatch.java index afc3b0405731be0aab4532d1fec43677f797bbe9..bf0d032401415acccf030bcc57f86ff153930cf1 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterChannelBatch.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterChannelBatch.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.tprovoost.sequenceblocks.loop; import icy.file.SequenceFileImporter; @@ -7,49 +25,41 @@ import plugins.tprovoost.sequenceblocks.importer.PositionedSequenceFileImporter; /** * Simple batch loop to iterate over all C channel from specified opened {@link SequenceFileImporter} object. - * + * * @author Stephane */ -public class SequenceFileImporterChannelBatch extends SequenceFileImporterBatch -{ +public class SequenceFileImporterChannelBatch extends SequenceFileImporterBatch { @Override - public void initializeLoop() - { + public void initializeLoop() { super.initializeLoop(); // can take position from element which should have been initialized here final PositionedSequenceFileImporter pi = element.getValue(); - try - { + try { // can iterate over C dimension ? if (pi.c == -1) limit = MetaDataUtil.getSizeC(pi.getMetadata(), (pi.s == -1) ? 0 : pi.s); else limit = 1; } - catch (Exception e) - { - throw new VarException(element, - "Error while initializing SequenceFileImporter channel batch: " + e.getMessage()); + catch (final Exception e) { + throw new VarException(element, "Error while initializing SequenceFileImporter channel batch: " + e.getMessage()); } } @Override - public void beforeIteration() - { + public void beforeIteration() { // set current position C - if (positionedImporter.getValue().c == -1) - { - element.getValue().c = getIterationCounter().getValue().intValue(); + if (positionedImporter.getValue().c == -1) { + element.getValue().c = getIterationCounter().getValue(); // force element changed event so loop get correctly executed element.valueChanged(element, element.getValue(), element.getValue()); } } @Override - public boolean isStopConditionReached() - { - return getIterationCounter().getValue().intValue() >= limit; + public boolean isStopConditionReached() { + return getIterationCounter().getValue() >= limit; } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterFrameBatch.java b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterFrameBatch.java index ba8bf1066324d59de57918deaf474eb654dae72b..9c554717841a9e39dec1876ca7e51ead35e7dedd 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterFrameBatch.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterFrameBatch.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.tprovoost.sequenceblocks.loop; import icy.file.SequenceFileImporter; @@ -7,49 +25,41 @@ import plugins.tprovoost.sequenceblocks.importer.PositionedSequenceFileImporter; /** * Simple batch loop to iterate over all T frame from the specified opened {@link SequenceFileImporter} object. - * + * * @author Stephane */ -public class SequenceFileImporterFrameBatch extends SequenceFileImporterBatch -{ +public class SequenceFileImporterFrameBatch extends SequenceFileImporterBatch { @Override - public void initializeLoop() - { + public void initializeLoop() { super.initializeLoop(); // can take position from element which should have been initialized here final PositionedSequenceFileImporter pi = element.getValue(); - try - { + try { // can iterate over T dimension ? if (pi.t == -1) limit = MetaDataUtil.getSizeT(pi.getMetadata(), (pi.s == -1) ? 0 : pi.s); else limit = 1; } - catch (Exception e) - { - throw new VarException(element, - "Error while initializing SequenceFileImporter frame batch: " + e.getMessage()); + catch (final Exception e) { + throw new VarException(element, "Error while initializing SequenceFileImporter frame batch: " + e.getMessage()); } } @Override - public void beforeIteration() - { + public void beforeIteration() { // set current position T - if (positionedImporter.getValue().t == -1) - { - element.getValue().t = getIterationCounter().getValue().intValue(); + if (positionedImporter.getValue().t == -1) { + element.getValue().t = getIterationCounter().getValue(); // force element changed event so loop get correctly executed element.valueChanged(element, element.getValue(), element.getValue()); } } @Override - public boolean isStopConditionReached() - { - return getIterationCounter().getValue().intValue() >= limit; + public boolean isStopConditionReached() { + return getIterationCounter().getValue() >= limit; } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterRegionBatch.java b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterRegionBatch.java index 05f05183d8836780a5e821f1701ded158786fcc3..3cf4b94fd33dda0b1ede6dc947a4bf2685bb6415 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterRegionBatch.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterRegionBatch.java @@ -1,9 +1,22 @@ -package plugins.tprovoost.sequenceblocks.loop; +/* + * 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.Rectangle; -import java.awt.geom.Rectangle2D; -import java.util.ArrayList; -import java.util.List; +package plugins.tprovoost.sequenceblocks.loop; import icy.file.SequenceFileImporter; import icy.roi.ROI; @@ -16,14 +29,18 @@ import plugins.adufour.vars.lang.VarROIArray; import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.importer.PositionedSequenceFileImporter; +import java.awt.*; +import java.awt.geom.Rectangle2D; +import java.util.ArrayList; +import java.util.List; + /** * Simple batch loop to iterate over a set of XY region defined by ROIs from the specified opened * {@link SequenceFileImporter} object. - * + * * @author Stephane */ -public class SequenceFileImporterRegionBatch extends SequenceFileImporterBatch -{ +public class SequenceFileImporterRegionBatch extends SequenceFileImporterBatch { // important to not initialize here (even with null) and create them in getBatchSource() and getBatchElement() protected VarROIArray rois; protected VarInteger inputRoisResolution; @@ -31,27 +48,22 @@ public class SequenceFileImporterRegionBatch extends SequenceFileImporterBatch protected List<Rectangle> regions; @Override - public void initializeLoop() - { + public void initializeLoop() { super.initializeLoop(); // can take position from element which should have been initialized here final PositionedSequenceFileImporter pi = element.getValue(); // can iterate over XY dimension ? - if ((pi.xyRegion == null) && (rois.getValue() != null)) - { + if ((pi.xyRegion == null) && (rois.getValue() != null)) { final int s = (pi.s == -1) ? 0 : pi.s; final Rectangle regionMask; - try - { + try { // mask for region - regionMask = new Rectangle(0, 0, MetaDataUtil.getSizeX(pi.getMetadata(), s), - MetaDataUtil.getSizeY(pi.getMetadata(), s)); + regionMask = new Rectangle(0, 0, MetaDataUtil.getSizeX(pi.getMetadata(), s), MetaDataUtil.getSizeY(pi.getMetadata(), s)); } - catch (Exception e) - { + catch (final Exception e) { throw new VarException(element, "Error while initializing SequenceFileImporter region batch: " + e.getMessage()); } @@ -60,9 +72,8 @@ public class SequenceFileImporterRegionBatch extends SequenceFileImporterBatch final double margeFactor = 1d + (inputRoisMargin.getValue().doubleValue() / 100d); // build 2D regions from ROI - regions = new ArrayList<Rectangle>(); - for (ROI roi : rois.getValue()) - { + regions = new ArrayList<>(); + for (final ROI roi : rois.getValue()) { Rectangle2D region = roi.getBounds5D().toRectangle2D(); // convert to full resolution if needed @@ -84,20 +95,17 @@ public class SequenceFileImporterRegionBatch extends SequenceFileImporterBatch } @Override - public void beforeIteration() - { + public void beforeIteration() { // set current position XY region - if (positionedImporter.getValue().xyRegion == null) - { - element.getValue().xyRegion = regions.get(getIterationCounter().getValue().intValue()); + if (positionedImporter.getValue().xyRegion == null) { + element.getValue().xyRegion = regions.get(getIterationCounter().getValue()); // force element changed event so loop get correctly executed element.valueChanged(element, element.getValue(), element.getValue()); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { super.declareInput(inputMap); // lazy creation @@ -114,8 +122,7 @@ public class SequenceFileImporterRegionBatch extends SequenceFileImporterBatch } @Override - public void declareLoopVariables(List<Var<?>> loopVariables) - { + public void declareLoopVariables(final List<Var<?>> loopVariables) { super.declareLoopVariables(loopVariables); // lazy creation @@ -132,8 +139,7 @@ public class SequenceFileImporterRegionBatch extends SequenceFileImporterBatch } @Override - public boolean isStopConditionReached() - { - return getIterationCounter().getValue().intValue() >= limit; + public boolean isStopConditionReached() { + return getIterationCounter().getValue() >= limit; } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterSeriesBatch.java b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterSeriesBatch.java index ffb8e57b7eec5d8a0c220be797cf52e763cae911..e9d9950c72324b31934d8a901f5826074d0b5bd6 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterSeriesBatch.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterSeriesBatch.java @@ -1,6 +1,22 @@ -package plugins.tprovoost.sequenceblocks.loop; +/* + * 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.tprovoost.sequenceblocks.loop; import icy.file.SequenceFileImporter; import icy.sequence.MetaDataUtil; @@ -9,39 +25,36 @@ import plugins.adufour.vars.lang.Var; import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.importer.PositionedSequenceFileImporter; +import java.util.List; + /** * Simple batch loop to iterate over all series from the specified opened {@link SequenceFileImporter} object. - * + * * @author Stephane */ -public class SequenceFileImporterSeriesBatch extends SequenceFileImporterBatch -{ +public class SequenceFileImporterSeriesBatch extends SequenceFileImporterBatch { @Override - public void initializeLoop() - { + public void initializeLoop() { super.initializeLoop(); // can take position from element which should have been initialized here final PositionedSequenceFileImporter pi = element.getValue(); - try - { + try { // can iterate over S dimension ? if (pi.s == -1) limit = MetaDataUtil.getNumSeries(pi.getMetadata()); else limit = 1; } - catch (Exception e) - { + catch (final Exception e) { throw new VarException(element, "Error while initializing SequenceFileImporter series batch: " + e.getMessage()); } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { super.declareInput(inputMap); // we don't want it here @@ -49,8 +62,7 @@ public class SequenceFileImporterSeriesBatch extends SequenceFileImporterBatch } @Override - public void declareLoopVariables(List<Var<?>> loopVariables) - { + public void declareLoopVariables(final List<Var<?>> loopVariables) { super.declareLoopVariables(loopVariables); // we don't want it here @@ -58,20 +70,17 @@ public class SequenceFileImporterSeriesBatch extends SequenceFileImporterBatch } @Override - public void beforeIteration() - { + public void beforeIteration() { // set current position S - if (positionedImporter.getValue().s == -1) - { - element.getValue().s = getIterationCounter().getValue().intValue(); + if (positionedImporter.getValue().s == -1) { + element.getValue().s = getIterationCounter().getValue(); // force element changed event so loop get correctly executed element.valueChanged(element, element.getValue(), element.getValue()); } } @Override - public boolean isStopConditionReached() - { - return getIterationCounter().getValue().intValue() >= limit; + public boolean isStopConditionReached() { + return getIterationCounter().getValue() >= limit; } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterSliceBatch.java b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterSliceBatch.java index 16f1dad4b7b1721f710c71458f7b359a6886699d..2abea99463eb2e11762f98d8bdcd19612f716d0a 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterSliceBatch.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterSliceBatch.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.tprovoost.sequenceblocks.loop; import icy.file.SequenceFileImporter; @@ -7,49 +25,41 @@ import plugins.tprovoost.sequenceblocks.importer.PositionedSequenceFileImporter; /** * Simple batch loop to iterate over all Z slice from specified opened {@link SequenceFileImporter} object. - * + * * @author Stephane */ -public class SequenceFileImporterSliceBatch extends SequenceFileImporterBatch -{ +public class SequenceFileImporterSliceBatch extends SequenceFileImporterBatch { @Override - public void initializeLoop() - { + public void initializeLoop() { super.initializeLoop(); // can take position from element which should have been initialized here final PositionedSequenceFileImporter pi = element.getValue(); - - try - { + + try { // can iterate over Z dimension ? if (pi.z == -1) limit = MetaDataUtil.getSizeZ(pi.getMetadata(), (pi.s == -1) ? 0 : pi.s); else limit = 1; } - catch (Exception e) - { - throw new VarException(element, - "Error while initializing SequenceFileImporter slice batch: " + e.getMessage()); + catch (final Exception e) { + throw new VarException(element, "Error while initializing SequenceFileImporter slice batch: " + e.getMessage()); } } @Override - public void beforeIteration() - { + public void beforeIteration() { // set current position Z - if (positionedImporter.getValue().z == -1) - { - element.getValue().z = getIterationCounter().getValue().intValue(); + if (positionedImporter.getValue().z == -1) { + element.getValue().z = getIterationCounter().getValue(); // force element changed event so loop get correctly executed element.valueChanged(element, element.getValue(), element.getValue()); } } @Override - public boolean isStopConditionReached() - { - return getIterationCounter().getValue().intValue() >= limit; + public boolean isStopConditionReached() { + return getIterationCounter().getValue() >= limit; } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterTileBatch.java b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterTileBatch.java index 4d6e434c6d49462cb6ef8bf6b00ef2e0660d09f6..ffdeb1cbb5b598254490e11d87091e1e9d688e9b 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterTileBatch.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFileImporterTileBatch.java @@ -1,7 +1,22 @@ -package plugins.tprovoost.sequenceblocks.loop; +/* + * 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.Rectangle; -import java.util.List; +package plugins.tprovoost.sequenceblocks.loop; import icy.file.SequenceFileImporter; import icy.image.ImageUtil; @@ -12,13 +27,15 @@ import plugins.adufour.vars.lang.VarInteger; import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.importer.PositionedSequenceFileImporter; +import java.awt.*; +import java.util.List; + /** * Simple batch loop to iterate over all XY tile from the specified opened {@link SequenceFileImporter} object. - * + * * @author Stephane */ -public class SequenceFileImporterTileBatch extends SequenceFileImporterBatch -{ +public class SequenceFileImporterTileBatch extends SequenceFileImporterBatch { // important to not initialize here (even with null) and create them in getBatchSource() and getBatchElement() protected VarInteger tileW; protected VarInteger tileH; @@ -26,16 +43,14 @@ public class SequenceFileImporterTileBatch extends SequenceFileImporterBatch protected List<Rectangle> tiles; @Override - public void initializeLoop() - { + public void initializeLoop() { super.initializeLoop(); // can take position from element which should have been initialized here final PositionedSequenceFileImporter pi = element.getValue(); // can iterate over XY dimension ? - if (pi.xyRegion == null) - { + if (pi.xyRegion == null) { final SequenceFileImporter imp = pi.importer; final int s = (pi.s == -1) ? 0 : pi.s; final int sizeX; @@ -43,13 +58,12 @@ public class SequenceFileImporterTileBatch extends SequenceFileImporterBatch int tw; int th; - try - { + try { sizeX = MetaDataUtil.getSizeX(pi.getMetadata(), s); sizeY = MetaDataUtil.getSizeY(pi.getMetadata(), s); - tw = tileW.getValue().intValue(); - th = tileH.getValue().intValue(); + tw = tileW.getValue(); + th = tileH.getValue(); // auto ? --> get it from importer if (tw == -1) tw = imp.getTileWidth(s); @@ -57,22 +71,20 @@ public class SequenceFileImporterTileBatch extends SequenceFileImporterBatch if (th == -1) th = imp.getTileHeight(s); } - catch (Exception e) - { - throw new VarException(element, - "Error while initializing SequenceFileImporter tile batch: " + e.getMessage()); + catch (final Exception e) { + throw new VarException(element, "Error while initializing SequenceFileImporter tile batch: " + e.getMessage()); } // any size supported ? --> use 1024 by default if (tw == -1) tw = 1024; - // tile loading not supported ? --> use full width + // tile loading not supported ? --> use full width else if (tw == 0) tw = sizeX; // any size supported ? --> use 1024 by default if (th == -1) th = 1024; - // tile loading not supported ? --> use full height + // tile loading not supported ? --> use full height else if (th == 0) th = sizeY; @@ -86,10 +98,9 @@ public class SequenceFileImporterTileBatch extends SequenceFileImporterBatch } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { super.declareInput(inputMap); - + // lazy creation if (tileW == null) tileW = new VarInteger("Tile width (-1 = auto)", -1); @@ -101,8 +112,7 @@ public class SequenceFileImporterTileBatch extends SequenceFileImporterBatch } @Override - public void declareLoopVariables(List<Var<?>> loopVariables) - { + public void declareLoopVariables(final List<Var<?>> loopVariables) { // need to be called after super.declareLoopVariables(loopVariables); @@ -117,20 +127,17 @@ public class SequenceFileImporterTileBatch extends SequenceFileImporterBatch } @Override - public void beforeIteration() - { + public void beforeIteration() { // set current position XY region - if (positionedImporter.getValue().xyRegion == null) - { - element.getValue().xyRegion = tiles.get(getIterationCounter().getValue().intValue()); + if (positionedImporter.getValue().xyRegion == null) { + element.getValue().xyRegion = tiles.get(getIterationCounter().getValue()); // force element changed event so loop get correctly executed element.valueChanged(element, element.getValue(), element.getValue()); } } @Override - public boolean isStopConditionReached() - { - return getIterationCounter().getValue().intValue() >= limit; + public boolean isStopConditionReached() { + return getIterationCounter().getValue() >= limit; } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFrameBatch.java b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFrameBatch.java index 2a77e4fcc0cc01dbaa3706497b76e5530cc693c4..8635b25ca0f1ff8bb79af9923442654ebe5b4a3b 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFrameBatch.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceFrameBatch.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.tprovoost.sequenceblocks.loop; import icy.plugin.interface_.PluginBundled; @@ -11,23 +29,20 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Simple batch loop to iterate over all T frame from an input Sequence. - * + * * @author Stephane */ -public class SequenceFrameBatch extends Batch implements PluginLibrary, PluginBundled -{ +public class SequenceFrameBatch extends Batch implements PluginLibrary, PluginBundled { // important to not initialize and create them in getBatchSource() and getBatchElement() protected VarSequence inputSequence; protected VarSequence element; - public SequenceFrameBatch() - { + public SequenceFrameBatch() { super(); } @Override - public VarSequence getBatchSource() - { + public VarSequence getBatchSource() { // initialize variable if needed if (inputSequence == null) inputSequence = new VarSequence("Sequence", null); @@ -36,8 +51,7 @@ public class SequenceFrameBatch extends Batch implements PluginLibrary, PluginBu } @Override - public VarSequence getBatchElement() - { + public VarSequence getBatchElement() { // initialize element if needed if (element == null) element = new VarSequence("Frame Sequence", null); @@ -46,8 +60,7 @@ public class SequenceFrameBatch extends Batch implements PluginLibrary, PluginBu } @Override - public void initializeLoop() - { + public void initializeLoop() { final Sequence value = inputSequence.getValue(); if (value == null) @@ -55,22 +68,18 @@ public class SequenceFrameBatch extends Batch implements PluginLibrary, PluginBu } @Override - public void beforeIteration() - { + public void beforeIteration() { // set result in element - element.setValue( - SequenceUtil.extractFrame(inputSequence.getValue(), getIterationCounter().getValue().intValue())); + element.setValue(SequenceUtil.extractFrame(inputSequence.getValue(), getIterationCounter().getValue())); } @Override - public boolean isStopConditionReached() - { - return getIterationCounter().getValue().intValue() >= inputSequence.getValue().getSizeT(); + public boolean isStopConditionReached() { + return getIterationCounter().getValue() >= inputSequence.getValue().getSizeT(); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceRegionBatch.java b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceRegionBatch.java index 99fc20a5e43b3639637ce1bd980146ffb82fe318..0409bdd7ac655ad239aafcc378e16af2583f0075 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceRegionBatch.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceRegionBatch.java @@ -1,6 +1,22 @@ -package plugins.tprovoost.sequenceblocks.loop; +/* + * 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.tprovoost.sequenceblocks.loop; import icy.plugin.interface_.PluginBundled; import icy.plugin.interface_.PluginLibrary; @@ -16,27 +32,26 @@ import plugins.adufour.vars.lang.VarSequence; import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.SequenceBlocks; +import java.util.List; + /** * Simple batch loop to iterate over a set of Region (ROIs) from an input Sequence. - * + * * @author Stephane */ -public class SequenceRegionBatch extends Batch implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class SequenceRegionBatch extends Batch implements SequenceBlock, PluginLibrary, PluginBundled { // important to not initialize here (even with null) and create them in getBatchSource() and getBatchElement() protected VarSequence inputSequence; protected VarSequence element; protected VarROIArray rois; protected VarROIArray currentRoi; - public SequenceRegionBatch() - { + public SequenceRegionBatch() { super(); } @Override - public VarROIArray getBatchSource() - { + public VarROIArray getBatchSource() { if (rois == null) rois = new VarROIArray("ROI(s)"); @@ -44,8 +59,7 @@ public class SequenceRegionBatch extends Batch implements SequenceBlock, PluginL } @Override - public VarSequence getBatchElement() - { + public VarSequence getBatchElement() { if (element == null) element = new VarSequence("Region Sequence", null); @@ -53,8 +67,7 @@ public class SequenceRegionBatch extends Batch implements SequenceBlock, PluginL } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { super.declareInput(inputMap); if (inputSequence == null) @@ -64,8 +77,7 @@ public class SequenceRegionBatch extends Batch implements SequenceBlock, PluginL } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { super.declareOutput(outputMap); if (currentRoi == null) @@ -75,8 +87,7 @@ public class SequenceRegionBatch extends Batch implements SequenceBlock, PluginL } @Override - public void initializeLoop() - { + public void initializeLoop() { final Sequence value = inputSequence.getValue(); if (value == null) @@ -87,39 +98,33 @@ public class SequenceRegionBatch extends Batch implements SequenceBlock, PluginL } @Override - public void beforeIteration() - { + public void beforeIteration() { // set result in element - final ROI roi = rois.getValue()[getIterationCounter().getValue().intValue()]; + final ROI roi = rois.getValue()[getIterationCounter().getValue()]; - try - { + try { element.setValue(SequenceUtil.getSubSequence(inputSequence.getValue(), roi)); - currentRoi.setValue(new ROI[] {roi}); + currentRoi.setValue(new ROI[]{roi}); } - catch (InterruptedException e) - { + catch (final InterruptedException e) { // nothing to do } } @Override - public boolean isStopConditionReached() - { - return getIterationCounter().getValue().intValue() >= rois.getValue().length; + public boolean isStopConditionReached() { + return getIterationCounter().getValue() >= rois.getValue().length; } @Override - public void declareLoopVariables(List<Var<?>> loopVariables) - { + public void declareLoopVariables(final List<Var<?>> loopVariables) { super.declareLoopVariables(loopVariables); loopVariables.add(inputSequence); loopVariables.add(currentRoi); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceSliceBatch.java b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceSliceBatch.java index e8c2003095f9ea416acb141df9c53a3fed7ed56d..d5600bb0daa2889d477f5173cfbd489016f86c85 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceSliceBatch.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/loop/SequenceSliceBatch.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.tprovoost.sequenceblocks.loop; import icy.plugin.interface_.PluginBundled; @@ -12,18 +30,16 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Simple batch loop to iterate over all Z slice from an input Sequence. - * + * * @author Stephane */ -public class SequenceSliceBatch extends Batch implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class SequenceSliceBatch extends Batch implements SequenceBlock, PluginLibrary, PluginBundled { // important to not initialize here (even with null) and create them in getBatchSource() and getBatchElement() protected VarSequence inputSequence; protected VarSequence element; @Override - public VarSequence getBatchSource() - { + public VarSequence getBatchSource() { // initialize variable if needed if (inputSequence == null) inputSequence = new VarSequence("Sequence", null); @@ -32,8 +48,7 @@ public class SequenceSliceBatch extends Batch implements SequenceBlock, PluginLi } @Override - public VarSequence getBatchElement() - { + public VarSequence getBatchElement() { // initialize element if needed if (element == null) element = new VarSequence("Slice Sequence", null); @@ -42,8 +57,7 @@ public class SequenceSliceBatch extends Batch implements SequenceBlock, PluginLi } @Override - public void initializeLoop() - { + public void initializeLoop() { final Sequence value = inputSequence.getValue(); if (value == null) @@ -51,22 +65,19 @@ public class SequenceSliceBatch extends Batch implements SequenceBlock, PluginLi } @Override - public void beforeIteration() - { + public void beforeIteration() { // set result in element element.setValue( - SequenceUtil.extractSlice(inputSequence.getValue(), getIterationCounter().getValue().intValue())); + SequenceUtil.extractSlice(inputSequence.getValue(), getIterationCounter().getValue())); } @Override - public boolean isStopConditionReached() - { - return getIterationCounter().getValue().intValue() >= inputSequence.getValue().getSizeZ(); + public boolean isStopConditionReached() { + return getIterationCounter().getValue() >= inputSequence.getValue().getSizeZ(); } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/op/AdditiveFillSequence.java b/src/main/java/plugins/tprovoost/sequenceblocks/op/AdditiveFillSequence.java index 2ed300e28c10eb0f6430699fe8eb1d21633c424c..4e2a833a4ac9694a5f83ef8a75f4afc25fb504cf 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/op/AdditiveFillSequence.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/op/AdditiveFillSequence.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.tprovoost.sequenceblocks.op; import icy.image.ImageDataIterator; @@ -21,82 +36,69 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Block to do additive fill of area inside the ROI regions with the specified value.<br> * The result of this operation is similar to heatmap production from ROIs. - * + * * @author Stephane */ -public class AdditiveFillSequence extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class AdditiveFillSequence extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { final protected VarSequence inputSequence = new VarSequence("Sequence", null); final protected VarROIArray rois = new VarROIArray("Roi(s)"); @Override - public void run() - { + public void run() { final Sequence sequence = inputSequence.getValue(); if (sequence == null) throw new VarException(inputSequence, "Input sequence is null."); - try - { - if (rois.getValue() != null) - { - for (ROI roi : rois.getValue()) + try { + if (rois.getValue() != null) { + for (final ROI roi : rois.getValue()) doAdditiveFill(sequence, roi, 1d); sequence.dataChanged(); } } - catch (InterruptedException e) - { + catch (final InterruptedException e) { // nothing to do } } - public static void doAdditiveFill(Sequence sequence, ROI roi, double value) throws InterruptedException - { + public static void doAdditiveFill(final Sequence sequence, final ROI roi, final double value) throws InterruptedException { doAdditiveFill(new SequenceDataIterator(sequence, roi), value); } - public static void doAdditiveFill(DataIterator it, double value) throws InterruptedException - { + public static void doAdditiveFill(final DataIterator it, final double value) throws InterruptedException { it.reset(); - while (!it.done()) - { + while (!it.done()) { it.set(it.get() + value); it.next(); } - try - { + try { // not really nice to do that here, but it's to preserve backward compatibility if (it instanceof SequenceDataIterator) ((SequenceDataIterator) it).flush(); else if (it instanceof ImageDataIterator) ((ImageDataIterator) it).flush(); } - catch (Throwable t) - { + catch (final Throwable t) { // ignore } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", inputSequence); inputMap.add("rois", rois); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } \ No newline at end of file diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/op/FillInnerSequence.java b/src/main/java/plugins/tprovoost/sequenceblocks/op/FillInnerSequence.java index 7dc0f4532a78ea1ea67d9f3e277f62b8b2679a6d..7c86437ffecfa5465997e3f2e79abec770cc42bd 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/op/FillInnerSequence.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/op/FillInnerSequence.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.tprovoost.sequenceblocks.op; import icy.plugin.abstract_.Plugin; @@ -20,57 +35,49 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Block to fill area inside the ROI regions with the specified value - * + * * @author Stephane */ -public class FillInnerSequence extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class FillInnerSequence extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { final protected VarSequence inputSequence = new VarSequence("Sequence", null); final protected VarROIArray rois = new VarROIArray("Roi(s)"); final protected VarDouble fillValue = new VarDouble("Value", 0d); @Override - public void run() - { + public void run() { final Sequence sequence = inputSequence.getValue(); if (sequence == null) throw new VarException(inputSequence, "Input sequence is null."); - try - { - if (rois.getValue() != null) - { - final double value = fillValue.getValue().doubleValue(); + try { + if (rois.getValue() != null) { + final double value = fillValue.getValue(); - for (ROI roi : rois.getValue()) + for (final ROI roi : rois.getValue()) DataIteratorUtil.set(new SequenceDataIterator(sequence, roi), value); sequence.dataChanged(); } } - catch (InterruptedException e) - { + catch (final InterruptedException e) { // nothing to do } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", inputSequence); inputMap.add("rois", rois); inputMap.add("value", fillValue); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } \ No newline at end of file diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/op/FillOuterSequence.java b/src/main/java/plugins/tprovoost/sequenceblocks/op/FillOuterSequence.java index 89d47ed586789e15bb70aeb34377d0307e38d9a8..d5acacfe146f27e7d9ea6b9cbfa19fe75d6ad7e5 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/op/FillOuterSequence.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/op/FillOuterSequence.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.tprovoost.sequenceblocks.op; import icy.plugin.abstract_.Plugin; @@ -19,72 +34,62 @@ import plugins.adufour.vars.lang.VarDouble; import plugins.adufour.vars.lang.VarROIArray; import plugins.adufour.vars.lang.VarSequence; import plugins.adufour.vars.util.VarException; -import plugins.kernel.roi.roi5d.ROI5DStackRectangle; +import plugins.kernel.roi.roi3d.ROI3DBox; import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Block to fill area outside the ROI regions with the specified value - * + * * @author Stephane */ -public class FillOuterSequence extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class FillOuterSequence extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { final protected VarSequence inputSequence = new VarSequence("Sequence", null); final protected VarROIArray rois = new VarROIArray("Roi(s)"); final protected VarDouble fillValue = new VarDouble("Value", 0d); @Override - public void run() - { + public void run() { final Sequence sequence = inputSequence.getValue(); if (sequence == null) throw new VarException(inputSequence, "Input sequence is null."); - try - { - if (rois.getValue() != null) - { - try - { + try { + if (rois.getValue() != null) { + try { final ROI roiUnion = ROIUtil.merge(CollectionUtil.asList(rois.getValue()), BooleanOperator.OR); - final ROI roiSeq = new ROI5DStackRectangle(sequence.getBounds5D()); + final ROI roiSeq = new ROI3DBox(sequence.getBounds5D().toRectangle3D()); final ROI roi = roiSeq.getSubtraction(roiUnion); - final double value = fillValue.getValue().doubleValue(); + final double value = fillValue.getValue(); DataIteratorUtil.set(new SequenceDataIterator(sequence, roi), value); sequence.dataChanged(); } - catch (UnsupportedOperationException e) - { + catch (final UnsupportedOperationException e) { throw new VarException(rois, e.getMessage()); } } } - catch (InterruptedException e) - { + catch (final InterruptedException e) { // nothing to do } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", inputSequence); inputMap.add("rois", rois); inputMap.add("value", fillValue); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } \ No newline at end of file diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveAllRois.java b/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveAllRois.java index 6ce1c1a3f93ff24a7ce22bb92fabf8f5e050f5f3..8259bb6beefc087b19fa4d4688359033b25af470 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveAllRois.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveAllRois.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.tprovoost.sequenceblocks.remove; import icy.plugin.abstract_.Plugin; @@ -13,16 +31,14 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Block to remove all the {@link ROI} from a Sequence - * + * * @author Stephane */ -public class RemoveAllRois extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class RemoveAllRois extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { final protected VarSequence inputSequence = new VarSequence("Sequence", null); @Override - public void run() - { + public void run() { final Sequence s = inputSequence.getValue(); if (s == null) throw new VarException(inputSequence, "Input sequence is null."); @@ -31,20 +47,17 @@ public class RemoveAllRois extends Plugin implements SequenceBlock, PluginLibrar } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", inputSequence); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveChannel.java b/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveChannel.java index 2fb63bfa7f979377579ecc37608f9e19390bab4e..b4a1fbb942c8b973d15ef23e74a66ccd39c6d5c4 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveChannel.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveChannel.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.tprovoost.sequenceblocks.remove; import icy.plugin.abstract_.Plugin; @@ -14,53 +32,46 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Block to remove a channel from a Sequence - * + * * @author Stephane */ -public class RemoveChannel extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class RemoveChannel extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { final protected VarSequence inputSequence = new VarSequence("Sequence", null); final protected VarInteger channelIdx = new VarInteger("Channel", 0); @Override - public void run() - { - Sequence s = inputSequence.getValue(); + public void run() { + final Sequence s = inputSequence.getValue(); if (s == null) throw new VarException(inputSequence, "Input sequence is null."); if (s.getSizeC() == 1) throw new VarException(inputSequence, "Cannot remove channel on single channel image"); - int channel = channelIdx.getValue().intValue(); + final int channel = channelIdx.getValue(); if (channel < 0 || channel >= s.getSizeC()) throw new VarException(channelIdx, "Channel index must be between 0 and " + (s.getSizeC() - 1)); - try - { + try { SequenceUtil.removeChannel(s, channel); } - catch (InterruptedException e) - { + catch (final InterruptedException e) { // nothing to do } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", inputSequence); inputMap.add("channel", channelIdx); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveFrame.java b/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveFrame.java index 4583bfd0a3ca4801db761ef27456083f5bf5e16b..71577229ed4d6dcb48c79b96833a0094c7325e6a 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveFrame.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveFrame.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.tprovoost.sequenceblocks.remove; import icy.plugin.abstract_.Plugin; @@ -14,40 +32,35 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Block to remove a frame from a Sequence - * + * * @author Stephane */ -public class RemoveFrame extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class RemoveFrame extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { final protected VarSequence inputSequence = new VarSequence("Sequence", null); final protected VarInteger frameInd = new VarInteger("Frame", 0); @Override - public void run() - { - Sequence s = inputSequence.getValue(); + public void run() { + final Sequence s = inputSequence.getValue(); if (s == null) throw new VarException(inputSequence, "Input sequence is null."); - SequenceUtil.removeTAndShift(s, frameInd.getValue().intValue()); + SequenceUtil.removeTAndShift(s, frameInd.getValue()); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", inputSequence); inputMap.add("frame", frameInd); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } \ No newline at end of file diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveOverlays.java b/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveOverlays.java index 78d90d27ef9c2723d56d26ecd3833807357e1b1d..16a6de0b9757349e7340a91de060d16101230ace 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveOverlays.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveOverlays.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.tprovoost.sequenceblocks.remove; import icy.painter.Overlay; @@ -17,53 +32,45 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Block to remove one or several {@link Overlay} from a {@link Sequence} - * + * * @author Stephane */ -public class RemoveOverlays extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class RemoveOverlays extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { final protected VarSequence inputSequence = new VarSequence("Sequence", null); - final protected VarArray<Overlay> overlays = new VarArray<Overlay>("Overlay(s)", Overlay[].class, new Overlay[0]); + final protected VarArray<Overlay> overlays = new VarArray<>("Overlay(s)", Overlay[].class, new Overlay[0]); @Override - public void run() - { + public void run() { final Sequence s = inputSequence.getValue(); if (s == null) throw new VarException(inputSequence, "Input sequence is null."); final Overlay[] o = overlays.getValue(); - if (o != null) - { + if (o != null) { s.beginUpdate(); - try - { - for (Overlay overlay : o) + try { + for (final Overlay overlay : o) s.removeOverlay(overlay); } - finally - { + finally { s.endUpdate(); } } } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", inputSequence); inputMap.add("overlay(s)", overlays); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveRois.java b/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveRois.java index 2866f0d39c92863ae77de550b4a3296bff843ece..eb6c415be9bf56012b155d3815f118b94d0a2016 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveRois.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveRois.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.tprovoost.sequenceblocks.remove; import icy.plugin.abstract_.Plugin; @@ -5,9 +23,6 @@ import icy.plugin.interface_.PluginBundled; import icy.plugin.interface_.PluginLibrary; import icy.roi.ROI; import icy.sequence.Sequence; - -import java.util.Arrays; - import plugins.adufour.blocks.tools.sequence.SequenceBlock; import plugins.adufour.blocks.util.VarList; import plugins.adufour.vars.lang.VarROIArray; @@ -15,19 +30,19 @@ import plugins.adufour.vars.lang.VarSequence; import plugins.adufour.vars.util.VarException; import plugins.tprovoost.sequenceblocks.SequenceBlocks; +import java.util.Arrays; + /** * Block to remove one or several {@link ROI} from a Sequence - * + * * @author Stephane */ -public class RemoveRois extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class RemoveRois extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { final protected VarSequence inputSequence = new VarSequence("Sequence", null); final protected VarROIArray rois = new VarROIArray("Roi(s)"); @Override - public void run() - { + public void run() { final Sequence s = inputSequence.getValue(); if (s == null) throw new VarException(inputSequence, "Input sequence is null."); @@ -38,21 +53,18 @@ public class RemoveRois extends Plugin implements SequenceBlock, PluginLibrary, } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", inputSequence); inputMap.add("rois(s)", rois); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } diff --git a/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveSlice.java b/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveSlice.java index 56fecece3e81d0ca07b1b386f7c6cf953674e677..30fafeb4b606aed294d5bc6e384c26d1a4256cfe 100644 --- a/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveSlice.java +++ b/src/main/java/plugins/tprovoost/sequenceblocks/remove/RemoveSlice.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.tprovoost.sequenceblocks.remove; import icy.plugin.abstract_.Plugin; @@ -14,40 +32,35 @@ import plugins.tprovoost.sequenceblocks.SequenceBlocks; /** * Block to remove a Z slice from a Sequence - * + * * @author Stephane */ -public class RemoveSlice extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled -{ +public class RemoveSlice extends Plugin implements SequenceBlock, PluginLibrary, PluginBundled { final protected VarSequence inputSequence = new VarSequence("Sequence", null); final protected VarInteger sliceInd = new VarInteger("Slice", 0); @Override - public void run() - { - Sequence s = inputSequence.getValue(); + public void run() { + final Sequence s = inputSequence.getValue(); if (s == null) throw new VarException(inputSequence, "Input sequence is null."); - SequenceUtil.removeZAndShift(s, sliceInd.getValue().intValue()); + SequenceUtil.removeZAndShift(s, sliceInd.getValue()); } @Override - public void declareInput(VarList inputMap) - { + public void declareInput(final VarList inputMap) { inputMap.add("sequence", inputSequence); inputMap.add("slice", sliceInd); } @Override - public void declareOutput(VarList outputMap) - { + public void declareOutput(final VarList outputMap) { // } @Override - public String getMainPluginClassName() - { + public String getMainPluginClassName() { return SequenceBlocks.class.getName(); } } \ No newline at end of file