diff --git a/.gitignore b/.gitignore index 3d47f986c41db29ec6dc0d5036bf760b3a1cf366..57f16fb67c1b1589981416b323d7a9debc728665 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,41 @@ -.idea/ +/build* +/workspace +setting.xml +release/ target/ -.settings/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ +icy.log + +### IntelliJ IDEA ### +.idea/ +*.iws *.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath .project -.classpath \ No newline at end of file +.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 3a88b344ed81becfb690c665931456862dbbb9a0..b1cf0acc61b86c43955910f4754b2897c234a50f 100644 --- a/pom.xml +++ b/pom.xml @@ -6,16 +6,14 @@ <!-- Inherited Icy Parent POM --> <parent> - <artifactId>pom-icy</artifactId> + <artifactId>pom-icy</artifactId> <groupId>org.bioimageanalysis.icy</groupId> - <version>2.0.0</version> - </parent> + <version>3.0.0-a.1</version> + </parent> <!-- Project Information --> <artifactId>timestamp-overlay</artifactId> - <version>1.0.6</version> - - <packaging>jar</packaging> + <version>2.0.0-a.1</version> <name>Timestamp Overlay</name> <description>Displays a customizable time stamp over a 2D sequence.</description> @@ -53,35 +51,11 @@ </developer> </developers> - <!-- Project properties --> - <properties> - - </properties> - - <profiles> - <profile> - <id>icy-plugin</id> - <activation> - <activeByDefault>true</activeByDefault> - </activation> - </profile> - </profiles> - - <!-- List of project's dependencies --> - <dependencies> - <!-- The core of Icy --> - <dependency> - <groupId>org.bioimageanalysis.icy</groupId> - <artifactId>icy-kernel</artifactId> - </dependency> - </dependencies> - <!-- Icy Maven repository (to find parent POM) --> <repositories> <repository> <id>icy</id> - <name>Icy's Nexus</name> - <url>https://icy-nexus.pasteur.fr/repository/Icy/</url> + <url>https://nexus-icy.pasteur.cloud/repository/icy/</url> </repository> </repositories> </project> diff --git a/src/main/java/plugins/fab/timestamp/TimeStampOverlay$DisplayStyle.class b/src/main/java/plugins/fab/timestamp/TimeStampOverlay$DisplayStyle.class deleted file mode 100644 index dfca7e9ba05cd8567731af1d9f74b4c160bbee1b..0000000000000000000000000000000000000000 Binary files a/src/main/java/plugins/fab/timestamp/TimeStampOverlay$DisplayStyle.class and /dev/null differ diff --git a/src/main/java/plugins/fab/timestamp/TimeStampOverlay.class b/src/main/java/plugins/fab/timestamp/TimeStampOverlay.class deleted file mode 100644 index a3e9ba1400212327f34cf891c077f373e2dac685..0000000000000000000000000000000000000000 Binary files a/src/main/java/plugins/fab/timestamp/TimeStampOverlay.class and /dev/null differ diff --git a/src/main/java/plugins/fab/timestamp/TimeStampOverlay.java b/src/main/java/plugins/fab/timestamp/TimeStampOverlay.java index 0d3ea623a4e026ed7a6accd0b8fc08d8fe6ab32b..dfb558f1e2af5be227ac046418d47e051667a064 100644 --- a/src/main/java/plugins/fab/timestamp/TimeStampOverlay.java +++ b/src/main/java/plugins/fab/timestamp/TimeStampOverlay.java @@ -1,28 +1,43 @@ +/* + * Copyright (c) 2010-2024. 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.fab.timestamp; -import java.awt.Color; -import java.awt.Font; -import java.awt.Graphics2D; +import org.bioimageanalysis.icy.common.geom.point.Point5D; +import org.bioimageanalysis.icy.common.math.MathUtil; +import org.bioimageanalysis.icy.common.math.UnitUtil; +import org.bioimageanalysis.icy.common.string.StringUtil; +import org.bioimageanalysis.icy.gui.GraphicsUtil; +import org.bioimageanalysis.icy.gui.canvas.IcyCanvas; +import org.bioimageanalysis.icy.model.overlay.Overlay; +import org.bioimageanalysis.icy.model.sequence.Sequence; +import org.bioimageanalysis.icy.system.logging.IcyLogger; +import org.jetbrains.annotations.NotNull; + +import java.awt.*; import java.awt.event.KeyEvent; -import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.util.concurrent.TimeUnit; -import icy.canvas.IcyCanvas; -import icy.gui.frame.progress.AnnounceFrame; -import icy.math.MathUtil; -import icy.math.UnitUtil; -import icy.painter.Overlay; -import icy.sequence.Sequence; -import icy.util.GraphicsUtil; -import icy.util.StringUtil; - -public class TimeStampOverlay extends Overlay -{ - enum DisplayStyle - { +public class TimeStampOverlay extends Overlay { + enum DisplayStyle { FRAME, TIME - }; + } String timeStampText; int x; @@ -33,8 +48,7 @@ public class TimeStampOverlay extends Overlay int fontSize = 20; int displaySelectionIndex = 0; - public TimeStampOverlay(Sequence sequence) - { + public TimeStampOverlay(final @NotNull Sequence sequence) { super("Timestamp"); x = 20; @@ -44,14 +58,12 @@ public class TimeStampOverlay extends Overlay /** * Display the time with all the units. - * - * @param valueInMs - * : value in milliseconds + * + * @param valueInMs : value in milliseconds * @param displayMs : Even if a unit is not relevant (equals to zero), it will be displayed. * @return <b>Example:</b> "2h 3min 40sec 350ms". */ - public static String getTimeAsString(double valueInMs, boolean displayMs) - { + public static String getTimeAsString(final double valueInMs, final boolean displayMs) { double v = Math.abs(valueInMs); final int day = (int) (v / (24d * 60d * 60d * 1000d)); @@ -69,37 +81,34 @@ public class TimeStampOverlay extends Overlay if (day > 0) result += day + "d "; if (hour > 0) - result += String.format("%2dh ", Integer.valueOf(hour)); + result += String.format("%2dh ", hour); else if (!StringUtil.isEmpty(result)) result += "00h "; if (minute > 0) - result += String.format("%2dmin ", Integer.valueOf(minute)); + result += String.format("%2dmin ", minute); else if (!StringUtil.isEmpty(result)) result += "00min "; if (second > 0) - result += String.format("%2dsec ", Integer.valueOf(second)); + result += String.format("%2dsec ", second); else if (!StringUtil.isEmpty(result)) result += "00sec "; if (ms > 0d) - result += String.format("%05.1fms", Double.valueOf(ms)); + result += String.format("%05.1fms", ms); else if (displayMs && !StringUtil.isEmpty(result)) - result += String.format("%05.1fms", Double.valueOf(0)); + result += String.format("%05.1fms", 0d); return result; } @Override - public void paint(Graphics2D g, Sequence sequence, IcyCanvas canvas) - { - + public void paint(final Graphics2D g, final Sequence sequence, final IcyCanvas canvas) { if (g == null) return; g.setColor(Color.white); g.setFont(font); - switch (displayStyle) - { + switch (displayStyle) { case FRAME: timeStampText = "Current frame: " + canvas.getPositionT(); break; @@ -107,7 +116,7 @@ public class TimeStampOverlay extends Overlay case TIME: final double timeIntervalMs = sequence.getTimeInterval() * 1000d; final TimeUnit unit = UnitUtil.getBestTimeUnit(timeIntervalMs * 10); - double ms = canvas.getPositionT() * timeIntervalMs; + final double ms = canvas.getPositionT() * timeIntervalMs; // minute or "higher" time unit ? if (unit.ordinal() >= TimeUnit.MINUTES.ordinal()) @@ -119,32 +128,28 @@ public class TimeStampOverlay extends Overlay g.drawString(timeStampText, x, y); - Rectangle2D r = GraphicsUtil.getStringBounds(g, font, timeStampText); + final Rectangle2D r = GraphicsUtil.getStringBounds(g, font, timeStampText); r.setRect(r.getX() + x, r.getY() + y, r.getWidth(), r.getHeight()); textBound = r; } @Override - public void keyPressed(KeyEvent e, Point2D imagePoint, IcyCanvas canvas) - { + public void keyPressed(final KeyEvent e, final Point5D.Double imagePoint, final IcyCanvas canvas) { if (e.isConsumed()) return; - if (e.getKeyChar() == 'm') - { + if (e.getKeyChar() == 'm') { x = (int) imagePoint.getX(); y = (int) imagePoint.getY(); - canvas.getSequence().painterChanged(this); + canvas.getSequence().overlayChanged(this); return; } // if ( !isPointInTextArea( imagePoint ) ) return; - if (e.getKeyChar() == 't') - { + if (e.getKeyChar() == 't') { displaySelectionIndex++; - if (displaySelectionIndex >= DisplayStyle.values().length) - { + if (displaySelectionIndex >= DisplayStyle.values().length) { displaySelectionIndex = 0; } @@ -152,26 +157,23 @@ public class TimeStampOverlay extends Overlay } - if (e.getKeyChar() == '+') - { + if (e.getKeyChar() == '+') { fontSize++; } - if (e.getKeyChar() == '-') - { + if (e.getKeyChar() == '-') { fontSize--; if (fontSize < 2) fontSize = 2; } - if (e.getKeyChar() == 'k') - { - canvas.getSequence().removePainter(this); - new AnnounceFrame("Time Stamp removed", 2); + if (e.getKeyChar() == 'k') { + canvas.getSequence().removeOverlay(this); + IcyLogger.info(this.getClass(), "Time Stamp removed"); } font = new Font("Arial", Font.BOLD, fontSize); - canvas.getSequence().painterChanged(this); + canvas.getSequence().overlayChanged(this); e.consume(); } diff --git a/src/main/java/plugins/fab/timestamp/Timestamp.class b/src/main/java/plugins/fab/timestamp/Timestamp.class deleted file mode 100644 index 09638ce64d13ceab40237f6f438d4c8e12bb17ef..0000000000000000000000000000000000000000 Binary files a/src/main/java/plugins/fab/timestamp/Timestamp.class and /dev/null differ diff --git a/src/main/java/plugins/fab/timestamp/Timestamp.java b/src/main/java/plugins/fab/timestamp/Timestamp.java index e6d10a77ff8c91e2985b668cb319f938e7e3289a..e54ab37a34e50c82ac397ab897ee91e35fa29307 100644 --- a/src/main/java/plugins/fab/timestamp/Timestamp.java +++ b/src/main/java/plugins/fab/timestamp/Timestamp.java @@ -1,17 +1,34 @@ -package plugins.fab.timestamp; +/* + * Copyright (c) 2010-2024. 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 icy.gui.frame.progress.ToolTipFrame; -import icy.plugin.abstract_.PluginActionable; -import icy.sequence.Sequence; +package plugins.fab.timestamp; -public class Timestamp extends PluginActionable -{ +import org.bioimageanalysis.icy.extension.plugin.abstract_.PluginActionable; +import org.bioimageanalysis.icy.extension.plugin.annotation_.IcyPluginName; +import org.bioimageanalysis.icy.gui.frame.progress.ToolTipFrame; +import org.bioimageanalysis.icy.model.sequence.Sequence; +@IcyPluginName("Timestamp") +public class Timestamp extends PluginActionable { // IcyFrame mainFrame ; @Override - public void run() - { + public void run() { new ToolTipFrame("<html>" + "<b>TimeStamp added.</b>" + "<br>" + "<br>Place your cursor over the TimeStamp's text and type one of the following letters to change the display:" + "<br>" + "<li> t : switch from frame to time (using time scale) display"