diff --git a/.gitignore b/.gitignore index 3d47f986c41db29ec6dc0d5036bf760b3a1cf366..8d47cace3a5bd898da9fb12bed716d60838191a4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ target/ .settings/ *.iml .project -.classpath \ No newline at end of file +.classpath +**/.DS_Store \ No newline at end of file diff --git a/pom.xml b/pom.xml index b79a069ae84ebba1bb6c23cbb9e91fbdcc743d36..66e632e42062de4569185d6a0fe698df70bf2785 100644 --- a/pom.xml +++ b/pom.xml @@ -6,20 +6,18 @@ <!-- 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>2.2.0</version> + </parent> <!-- Project Information --> <artifactId>microscope-remote</artifactId> - <version>2.3.1</version> - - <packaging>jar</packaging> + <version>3.0.0</version> <name>Microscope Remote</name> - <description>Move your XY Stage and Focus Device with your mouse. </description> - <url>http://icy.bioimageanalysis.org/plugin/microscope-remote/</url> + <description>Move your XY Stage and Focus Device with your mouse.</description> + <url>https://icy.bioimageanalysis.org/plugin/microscope-remote/</url> <inceptionYear>2020</inceptionYear> <organization> @@ -53,47 +51,12 @@ </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> - <version>${icy-kernel.version}</version> - </dependency> - - <dependency> - <groupId>org.bioimageanalysis.icy</groupId> - <artifactId>icy-insubstantial</artifactId> - <version>${icy-insubstantial.version}</version> - <exclusions> - <exclusion> - <groupId>*</groupId> - <artifactId>*</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> <groupId>org.bioimageanalysis.icy</groupId> <artifactId>micromanager</artifactId> - <version>${micromanager.version}</version> </dependency> - </dependencies> <!-- Icy Maven repository (to find parent POM) --> diff --git a/src/main/java/plugins/tprovoost/Microscopy/MicroscopeRemote/MicroscopeRemotePlugin.java b/src/main/java/plugins/tprovoost/Microscopy/MicroscopeRemote/MicroscopeRemotePlugin.java index 601ac96de0db514eec4101d81135dcf65b555096..d49896a9ce9440b461bf6cd6afb2702ee10fd194 100644 --- a/src/main/java/plugins/tprovoost/Microscopy/MicroscopeRemote/MicroscopeRemotePlugin.java +++ b/src/main/java/plugins/tprovoost/Microscopy/MicroscopeRemote/MicroscopeRemotePlugin.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.Microscopy.MicroscopeRemote; import icy.gui.frame.IcyFrameAdapter; @@ -8,25 +26,20 @@ import plugins.tprovoost.Microscopy.gui.RemoteFrame; /** * @author Irsath Nguyen */ -public class MicroscopeRemotePlugin extends MicroscopePlugin -{ +public class MicroscopeRemotePlugin extends MicroscopePlugin { // static instance static RemoteFrame instance = null; - public MicroscopeRemotePlugin() - { - if (instance == null) - { + public MicroscopeRemotePlugin() { + if (instance == null) { // Creation of the frame. instance = new RemoteFrame(this); // Add a listener on the frame : when the frame is closed // the plugin is removed from the GUI plugin - instance.addFrameListener(new IcyFrameAdapter() - { + instance.addFrameListener(new IcyFrameAdapter() { @Override - public void icyFrameClosed(IcyFrameEvent e) - { + public void icyFrameClosed(final IcyFrameEvent e) { shutdown(); } }); @@ -34,15 +47,13 @@ public class MicroscopeRemotePlugin extends MicroscopePlugin } @Override - public void start() - { + public void start() { if (instance != null) instance.toFront(); } @Override - public void shutdown() - { + public void shutdown() { super.shutdown(); if (instance != null) diff --git a/src/main/java/plugins/tprovoost/Microscopy/gui/InverterCheckBox.java b/src/main/java/plugins/tprovoost/Microscopy/gui/InverterCheckBox.java index 417b1b31742e1a4efb4bc08a933b842f37483248..2f1625876872c079ca41fee799cbec600e76bbef 100644 --- a/src/main/java/plugins/tprovoost/Microscopy/gui/InverterCheckBox.java +++ b/src/main/java/plugins/tprovoost/Microscopy/gui/InverterCheckBox.java @@ -1,78 +1,86 @@ +/* + * 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.Microscopy.gui; -import java.awt.Color; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.RenderingHints; +import javax.swing.*; +import java.awt.*; import java.awt.image.BufferedImage; -import javax.swing.JCheckBox; - public class InverterCheckBox extends JCheckBox { + private static final int KNOB_LENGTH = 40; + private static final int KNOB_HEIGHT = 20; + private static final int BUTTON_SIZE = 20; - /** */ - private static final long serialVersionUID = 4893333197103321565L; - - private static int knobLength = 40; - private static int knobHeight = 20; - private static int buttonSize = 20; - - // IMAGES - private BufferedImage imgBtnInvertOn; - private BufferedImage imgBtnInvertOff; - private BufferedImage imgLightOn; - private BufferedImage imgLightOff; + // IMAGES + private BufferedImage imgBtnInvertOn; + private BufferedImage imgBtnInvertOff; + private BufferedImage imgLightOn; + private BufferedImage imgLightOff; - public InverterCheckBox(String string) { - super(string); - } + public InverterCheckBox(final String string) { + super(string); + } - public void setImages(BufferedImage imgBtnInvertOn, - BufferedImage imgBtnInvertOff, BufferedImage imgLightOn, - BufferedImage imgLightOff) { - this.imgBtnInvertOn = imgBtnInvertOn; - this.imgBtnInvertOff = imgBtnInvertOff; - this.imgLightOn = imgLightOn; - this.imgLightOff = imgLightOff; - } + public void setImages(final BufferedImage imgBtnInvertOn, final BufferedImage imgBtnInvertOff, final BufferedImage imgLightOn, final BufferedImage imgLightOff) { + this.imgBtnInvertOn = imgBtnInvertOn; + this.imgBtnInvertOff = imgBtnInvertOff; + this.imgLightOn = imgLightOn; + this.imgLightOff = imgLightOff; + } - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - boolean selected = isSelected(); - String text = getText(); - Font f = new Font("Arial", Font.BOLD, 16); - int actualWidthIdx = 30; - int height = getHeight(); + @Override + protected void paintComponent(final Graphics g) { + super.paintComponent(g); + final boolean selected = isSelected(); + final String text = getText(); + final Font f = new Font("Arial", Font.BOLD, 16); + int actualWidthIdx = 30; + final int height = getHeight(); - Graphics2D g2 = (Graphics2D) g.create(); - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); - g2.setFont(f); - FontMetrics fm = g2.getFontMetrics(); - g2.setColor(new Color(39, 39, 39, 255)); - g2.fillRect(0, 0, getWidth(), height); - g2.setColor(Color.lightGray); + final Graphics2D g2 = (Graphics2D) g.create(); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2.setFont(f); + final FontMetrics fm = g2.getFontMetrics(); + g2.setColor(new Color(39, 39, 39, 255)); + g2.fillRect(0, 0, getWidth(), height); + g2.setColor(Color.lightGray); - // Draw the knob - if (selected) { - g2.drawImage(imgBtnInvertOn, actualWidthIdx - 20, height / 2- knobHeight / 2, knobLength, knobHeight, null); - } else { - g2.drawImage(imgBtnInvertOff, actualWidthIdx - 20, height / 2- knobHeight / 2, knobLength, knobHeight, null); - } - actualWidthIdx += 20; + // Draw the knob + if (selected) { + g2.drawImage(imgBtnInvertOn, actualWidthIdx - 20, height / 2 - KNOB_HEIGHT / 2, KNOB_LENGTH, KNOB_HEIGHT, null); + } + else { + g2.drawImage(imgBtnInvertOff, actualWidthIdx - 20, height / 2 - KNOB_HEIGHT / 2, KNOB_LENGTH, KNOB_HEIGHT, null); + } + actualWidthIdx += 20; - // draw the text - g2.drawString(text, actualWidthIdx += 20, height / 2 + fm.getHeight()/ 2); - actualWidthIdx += 120; + // draw the text + g2.drawString(text, actualWidthIdx += 20, height / 2 + fm.getHeight() / 2); + actualWidthIdx += 120; - // draw the light - if (selected) { - g2.drawImage(imgLightOn, actualWidthIdx + 20, height / 2- buttonSize / 2, buttonSize, buttonSize, null); - } else { - g2.drawImage(imgLightOff, actualWidthIdx + 20, height / 2- buttonSize / 2, buttonSize, buttonSize, null); - } - g2.dispose(); - } + // draw the light + if (selected) { + g2.drawImage(imgLightOn, actualWidthIdx + 20, height / 2 - BUTTON_SIZE / 2, BUTTON_SIZE, BUTTON_SIZE, null); + } + else { + g2.drawImage(imgLightOff, actualWidthIdx + 20, height / 2 - BUTTON_SIZE / 2, BUTTON_SIZE, BUTTON_SIZE, null); + } + g2.dispose(); + } } \ No newline at end of file diff --git a/src/main/java/plugins/tprovoost/Microscopy/gui/MemoryButton.java b/src/main/java/plugins/tprovoost/Microscopy/gui/MemoryButton.java index 75d0325a1d4885a4099a660934133bcd741e2393..4cf2a336f9db0ff3f29a834e8a990137a24f506d 100644 --- a/src/main/java/plugins/tprovoost/Microscopy/gui/MemoryButton.java +++ b/src/main/java/plugins/tprovoost/Microscopy/gui/MemoryButton.java @@ -1,28 +1,35 @@ -package plugins.tprovoost.Microscopy.gui; +/* + * 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.Color; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.RenderingHints; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.image.BufferedImage; - -import javax.swing.JButton; +package plugins.tprovoost.Microscopy.gui; import icy.gui.frame.progress.AnnounceFrame; import icy.gui.frame.progress.FailedAnnounceFrame; import icy.type.point.Point3D; import plugins.tprovoost.Microscopy.MicroManager.tools.StageMover; -public class MemoryButton extends JButton implements MouseListener -{ - - /** Default serial UID */ - private static final long serialVersionUID = 1L; +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.image.BufferedImage; +public class MemoryButton extends JButton implements MouseListener { /** * When the button is pressed, the {@link System#nanoTime()} is stored in * this variable. @@ -30,14 +37,15 @@ public class MemoryButton extends JButton implements MouseListener long datePressed = 0; // IMAGES FOR DRAWING - private BufferedImage imgMemBtnOn = null; - private BufferedImage imgMemBtnOff = null; + private final BufferedImage imgMemBtnOn; + private final BufferedImage imgMemBtnOff; - /** This variable contains the value of the 3D point in this memory button. */ + /** + * This variable contains the value of the 3D point in this memory button. + */ private Point3D.Double memoryButtonPoint; - public MemoryButton(String string, BufferedImage imgMemBtnOn, BufferedImage imgMemBtnOff) - { + public MemoryButton(final String string, final BufferedImage imgMemBtnOn, final BufferedImage imgMemBtnOff) { super(string); this.imgMemBtnOn = imgMemBtnOn; @@ -46,15 +54,13 @@ public class MemoryButton extends JButton implements MouseListener addMouseListener(this); } - private void forgetPoint() - { + private void forgetPoint() { memoryButtonPoint = null; setSelected(false); } - private void rememberPoint() throws Exception - { - Point3D.Double xyz = StageMover.getXYZ(); + private void rememberPoint() throws Exception { + final Point3D.Double xyz = StageMover.getXYZ(); if (memoryButtonPoint == null) memoryButtonPoint = xyz; else @@ -62,33 +68,27 @@ public class MemoryButton extends JButton implements MouseListener setSelected(true); } - private void gotoPoint() throws Exception - { - if (memoryButtonPoint != null) - { + private void gotoPoint() throws Exception { + if (memoryButtonPoint != null) { StageMover.moveXYAbsolute(memoryButtonPoint.x, memoryButtonPoint.y); StageMover.moveZAbsolute(memoryButtonPoint.z); } } @Override - public void mouseEntered(MouseEvent e) - { + public void mouseEntered(final MouseEvent e) { } @Override - public void mouseExited(MouseEvent e) - { + public void mouseExited(final MouseEvent e) { } @Override - public void mouseClicked(MouseEvent e) - { + public void mouseClicked(final MouseEvent e) { } @Override - public void mousePressed(MouseEvent e) - { + public void mousePressed(final MouseEvent e) { if (e.isControlDown()) forgetPoint(); else @@ -96,62 +96,55 @@ public class MemoryButton extends JButton implements MouseListener } @Override - public void mouseReleased(MouseEvent e) - { + public void mouseReleased(final MouseEvent e) { // quick press ? - if (System.nanoTime() - datePressed < 1500000000L) - { - try - { + if (System.nanoTime() - datePressed < 1500000000L) { + try { gotoPoint(); } - catch (Exception e1) - { + catch (final Exception e1) { new AnnounceFrame("Error while going to the saved point."); } } - else - { + else { // long press - try - { + try { rememberPoint(); } - catch (Exception e1) - { + catch (final Exception e1) { new FailedAnnounceFrame("Failed to save position, please try again", 3); } } } @Override - public void paint(Graphics g) - { + public void paint(final Graphics g) { super.paint(g); - boolean selected = isSelected(); - int width = getWidth(); - int height = getHeight(); - Graphics2D g2 = (Graphics2D) g.create(); + final boolean selected = isSelected(); + final int width = getWidth(); + final int height = getHeight(); + final Graphics2D g2 = (Graphics2D) g.create(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - if (selected) - { + if (selected) { g2.drawImage(imgMemBtnOn, 0, 0, width, height, null); g2.setColor(Color.black); } - else - { + else { g2.drawImage(imgMemBtnOff, 0, 0, width, height, null); g2.setColor(Color.LIGHT_GRAY); } g2.setFont(new Font("Arial", Font.BOLD, 20)); - FontMetrics fm = g2.getFontMetrics(); - String toDisplay = getText(); - g2.drawString(toDisplay, width / 2 - fm.charsWidth(toDisplay.toCharArray(), 0, toDisplay.length()) / 2, - height / 2 + fm.getHeight() / 3); + final FontMetrics fm = g2.getFontMetrics(); + final String toDisplay = getText(); + g2.drawString( + toDisplay, + width / 2 - fm.charsWidth(toDisplay.toCharArray(), 0, toDisplay.length()) / 2, + height / 2 + fm.getHeight() / 3 + ); g2.dispose(); } } \ No newline at end of file diff --git a/src/main/java/plugins/tprovoost/Microscopy/gui/PanelMoverXY.java b/src/main/java/plugins/tprovoost/Microscopy/gui/PanelMoverXY.java index 5a1d2f32b654c0dbb80ae27b126bda7a60a926a0..ce128cc336cbd3bbd4a7b31a0a068a8109c142c5 100644 --- a/src/main/java/plugins/tprovoost/Microscopy/gui/PanelMoverXY.java +++ b/src/main/java/plugins/tprovoost/Microscopy/gui/PanelMoverXY.java @@ -1,14 +1,29 @@ +/* + * 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.Microscopy.gui; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.GradientPaint; -import java.awt.Graphics; -import java.awt.Graphics2D; +import plugins.tprovoost.Microscopy.MicroManager.MicroManager; +import plugins.tprovoost.Microscopy.MicroManager.tools.StageMover; + +import javax.swing.*; +import java.awt.*; import java.awt.MultipleGradientPaint.CycleMethod; -import java.awt.Paint; -import java.awt.RadialGradientPaint; -import java.awt.RenderingHints; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; @@ -16,32 +31,21 @@ import java.awt.geom.AffineTransform; import java.awt.geom.Point2D; import java.awt.image.BufferedImage; -import javax.swing.JPanel; - -import plugins.tprovoost.Microscopy.MicroManager.MicroManager; -import plugins.tprovoost.Microscopy.MicroManager.tools.StageMover; - /** * @author Irsath Nguyen */ -public class PanelMoverXY extends JPanel implements MouseListener, MouseMotionListener, Runnable -{ - - /** - * Generated serial UID - */ - private static final long serialVersionUID = -5025582239086787935L; - +public class PanelMoverXY extends JPanel implements MouseListener, MouseMotionListener, Runnable { private BufferedImage imgXYBg = null; private static final int SIZE_PANEL_MOVER = 200; - /** Movement Vector */ - private Point2D vector; - private RemoteFrame frame; - private Thread moveThread; + /** + * Movement Vector + */ + private final Point2D vector; + private final RemoteFrame frame; + private final Thread moveThread; - public PanelMoverXY(RemoteFrame frame) - { + public PanelMoverXY(final RemoteFrame frame) { super(); this.frame = frame; @@ -59,95 +63,90 @@ public class PanelMoverXY extends JPanel implements MouseListener, MouseMotionLi } @Override - public void paintComponent(Graphics g) - { + public void paintComponent(final Graphics g) { super.paintComponent(g); - int w = getWidth(); - int h = getHeight(); - AffineTransform at; - Graphics2D g2 = (Graphics2D) g.create(); + final int w = getWidth(); + final int h = getHeight(); + final AffineTransform at; + final Graphics2D g2 = (Graphics2D) g.create(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setColor(new Color(39, 39, 39)); g2.fillRect(0, 0, w, h); - if (imgXYBg != null) - { + if (imgXYBg != null) { g2.drawImage(imgXYBg, 0, 0, w, h, null); - int stickBallDiameter = w / 5; - Point2D centerBall = new Point2D.Double(w / 2d + vector.getX(), h / 2d + vector.getY()); + final int stickBallDiameter = w / 5; + final Point2D centerBall = new Point2D.Double(w / 2d + vector.getX(), h / 2d + vector.getY()); g2.setColor(Color.darkGray); - double normVector = norm(vector); - if (vector.getX() != 0 || vector.getY() != 0) - { + final double normVector = norm(vector); + if (vector.getX() != 0 || vector.getY() != 0) { g2.setColor(Color.blue); // ---------- // draw stick // ---------- - Graphics2D g3 = (Graphics2D) g2.create(); + final Graphics2D g3 = (Graphics2D) g2.create(); at = AffineTransform.getTranslateInstance(centerBall.getX(), centerBall.getY()); at.rotate(-vector.getX(), -vector.getY()); - at.translate(0, -stickBallDiameter / 4); + at.translate(0, -stickBallDiameter / 4d); g3.transform(at); - g3.setPaint(new GradientPaint(new Point2D.Double(0, 0), Color.BLACK, new Point2D.Double(0, - (getWidth() / 5) / 4), Color.LIGHT_GRAY, true)); - g3.fillRoundRect(0, 0, (int) normVector, stickBallDiameter / 2, stickBallDiameter / 2, - stickBallDiameter / 2); + g3.setPaint(new GradientPaint( + new Point2D.Double(0, 0), + Color.BLACK, + new Point2D.Double(0, (getWidth() / 5d) / 4d), + Color.LIGHT_GRAY, + true + )); + g3.fillRoundRect(0, 0, (int) normVector, stickBallDiameter / 2, stickBallDiameter / 2, stickBallDiameter / 2); g3.dispose(); } // --------- // draw ball // --------- - Paint defaultPaint = g2.getPaint(); - Point2D centerGradient = new Point2D.Double(centerBall.getX(), centerBall.getY()); - float radiusGradient = stickBallDiameter / 2; - Point2D focusSpotLightGradient; - if (Math.abs(vector.getX()) <= 1 && Math.abs(vector.getY()) <= 1) - { + final Paint defaultPaint = g2.getPaint(); + final Point2D centerGradient = new Point2D.Double(centerBall.getX(), centerBall.getY()); + final float radiusGradient = stickBallDiameter / 2f; + final Point2D focusSpotLightGradient; + if (Math.abs(vector.getX()) <= 1 && Math.abs(vector.getY()) <= 1) { focusSpotLightGradient = new Point2D.Double(centerBall.getX(), centerBall.getY()); } - else - { - focusSpotLightGradient = new Point2D.Double(centerBall.getX() + vector.getX() * (radiusGradient - 5) - / normVector, centerBall.getY() + vector.getY() / normVector * (radiusGradient - 5)); + else { + focusSpotLightGradient = new Point2D.Double( + centerBall.getX() + vector.getX() * (radiusGradient - 5) / normVector, + centerBall.getY() + vector.getY() / normVector * (radiusGradient - 5) + ); } - float[] dist = {0.1f, 0.3f, 1.0f}; - Color[] colors = {new Color(0.9f, 0.9f, 0.9f), Color.LIGHT_GRAY, Color.DARK_GRAY}; - RadialGradientPaint p = new RadialGradientPaint(centerGradient, radiusGradient, focusSpotLightGradient, - dist, colors, CycleMethod.NO_CYCLE); + final float[] dist = {0.1f, 0.3f, 1.0f}; + final Color[] colors = {new Color(0.9f, 0.9f, 0.9f), Color.LIGHT_GRAY, Color.DARK_GRAY}; + final RadialGradientPaint p = new RadialGradientPaint(centerGradient, radiusGradient, focusSpotLightGradient, dist, colors, CycleMethod.NO_CYCLE); g2.setPaint(p); - g2.fillOval((int) centerBall.getX() - stickBallDiameter / 2, (int) centerBall.getY() - stickBallDiameter - / 2, stickBallDiameter, stickBallDiameter); + g2.fillOval((int) centerBall.getX() - stickBallDiameter / 2, (int) centerBall.getY() - stickBallDiameter / 2, stickBallDiameter, stickBallDiameter); g2.setPaint(defaultPaint); g2.setColor(Color.BLACK); - g2.drawOval((int) centerBall.getX() - stickBallDiameter / 2, (int) centerBall.getY() - stickBallDiameter - / 2, stickBallDiameter, stickBallDiameter); + g2.drawOval((int) centerBall.getX() - stickBallDiameter / 2, (int) centerBall.getY() - stickBallDiameter / 2, stickBallDiameter, stickBallDiameter); } g2.dispose(); } - public void applyMovementXY() throws Exception - { - double vx = vector.getX(); - double vy = vector.getY(); + public void applyMovementXY() throws Exception { + final double vx = vector.getX(); + final double vy = vector.getY(); if (vx == 0 && vy == 0)// no movement, do not send a signal return; - - double normV = norm(vector); - double x = vx / normV; - double y = vy / normV; - - double movementX; - double movementY; - double percent = norm(vector) * frame._sliderSpeed.getValue(); - double pxSize = MicroManager.getPixelSize(); - - if (pxSize == 0d) - { + + final double normV = norm(vector); + final double x = vx / normV; + final double y = vy / normV; + + final double movementX; + final double movementY; + final double percent = norm(vector) * frame._sliderSpeed.getValue(); + final double pxSize = MicroManager.getPixelSize(); + + if (pxSize == 0d) { movementX = x * 0.001 * percent * percent; movementY = y * 0.001 * percent * percent; } - else - { + else { movementX = x * 0.001 * pxSize * percent * percent; movementY = y * 0.001 * pxSize * percent * percent; } @@ -155,20 +154,18 @@ public class PanelMoverXY extends JPanel implements MouseListener, MouseMotionLi StageMover.moveXYRelative(movementX, movementY, true); } - private double norm(Point2D vector) - { - double x = vector.getX(); - double y = vector.getY(); + private double norm(final Point2D vector) { + final double x = vector.getX(); + final double y = vector.getY(); return Math.sqrt(x * x + y * y); } @Override - public void mouseDragged(MouseEvent e) - { + public void mouseDragged(final MouseEvent e) { int x = e.getX(); int y = e.getY(); - int width = getWidth(); - int height = getHeight(); + final int width = getWidth(); + final int height = getHeight(); if (x < 0) x = 0; @@ -179,67 +176,55 @@ public class PanelMoverXY extends JPanel implements MouseListener, MouseMotionLi y = 0; if (y > height) y = height; - vector.setLocation(x - width / 2, y - height / 2); + vector.setLocation(x - width / 2d, y - height / 2d); repaint(); } @Override - public void mousePressed(MouseEvent e) - { - vector.setLocation(e.getX() - (getWidth() / 2), e.getY() - (getHeight() / 2)); + public void mousePressed(final MouseEvent e) { + vector.setLocation(e.getX() - (getWidth() / 2d), e.getY() - (getHeight() / 2d)); repaint(); } @Override - public void mouseReleased(MouseEvent e) - { - vector.setLocation(0, 0); + public void mouseReleased(final MouseEvent e) { + vector.setLocation(0d, 0d); repaint(); } @Override - public void mouseMoved(MouseEvent e) - { + public void mouseMoved(final MouseEvent e) { } @Override - public void mouseClicked(MouseEvent e) - { + public void mouseClicked(final MouseEvent e) { } @Override - public void mouseEntered(MouseEvent e) - { + public void mouseEntered(final MouseEvent e) { } @Override - public void mouseExited(MouseEvent e) - { + public void mouseExited(final MouseEvent e) { } - + @Override - public void run() - { - while (!moveThread.isInterrupted()) - { - try - { + public void run() { + while (!moveThread.isInterrupted()) { + try { applyMovementXY(); Thread.sleep(1); } - catch (InterruptedException e) - { + catch (final InterruptedException e) { moveThread.interrupt(); } - catch (Exception e) - { + catch (final Exception e) { System.err.println(e.getMessage()); } } } - public void shutdown() - { + public void shutdown() { // end process moveThread.interrupt(); } diff --git a/src/main/java/plugins/tprovoost/Microscopy/gui/PanelMoverZ.java b/src/main/java/plugins/tprovoost/Microscopy/gui/PanelMoverZ.java index f6dabc537242f7f313b8fb112366d2273b5c8e1e..6aa7088d1d0490f83076f2fb5ed68170b17db160 100644 --- a/src/main/java/plugins/tprovoost/Microscopy/gui/PanelMoverZ.java +++ b/src/main/java/plugins/tprovoost/Microscopy/gui/PanelMoverZ.java @@ -1,30 +1,36 @@ +/* + * 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.Microscopy.gui; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.RenderingHints; +import plugins.tprovoost.Microscopy.MicroManager.tools.StageMover; + +import javax.swing.*; +import java.awt.*; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.awt.image.BufferedImage; -import javax.swing.JPanel; - -import plugins.tprovoost.Microscopy.MicroManager.tools.StageMover; - /** * @author Irsath Nguyen */ -public class PanelMoverZ extends JPanel implements MouseListener, MouseMotionListener, Runnable -{ - /** - * Generated serial UID - */ - private static final long serialVersionUID = -5025582239086787935L; - +public class PanelMoverZ extends JPanel implements MouseListener, MouseMotionListener, Runnable { // CONSTANTS private static final int SIZE_PANEL_MOVERZ_W = 50; private static final int SIZE_PANEL_MOVERZ_H = 200; @@ -34,16 +40,17 @@ public class PanelMoverZ extends JPanel implements MouseListener, MouseMotionLis private BufferedImage imgZBg = null; private BufferedImage imgZBar = null; - /** Movement Vector */ + /** + * Movement Vector + */ int oldY; private int startPos = 0; - private RemoteFrame frame; - private Thread moveThread; + private final RemoteFrame frame; + private final Thread moveThread; private double offZ = 0d; - public PanelMoverZ(RemoteFrame frame) - { + public PanelMoverZ(final RemoteFrame frame) { super(); this.frame = frame; @@ -61,34 +68,30 @@ public class PanelMoverZ extends JPanel implements MouseListener, MouseMotionLis } @Override - public void paintComponent(Graphics g) - { + public void paintComponent(final Graphics g) { super.paintComponent(g); - int w = getWidth(); - int h = getHeight(); - Graphics2D g2 = (Graphics2D) g.create(); + final int w = getWidth(); + final int h = getHeight(); + final Graphics2D g2 = (Graphics2D) g.create(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setColor(new Color(39, 39, 39)); g2.fillRect(0, 0, w, h); - if (imgZBg != null && imgZBar != null) - { + if (imgZBg != null && imgZBar != null) { // draw the background + joystick g2.drawImage(imgZBg, 0, 0, w, h, null); - double ecartNormal = (double) h / 8d; + final double ecartNormal = (double) h / 8d; double lastPos = h / 2d + startPos; - for (int i = 0; i < BARS_NUMBER; ++i) - { + for (int i = 0; i < BARS_NUMBER; ++i) { g2.drawImage(imgZBar, 0, (int) lastPos, w, imgZBar.getHeight(null) * w / imgZBar.getWidth(null), null); - lastPos = lastPos + ecartNormal / (1d + 0.1 * i * i); + lastPos = lastPos + ecartNormal / (1d + .1d * i * i); if (lastPos > h) break; } lastPos = h / 2d + startPos; - for (int i = 0; i < BARS_NUMBER; ++i) - { + for (int i = 0; i < BARS_NUMBER; ++i) { g2.drawImage(imgZBar, 0, (int) lastPos, w, imgZBar.getHeight(null) * w / imgZBar.getWidth(null), null); - lastPos = lastPos - ecartNormal / (1d + 0.1 * i * i); + lastPos = lastPos - ecartNormal / (1d + .1d * i * i); if (lastPos < 0) break; } @@ -97,30 +100,26 @@ public class PanelMoverZ extends JPanel implements MouseListener, MouseMotionLis } @Override - public void mouseDragged(MouseEvent e) - { + public void mouseDragged(final MouseEvent e) { final int movY = e.getY() - oldY; if (movY == 0) return; oldY = e.getY(); - double ecartNormal = getHeight() / 8d / 2d; - if (movY > 0) - { + final double ecartNormal = getHeight() / 8d / 2d; + if (movY > 0) { ++startPos; if (startPos > ecartNormal) startPos = (int) -ecartNormal; } - else - { + else { --startPos; if (startPos < -ecartNormal) startPos = (int) ecartNormal; } final int percent = frame._sliderSpeed.getValue(); - synchronized (this) - { + synchronized (this) { offZ += movY * 0.1 * percent * percent; } @@ -128,74 +127,60 @@ public class PanelMoverZ extends JPanel implements MouseListener, MouseMotionLis } @Override - public void mouseMoved(MouseEvent e) - { + public void mouseMoved(final MouseEvent e) { } @Override - public void mouseClicked(MouseEvent e) - { + public void mouseClicked(final MouseEvent e) { } @Override - public void mouseEntered(MouseEvent e) - { + public void mouseEntered(final MouseEvent e) { } @Override - public void mouseExited(MouseEvent e) - { + public void mouseExited(final MouseEvent e) { } @Override - public void mousePressed(MouseEvent e) - { + public void mousePressed(final MouseEvent e) { oldY = e.getY(); - setCursor(new Cursor(Cursor.N_RESIZE_CURSOR | Cursor.S_RESIZE_CURSOR)); + setCursor(new Cursor(Cursor.S_RESIZE_CURSOR)); repaint(); } @Override - public void mouseReleased(MouseEvent e) - { + public void mouseReleased(final MouseEvent e) { setCursor(Cursor.getDefaultCursor()); repaint(); } @Override - public void run() - { - while (!moveThread.isInterrupted()) - { + public void run() { + while (!moveThread.isInterrupted()) { final double off; - synchronized (this) - { + synchronized (this) { off = offZ; offZ = 0d; } - if (off != 0d) - { - try - { + if (off != 0d) { + try { StageMover.moveZRelative(off, false); Thread.sleep(1); } - catch (InterruptedException e) - { + catch (final InterruptedException e) { moveThread.interrupt(); } - catch (Exception e) - { + catch (final Exception e) { System.err.println(e.getMessage()); } } } } - public void shutdown() - { + public void shutdown() { // end process moveThread.interrupt(); } diff --git a/src/main/java/plugins/tprovoost/Microscopy/gui/RemoteFrame.java b/src/main/java/plugins/tprovoost/Microscopy/gui/RemoteFrame.java index 3627cffe94dda5311ef5f3231899cc4da0a06886..0decec3250a03c4a9c07461205a02e05091b3a35 100644 --- a/src/main/java/plugins/tprovoost/Microscopy/gui/RemoteFrame.java +++ b/src/main/java/plugins/tprovoost/Microscopy/gui/RemoteFrame.java @@ -1,28 +1,22 @@ -package plugins.tprovoost.Microscopy.gui; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.GridLayout; -import java.awt.RenderingHints; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.image.BufferedImage; -import java.util.prefs.Preferences; +/* + * Copyright (c) 2010-2023. Institut Pasteur. + * + * This file is part of Icy. + * Icy is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Icy is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Icy. If not, see <https://www.gnu.org/licenses/>. + */ -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JSlider; -import javax.swing.SwingConstants; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; +package plugins.tprovoost.Microscopy.gui; import icy.gui.frame.IcyFrame; import icy.gui.util.GuiUtil; @@ -36,6 +30,11 @@ import plugins.tprovoost.Microscopy.MicroManager.tools.StageMover.StageListener; import plugins.tprovoost.Microscopy.MicroManagerForIcy.MicroscopePlugin; import plugins.tprovoost.Microscopy.MicroscopeRemote.MicroscopeRemotePlugin; +import javax.swing.*; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.util.prefs.Preferences; + /** * This class is the core of the Remote Plugin. Three different threads are * running while using this class: @@ -44,11 +43,10 @@ import plugins.tprovoost.Microscopy.MicroscopeRemote.MicroscopeRemotePlugin; * <li>Moving the XY Stage</li> * <li>Moving the Z Stage.</li> * </ul> - * + * * @author Thomas Provoost */ -public class RemoteFrame extends IcyFrame implements StageListener -{ +public class RemoteFrame extends IcyFrame implements StageListener { // ------- // GUI // ------- @@ -65,14 +63,14 @@ public class RemoteFrame extends IcyFrame implements StageListener // IMAGES // -------- public Color transparentColor = new Color(255, 255, 255, 0); - private BufferedImage imgRemoteBg = null; - private BufferedImage imgSliderKnob = null; - private BufferedImage imgMemBtnOn = null; - private BufferedImage imgMemBtnOff = null; - private BufferedImage imgInvertSwitchOn = null; - private BufferedImage imgInvertSwitchOff = null; - private BufferedImage imgInvertLightOn = null; - private BufferedImage imgInvertLightOff = null; + private final BufferedImage imgRemoteBg; + private final BufferedImage imgSliderKnob; + private final BufferedImage imgMemBtnOn; + private final BufferedImage imgMemBtnOff; + private final BufferedImage imgInvertSwitchOn; + private final BufferedImage imgInvertSwitchOff; + private final BufferedImage imgInvertLightOn; + private final BufferedImage imgInvertLightOff; // CONSTANTS public final static String currentPath = "plugins/tprovoost/Microscopy/images/"; @@ -86,8 +84,7 @@ public class RemoteFrame extends IcyFrame implements StageListener private static final String REMOTE = "prefs_remote"; private static final String SPEED = "speed"; - public RemoteFrame(MicroscopeRemotePlugin plugin) - { + public RemoteFrame(final MicroscopeRemotePlugin plugin) { super("Remote", false, true, false, true); this.plugin = plugin; @@ -110,15 +107,14 @@ public class RemoteFrame extends IcyFrame implements StageListener StageMover.addListener(this); } - private void initializeGui() - { + private void initializeGui() { // ------------- // MOUSE MOVER // ------------ panelMoverXY = new PanelMoverXY(RemoteFrame.this); panelMoverZ = new PanelMoverZ(RemoteFrame.this); - JPanel panelMover = GuiUtil.generatePanel(); + final JPanel panelMover = GuiUtil.generatePanel(); panelMover.setLayout(new BoxLayout(panelMover, BoxLayout.X_AXIS)); panelMover.add(panelMoverXY); panelMover.add(Box.createRigidArea(new Dimension(20, 10))); @@ -129,15 +125,14 @@ public class RemoteFrame extends IcyFrame implements StageListener // --------- // SPEED // --------- - JPanel panel_speed = GuiUtil.generatePanel(); + final JPanel panel_speed = GuiUtil.generatePanel(); panel_speed.setLayout(new BoxLayout(panel_speed, BoxLayout.X_AXIS)); panel_speed.setOpaque(false); - _sliderSpeed = new JSlider(1, 10, 1) - { + _sliderSpeed = new JSlider(1, 10, 1) { private static final long serialVersionUID = 1L; - private BufferedImage toDraw; - int heightKnob; + private final BufferedImage toDraw; + final int heightKnob; { heightKnob = (int) (imgSliderKnob.getHeight(null) / 1.5); @@ -145,23 +140,19 @@ public class RemoteFrame extends IcyFrame implements StageListener } @Override - protected void paintComponent(Graphics g) - { - ((Graphics2D) g).drawImage(toDraw, null, (int) ((getValue() - 1) * (getWidth() / getMaximum())), - getHeight() / 2 - heightKnob / 2); + protected void paintComponent(final Graphics g) { + ((Graphics2D) g).drawImage( + toDraw, + null, + (getValue() - 1) * (getWidth() / getMaximum()), + getHeight() / 2 - heightKnob / 2 + ); } }; _sliderSpeed.setOpaque(false); final JLabel lbl_value = new JLabel(" " + _sliderSpeed.getValue()); - _sliderSpeed.addChangeListener(new ChangeListener() - { - @Override - public void stateChanged(ChangeEvent changeevent) - { - lbl_value.setText("" + _sliderSpeed.getValue()); - } - }); + _sliderSpeed.addChangeListener(changeevent -> lbl_value.setText("" + _sliderSpeed.getValue())); panel_speed.add(_sliderSpeed); panel_speed.add(Box.createHorizontalGlue()); @@ -173,38 +164,17 @@ public class RemoteFrame extends IcyFrame implements StageListener // ------------------- _cbInvertX = new InverterCheckBox("Invert X-Axis"); _cbInvertX.setImages(imgInvertSwitchOn, imgInvertSwitchOff, imgInvertLightOn, imgInvertLightOff); - _cbInvertX.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent arg0) - { - StageMover.setInvertX(_cbInvertX.isSelected()); - } - }); + _cbInvertX.addActionListener(arg0 -> StageMover.setInvertX(_cbInvertX.isSelected())); _cbInvertY = new InverterCheckBox("Invert Y-Axis"); _cbInvertY.setImages(imgInvertSwitchOn, imgInvertSwitchOff, imgInvertLightOn, imgInvertLightOff); - _cbInvertY.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent arg0) - { - StageMover.setInvertY(_cbInvertY.isSelected()); - } - }); + _cbInvertY.addActionListener(arg0 -> StageMover.setInvertY(_cbInvertY.isSelected())); _cbInvertZ = new InverterCheckBox("Invert Z-Axis"); _cbInvertZ.setImages(imgInvertSwitchOn, imgInvertSwitchOff, imgInvertLightOn, imgInvertLightOff); - _cbInvertZ.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent arg0) - { - StageMover.setInvertZ(_cbInvertZ.isSelected()); - } - }); + _cbInvertZ.addActionListener(arg0 -> StageMover.setInvertZ(_cbInvertZ.isSelected())); - JPanel panelInvert = GuiUtil.generatePanel(); + final JPanel panelInvert = GuiUtil.generatePanel(); panelInvert.setOpaque(false); panelInvert.setLayout(new GridLayout(3, 1)); panelInvert.setMaximumSize(new Dimension(Integer.MAX_VALUE, 60)); @@ -213,39 +183,30 @@ public class RemoteFrame extends IcyFrame implements StageListener panelInvert.add(_cbInvertZ); // MEMORY BUTTONS - MemoryButton btnM1 = new MemoryButton("M1", imgMemBtnOn, imgMemBtnOff); - MemoryButton btnM2 = new MemoryButton("M2", imgMemBtnOn, imgMemBtnOff); - MemoryButton btnM3 = new MemoryButton("M3", imgMemBtnOn, imgMemBtnOff); - MemoryButton btnM4 = new MemoryButton("M4", imgMemBtnOn, imgMemBtnOff); + final MemoryButton btnM1 = new MemoryButton("M1", imgMemBtnOn, imgMemBtnOff); + final MemoryButton btnM2 = new MemoryButton("M2", imgMemBtnOn, imgMemBtnOff); + final MemoryButton btnM3 = new MemoryButton("M3", imgMemBtnOn, imgMemBtnOff); + final MemoryButton btnM4 = new MemoryButton("M4", imgMemBtnOn, imgMemBtnOff); - JButton btnHelp = new JButton(new IcyIcon(imgMemBtnOff)) - { + final JButton btnHelp = new JButton(new IcyIcon(imgMemBtnOff)) { private static final long serialVersionUID = 1L; @Override - public void paint(Graphics g) - { - int w = getWidth(); - int h = getHeight(); - Graphics2D g2 = (Graphics2D) g; + public void paint(final Graphics g) { + final int w = getWidth(); + final int h = getHeight(); + final Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.drawImage(imgMemBtnOff, 0, 0, w, h, null); g2.setFont(new Font("Arial", Font.BOLD, 16)); - FontMetrics fm = g2.getFontMetrics(); + final FontMetrics fm = g2.getFontMetrics(); g2.setColor(Color.LIGHT_GRAY); g2.drawString("?", getWidth() / 2 - fm.charWidth('?') / 2, getHeight() / 2 + fm.getHeight() / 3); } }; - btnHelp.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent actionevent) - { - NetworkUtil.openBrowser(plugin.getDescriptor().getWeb()); - } - }); + btnHelp.addActionListener(actionevent -> NetworkUtil.openBrowser(plugin.getDescriptor().getWeb())); - JPanel panelMemoryButtons = new JPanel(new GridLayout(1, 4)); + final JPanel panelMemoryButtons = new JPanel(new GridLayout(1, 4)); panelMemoryButtons.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panelMemoryButtons.setOpaque(false); panelMemoryButtons.setPreferredSize(new Dimension(60, 40)); @@ -259,12 +220,10 @@ public class RemoteFrame extends IcyFrame implements StageListener // COORDINATES // ---------- Point3D.Double pos; - try - { + try { pos = StageMover.getXYZ(); } - catch (Exception e) - { + catch (final Exception e) { pos = new Point3D.Double(); } @@ -275,7 +234,7 @@ public class RemoteFrame extends IcyFrame implements StageListener _lblY.setHorizontalAlignment(SwingConstants.CENTER); _lblZ.setHorizontalAlignment(SwingConstants.CENTER); - JPanel panelCoords = new JPanel(new GridLayout(3, 1)); + final JPanel panelCoords = new JPanel(new GridLayout(3, 1)); panelCoords.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panelCoords.setOpaque(false); panelCoords.setBackground(transparentColor); @@ -284,13 +243,9 @@ public class RemoteFrame extends IcyFrame implements StageListener panelCoords.add(Box.createVerticalGlue()); panelCoords.add(_lblZ); - JPanel panelAll = new JPanel() - { - private static final long serialVersionUID = 1L; - + final JPanel panelAll = new JPanel() { @Override - protected void paintComponent(Graphics g) - { + protected void paintComponent(final Graphics g) { checkInverts(); g.drawImage(imgRemoteBg, 0, 0, getWidth(), getHeight(), null); } @@ -314,57 +269,49 @@ public class RemoteFrame extends IcyFrame implements StageListener /** * Load preferences : speed, invertX and invertY. */ - private void loadPreferences() - { - Preferences root = Preferences.userNodeForPackage(getClass()); + private void loadPreferences() { + final Preferences root = Preferences.userNodeForPackage(getClass()); _prefs = root.node(root.absolutePath() + "/" + REMOTE); _sliderSpeed.setValue(_prefs.getInt(SPEED, 1)); checkInverts(); } @Override - public void stateChanged() - { + public void stateChanged() { super.stateChanged(); pack(); } @Override - public void onClosed() - { + public void onClosed() { panelMoverXY.shutdown(); panelMoverZ.shutdown(); _prefs.putInt(SPEED, _sliderSpeed.getValue()); StageMover.removeListener(this); } - private void checkInverts() - { + private void checkInverts() { _cbInvertX.setSelected(StageMover.isInvertX()); _cbInvertY.setSelected(StageMover.isInvertY()); _cbInvertZ.setSelected(StageMover.isInvertZ()); } @Override - public void onStagePositionChanged(String s, double z) - { - _lblZ.setText("Z: " + StringUtil.toString(z, 2) + " �m"); + public void onStagePositionChanged(final String s, final double z) { + _lblZ.setText("Z: " + StringUtil.toString(z, 2) + " μm"); } @Override - public void onXYStagePositionChanged(String s, double x, double y) - { - _lblX.setText("X: " + StringUtil.toString(x, 2) + " �m"); - _lblY.setText("Y: " + StringUtil.toString(y, 2) + " �m"); + public void onXYStagePositionChanged(final String s, final double x, final double y) { + _lblX.setText("X: " + StringUtil.toString(x, 2) + " μm"); + _lblY.setText("Y: " + StringUtil.toString(y, 2) + " μm"); } @Override - public void onXYStagePositionChangedRelative(String s, double d, double d1) - { + public void onXYStagePositionChangedRelative(final String s, final double d, final double d1) { } @Override - public void onStagePositionChangedRelative(String s, double d) - { + public void onStagePositionChangedRelative(final String s, final double d) { } } \ No newline at end of file diff --git a/src/main/java/plugins/tprovoost/Microscopy/images/RemoteFull_2.png b/src/main/resources/plugins/tprovoost/Microscopy/images/RemoteFull_2.png similarity index 100% rename from src/main/java/plugins/tprovoost/Microscopy/images/RemoteFull_2.png rename to src/main/resources/plugins/tprovoost/Microscopy/images/RemoteFull_2.png diff --git a/src/main/java/plugins/tprovoost/Microscopy/images/btnRound.png b/src/main/resources/plugins/tprovoost/Microscopy/images/btnRound.png similarity index 100% rename from src/main/java/plugins/tprovoost/Microscopy/images/btnRound.png rename to src/main/resources/plugins/tprovoost/Microscopy/images/btnRound.png diff --git a/src/main/java/plugins/tprovoost/Microscopy/images/btnRound_off.png b/src/main/resources/plugins/tprovoost/Microscopy/images/btnRound_off.png similarity index 100% rename from src/main/java/plugins/tprovoost/Microscopy/images/btnRound_off.png rename to src/main/resources/plugins/tprovoost/Microscopy/images/btnRound_off.png diff --git a/src/main/java/plugins/tprovoost/Microscopy/images/btn_switchOff.png b/src/main/resources/plugins/tprovoost/Microscopy/images/btn_switchOff.png similarity index 100% rename from src/main/java/plugins/tprovoost/Microscopy/images/btn_switchOff.png rename to src/main/resources/plugins/tprovoost/Microscopy/images/btn_switchOff.png diff --git a/src/main/java/plugins/tprovoost/Microscopy/images/btn_switchOn.png b/src/main/resources/plugins/tprovoost/Microscopy/images/btn_switchOn.png similarity index 100% rename from src/main/java/plugins/tprovoost/Microscopy/images/btn_switchOn.png rename to src/main/resources/plugins/tprovoost/Microscopy/images/btn_switchOn.png diff --git a/src/main/java/plugins/tprovoost/Microscopy/images/knob.png b/src/main/resources/plugins/tprovoost/Microscopy/images/knob.png similarity index 100% rename from src/main/java/plugins/tprovoost/Microscopy/images/knob.png rename to src/main/resources/plugins/tprovoost/Microscopy/images/knob.png diff --git a/src/main/java/plugins/tprovoost/Microscopy/images/memoryOff.png b/src/main/resources/plugins/tprovoost/Microscopy/images/memoryOff.png similarity index 100% rename from src/main/java/plugins/tprovoost/Microscopy/images/memoryOff.png rename to src/main/resources/plugins/tprovoost/Microscopy/images/memoryOff.png diff --git a/src/main/java/plugins/tprovoost/Microscopy/images/memoryOn.png b/src/main/resources/plugins/tprovoost/Microscopy/images/memoryOn.png similarity index 100% rename from src/main/java/plugins/tprovoost/Microscopy/images/memoryOn.png rename to src/main/resources/plugins/tprovoost/Microscopy/images/memoryOn.png diff --git a/src/main/java/plugins/tprovoost/Microscopy/images/remote_backgroundXY.png b/src/main/resources/plugins/tprovoost/Microscopy/images/remote_backgroundXY.png similarity index 100% rename from src/main/java/plugins/tprovoost/Microscopy/images/remote_backgroundXY.png rename to src/main/resources/plugins/tprovoost/Microscopy/images/remote_backgroundXY.png diff --git a/src/main/java/plugins/tprovoost/Microscopy/images/remote_backgroundZ.png b/src/main/resources/plugins/tprovoost/Microscopy/images/remote_backgroundZ.png similarity index 100% rename from src/main/java/plugins/tprovoost/Microscopy/images/remote_backgroundZ.png rename to src/main/resources/plugins/tprovoost/Microscopy/images/remote_backgroundZ.png diff --git a/src/main/java/plugins/tprovoost/Microscopy/images/singleBarZ.png b/src/main/resources/plugins/tprovoost/Microscopy/images/singleBarZ.png similarity index 100% rename from src/main/java/plugins/tprovoost/Microscopy/images/singleBarZ.png rename to src/main/resources/plugins/tprovoost/Microscopy/images/singleBarZ.png