diff --git a/.gitignore b/.gitignore index 159dee38dba1df3c6af2c3793586d29a79dfa29e..57f16fb67c1b1589981416b323d7a9debc728665 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,41 @@ -.idea/ -.settings/ -build/ +/build* +/workspace +setting.xml +release/ target/ -bin/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ +icy.log + +### IntelliJ IDEA ### +.idea/ +*.iws *.iml -*.jar +*.ipr + +### Eclipse ### +.apt_generated .classpath +.factorypath .project -export.jardesc +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### **/.DS_Store +Icon? \ No newline at end of file diff --git a/pom.xml b/pom.xml index 99e28706964b287f0d9b4d1af0e0f10bdf5ca574..176698256dd00ef9e08d785ef7eeb59e16c58631 100644 --- a/pom.xml +++ b/pom.xml @@ -7,11 +7,11 @@ <parent> <groupId>org.bioimageanalysis.icy</groupId> <artifactId>pom-icy</artifactId> - <version>2.2.0</version> + <version>3.0.0-a.1</version> </parent> <artifactId>color-picker-threshold</artifactId> - <version>2.0.0</version> + <version>2.0.0-a.1</version> <name>Color Picker Threshold</name> <description> @@ -21,16 +21,24 @@ </description> <dependencies> + <dependency> + <groupId>org.bioimageanalysis.icy</groupId> + <artifactId>kernel-extensions</artifactId> + </dependency> <dependency> <groupId>org.bioimageanalysis.icy</groupId> <artifactId>nherve-toolbox</artifactId> </dependency> + <dependency> + <groupId>org.bioimageanalysis.icy</groupId> + <artifactId>vecmath</artifactId> + </dependency> </dependencies> <repositories> <repository> <id>icy</id> - <url>https://icy-nexus.pasteur.fr/repository/Icy/</url> + <url>https://nexus-icy.pasteur.cloud/repository/icy/</url> </repository> </repositories> </project> \ No newline at end of file diff --git a/src/main/java/plugins/nherve/colorpickerthreshold/ColorPickerThreshold.java b/src/main/java/plugins/nherve/colorpickerthreshold/ColorPickerThreshold.java index 5f0a92d8a944a697a41e4eaa081e92adcbe472f9..dfea999443ea705563d565358415d8adf759bd12 100644 --- a/src/main/java/plugins/nherve/colorpickerthreshold/ColorPickerThreshold.java +++ b/src/main/java/plugins/nherve/colorpickerthreshold/ColorPickerThreshold.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2023. Institut Pasteur. + * Copyright (c) 2010-2024. Institut Pasteur. * * This file is part of Icy. * Icy is free software: you can redistribute it and/or modify @@ -18,17 +18,21 @@ package plugins.nherve.colorpickerthreshold; -import icy.canvas.IcyCanvas; -import icy.gui.util.ComponentUtil; -import icy.gui.util.GuiUtil; -import icy.image.IcyBufferedImage; -import icy.main.Icy; -import icy.painter.Overlay; -import icy.sequence.Sequence; -import icy.swimmingPool.SwimmingObject; -import icy.type.TypeUtil; -import icy.type.point.Point5D; -import plugins.kernel.roi.roi2d.ROI2DArea; +import org.bioimageanalysis.extension.kernel.roi.roi2d.ROI2DArea; +import org.bioimageanalysis.icy.Icy; +import org.bioimageanalysis.icy.common.geom.point.Point5D; +import org.bioimageanalysis.icy.common.type.TypeUtil; +import org.bioimageanalysis.icy.extension.plugin.annotation_.IcyPluginIcon; +import org.bioimageanalysis.icy.extension.plugin.annotation_.IcyPluginName; +import org.bioimageanalysis.icy.gui.GuiUtil; +import org.bioimageanalysis.icy.gui.canvas.IcyCanvas; +import org.bioimageanalysis.icy.gui.component.ComponentUtil; +import org.bioimageanalysis.icy.model.image.IcyBufferedImage; +import org.bioimageanalysis.icy.model.overlay.Overlay; +import org.bioimageanalysis.icy.model.sequence.Sequence; +import org.bioimageanalysis.icy.model.swimmingPool.SwimmingObject; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; import plugins.nherve.toolbox.Algorithm; import plugins.nherve.toolbox.NherveToolbox; import plugins.nherve.toolbox.image.BinaryIcyBufferedImage; @@ -62,10 +66,10 @@ import java.util.ArrayList; * * @author Nicolas HERVE - nicolas.herve@pasteur.fr */ +@IcyPluginName("Color Picker Threshold") +@IcyPluginIcon(path = "/ColorPickerThreshold_icon.png") public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPickerThreshold.ColorPickerThresholdPainter> implements ActionListener, ChangeListener, ItemListener { - class ColorBox extends JPanel implements ActionListener { - /** * The color selector manages and displays the colors picked by the * user. @@ -73,7 +77,6 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic * @author Nicolas HERVE - nicolas.herve@pasteur.fr */ private class ColorSelector extends JPanel implements MouseListener { - private final ColorBox box; /** @@ -86,6 +89,7 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic setOpaque(true); } + @Contract(pure = true) @Override public Dimension getPreferredSize() { return COL_DIM; @@ -99,7 +103,7 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic * ) */ @Override - public void mouseClicked(final MouseEvent me) { + public void mouseClicked(final @NotNull MouseEvent me) { if (me.getButton() == MouseEvent.BUTTON1) { final int row = (int) Math.floor((double) me.getY() / (double) COL_FULL_BLOCK_SIZE); final int col = (int) Math.floor((double) me.getX() / (double) COL_FULL_BLOCK_SIZE); @@ -114,6 +118,7 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic * java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent * ) */ + @Contract(pure = true) @Override public void mouseEntered(final MouseEvent e) { // Nothing to do here @@ -126,6 +131,7 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic * java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent * ) */ + @Contract(pure = true) @Override public void mouseExited(final MouseEvent e) { // Nothing to do here @@ -138,6 +144,7 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic * java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent * ) */ + @Contract(pure = true) @Override public void mousePressed(final MouseEvent e) { // Nothing to do here @@ -150,6 +157,7 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic * java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent * ) */ + @Contract(pure = true) @Override public void mouseReleased(final MouseEvent e) { // Nothing to do here @@ -161,7 +169,7 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic * @see javax.swing.JComponent#paintComponent(java.awt.Graphics) */ @Override - public void paintComponent(final Graphics g) { + public void paintComponent(final @NotNull Graphics g) { g.setColor(getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); @@ -354,7 +362,7 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic } @Override - public void actionPerformed(final ActionEvent e) { + public void actionPerformed(final @NotNull ActionEvent e) { final Object o = e.getSource(); if (o == null) { @@ -373,7 +381,6 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic } } } - } /** @@ -382,7 +389,6 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic * @author Nicolas HERVE - nicolas.herve@pasteur.fr */ interface ColorBoxListener { - /** * Cancel filter. */ @@ -405,7 +411,6 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic * @author Nicolas HERVE - nicolas.herve@pasteur.fr */ public class ColorPickerThresholdPainter extends Overlay implements ColorBoxListener { - /** * The mask. */ @@ -577,13 +582,10 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic public void setSequence(final Sequence sequence) { this.sequence = sequence; } - } private final static int COL_BLOCK_BORDER = 1; - private final static int COL_BLOCK_SPACER = 1; - private final static int COL_BLOCK_SIZE = 25; /** @@ -788,7 +790,7 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ @Override - public void actionPerformed(final ActionEvent e) { + public void actionPerformed(final @NotNull ActionEvent e) { final Object o = e.getSource(); if (o == null) { @@ -877,7 +879,6 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic } if (o instanceof JRadioButton) { - final JRadioButton b = (JRadioButton) e.getSource(); if (b == rbRGB) { choosenCS = ColorSpaceTools.RGB; @@ -945,7 +946,7 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic * @return the mask * @throws SignatureException the signature exception */ - private Mask doFilter(final ColorPickerThresholdPainter painter) throws SignatureException { + private Mask doFilter(final @NotNull ColorPickerThresholdPainter painter) throws SignatureException { final Sequence currentSequence = painter.getSequence(); final IcyBufferedImage currentImage = currentSequence.getFirstImage(); Mask m = null; @@ -976,7 +977,7 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic * @return the mask * @throws MaskException the mask exception */ - private Mask filter1(final ColorBox box, final IcyBufferedImage image) throws MaskException { + private @NotNull Mask filter1(final @NotNull ColorBox box, final IcyBufferedImage image) throws MaskException { if (box.nbColors == 0) { throw new MaskException("No color selected, filtering aborted"); } @@ -1035,7 +1036,7 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic * @throws MaskException the mask exception * @throws SignatureException the signature exception */ - private Mask filter2(final ColorBox boxP, final ColorBox boxN, final IcyBufferedImage image) throws MaskException, SignatureException { + private @NotNull Mask filter2(final @NotNull ColorBox boxP, final ColorBox boxN, final IcyBufferedImage image) throws MaskException, SignatureException { if (boxP.nbColors == 0) { throw new MaskException("No positive color selected, filtering aborted"); } @@ -1130,7 +1131,7 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic * java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent) */ @Override - public void itemStateChanged(final ItemEvent e) { + public void itemStateChanged(final @NotNull ItemEvent e) { final Object o = e.getSource(); if (o == null) { @@ -1214,7 +1215,7 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic * * @param distance the new distance */ - public void setDistance(final ColorDistance distance) { + public void setDistance(final @NotNull ColorDistance distance) { this.distance = distance; colMaxDist = (int) Math.floor(distance.getMaxDistance()); @@ -1230,7 +1231,7 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic } @Override - public void fillInterface(final JPanel mainPanel) { + public void fillInterface(final @NotNull JPanel mainPanel) { // KNN final ButtonGroup bgd = new ButtonGroup(); rbL1 = new JRadioButton("L1"); @@ -1369,7 +1370,7 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic * ) */ @Override - public void stateChanged(final ChangeEvent e) { + public void stateChanged(final @NotNull ChangeEvent e) { final JSlider s = (JSlider) e.getSource(); if (s == null) { return; @@ -1399,5 +1400,4 @@ public class ColorPickerThreshold extends PainterManagerSingletonPlugin<ColorPic @Override public void stopInterface() { } - }