diff --git a/pom.xml b/pom.xml
index e756b2a..430c25d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -192,6 +192,7 @@
org.scijava
scijava-common
+ 2.98.1-SNAPSHOT
org.scijava
@@ -207,6 +208,10 @@
com.miglayout
miglayout-swing
+
+ org.apache.commons
+ commons-compress
+
org.jfree
jfreechart
diff --git a/src/main/java/net/imagej/ui/swing/SwingColorBar.java b/src/main/java/net/imagej/ui/swing/SwingColorBar.java
index 0bbea6a..d85e523 100644
--- a/src/main/java/net/imagej/ui/swing/SwingColorBar.java
+++ b/src/main/java/net/imagej/ui/swing/SwingColorBar.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -47,7 +47,7 @@
/**
* A widget for displaying a {@link ColorTable} as a bar.
- *
+ *
* @author Curtis Rueden
* @author Grant Harris
*/
@@ -81,7 +81,7 @@ public SwingColorBar(final ColorTable lut, final int height) {
/** Sets the {@link ColorTable} displayed by this color bar. */
public void setColorTable(final ColorTable colorTable) {
-
+
if (bar == null || bar.getWidth() != colorTable.getLength()) {
// create compatible image
bar = AWTImageTools.createImage(colorTable.getLength(), 1);
@@ -94,7 +94,7 @@ public void setColorTable(final ColorTable colorTable) {
gfx.setColor(new Color(argb, false));
gfx.drawLine(i, 0, i, 1);
}
- gfx.dispose();
+ gfx.dispose();
}
// -- JComponent methods --
@@ -124,11 +124,11 @@ public void paintComponent(final Graphics g) {
// -- Main method --
public static void main(final String[] args) {
- final ColorTable[] luts =
- { ColorTables.FIRE, ColorTables.ICE, ColorTables.SPECTRUM,
- ColorTables.RED, ColorTables.GREEN, ColorTables.BLUE, ColorTables.CYAN,
- ColorTables.MAGENTA, ColorTables.YELLOW, ColorTables.GRAYS,
- ColorTables.REDGREEN, ColorTables.RGB332 };
+ final ColorTable[] luts = { ColorTables.FIRE, ColorTables.ICE,
+ ColorTables.SPECTRUM, ColorTables.RED, ColorTables.GREEN,
+ ColorTables.BLUE, ColorTables.CYAN, ColorTables.MAGENTA,
+ ColorTables.YELLOW, ColorTables.GRAYS, ColorTables.REDGREEN,
+ ColorTables.RGB332 };
final JFrame frame = new JFrame();
frame.setTitle("LUTs");
diff --git a/src/main/java/net/imagej/ui/swing/commands/OverlayManager.java b/src/main/java/net/imagej/ui/swing/commands/OverlayManager.java
index 3344cd3..7b338ef 100644
--- a/src/main/java/net/imagej/ui/swing/commands/OverlayManager.java
+++ b/src/main/java/net/imagej/ui/swing/commands/OverlayManager.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -39,7 +39,7 @@
/**
* Command to pop up the {@link SwingOverlayManager}.
- *
+ *
* @author Adam Fraser
*/
@Plugin(type = Command.class, menu = { //
@@ -51,7 +51,8 @@ public class OverlayManager extends ContextCommand {
@Override
public void run() {
- final SwingOverlayManager overlaymgr = new SwingOverlayManager(getContext());
+ final SwingOverlayManager overlaymgr = new SwingOverlayManager(
+ getContext());
overlaymgr.setVisible(true);
}
diff --git a/src/main/java/net/imagej/ui/swing/mdi/viewer/SwingMdiImageDisplayViewer.java b/src/main/java/net/imagej/ui/swing/mdi/viewer/SwingMdiImageDisplayViewer.java
index b12630a..47ac4e5 100644
--- a/src/main/java/net/imagej/ui/swing/mdi/viewer/SwingMdiImageDisplayViewer.java
+++ b/src/main/java/net/imagej/ui/swing/mdi/viewer/SwingMdiImageDisplayViewer.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -44,14 +44,15 @@
/**
* Multiple Document Interface implementation of Swing image display viewer. The
* MDI display is housed in a {@link JInternalFrame}.
- *
+ *
* @author Grant Harris
* @author Curtis Rueden
* @author Lee Kamentsky
* @see SwingImageDisplayViewer
*/
@Plugin(type = DisplayViewer.class)
-public class SwingMdiImageDisplayViewer extends AbstractSwingImageDisplayViewer
+public class SwingMdiImageDisplayViewer extends
+ AbstractSwingImageDisplayViewer
{
// -- DisplayViewer methods --
diff --git a/src/main/java/net/imagej/ui/swing/overlay/AbstractJHotDrawAdapter.java b/src/main/java/net/imagej/ui/swing/overlay/AbstractJHotDrawAdapter.java
index 04f1417..567f0e4 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/AbstractJHotDrawAdapter.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/AbstractJHotDrawAdapter.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -55,7 +55,7 @@
/**
* An abstract class that gives default behavior for the {@link JHotDrawAdapter}
* interface.
- *
+ *
* @author Lee Kamentsky
*/
public abstract class AbstractJHotDrawAdapter
diff --git a/src/main/java/net/imagej/ui/swing/overlay/AngleJHotDrawAdapter.java b/src/main/java/net/imagej/ui/swing/overlay/AngleJHotDrawAdapter.java
index a4ceaf1..2e53fdf 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/AngleJHotDrawAdapter.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/AngleJHotDrawAdapter.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -46,7 +46,7 @@
/**
* JHotDraw adapter for angle overlays.
- *
+ *
* @author Lee Kamentsky
* @author Barry DeZonia
* @see SwingAngleTool
diff --git a/src/main/java/net/imagej/ui/swing/overlay/BezierPathFunctions.java b/src/main/java/net/imagej/ui/swing/overlay/BezierPathFunctions.java
index 21b5216..fbdf66f 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/BezierPathFunctions.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/BezierPathFunctions.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -47,7 +47,7 @@
/**
* Utility functions for {@link GeneralPathJHotDrawAdapter}.
- *
+ *
* @author Johannes Schindelin
*/
public class BezierPathFunctions {
@@ -115,11 +115,10 @@ public static void addToRegionOfInterest(final PathIterator iterator,
}
public enum OP {
- ADD, XOR, INTERSECT, SUBTRACT
+ ADD, XOR, INTERSECT, SUBTRACT
}
- public static BezierPath add(final BezierPath path1, final BezierPath path2)
- {
+ public static BezierPath add(final BezierPath path1, final BezierPath path2) {
return op(path1, path2, OP.ADD);
}
diff --git a/src/main/java/net/imagej/ui/swing/overlay/DefaultJHotDrawAdapter.java b/src/main/java/net/imagej/ui/swing/overlay/DefaultJHotDrawAdapter.java
index 5240e6a..f6ed97f 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/DefaultJHotDrawAdapter.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/DefaultJHotDrawAdapter.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -60,7 +60,7 @@
* The default adapter handles any kind of overlay. It uses the fill color and
* alpha of the overlay to draw the mask and leaves the rest of the figure
* transparent.
- *
+ *
* @author Lee Kamentsky
*/
@Plugin(type = JHotDrawAdapter.class,
@@ -95,8 +95,8 @@ public Figure createDefaultFigure() {
}
@Override
- public void
- updateFigure(final OverlayView overlay, final ImageFigure figure)
+ public void updateFigure(final OverlayView overlay,
+ final ImageFigure figure)
{
super.updateFigure(overlay, figure);
@@ -109,18 +109,16 @@ public Figure createDefaultFigure() {
final long minY = (long) Math.floor(roi.realMin(1));
final long maxY = (long) Math.ceil(roi.realMax(1)) + 1;
final ColorRGB color = overlay.getData().getFillColor();
- final IndexColorModel cm =
- new IndexColorModel(1, 2, new byte[] { 0, (byte) color.getRed() },
- new byte[] { 0, (byte) color.getGreen() }, new byte[] { 0,
- (byte) color.getBlue() }, new byte[] { 0,
- (byte) overlay.getData().getAlpha() });
+ final IndexColorModel cm = new IndexColorModel(1, 2, new byte[] { 0,
+ (byte) color.getRed() }, new byte[] { 0, (byte) color.getGreen() },
+ new byte[] { 0, (byte) color.getBlue() }, new byte[] { 0, (byte) overlay
+ .getData().getAlpha() });
final int w = (int) (maxX - minX);
final int h = (int) (maxY - minY);
- final BufferedImage img =
- new BufferedImage(w, h, BufferedImage.TYPE_BYTE_INDEXED, cm);
- final SampleModel sm =
- new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE, w, h,
- new int[] { 1 });
+ final BufferedImage img = new BufferedImage(w, h,
+ BufferedImage.TYPE_BYTE_INDEXED, cm);
+ final SampleModel sm = new SinglePixelPackedSampleModel(
+ DataBuffer.TYPE_BYTE, w, h, new int[] { 1 });
final DataBuffer dbuncast = sm.createDataBuffer();
assert dbuncast instanceof DataBufferByte;
final DataBufferByte db = (DataBufferByte) dbuncast;
@@ -140,8 +138,8 @@ public Figure createDefaultFigure() {
index++;
}
}
- final Raster raster =
- Raster.createRaster(sm, db, new java.awt.Point(0, 0));
+ final Raster raster = Raster.createRaster(sm, db, new java.awt.Point(0,
+ 0));
img.setData(raster);
figure.setBounds(new Rectangle2D.Double(minX, minY, w, h));
figure.setBufferedImage(img);
diff --git a/src/main/java/net/imagej/ui/swing/overlay/EllipseJHotDrawAdapter.java b/src/main/java/net/imagej/ui/swing/overlay/EllipseJHotDrawAdapter.java
index 19ad2a4..ef6e9a9 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/EllipseJHotDrawAdapter.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/EllipseJHotDrawAdapter.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -50,7 +50,7 @@
/**
* JHotDraw adapter for ellipse overlays.
- *
+ *
* @author Lee Kamentsky
* @author Barry DeZonia
* @see SwingEllipseTool
@@ -99,8 +99,7 @@ public Figure createDefaultFigure() {
}
@Override
- public void updateFigure(final OverlayView view, final EllipseFigure figure)
- {
+ public void updateFigure(final OverlayView view, final EllipseFigure figure) {
super.updateFigure(view, figure);
final EllipseOverlay overlay = downcastOverlay(view.getData());
final double centerX = overlay.getOrigin(0);
@@ -113,8 +112,8 @@ public void updateFigure(final OverlayView view, final EllipseFigure figure)
}
@Override
- public void
- updateOverlay(final EllipseFigure figure, final OverlayView view)
+ public void updateOverlay(final EllipseFigure figure,
+ final OverlayView view)
{
super.updateOverlay(figure, view);
final EllipseOverlay overlay = downcastOverlay(view.getData());
diff --git a/src/main/java/net/imagej/ui/swing/overlay/FigureCreatedEvent.java b/src/main/java/net/imagej/ui/swing/overlay/FigureCreatedEvent.java
index c5e8be6..fef45af 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/FigureCreatedEvent.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/FigureCreatedEvent.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,11 +35,10 @@
import org.jhotdraw.draw.Figure;
-
/**
* An event that reports the creation of a JHotDraw {@link Figure}, linked to an
* ImageJ {@link OverlayView} in a particular {@link ImageDisplay}.
- *
+ *
* @author Lee Kamentsky
* @author Curtis Rueden
*/
diff --git a/src/main/java/net/imagej/ui/swing/overlay/GeneralPathFigure.java b/src/main/java/net/imagej/ui/swing/overlay/GeneralPathFigure.java
index 7c8a0a3..28abb69 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/GeneralPathFigure.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/GeneralPathFigure.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -54,9 +54,8 @@
/**
* A composite figure, made up of possibly-overlapping {@link BezierFigure}s.
- *
* The described figures are always winding rule even/odd.
- *
+ *
* @author Johannes Schindelin
*/
@SuppressWarnings("hiding")
@@ -67,10 +66,13 @@ public class GeneralPathFigure extends AbstractAttributedFigure {
public GeneralPathFigure(final BezierFigure... list) {
figures = new ArrayList() {
+
@Override
public boolean add(final BezierFigure figure) {
- figure.restoreAttributesTo(GeneralPathFigure.this.getAttributesRestoreData());
+ figure.restoreAttributesTo(GeneralPathFigure.this
+ .getAttributesRestoreData());
figure.addFigureListener(new FigureListener() {
+
@Override
public void areaInvalidated(FigureEvent e) {
invalidate();
@@ -80,7 +82,8 @@ public void areaInvalidated(FigureEvent e) {
@Override
public void attributeChanged(FigureEvent e) {
invalidate();
- fireAttributeChanged(e.getAttribute(), e.getOldValue(), e.getNewValue());
+ fireAttributeChanged(e.getAttribute(), e.getOldValue(), e
+ .getNewValue());
}
@Override
@@ -228,9 +231,8 @@ public void restoreAttributesTo(Object restoreData) {
}
/**
- * Sets an attribute of the figure.
- * AttributeKey name and semantics are defined by the class implementing
- * the figure interface.
+ * Sets an attribute of the figure. AttributeKey name and semantics are
+ * defined by the class implementing the figure interface.
*/
@Override
public void set(AttributeKey key, T newValue) {
@@ -240,7 +242,7 @@ public void set(AttributeKey key, T newValue) {
}
}
- /* -- public methods -- */
+ /* -- public methods -- */
@SuppressWarnings("null")
public synchronized void setGeneralPath(final GeneralPath path) {
@@ -252,24 +254,25 @@ public synchronized void setGeneralPath(final GeneralPath path) {
for (; !iterator.isDone(); iterator.next()) {
int type = iterator.currentSegment(segment);
switch (type) {
- case PathIterator.SEG_MOVETO:
- if (bezierPath != null) add(bezierPath, false);
- bezierPath = new BezierPath();
- bezierPath.moveTo(segment[0], segment[1]);
- break;
- case PathIterator.SEG_LINETO:
- bezierPath.lineTo(segment[0], segment[1]);
- break;
- case PathIterator.SEG_QUADTO:
- bezierPath.quadTo(segment[0], segment[1], segment[2], segment[3]);
- break;
- case PathIterator.SEG_CUBICTO:
- bezierPath.curveTo(segment[0], segment[1], segment[2], segment[3], segment[4], segment[5]);
- break;
- case PathIterator.SEG_CLOSE:
- add(bezierPath, true);
- bezierPath = null;
- break;
+ case PathIterator.SEG_MOVETO:
+ if (bezierPath != null) add(bezierPath, false);
+ bezierPath = new BezierPath();
+ bezierPath.moveTo(segment[0], segment[1]);
+ break;
+ case PathIterator.SEG_LINETO:
+ bezierPath.lineTo(segment[0], segment[1]);
+ break;
+ case PathIterator.SEG_QUADTO:
+ bezierPath.quadTo(segment[0], segment[1], segment[2], segment[3]);
+ break;
+ case PathIterator.SEG_CUBICTO:
+ bezierPath.curveTo(segment[0], segment[1], segment[2], segment[3],
+ segment[4], segment[5]);
+ break;
+ case PathIterator.SEG_CLOSE:
+ add(bezierPath, true);
+ bezierPath = null;
+ break;
}
}
if (bezierPath != null) add(bezierPath, false);
diff --git a/src/main/java/net/imagej/ui/swing/overlay/GeneralPathJHotDrawAdapter.java b/src/main/java/net/imagej/ui/swing/overlay/GeneralPathJHotDrawAdapter.java
index 6520f3e..35b9016 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/GeneralPathJHotDrawAdapter.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/GeneralPathJHotDrawAdapter.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -45,10 +45,11 @@
/**
* JHotDraw adapter for composite area selections.
- *
+ *
* @author Johannes Schindelin
*/
-@Plugin(type = JHotDrawAdapter.class, priority = GeneralPathJHotDrawAdapter.PRIORITY)
+@Plugin(type = JHotDrawAdapter.class,
+ priority = GeneralPathJHotDrawAdapter.PRIORITY)
public class GeneralPathJHotDrawAdapter extends
AbstractJHotDrawAdapter
{
@@ -81,8 +82,7 @@ public Overlay createNewOverlay() {
@Override
public Figure createDefaultFigure() {
- final GeneralPathFigure figure =
- new GeneralPathFigure(new PolygonFigure());
+ final GeneralPathFigure figure = new GeneralPathFigure(new PolygonFigure());
initDefaultSettings(figure);
figure.set(AttributeKeys.WINDING_RULE, AttributeKeys.WindingRule.EVEN_ODD);
return figure;
diff --git a/src/main/java/net/imagej/ui/swing/overlay/IJBezierTool.java b/src/main/java/net/imagej/ui/swing/overlay/IJBezierTool.java
index 5d8d37c..c23e901 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/IJBezierTool.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/IJBezierTool.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,10 +35,9 @@
import org.jhotdraw.draw.DrawingView;
import org.jhotdraw.draw.tool.BezierTool;
-
/**
* A JHotDraw {@link BezierTool} for ImageJ's Swing UI.
- *
+ *
* @author Lee Kamentsky
* @author Johannes Schindelin
*/
@@ -67,8 +66,8 @@ protected void finishCreation(final BezierFigure figure,
final DrawingView drawingView)
{
super.finishCreation(figure, drawingView);
- final JHotDrawService jHotDrawService =
- getDisplay().getContext().getService(JHotDrawService.class);
+ final JHotDrawService jHotDrawService = getDisplay().getContext()
+ .getService(JHotDrawService.class);
jHotDrawService.linkOverlay(figure, getAdapter(), getDisplay());
}
diff --git a/src/main/java/net/imagej/ui/swing/overlay/IJCreationTool.java b/src/main/java/net/imagej/ui/swing/overlay/IJCreationTool.java
index 6abdd7a..3db7f85 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/IJCreationTool.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/IJCreationTool.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -38,10 +38,12 @@
/**
* A JHotDraw {@link CreationTool} for ImageJ's Swing UI.
- *
+ *
* @author Lee Kamentsky
*/
-public class IJCreationTool extends CreationTool implements JHotDrawTool {
+public class IJCreationTool extends CreationTool implements
+ JHotDrawTool
+{
private final ImageDisplay display;
private final JHotDrawAdapter adapter;
@@ -65,9 +67,9 @@ protected Figure createFigure() {
@Override
protected void creationFinished(final Figure figure) {
super.creationFinished(figure);
- final JHotDrawService jHotDrawService =
- getDisplay().getContext().getService(JHotDrawService.class);
- jHotDrawService.linkOverlay((F)figure, getAdapter(), getDisplay());
+ final JHotDrawService jHotDrawService = getDisplay().getContext()
+ .getService(JHotDrawService.class);
+ jHotDrawService.linkOverlay((F) figure, getAdapter(), getDisplay());
}
// -- JHotDrawTool methods --
@@ -94,14 +96,14 @@ public void mouseClicked(MouseEvent evt) {
if (!isLeftClick(evt)) return;
super.mouseClicked(evt);
}
-
+
@Override
public void mousePressed(MouseEvent evt) {
if (!isLeftClick(evt)) return;
super.mousePressed(evt);
adapter.mouseDown(getDisplay(), evt.getX(), evt.getY());
}
-
+
@Override
public void mouseReleased(MouseEvent evt) {
if (!isLeftClick(evt)) return;
diff --git a/src/main/java/net/imagej/ui/swing/overlay/IJDelegationSelectionTool.java b/src/main/java/net/imagej/ui/swing/overlay/IJDelegationSelectionTool.java
index b4a1f43..e295b3c 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/IJDelegationSelectionTool.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/IJDelegationSelectionTool.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,7 +35,7 @@
/**
* A JHotDraw {@link DelegationSelectionTool} for ImageJ's Swing UI.
- *
+ *
* @author Johannes Schindelin
*/
public class IJDelegationSelectionTool extends DelegationSelectionTool
diff --git a/src/main/java/net/imagej/ui/swing/overlay/JHotDrawAdapter.java b/src/main/java/net/imagej/ui/swing/overlay/JHotDrawAdapter.java
index 87bcab9..af455e7 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/JHotDrawAdapter.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/JHotDrawAdapter.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -51,7 +51,7 @@
* merely by implementing this interface, it is encouraged to instead extend
* {@link AbstractJHotDrawAdapter}, for convenience.
*
- *
+ *
* @author Lee Kamentsky
* @author Curtis Rueden
*/
@@ -61,7 +61,7 @@ public interface JHotDrawAdapter extends ImageJPlugin,
/**
* Determines whether the adapter is designed to work with the given tool.
- *
+ *
* @param tool The tool in question.
* @return True iff the adapter is compatible with the given tool.
*/
@@ -70,7 +70,7 @@ public interface JHotDrawAdapter extends ImageJPlugin,
/**
* Determines whether the adapter can handle a particular overlay, or overlay
* / figure combination.
- *
+ *
* @param overlay - an overlay that might be editable
* @param figure - a figure that will be either updated by the overlay or will
* update the overlay. The figure can be null: this indicates that
@@ -81,7 +81,7 @@ public interface JHotDrawAdapter extends ImageJPlugin,
/**
* Creates a new overlay.
- *
+ *
* @return an Overlay of the associated type in the default initial state
*/
Overlay createNewOverlay();
@@ -91,7 +91,7 @@ public interface JHotDrawAdapter extends ImageJPlugin,
/**
* Update the overlay to match the appearance of the figure
- *
+ *
* @param figure the figure that holds the current correct appearance
* @param view view of the overlay that needs to be changed to bring it
* in-sync with the figure.
@@ -100,7 +100,7 @@ public interface JHotDrawAdapter extends ImageJPlugin,
/**
* Update the appearance of the figure to match the overlay
- *
+ *
* @param view view of the overlay to be represented by the figure
* @param figure the figure that is to be made to look like the overlay
*/
diff --git a/src/main/java/net/imagej/ui/swing/overlay/JHotDrawService.java b/src/main/java/net/imagej/ui/swing/overlay/JHotDrawService.java
index a9d2916..6fa1056 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/JHotDrawService.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/JHotDrawService.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -54,7 +54,7 @@
/**
* The JHotDraw service manages the bidirectional linkage between ImageJ
* {@link Overlay}s and JHotDraw {@link Figure}s.
- *
+ *
* @author Lee Kamentsky
* @author Curtis Rueden
*/
@@ -79,7 +79,7 @@ public class JHotDrawService extends AbstractService implements ImageJService {
/**
* Gets the adapter associated with the given tool.
- *
+ *
* @param tool The tool for which a compatible adapter is needed.
* @return the highest-priority adapter that supports the tool
*/
@@ -92,7 +92,7 @@ public JHotDrawAdapter> getAdapter(final Tool tool) {
/**
* Gets the first available adapter for the given overlay.
- *
+ *
* @param overlay the overlay to adapt
* @return the highest-priority adapter that supports the overlay
*/
@@ -102,7 +102,7 @@ public JHotDrawAdapter> getAdapter(final Overlay overlay) {
/**
* Gets the first available adapter for the given overlay.
- *
+ *
* @param overlay the overlay to adapt
* @param figure the figure to be associated with the overlay
* @return the highest-priority adapter that supports the overlay adapted to
@@ -119,7 +119,7 @@ public JHotDrawAdapter> getAdapter(final Overlay overlay,
/**
* Gets all adapters capable of handling a given overlay.
- *
+ *
* @param overlay the overlay to adapt
* @return a collection of all adapters capable of handling the overlay
*/
@@ -129,7 +129,7 @@ public ArrayList> getAdapters(final Overlay overlay) {
/**
* Gets all adapters capable of handling a given overlay/figure combination.
- *
+ *
* @param overlay the overlay to adapt
* @param figure the figure to be associated with the overlay
* @return collection of valid adapters
@@ -137,8 +137,7 @@ public ArrayList> getAdapters(final Overlay overlay) {
public ArrayList> getAdapters(final Overlay overlay,
final Figure figure)
{
- final ArrayList> result =
- new ArrayList<>();
+ final ArrayList> result = new ArrayList<>();
for (final JHotDrawAdapter> adapter : adapters()) {
if (adapter.supports(overlay, figure)) result.add(adapter);
}
@@ -175,8 +174,8 @@ private List> adapters() {
if (adapters == null) {
// ask the plugin service for the list of available JHotDraw adapters
@SuppressWarnings({ "rawtypes", "unchecked" })
- final List> instances =
- (List) pluginService.createInstancesOfType(JHotDrawAdapter.class);
+ final List> instances = (List) pluginService
+ .createInstancesOfType(JHotDrawAdapter.class);
adapters = instances;
log.info("Found " + adapters.size() + " JHotDraw adapters.");
}
diff --git a/src/main/java/net/imagej/ui/swing/overlay/JHotDrawTool.java b/src/main/java/net/imagej/ui/swing/overlay/JHotDrawTool.java
index 90c4de4..587162c 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/JHotDrawTool.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/JHotDrawTool.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -40,7 +40,7 @@
/**
* A JHotDraw {@link Tool} (not a {@link org.scijava.tool.Tool}) with
* some extra needed API methods.
- *
+ *
* @author Johannes Schindelin
*/
public interface JHotDrawTool extends Tool {
diff --git a/src/main/java/net/imagej/ui/swing/overlay/LineJHotDrawAdapter.java b/src/main/java/net/imagej/ui/swing/overlay/LineJHotDrawAdapter.java
index 408f26e..7f6670b 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/LineJHotDrawAdapter.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/LineJHotDrawAdapter.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
/**
* JHotDraw adapter for line overlays.
- *
+ *
* @author Lee Kamentsky
* @author Barry DeZonia
* @see SwingLineTool
diff --git a/src/main/java/net/imagej/ui/swing/overlay/PointFigure.java b/src/main/java/net/imagej/ui/swing/overlay/PointFigure.java
index d9692a2..a204b8f 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/PointFigure.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/PointFigure.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -48,7 +48,7 @@
/**
* Implementation of a point as a JHotDraw figure.
- *
+ *
* @author Johannes Schindelin
* @author Barry DeZonia
*/
@@ -175,8 +175,8 @@ public boolean contains(final Point2D.Double p) {
}
@Override
- public void
- setBounds(final Point2D.Double anchor, final Point2D.Double lead)
+ public void setBounds(final Point2D.Double anchor,
+ final Point2D.Double lead)
{
double dx = anchor.x - bounds.x;
double dy = anchor.y - bounds.y;
@@ -185,7 +185,7 @@ public boolean contains(final Point2D.Double p) {
/**
* Moves the Figure to a new location.
- *
+ *
* @param tx the transformation matrix.
*/
@Override
@@ -288,5 +288,4 @@ public void draw(final Graphics2D g) {
}
}
-
}
diff --git a/src/main/java/net/imagej/ui/swing/overlay/PointJHotDrawOverlay.java b/src/main/java/net/imagej/ui/swing/overlay/PointJHotDrawOverlay.java
index 9796e9d..9fe4d75 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/PointJHotDrawOverlay.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/PointJHotDrawOverlay.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -44,7 +44,7 @@
/**
* JHotDraw adapter for point tool.
- *
+ *
* @author Barry DeZonia
* @see SwingPointTool
*/
diff --git a/src/main/java/net/imagej/ui/swing/overlay/PolygonFigure.java b/src/main/java/net/imagej/ui/swing/overlay/PolygonFigure.java
index 9fae53c..2697744 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/PolygonFigure.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/PolygonFigure.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -38,7 +38,7 @@
/**
* TODO
- *
+ *
* @author Johannes Schindelin
*/
public class PolygonFigure extends BezierFigure {
diff --git a/src/main/java/net/imagej/ui/swing/overlay/PolygonJHotDrawAdapter.java b/src/main/java/net/imagej/ui/swing/overlay/PolygonJHotDrawAdapter.java
index 612abf9..7821303 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/PolygonJHotDrawAdapter.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/PolygonJHotDrawAdapter.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -52,7 +52,7 @@
/**
* JHotDraw adapter for polygon/freehand overlays.
- *
+ *
* @author Lee Kamentsky
* @author Barry DeZonia
* @see SwingPolygonTool
@@ -98,8 +98,7 @@ public Figure createDefaultFigure() {
}
@Override
- public void updateOverlay(final BezierFigure figure, final OverlayView view)
- {
+ public void updateOverlay(final BezierFigure figure, final OverlayView view) {
super.updateOverlay(figure, view);
final PolygonOverlay poverlay = downcastOverlay(view.getData());
final PolygonRegionOfInterest roi = poverlay.getRegionOfInterest();
diff --git a/src/main/java/net/imagej/ui/swing/overlay/PolygonNodeHandle.java b/src/main/java/net/imagej/ui/swing/overlay/PolygonNodeHandle.java
index db5eca4..a217d5d 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/PolygonNodeHandle.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/PolygonNodeHandle.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -38,9 +38,9 @@
/**
* The BezierFigure uses a BezierNodeHandle which can change the curve
- * connecting vertices from a line to a Bezier curve. We subclass both
- * the figure and the node handle to defeat this.
- *
+ * connecting vertices from a line to a Bezier curve. We subclass both the
+ * figure and the node handle to defeat this.
+ *
* @author Johannes Schindelin
*/
public class PolygonNodeHandle extends BezierNodeHandle {
@@ -60,9 +60,9 @@ public void trackEnd(final Point anchor, final Point lead,
final int modifiersEx)
{
// Remove the behavior associated with the shift keys
- super.trackEnd(anchor, lead, modifiersEx &
- ~(InputEvent.META_DOWN_MASK | InputEvent.CTRL_DOWN_MASK |
- InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
+ super.trackEnd(anchor, lead, modifiersEx & ~(InputEvent.META_DOWN_MASK |
+ InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK |
+ InputEvent.SHIFT_DOWN_MASK));
}
}
diff --git a/src/main/java/net/imagej/ui/swing/overlay/PolylineFigure.java b/src/main/java/net/imagej/ui/swing/overlay/PolylineFigure.java
index f624107..f4ddffa 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/PolylineFigure.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/PolylineFigure.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -38,7 +38,7 @@
/**
* JHotDraw Figure for a multi-segmented line
- *
+ *
* @author Benjamin Nanes
*/
public class PolylineFigure extends BezierFigure {
diff --git a/src/main/java/net/imagej/ui/swing/overlay/PolylineJHotDrawAdapter.java b/src/main/java/net/imagej/ui/swing/overlay/PolylineJHotDrawAdapter.java
index d2085e7..e4bf389 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/PolylineJHotDrawAdapter.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/PolylineJHotDrawAdapter.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
/**
* JHotDraw adapter for multi-segmented lines
- *
+ *
* @author Benjamin Nanes
*/
@Plugin(type = JHotDrawAdapter.class, priority = SwingPolylineTool.PRIORITY)
diff --git a/src/main/java/net/imagej/ui/swing/overlay/RectangleJHotDrawAdapter.java b/src/main/java/net/imagej/ui/swing/overlay/RectangleJHotDrawAdapter.java
index 3c8eb36..c608c8d 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/RectangleJHotDrawAdapter.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/RectangleJHotDrawAdapter.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
/**
* JHotDraw adapter for rectangle overlays.
- *
+ *
* @author Lee Kamentsky
* @author Grant Harris
* @author Barry DeZonia
@@ -94,8 +94,8 @@ public Figure createDefaultFigure() {
}
@Override
- public void
- updateFigure(final OverlayView view, final RectangleFigure figure)
+ public void updateFigure(final OverlayView view,
+ final RectangleFigure figure)
{
super.updateFigure(view, figure);
final RectangleOverlay overlay = downcastOverlay(view.getData());
diff --git a/src/main/java/net/imagej/ui/swing/overlay/SwingOverlayManager.java b/src/main/java/net/imagej/ui/swing/overlay/SwingOverlayManager.java
index 3cbe154..de5e32f 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/SwingOverlayManager.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/SwingOverlayManager.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -104,21 +104,20 @@
/**
* Overlay Manager Swing UI
- *
+ *
* @author Barry DeZonia
* @author Adam Fraser
*/
-public class SwingOverlayManager
- extends JFrame
- implements ActionListener, ItemListener
+public class SwingOverlayManager extends JFrame implements ActionListener,
+ ItemListener
{
// -- constants --
-
- //private static final long serialVersionUID = -6498169032123522303L;
+
+ // private static final long serialVersionUID = -6498169032123522303L;
// no longer supported
- //private static final String ACTION_ADD = "add";
+ // private static final String ACTION_ADD = "add";
private static final String ACTION_ADD_PARTICLES = "add particles";
private static final String ACTION_AND = "and";
private static final String ACTION_DELETE = "delete";
@@ -142,14 +141,14 @@ public class SwingOverlayManager
private static final String ACTION_SORT = "sort";
private static final String ACTION_SPECIFY = "specify";
// no longer supported
- //private static final String ACTION_UPDATE = "update";
+ // private static final String ACTION_UPDATE = "update";
private static final String ACTION_XOR = "xor";
-
+
private static final String LAST_X = "lastXLocation";
private static final String LAST_Y = "lastYLocation";
// -- instance variables --
-
+
private final Context context;
private final JList jlist;
private final JCheckBox showAllCheckBox;
@@ -179,16 +178,16 @@ public class SwingOverlayManager
private boolean altDown = false;
// -- constructor --
-
+
/**
- * Creates a JList to list the overlays.
+ * Creates a JList to list the overlays.
*/
public SwingOverlayManager(final Context context) {
this.context = context;
context.inject(this);
jlist = new JList<>(new OverlayListModel(overlayService.getOverlayInfo()));
- //jlist.setCellRenderer(new OverlayRenderer());
+ // jlist.setCellRenderer(new OverlayRenderer());
final JScrollPane listScroller = new JScrollPane(jlist);
listScroller.setPreferredSize(new Dimension(250, 80));
@@ -199,10 +198,10 @@ public SwingOverlayManager(final Context context) {
listPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
final JPanel buttonPane = new JPanel();
- buttonPane.setLayout(new GridLayout(9,1,5,0));
+ buttonPane.setLayout(new GridLayout(9, 1, 5, 0));
// NO LONGER SUPPORTING
- //buttonPane.add(getAddButton());
- //buttonPane.add(getUpdateButton());
+ // buttonPane.add(getAddButton());
+ // buttonPane.add(getUpdateButton());
buttonPane.add(getDeleteButton());
buttonPane.add(getRenameButton());
buttonPane.add(getMeasureButton());
@@ -215,17 +214,17 @@ public SwingOverlayManager(final Context context) {
final JPanel boolPane = new JPanel();
boolPane.setLayout(new BoxLayout(boolPane, BoxLayout.Y_AXIS));
- showAllCheckBox = new JCheckBox("Show All",false);
- editModeCheckBox = new JCheckBox("Edit Mode",false);
+ showAllCheckBox = new JCheckBox("Show All", false);
+ editModeCheckBox = new JCheckBox("Edit Mode", false);
boolPane.add(showAllCheckBox);
boolPane.add(editModeCheckBox);
showAllCheckBox.addItemListener(this);
editModeCheckBox.addItemListener(this);
-
+
final JPanel controlPanel = new JPanel();
controlPanel.setLayout(new BorderLayout());
- controlPanel.add(buttonPane,BorderLayout.CENTER);
- controlPanel.add(boolPane,BorderLayout.SOUTH);
+ controlPanel.add(buttonPane, BorderLayout.CENTER);
+ controlPanel.add(boolPane, BorderLayout.SOUTH);
final Container cp = this.getContentPane();
cp.add(listPanel, BorderLayout.CENTER);
@@ -236,16 +235,16 @@ public SwingOverlayManager(final Context context) {
setupCloseListener();
setupKeyListener();
restoreLocation();
-
+
pack();
-
+
eventService.subscribe(this);
populateOverlayList();
}
// -- public interface --
-
+
@Override
public void actionPerformed(final ActionEvent e) {
final String command = e.getActionCommand();
@@ -254,71 +253,47 @@ public void actionPerformed(final ActionEvent e) {
if (command.equals(ACTION_ADD))
add();
*/
- if (command.equals(ACTION_ADD_PARTICLES))
- addParticles();
- else if (command.equals(ACTION_AND))
- and();
- else if (command.equals(ACTION_DELETE))
- delete();
- else if (command.equals(ACTION_DESELECT))
- deselect();
- else if (command.equals(ACTION_DIVIDE))
- divide();
- else if (command.equals(ACTION_DRAW))
- draw();
- else if (command.equals(ACTION_FILL))
- fill();
- else if (command.equals(ACTION_FLATTEN))
- flatten();
- else if (command.equals(ACTION_HELP))
- help();
- else if (command.equals(ACTION_LIST))
- getList();
- else if (command.equals(ACTION_MEASURE))
- measure();
- else if (command.equals(ACTION_MULTI_MEASURE))
- multiMeasure();
- else if (command.equals(ACTION_MULTI_PLOT))
- multiPlot();
- else if (command.equals(ACTION_OPEN))
- open();
- else if (command.equals(ACTION_OPTIONS))
- options();
- else if (command.equals(ACTION_OR))
- or();
- else if (command.equals(ACTION_PROPERTIES))
- properties();
- else if (command.equals(ACTION_REMOVE_SLICE_INFO))
- removeSliceInfo();
- else if (command.equals(ACTION_RENAME))
- rename();
- else if (command.equals(ACTION_SAVE))
- save();
- else if (command.equals(ACTION_SORT))
- sort();
- else if (command.equals(ACTION_SPECIFY))
- specify();
+ if (command.equals(ACTION_ADD_PARTICLES)) addParticles();
+ else if (command.equals(ACTION_AND)) and();
+ else if (command.equals(ACTION_DELETE)) delete();
+ else if (command.equals(ACTION_DESELECT)) deselect();
+ else if (command.equals(ACTION_DIVIDE)) divide();
+ else if (command.equals(ACTION_DRAW)) draw();
+ else if (command.equals(ACTION_FILL)) fill();
+ else if (command.equals(ACTION_FLATTEN)) flatten();
+ else if (command.equals(ACTION_HELP)) help();
+ else if (command.equals(ACTION_LIST)) getList();
+ else if (command.equals(ACTION_MEASURE)) measure();
+ else if (command.equals(ACTION_MULTI_MEASURE)) multiMeasure();
+ else if (command.equals(ACTION_MULTI_PLOT)) multiPlot();
+ else if (command.equals(ACTION_OPEN)) open();
+ else if (command.equals(ACTION_OPTIONS)) options();
+ else if (command.equals(ACTION_OR)) or();
+ else if (command.equals(ACTION_PROPERTIES)) properties();
+ else if (command.equals(ACTION_REMOVE_SLICE_INFO)) removeSliceInfo();
+ else if (command.equals(ACTION_RENAME)) rename();
+ else if (command.equals(ACTION_SAVE)) save();
+ else if (command.equals(ACTION_SORT)) sort();
+ else if (command.equals(ACTION_SPECIFY)) specify();
/*
else if (command.equals(ACTION_UPDATE))
update();
*/
- else if (command.equals(ACTION_XOR))
- xor();
+ else if (command.equals(ACTION_XOR)) xor();
}
// -- private helpers for overlay list maintenance --
-
private class OverlayListModel extends AbstractListModel {
- //private static final long serialVersionUID = 7941252533859436640L;
+ // private static final long serialVersionUID = 7941252533859436640L;
private OverlayInfoList overlayInfoList;
-
+
public OverlayListModel(OverlayInfoList list) {
overlayInfoList = list;
}
-
+
@Override
public OverlayInfo getElementAt(final int index) {
return overlayInfoList.getOverlayInfo(index);
@@ -352,7 +327,7 @@ private void populateOverlayList() {
}
jlist.updateUI();
}
-
+
/*
private class OverlayRenderer extends DefaultListCellRenderer {
@@ -372,10 +347,10 @@ public Component getListCellRendererComponent(final JList list,
final Overlay overlay = (Overlay) value;
// TODO: create overlay thumbnail from overlay
final ImageIcon icon = iconTable.get(overlay);
-// if (icon == null) {
-// icon = new ImageIcon(...);
-// iconTable.put(overlay, ImageIcon);
-// }
+ // if (icon == null) {
+ // icon = new ImageIcon(...);
+ // iconTable.put(overlay, ImageIcon);
+ // }
label.setIcon(icon);
}
else {
@@ -392,21 +367,22 @@ public Component getListCellRendererComponent(final JList list,
@EventHandler
protected void onEvent(final OverlayCreatedEvent event) {
- //System.out.println("\tCREATED: " + event.toString());
+ // System.out.println("\tCREATED: " + event.toString());
overlayService.getOverlayInfo().addOverlay(event.getObject());
jlist.updateUI();
}
@EventHandler
protected void onEvent(final OverlayDeletedEvent event) {
- //System.out.println("\tDELETED: " + event.toString());
+ // System.out.println("\tDELETED: " + event.toString());
Overlay overlay = event.getObject();
overlayService.getOverlayInfo().deleteOverlay(overlay);
- int[] newSelectedIndices = overlayService.getOverlayInfo().selectedIndices();
+ int[] newSelectedIndices = overlayService.getOverlayInfo()
+ .selectedIndices();
jlist.setSelectedIndices(newSelectedIndices);
jlist.updateUI();
}
-
+
/*
// Update when a display is activated.
@EventHandler
@@ -424,7 +400,8 @@ protected void onEvent(final DataViewSelectionEvent event) {
// Select or deselect the corresponding overlay in the list
final Overlay overlay = (Overlay) event.getView().getData();
final int overlayIndex = overlayService.getOverlayInfo().findIndex(overlay);
- final OverlayInfo overlayInfo = overlayService.getOverlayInfo().getOverlayInfo(overlayIndex);
+ final OverlayInfo overlayInfo = overlayService.getOverlayInfo()
+ .getOverlayInfo(overlayIndex);
overlayInfo.setSelected(event.isSelected());
/* old way
if (event.isSelected()) {
@@ -464,23 +441,23 @@ protected void onKeyPressedEvent(KyPressedEvent ev) {
if (key == KeyCode.DELETE) delete();
}
*/
-
+
@SuppressWarnings("unused")
@EventHandler
protected void onEvent(OverlayRestructuredEvent event) {
- //System.out.println("restructured");
+ // System.out.println("restructured");
jlist.updateUI();
}
@SuppressWarnings("unused")
@EventHandler
protected void onEvent(OverlayUpdatedEvent event) {
- //System.out.println("updated");
+ // System.out.println("updated");
jlist.updateUI();
}
// -- private helpers that implement overlay interaction commands --
-
+
/* no longer supported
private void add() {
final ImageDisplay activeDisplay =
@@ -496,32 +473,36 @@ private void add() {
jlist.updateUI();
}
*/
-
+
private void addParticles() {
JOptionPane.showMessageDialog(this, "unimplemented");
}
-
+
private void and() {
makeCompositeOverlay(CompositeOverlay.Operation.AND);
}
-
+
private void delete() {
if (overlayService.getOverlayInfo().getOverlayInfoCount() == 0) return;
List overlaysToDelete = new LinkedList<>();
- final int[] selectedIndices = overlayService.getOverlayInfo().selectedIndices();
+ final int[] selectedIndices = overlayService.getOverlayInfo()
+ .selectedIndices();
if (selectedIndices.length == 0) {
- final int result =
- JOptionPane.showConfirmDialog(
- this, "Delete all overlays?", "Delete All", JOptionPane.YES_NO_OPTION);
+ final int result = JOptionPane.showConfirmDialog(this,
+ "Delete all overlays?", "Delete All", JOptionPane.YES_NO_OPTION);
if (result != JOptionPane.YES_OPTION) return;
- for (int i = 0; i < overlayService.getOverlayInfo().getOverlayInfoCount(); i++) {
- overlaysToDelete.add(overlayService.getOverlayInfo().getOverlayInfo(i).getOverlay());
+ for (int i = 0; i < overlayService.getOverlayInfo()
+ .getOverlayInfoCount(); i++)
+ {
+ overlaysToDelete.add(overlayService.getOverlayInfo().getOverlayInfo(i)
+ .getOverlay());
}
}
else {
for (int i = 0; i < selectedIndices.length; i++) {
int index = selectedIndices[i];
- overlaysToDelete.add(overlayService.getOverlayInfo().getOverlayInfo(index).getOverlay());
+ overlaysToDelete.add(overlayService.getOverlayInfo().getOverlayInfo(
+ index).getOverlay());
}
}
for (Overlay overlay : overlaysToDelete) {
@@ -531,37 +512,35 @@ private void delete() {
overlayService.removeOverlay(overlay);
}
}
-
+
private void deselect() {
overlayService.getOverlayInfo().deselectAll();
jlist.clearSelection();
}
-
+
/**
* Takes the currently selected CompositeOverlay and turns it into its
- * constituent overlays. The CompositeOverlay is deleted. It does one layer
- * of division (it is not a deep division).
+ * constituent overlays. The CompositeOverlay is deleted. It does one layer of
+ * division (it is not a deep division).
*/
private void divide() {
List overlays = overlayService.getOverlayInfo().selectedOverlays();
int i = 0;
while (i < overlays.size()) {
Overlay o = overlays.get(i);
- if (! (o instanceof CompositeOverlay))
- overlays.remove(i);
- else
- i++;
+ if (!(o instanceof CompositeOverlay)) overlays.remove(i);
+ else i++;
}
if (overlays.size() == 0) {
- JOptionPane.showMessageDialog(
- this, "One or more composite overlays must be selected");
+ JOptionPane.showMessageDialog(this,
+ "One or more composite overlays must be selected");
return;
}
for (Overlay o : overlays) {
overlayService.divideCompositeOverlay((CompositeOverlay) o);
}
}
-
+
private void draw() {
ChannelCollection channels = getChannels();
List selected = overlayService.getOverlayInfo().selectedOverlays();
@@ -579,90 +558,94 @@ private void fill() {
overlayService.fillOverlay(o, disp, channels);
}
}
-
+
private void flatten() {
- final ImageDisplay imageDisplay =
- imageDisplayService.getActiveImageDisplay();
+ final ImageDisplay imageDisplay = imageDisplayService
+ .getActiveImageDisplay();
if (imageDisplay == null) return;
// FIXME: Migrate Flatten functionality into a core service API.
commandService.run("net.imagej.plugins.commands.display.Flatten", true,
"display", imageDisplay);
}
-
+
private void help() {
try {
- final URL url =
- new URL("https://imagej.net/software/imagej2/implementation-notes#image--overlay--overlay-manager");
+ final URL url = new URL(
+ "https://imagej.net/software/imagej2/implementation-notes#image--overlay--overlay-manager");
platformService.open(url);
- } catch (IOException e) {
+ }
+ catch (IOException e) {
// do nothing
}
}
-
+
private void getList() {
JOptionPane.showMessageDialog(this, "unimplemented");
}
-
+
private void measure() {
JOptionPane.showMessageDialog(this, "unimplemented");
}
-
+
private void multiMeasure() {
JOptionPane.showMessageDialog(this, "unimplemented");
}
-
+
private void multiPlot() {
JOptionPane.showMessageDialog(this, "unimplemented");
}
-
+
private void open() {
JOptionPane.showMessageDialog(this, "unimplemented");
}
-
+
private void options() {
JOptionPane.showMessageDialog(this, "unimplemented");
}
-
+
private void or() {
makeCompositeOverlay(CompositeOverlay.Operation.OR);
}
-
+
private void properties() {
int[] selected = overlayService.getOverlayInfo().selectedIndices();
if (selected.length == 0) {
- JOptionPane.showMessageDialog(this, "This command requires one or more selections");
+ JOptionPane.showMessageDialog(this,
+ "This command requires one or more selections");
return;
}
// else one or more selections exist
runPropertiesPlugin();
}
-
+
private void removeSliceInfo() {
JOptionPane.showMessageDialog(this, "unimplemented");
}
-
+
private void rename() {
- final int[] selectedIndices = overlayService.getOverlayInfo().selectedIndices();
+ final int[] selectedIndices = overlayService.getOverlayInfo()
+ .selectedIndices();
if (selectedIndices.length < 1) {
JOptionPane.showMessageDialog(this, "Must select an overlay to rename");
return;
}
if (selectedIndices.length > 1) {
- JOptionPane.showMessageDialog(this, "Cannot rename multiple overlays simultaneously");
+ JOptionPane.showMessageDialog(this,
+ "Cannot rename multiple overlays simultaneously");
return;
}
- final OverlayInfo info = overlayService.getOverlayInfo().getOverlayInfo(selectedIndices[0]);
+ final OverlayInfo info = overlayService.getOverlayInfo().getOverlayInfo(
+ selectedIndices[0]);
if (info == null) return;
// TODO - UI agnostic way here
- final String name = JOptionPane.showInputDialog(this, "Enter new name for overlay");
- if ((name == null) || (name.length() == 0))
- info.getOverlay().setName(null);
- else
- info.getOverlay().setName(name);
+ final String name = JOptionPane.showInputDialog(this,
+ "Enter new name for overlay");
+ if ((name == null) || (name.length() == 0)) info.getOverlay().setName(null);
+ else info.getOverlay().setName(name);
jlist.updateUI();
}
-
+
private void save() {
JOptionPane.showMessageDialog(this, "unimplemented");
/*
@@ -672,7 +655,7 @@ private void save() {
JOptionPane.showMessageDialog(this, "Cannot save - one or more overlays must be selected first");
return;
}
-
+
final JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle("Save Overlay to file ...");
chooser.setAcceptAllFileFilterUsed(false);
@@ -689,7 +672,7 @@ private void save() {
basename.toLowerCase().endsWith(".zip")) {
basename = basename.substring(0,basename.length()-4);
}
-
+
// one roi selected
if (selectedIndices.length == 1) {
// save overlay in its own user named .ovl file
@@ -704,24 +687,24 @@ private void save() {
}
*/
}
-
+
private void sort() {
overlayService.getOverlayInfo().sort();
int[] newSelections = overlayService.getOverlayInfo().selectedIndices();
jlist.setSelectedIndices(newSelections);
jlist.updateUI();
}
-
+
private void specify() {
- final ImageDisplay imageDisplay =
- imageDisplayService.getActiveImageDisplay();
+ final ImageDisplay imageDisplay = imageDisplayService
+ .getActiveImageDisplay();
if (imageDisplay == null) return;
// FIXME: Migrate SelectionSpecify functionality into OverlayService API.
commandService.run("net.imagej.plugins.commands.overlay.SelectionSpecify",
true, "display", imageDisplay);
}
-
+
/*
* old functionality : now that all overlays always tracked this no longer
* makes sense
@@ -735,14 +718,14 @@ private void update() {
"Exactly one item must be selected");
return;
}
-
+
final Overlay overlay = getActiveOverlay();
if (overlay == null) {
JOptionPane.showMessageDialog(this,
"An overlay must be selected in the current view");
return;
}
-
+
final int index = infoList.findIndex(overlay);
if (index != -1) {
// already in list
@@ -756,16 +739,18 @@ private void update() {
jlist.updateUI();
}
*/
-
+
private void xor() {
makeCompositeOverlay(CompositeOverlay.Operation.XOR);
}
-
+
// -- private helpers for hotkey handling --
private void setupKeyListener() {
- //KeyListener listener = new AWTKeyEventDispatcher(fakeDisplay, eventService);
+ // KeyListener listener = new AWTKeyEventDispatcher(fakeDisplay,
+ // eventService);
final KeyListener listener = new KeyListener() {
+
@Override
public void keyPressed(KeyEvent e) {
altDown = e.isAltDown() || e.isAltGraphDown();
@@ -776,15 +761,17 @@ public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_F) flatten();
if (e.getKeyCode() == KeyEvent.VK_DELETE) delete();
}
+
@Override
public void keyReleased(KeyEvent e) {
altDown = e.isAltDown() || e.isAltGraphDown();
shiftDown = e.isShiftDown();
}
+
@Override
public void keyTyped(KeyEvent e) { /* do nothing */ }
};
-
+
final Stack stack = new Stack<>();
stack.push(this);
while (!stack.empty()) {
@@ -799,7 +786,7 @@ public void keyTyped(KeyEvent e) { /* do nothing */ }
}
// -- private helpers for frame location --
-
+
/** Persists the application frame's current location. */
private void saveLocation() {
Prefs.put(getClass(), LAST_X, getLocation().x);
@@ -812,9 +799,10 @@ private void restoreLocation() {
final int lastY = Prefs.getInt(getClass(), LAST_Y, 0);
setLocation(lastX, lastY);
}
-
+
private void setupCloseListener() {
addWindowListener(new WindowAdapter() {
+
@Override
public void windowClosing(WindowEvent e) {
// Remember screen location of window for next time
@@ -826,14 +814,16 @@ public void windowClosing(WindowEvent e) {
// -- private helpers for list selection event listening --
private void setupListSelectionListener() {
- final ListSelectionListener
- listSelectionListener = new ListSelectionListener() {
+ final ListSelectionListener listSelectionListener =
+ new ListSelectionListener()
+ {
+
@Override
public void valueChanged(final ListSelectionEvent listSelectionEvent) {
if (selecting) return;
selecting = true;
- final ImageDisplay display =
- imageDisplayService.getActiveImageDisplay();
+ final ImageDisplay display = imageDisplayService
+ .getActiveImageDisplay();
if (display == null) return;
final JList> list = (JList>) listSelectionEvent.getSource();
final List> selectionValues = list.getSelectedValuesList();
@@ -860,10 +850,9 @@ public void valueChanged(final ListSelectionEvent listSelectionEvent) {
}
// -- private helpers for constructing popup menu --
-
+
private JPopupMenu getPopupMenu() {
- if (popupMenu == null)
- popupMenu = createPopupMenu();
+ if (popupMenu == null) popupMenu = createPopupMenu();
return popupMenu;
}
@@ -886,7 +875,7 @@ private JPopupMenu createPopupMenu() {
menu.add(getOptionsMenuItem());
return menu;
}
-
+
private JMenuItem getAddParticlesMenuItem() {
final JMenuItem item;
item = new JMenuItem("Add Particles");
@@ -894,7 +883,7 @@ private JMenuItem getAddParticlesMenuItem() {
item.addActionListener(this);
return item;
}
-
+
private JMenuItem getAndMenuItem() {
final JMenuItem item;
item = new JMenuItem("AND");
@@ -902,7 +891,7 @@ private JMenuItem getAndMenuItem() {
item.addActionListener(this);
return item;
}
-
+
private JMenuItem getHelpMenuItem() {
final JMenuItem item;
item = new JMenuItem("Help");
@@ -910,7 +899,7 @@ private JMenuItem getHelpMenuItem() {
item.addActionListener(this);
return item;
}
-
+
private JMenuItem getListMenuItem() {
final JMenuItem item;
item = new JMenuItem("List");
@@ -918,7 +907,7 @@ private JMenuItem getListMenuItem() {
item.addActionListener(this);
return item;
}
-
+
private JMenuItem getMultiMeasureMenuItem() {
final JMenuItem item;
item = new JMenuItem("Multi Measure");
@@ -926,7 +915,7 @@ private JMenuItem getMultiMeasureMenuItem() {
item.addActionListener(this);
return item;
}
-
+
private JMenuItem getMultiPlotMenuItem() {
final JMenuItem item;
item = new JMenuItem("Multi Plot");
@@ -934,7 +923,7 @@ private JMenuItem getMultiPlotMenuItem() {
item.addActionListener(this);
return item;
}
-
+
private JMenuItem getOpenMenuItem() {
final JMenuItem item;
item = new JMenuItem("Open...");
@@ -942,7 +931,7 @@ private JMenuItem getOpenMenuItem() {
item.addActionListener(this);
return item;
}
-
+
private JMenuItem getOptionsMenuItem() {
final JMenuItem item;
item = new JMenuItem("Options...");
@@ -950,7 +939,7 @@ private JMenuItem getOptionsMenuItem() {
item.addActionListener(this);
return item;
}
-
+
private JMenuItem getOrMenuItem() {
final JMenuItem item;
item = new JMenuItem("OR (Combine)");
@@ -958,7 +947,7 @@ private JMenuItem getOrMenuItem() {
item.addActionListener(this);
return item;
}
-
+
private JMenuItem getRemoveSliceInfoMenuItem() {
final JMenuItem item;
item = new JMenuItem("Remove Slice Info");
@@ -966,7 +955,7 @@ private JMenuItem getRemoveSliceInfoMenuItem() {
item.addActionListener(this);
return item;
}
-
+
private JMenuItem getSaveMenuItem() {
final JMenuItem item;
item = new JMenuItem("Save...");
@@ -974,7 +963,7 @@ private JMenuItem getSaveMenuItem() {
item.addActionListener(this);
return item;
}
-
+
private JMenuItem getSortMenuItem() {
final JMenuItem item;
item = new JMenuItem("Sort");
@@ -982,7 +971,7 @@ private JMenuItem getSortMenuItem() {
item.addActionListener(this);
return item;
}
-
+
private JMenuItem getSpecifyMenuItem() {
final JMenuItem item;
item = new JMenuItem("Specify...");
@@ -990,7 +979,7 @@ private JMenuItem getSpecifyMenuItem() {
item.addActionListener(this);
return item;
}
-
+
private JMenuItem getDivideMenuItem() {
final JMenuItem item;
item = new JMenuItem("Divide");
@@ -998,7 +987,7 @@ private JMenuItem getDivideMenuItem() {
item.addActionListener(this);
return item;
}
-
+
private JMenuItem getXorMenuItem() {
final JMenuItem item;
item = new JMenuItem("XOR");
@@ -1006,7 +995,7 @@ private JMenuItem getXorMenuItem() {
item.addActionListener(this);
return item;
}
-
+
// -- private helpers to implement main pane button controls --
/* no longer supported
@@ -1017,76 +1006,81 @@ private JButton getAddButton() {
return button;
}
*/
-
+
private JButton getDeleteButton() {
final JButton button = new JButton("Delete");
button.setActionCommand(ACTION_DELETE);
button.addActionListener(this);
return button;
}
-
+
private JButton getDeselectButton() {
final JButton button = new JButton("Deselect");
button.setActionCommand(ACTION_DESELECT);
button.addActionListener(this);
return button;
}
-
+
private JButton getDrawButton() {
final JButton button = new JButton("Draw");
button.setActionCommand(ACTION_DRAW);
button.addActionListener(this);
return button;
}
-
+
private JButton getFillButton() {
final JButton button = new JButton("Fill");
button.setActionCommand(ACTION_FILL);
button.addActionListener(this);
return button;
}
-
+
private JButton getFlattenButton() {
final JButton button = new JButton("Flatten [f]");
button.setActionCommand(ACTION_FLATTEN);
button.addActionListener(this);
return button;
}
-
+
private JButton getMeasureButton() {
final JButton button = new JButton("Measure");
button.setActionCommand(ACTION_MEASURE);
button.addActionListener(this);
return button;
}
-
+
private JButton getMoreButton() {
- final JButton button = new JButton("More "+'\u00bb');
+ final JButton button = new JButton("More " + '\u00bb');
button.addMouseListener(new MouseListener() {
+
@Override
public void mouseClicked(MouseEvent e) {
getPopupMenu().show(e.getComponent(), e.getX(), e.getY());
}
+
@Override
public void mouseEntered(MouseEvent evt) { /* do nothing */ }
+
@Override
public void mouseExited(MouseEvent evt) { /* do nothing */ }
+
@Override
public void mousePressed(MouseEvent evt) { /* do nothing */ }
+
@Override
public void mouseReleased(MouseEvent evt) { /* do nothing */ }
-
+
});
return button;
}
-
+
private JButton getPropertiesButton() {
final JButton button = new JButton("Properties...");
button.setActionCommand(ACTION_PROPERTIES);
button.addActionListener(this);
return button;
}
-
+
private JButton getRenameButton() {
final JButton button = new JButton("Rename...");
button.setActionCommand(ACTION_RENAME);
@@ -1102,32 +1096,31 @@ private JButton getUpdateButton() {
return button;
}
*/
-
+
// -- private helpers to change state when checkboxes change --
// TODO
-
+
@Override
public void itemStateChanged(ItemEvent evt) {
final boolean selected = (evt.getStateChange() == ItemEvent.SELECTED);
if (evt.getSource() == showAllCheckBox) {
- //System.out.println("show all is now "+selected);
+ // System.out.println("show all is now "+selected);
}
if (evt.getSource() == editModeCheckBox) {
- //System.out.println("edit mode is now "+selected);
+ // System.out.println("edit mode is now "+selected);
// link both checkboxes in selected case
- if (selected)
- showAllCheckBox.setSelected(true);
+ if (selected) showAllCheckBox.setSelected(true);
}
}
// -- private helpers for TODO XXXX --
-
+
// TODO - assumes first selected overlay view is the only one. bad?
@SuppressWarnings("unused")
private Overlay getActiveOverlay() {
- final ImageDisplay activeDisplay =
- imageDisplayService.getActiveImageDisplay();
+ final ImageDisplay activeDisplay = imageDisplayService
+ .getActiveImageDisplay();
if (activeDisplay == null) return null;
final List views = activeDisplay;
for (DataView view : views) {
@@ -1136,10 +1129,11 @@ private Overlay getActiveOverlay() {
}
return null;
}
-
+
private void runPropertiesPlugin() {
final Map inputMap = new HashMap<>();
- inputMap.put("overlays", overlayService.getOverlayInfo().selectedOverlays());
+ inputMap.put("overlays", overlayService.getOverlayInfo()
+ .selectedOverlays());
// FIXME: Migrate OverlayProperties functionality into OverlayService API.
commandService.run(
"net.imagej.plugins.commands.overlay.SelectedManagerOverlayProperties",
@@ -1151,16 +1145,17 @@ private ChannelCollection getChannels() {
if (altDown) return opts.getBgValues();
return opts.getFgValues();
}
-
+
private void makeCompositeOverlay(CompositeOverlay.Operation op) {
ImageDisplay imageDisplay = imageDisplayService.getActiveImageDisplay();
if (imageDisplay == null) return;
List overlays = overlayService.getOverlayInfo().selectedOverlays();
- if (overlays.size() == 0) overlays = overlayService.getOverlays(imageDisplay);
+ if (overlays.size() == 0) overlays = overlayService.getOverlays(
+ imageDisplay);
if (overlays.size() < 2) {
JOptionPane.showMessageDialog(this,
- "This command only works with 2 or more overlays");
- return;
+ "This command only works with 2 or more overlays");
+ return;
}
// else overlays.size() >= 2
CompositeOverlay newOverlay = new CompositeOverlay(context);
@@ -1169,5 +1164,5 @@ private void makeCompositeOverlay(CompositeOverlay.Operation op) {
imageDisplay.display(newOverlay);
imageDisplay.update();
}
-
+
}
diff --git a/src/main/java/net/imagej/ui/swing/overlay/ThresholdFigure.java b/src/main/java/net/imagej/ui/swing/overlay/ThresholdFigure.java
index f52cfc3..83f87d0 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/ThresholdFigure.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/ThresholdFigure.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -51,7 +51,7 @@
/**
* Implementation of JHotDraw Figure that can display a {@link ThresholdOverlay}
- *
+ *
* @author Barry DeZonia
*/
public class ThresholdFigure extends AbstractAttributedFigure implements
@@ -65,7 +65,7 @@ public class ThresholdFigure extends AbstractAttributedFigure implements
private final ThresholdOverlay overlay;
private final Rectangle2D.Double rect;
private double[] tmpPos;
-
+
public ThresholdFigure(ImageDisplay display, Dataset dataset,
ThresholdOverlay overlay)
{
@@ -79,7 +79,7 @@ public ThresholdFigure(ImageDisplay display, Dataset dataset,
set(AttributeKeys.FILL_COLOR, Color.DARK_GRAY); // always have a color set
overlay.setFigure(this);
}
-
+
@Override
public boolean contains(Point2D.Double pt) {
int d = dataset.numDimensions();
@@ -127,12 +127,12 @@ public Double getStartPoint() {
public Double getEndPoint() {
return new Double(dataset.max(0), dataset.max(1));
}
-
+
@Override
public Rectangle2D.Double getDrawingArea() {
return new Rectangle2D.Double(0, 0, dataset.max(0), dataset.max(1));
}
-
+
@Override
public void setBounds(Double anchor, Double lead) {
// do nothing
diff --git a/src/main/java/net/imagej/ui/swing/overlay/ThresholdJHotDrawAdapter.java b/src/main/java/net/imagej/ui/swing/overlay/ThresholdJHotDrawAdapter.java
index d98a1ec..4496315 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/ThresholdJHotDrawAdapter.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/ThresholdJHotDrawAdapter.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -47,7 +47,7 @@
/**
* JHotDraw adapter for threshold overlays.
- *
+ *
* @author Barry DeZonia
* @see SwingPolygonTool
*/
diff --git a/src/main/java/net/imagej/ui/swing/overlay/ToolDelegator.java b/src/main/java/net/imagej/ui/swing/overlay/ToolDelegator.java
index 7aa9756..4374612 100644
--- a/src/main/java/net/imagej/ui/swing/overlay/ToolDelegator.java
+++ b/src/main/java/net/imagej/ui/swing/overlay/ToolDelegator.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -44,7 +44,7 @@
/**
* TODO
- *
+ *
* @author Johannes Schindelin
*/
public class ToolDelegator extends AbstractTool {
@@ -235,9 +235,8 @@ protected boolean maybeSwitchTool(final MouseEvent event) {
JHotDrawTool tool = creationTool;
final DrawingView view = getView();
if (view != null && view.isEnabled()) {
- if (view.findHandle(anchor) != null ||
- (view.findFigure(anchor) != null && view.findFigure(anchor)
- .isSelectable()))
+ if (view.findHandle(anchor) != null || (view.findFigure(anchor) != null &&
+ view.findFigure(anchor).isSelectable()))
{
if (selection) tool = selectionTool;
else tool = null;
diff --git a/src/main/java/net/imagej/ui/swing/sdi/viewer/SwingSdiImageDisplayViewer.java b/src/main/java/net/imagej/ui/swing/sdi/viewer/SwingSdiImageDisplayViewer.java
index d3f7ee1..863425e 100644
--- a/src/main/java/net/imagej/ui/swing/sdi/viewer/SwingSdiImageDisplayViewer.java
+++ b/src/main/java/net/imagej/ui/swing/sdi/viewer/SwingSdiImageDisplayViewer.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -42,13 +42,14 @@
/**
* Single Document Interface implementation of Swing image display viewer. The
* SDI display is housed in a {@link JFrame}.
- *
+ *
* @author Curtis Rueden
* @author Lee Kamentsky
* @see SwingImageDisplayViewer
*/
@Plugin(type = DisplayViewer.class)
-public class SwingSdiImageDisplayViewer extends AbstractSwingImageDisplayViewer
+public class SwingSdiImageDisplayViewer extends
+ AbstractSwingImageDisplayViewer
{
// -- DisplayViewer methods --
diff --git a/src/main/java/net/imagej/ui/swing/tools/SwingAngleTool.java b/src/main/java/net/imagej/ui/swing/tools/SwingAngleTool.java
index 6b1d1aa..8fb7bdd 100644
--- a/src/main/java/net/imagej/ui/swing/tools/SwingAngleTool.java
+++ b/src/main/java/net/imagej/ui/swing/tools/SwingAngleTool.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,7 +35,7 @@
/**
* Swing/JHotDraw implementation of angle tool.
- *
+ *
* @author Lee Kamentsky
* @author Barry DeZonia
* @see net.imagej.ui.swing.overlay.AngleJHotDrawAdapter
diff --git a/src/main/java/net/imagej/ui/swing/tools/SwingEllipseTool.java b/src/main/java/net/imagej/ui/swing/tools/SwingEllipseTool.java
index 1d92389..a91438d 100644
--- a/src/main/java/net/imagej/ui/swing/tools/SwingEllipseTool.java
+++ b/src/main/java/net/imagej/ui/swing/tools/SwingEllipseTool.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,7 +35,7 @@
/**
* Swing/JHotDraw implementation of ellipse tool.
- *
+ *
* @author Lee Kamentsky
* @author Barry DeZonia
* @see net.imagej.ui.swing.overlay.EllipseJHotDrawAdapter
diff --git a/src/main/java/net/imagej/ui/swing/tools/SwingLineTool.java b/src/main/java/net/imagej/ui/swing/tools/SwingLineTool.java
index d692f5c..0af65d1 100644
--- a/src/main/java/net/imagej/ui/swing/tools/SwingLineTool.java
+++ b/src/main/java/net/imagej/ui/swing/tools/SwingLineTool.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,7 +35,7 @@
/**
* Swing/JHotDraw implementation of line tool.
- *
+ *
* @author Lee Kamentsky
* @author Barry DeZonia
* @see net.imagej.ui.swing.overlay.LineJHotDrawAdapter
diff --git a/src/main/java/net/imagej/ui/swing/tools/SwingPointTool.java b/src/main/java/net/imagej/ui/swing/tools/SwingPointTool.java
index 5d8f755..d7160c3 100644
--- a/src/main/java/net/imagej/ui/swing/tools/SwingPointTool.java
+++ b/src/main/java/net/imagej/ui/swing/tools/SwingPointTool.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -36,7 +36,7 @@
/**
* Swing/JHotDraw implementation of point tool.
- *
+ *
* @author Barry DeZonia
* @see net.imagej.ui.swing.overlay.PointJHotDrawOverlay
*/
diff --git a/src/main/java/net/imagej/ui/swing/tools/SwingPolygonTool.java b/src/main/java/net/imagej/ui/swing/tools/SwingPolygonTool.java
index d9e363f..0338622 100644
--- a/src/main/java/net/imagej/ui/swing/tools/SwingPolygonTool.java
+++ b/src/main/java/net/imagej/ui/swing/tools/SwingPolygonTool.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,7 +35,7 @@
/**
* Swing/JHotDraw implementation of polygon/freehand tool.
- *
+ *
* @author Lee Kamentsky
* @author Barry DeZonia
* @see net.imagej.ui.swing.overlay.PolygonJHotDrawAdapter
diff --git a/src/main/java/net/imagej/ui/swing/tools/SwingPolylineTool.java b/src/main/java/net/imagej/ui/swing/tools/SwingPolylineTool.java
index 5399386..334ee3f 100644
--- a/src/main/java/net/imagej/ui/swing/tools/SwingPolylineTool.java
+++ b/src/main/java/net/imagej/ui/swing/tools/SwingPolylineTool.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,12 +35,11 @@
/**
* Swing/JHotDraw implementation of multi-segmented line tool.
- *
+ *
* @author Benjamin Nanes
*/
-@Plugin(type = Tool.class, name = "Polyline",
- description = "Polyline overlays", iconPath = "/icons/tools/polyline.png",
- priority = SwingPolylineTool.PRIORITY)
+@Plugin(type = Tool.class, name = "Polyline", description = "Polyline overlays",
+ iconPath = "/icons/tools/polyline.png", priority = SwingPolylineTool.PRIORITY)
public class SwingPolylineTool extends AbstractTool {
public static final double PRIORITY = SwingLineTool.PRIORITY - 1;
diff --git a/src/main/java/net/imagej/ui/swing/tools/SwingRectangleTool.java b/src/main/java/net/imagej/ui/swing/tools/SwingRectangleTool.java
index 20ec08e..0e5e17d 100644
--- a/src/main/java/net/imagej/ui/swing/tools/SwingRectangleTool.java
+++ b/src/main/java/net/imagej/ui/swing/tools/SwingRectangleTool.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,15 +35,14 @@
/**
* Swing/JHotDraw implementation of rectangle tool.
- *
+ *
* @author Lee Kamentsky
* @author Grant Harris
* @author Barry DeZonia
* @see net.imagej.ui.swing.overlay.RectangleJHotDrawAdapter
*/
@Plugin(type = Tool.class, name = "Rectangle",
- description = "Rectangular overlays",
- iconPath = "/icons/tools/rectangle.png",
+ description = "Rectangular overlays", iconPath = "/icons/tools/rectangle.png",
priority = SwingRectangleTool.PRIORITY)
public class SwingRectangleTool extends AbstractTool {
diff --git a/src/main/java/net/imagej/ui/swing/tools/SwingTextTool.java b/src/main/java/net/imagej/ui/swing/tools/SwingTextTool.java
index 0e1125f..57ef7f8 100644
--- a/src/main/java/net/imagej/ui/swing/tools/SwingTextTool.java
+++ b/src/main/java/net/imagej/ui/swing/tools/SwingTextTool.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -36,7 +36,7 @@
/**
* Swing/JHotDraw implementation of text tool.
- *
+ *
* @author Curtis Rueden
*/
@Plugin(type = Tool.class, name = "Text", description = "Text tool",
diff --git a/src/main/java/net/imagej/ui/swing/updater/ConflictDialog.java b/src/main/java/net/imagej/ui/swing/updater/ConflictDialog.java
index aba8130..0be9417 100644
--- a/src/main/java/net/imagej/ui/swing/updater/ConflictDialog.java
+++ b/src/main/java/net/imagej/ui/swing/updater/ConflictDialog.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -54,8 +54,9 @@
import net.imagej.updater.Conflicts.Resolution;
/**
- * This dialog lists conflicts and let's the user choose how to resolve (or ignore) them.
- *
+ * This dialog lists conflicts and let's the user choose how to resolve (or
+ * ignore) them.
+ *
* @author Johannes Schindelin
*/
@SuppressWarnings("serial")
@@ -96,7 +97,8 @@ public ConflictDialog(final UpdaterFrame owner, final String title) {
final JPanel buttons = new JPanel();
ok = SwingTools.button("OK", "Apply resolutions [Enter]", this, buttons);
cancel = SwingTools.button("Cancel", "Dismiss [Esc]", this, buttons);
- buttons.setMaximumSize(buttons.getPreferredSize()); // do not allow vertical resizing
+ buttons.setMaximumSize(buttons.getPreferredSize()); // do not allow vertical
+ // resizing
rootPanel.add(buttons);
// do not show, right now
@@ -114,8 +116,7 @@ public ConflictDialog(final UpdaterFrame owner, final String title) {
@Override
public void windowClosing(final WindowEvent e) {
updateConflictList();
- if (conflictList.size() > 0)
- wasCanceled = true;
+ if (conflictList.size() > 0) wasCanceled = true;
}
});
}
@@ -161,7 +162,8 @@ protected void listIssues() {
for (final Conflict conflict : conflictList) {
maybeAddSeparator();
- newText(conflict.getSeverity().toString() + ": ", conflict.isError() ? red : normal);
+ newText(conflict.getSeverity().toString() + ": ", conflict.isError() ? red
+ : normal);
final String filename = conflict.getFilename();
if (filename != null) addText(filename, bold);
addText("\n" + conflict.getConflict());
diff --git a/src/main/java/net/imagej/ui/swing/updater/DiffFile.java b/src/main/java/net/imagej/ui/swing/updater/DiffFile.java
index db24808..9258c10 100644
--- a/src/main/java/net/imagej/ui/swing/updater/DiffFile.java
+++ b/src/main/java/net/imagej/ui/swing/updater/DiffFile.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -62,10 +62,11 @@
/**
* A {@link JFrame} to show the differences between the remote and local
* versions of a file known to the ImageJ Updater.
- *
+ *
* @author Johannes Schindelin
*/
public class DiffFile extends JFrame {
+
private static final long serialVersionUID = 1L;
protected String title;
protected LogService log;
@@ -80,17 +81,16 @@ public class DiffFile extends JFrame {
/**
* Initialize the frame.
- *
- * @param files
- * the collection of files, including information about the
- * update site from which we got the file
- * @param file
- * the file to diff
- * @param mode
- * the diff mode
+ *
+ * @param files the collection of files, including information about the
+ * update site from which we got the file
+ * @param file the file to diff
+ * @param mode the diff mode
* @throws MalformedURLException
*/
- public DiffFile(final FilesCollection files, final FileObject file, final Mode mode) throws MalformedURLException {
+ public DiffFile(final FilesCollection files, final FileObject file,
+ final Mode mode) throws MalformedURLException
+ {
util = files.util;
title = file.getLocalFilename(true) + " differences";
log = files.log;
@@ -110,10 +110,10 @@ public DiffFile(final FilesCollection files, final FileObject file, final Mode m
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
getContentPane().add(diffView);
addWindowListener(new WindowAdapter() {
+
@Override
public void windowClosing(WindowEvent e) {
- if (worker != null)
- worker.interrupt();
+ if (worker != null) worker.interrupt();
}
});
pack();
@@ -121,18 +121,19 @@ public void windowClosing(WindowEvent e) {
/**
* Switch to a different diff mode.
- *
- * @param mode
- * the mode to diff to
+ *
+ * @param mode the mode to diff to
*/
protected void show(final Mode mode) {
show(() -> {
try {
setTitle(title + " (" + mode + ")");
diff.showDiff(filename, remote, local, mode);
- } catch (MalformedURLException e) {
+ }
+ catch (MalformedURLException e) {
log.error(e);
- } catch (IOException e) {
+ }
+ catch (IOException e) {
log.error(e);
}
});
@@ -140,31 +141,30 @@ protected void show(final Mode mode) {
/**
* Show a different diff.
- *
- * @param runnable
- * the object printing to the {@link DiffView}
+ *
+ * @param runnable the object printing to the {@link DiffView}
*/
protected synchronized void show(final Runnable runnable) {
- if (worker != null)
- worker.interrupt();
- else
- diffView.setCursor(waitCursor);
+ if (worker != null) worker.interrupt();
+ else diffView.setCursor(waitCursor);
worker = new Thread() {
+
@Override
public void run() {
try {
clearDiff();
runnable.run();
- } catch (RuntimeException e) {
- if (!(e.getCause() instanceof InterruptedException))
- log.error(e);
+ }
+ catch (RuntimeException e) {
+ if (!(e.getCause() instanceof InterruptedException)) log.error(e);
worker.interrupt();
- } catch (Error e) {
+ }
+ catch (Error e) {
log.error(e);
worker.interrupt();
}
diffView.setCursor(normalCursor);
- synchronized(DiffFile.this) {
+ synchronized (DiffFile.this) {
worker = null;
}
}
@@ -179,7 +179,8 @@ protected void clearDiff() {
final Document doc = diffView.getDocument();
try {
doc.remove(diffOffset, doc.getLength() - diffOffset);
- } catch (BadLocationException e) {
+ }
+ catch (BadLocationException e) {
log.error(e);
}
}
@@ -189,9 +190,9 @@ protected void clearDiff() {
*/
private void addModeLinks() {
for (final Mode mode : Mode.values()) {
- if (diffView.getDocument().getLength() > 0)
- diffView.normal(" ");
+ if (diffView.getDocument().getLength() > 0) diffView.normal(" ");
diffView.link(mode.toString(), new ActionListener() {
+
@Override
public void actionPerformed(ActionEvent e) {
show(mode);
@@ -201,24 +202,24 @@ public void actionPerformed(ActionEvent e) {
}
/**
- * Add an action link to show the Git log of the file.
- *
- * This method only adds the link if it can determine where the source for
- * this component lives.
- *
- * @param files
- * the file collection including information where the file lives
- * @param fileObject
- * the component to inspect
+ * Add an action link to show the Git log of the file. This method only adds
+ * the link if it can determine where the source for this component lives.
+ *
+ * @param files the file collection including information where the file lives
+ * @param fileObject the component to inspect
*/
- private void addGitLogLink(final FilesCollection files, final FileObject fileObject) {
- // first, we need to find Implementation-Build entries in the respective manifests
+ private void addGitLogLink(final FilesCollection files,
+ final FileObject fileObject)
+ {
+ // first, we need to find Implementation-Build entries in the respective
+ // manifests
String commitLocal = getCommit(local);
if (commitLocal == null || "".equals(commitLocal)) commitLocal = "HEAD";
String commitRemote = getCommit(remote);
if (commitLocal.equals(commitRemote)) {
- diffView.warn("The remote and local versions were built from the same commit!");
+ diffView.warn(
+ "The remote and local versions were built from the same commit!");
return;
}
@@ -228,12 +229,17 @@ private void addGitLogLink(final FilesCollection files, final FileObject fileObj
directory = directory.getParentFile();
if (directory == null) return;
}
- final String baseName = fileObject.filename.substring(fileObject.filename.lastIndexOf('/') + 1);
- for (String pair : new String[] { "ij-[1-9].* ImageJA", "ij-[a-z].* imagej2", "imglib.* imglib", "TrakEM2.* TrakEM2", "mpicbg.* mpicbg" }) {
+ final String baseName = fileObject.filename.substring(fileObject.filename
+ .lastIndexOf('/') + 1);
+ for (String pair : new String[] { "ij-[1-9].* ImageJA",
+ "ij-[a-z].* imagej2", "imglib.* imglib", "TrakEM2.* TrakEM2",
+ "mpicbg.* mpicbg" })
+ {
final int space = pair.indexOf(' ');
final String pattern = pair.substring(0, space);
if (baseName.matches(pattern)) {
- final File submodule = new File(directory, "modules/" + pair.substring(space + 1));
+ final File submodule = new File(directory, "modules/" + pair.substring(
+ space + 1));
if (new File(submodule, ".git").isDirectory()) {
directory = submodule;
break;
@@ -242,7 +248,8 @@ private void addGitLogLink(final FilesCollection files, final FileObject fileObj
}
final File gitWorkingDirectory = directory;
- // now, let's find the directory where the first source of the local .jar is stored
+ // now, let's find the directory where the first source of the local .jar is
+ // stored
final String relativePath = findSourceDirectory(gitWorkingDirectory, local);
if (relativePath == null) return;
@@ -256,25 +263,28 @@ private void addGitLogLink(final FilesCollection files, final FileObject fileObj
commitRange = commitLocal;
long millis = UpdaterUtil.timestamp2millis(fileObject.current.timestamp);
since = "--since=" + (millis / 1000l - 5 * 60);
- warning = "No precise commit information in the remote .jar;\n"
- + "\tUsing timestamp from Updater instead: " + new Date(millis) + " - 5 minutes";
+ warning = "No precise commit information in the remote .jar;\n" +
+ "\tUsing timestamp from Updater instead: " + new Date(millis) +
+ " - 5 minutes";
}
- if (diffView.getDocument().getLength() > 0)
- diffView.normal(" ");
+ if (diffView.getDocument().getLength() > 0) diffView.normal(" ");
diffView.link("Git Log", e -> show(() -> {
setTitle(title + " (Git Log)");
final PrintStream out = diffView.getPrintStream();
out.println("\n");
if (warning != null) diffView.warn(warning + "\n\n");
- final String git = System.getProperty("imagej.updater.git.command", "git");
- ProcessUtils.exec(gitWorkingDirectory, out, out, git, "log", "-M", "-p", since, commitRange, "--", relativePath);
+ final String git = System.getProperty("imagej.updater.git.command",
+ "git");
+ ProcessUtils.exec(gitWorkingDirectory, out, out, git, "log", "-M", "-p",
+ since, commitRange, "--", relativePath);
}));
}
/**
- * Given a {@link URL} to a .jar file, extract the Implementation-Build entry from the manifest.
- *
+ * Given a {@link URL} to a .jar file, extract the Implementation-Build
+ * entry from the manifest.
+ *
* @param jarURL the URL to the .jar file
*/
private String getCommit(final URL jarURL) {
@@ -282,29 +292,32 @@ private String getCommit(final URL jarURL) {
final JarInputStream in = new JarInputStream(util.openStream(jarURL));
in.close();
Manifest manifest = in.getManifest();
- if (manifest == null)
- for (;;) {
- final JarEntry entry = in.getNextJarEntry();
- if (entry == null) return null;
- if (entry.getName().equals("META-INF/MANIFEST.MF")) {
- manifest = new Manifest(in);
- break;
- }
+ if (manifest == null) for (;;) {
+ final JarEntry entry = in.getNextJarEntry();
+ if (entry == null) return null;
+ if (entry.getName().equals("META-INF/MANIFEST.MF")) {
+ manifest = new Manifest(in);
+ break;
}
- final Attributes attributes = manifest.getMainAttributes();
+ }
+ final Attributes attributes = manifest.getMainAttributes();
return attributes.getValue(new Attributes.Name("Implementation-Build"));
- } catch (IOException e) {
+ }
+ catch (IOException e) {
return null;
}
}
/**
- * Given a {@link URL} to a .jar file, extract the path of the first .class file contained therein.
- *
+ * Given a {@link URL} to a .jar file, extract the path of the first
+ * .class file contained therein.
+ *
* @param jarURL the URL to the .jar file
* @return the path stored in the .jar file
*/
- private String findSourceDirectory(final File gitWorkingDirectory, final URL jarURL) {
+ private String findSourceDirectory(final File gitWorkingDirectory,
+ final URL jarURL)
+ {
try {
int maxCount = 3;
final JarInputStream in = new JarInputStream(util.openStream(jarURL));
@@ -317,25 +330,33 @@ private String findSourceDirectory(final File gitWorkingDirectory, final URL jar
final ByteCodeAnalyzer analyzer = Diff.analyzeByteCode(in, false);
final String sourceFile = analyzer.getSourceFile();
if (sourceFile == null) continue;
- final String suffix = path.substring(0, path.lastIndexOf('/') + 1) + sourceFile;
- final String git = System.getProperty("imagej.updater.git.command", "git");
+ final String suffix = path.substring(0, path.lastIndexOf('/') + 1) +
+ sourceFile;
+ final String git = System.getProperty("imagej.updater.git.command",
+ "git");
try {
- path = ProcessUtils.exec(gitWorkingDirectory, null, null, git, "ls-files", "*/" + suffix);
+ path = ProcessUtils.exec(gitWorkingDirectory, null, null, git,
+ "ls-files", "*/" + suffix);
if (path.length() <= suffix.length()) continue;
if (path.endsWith("\n")) path = path.substring(0, path.length() - 1);
- } catch (RuntimeException e) {
+ }
+ catch (RuntimeException e) {
/* ignore */
continue;
}
if (path.indexOf('\n') >= 0) continue; // ls-files found multiple files
path = path.substring(0, path.length() - suffix.length());
if ("".equals(path)) path = ".";
- else if (path.endsWith("/src/main/java/")) path = path.substring(0, path.length() - "/src/main/java/".length());
+ else if (path.endsWith("/src/main/java/")) path = path.substring(0, path
+ .length() - "/src/main/java/".length());
in.close();
return path;
}
in.close();
- } catch (IOException e) { /* ignore */ e.printStackTrace(); }
+ }
+ catch (IOException e) {
+ /* ignore */ e.printStackTrace();
+ }
return null;
}
}
diff --git a/src/main/java/net/imagej/ui/swing/updater/DiffView.java b/src/main/java/net/imagej/ui/swing/updater/DiffView.java
index 9d60212..5245705 100644
--- a/src/main/java/net/imagej/ui/swing/updater/DiffView.java
+++ b/src/main/java/net/imagej/ui/swing/updater/DiffView.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -60,16 +60,16 @@
import org.scijava.util.ProcessUtils;
/**
- * A scroll pane that colorizes diff output.
- *
- * It offers a {@link PrintStream} for use with
- * {@link ProcessUtils#exec(java.io.File, PrintStream, PrintStream, String...)}. It
- * can also show links that might update the view by calling an
+ * A scroll pane that colorizes diff output. It offers a {@link PrintStream} for
+ * use with
+ * {@link ProcessUtils#exec(java.io.File, PrintStream, PrintStream, String...)}.
+ * It can also show links that might update the view by calling an
* {@link ActionListener}. Otherwise, this class is pretty dumb.
- *
+ *
* @author Johannes Schindelin
*/
public class DiffView extends JScrollPane {
+
private static final long serialVersionUID = 1L;
protected static final String ACTION_ATTRIBUTE = "ACTION";
@@ -112,38 +112,37 @@ public DiffView() {
getVerticalScrollBar().setUnitIncrement(10);
textPane.addMouseListener(new MouseAdapter() {
+
@Override
public void mouseClicked(MouseEvent event) {
ActionListener action = getAction(event);
- if (action != null)
- action.actionPerformed(new ActionEvent(DiffView.this, 0, "action"));
+ if (action != null) action.actionPerformed(new ActionEvent(
+ DiffView.this, 0, "action"));
}
});
}
private ActionListener getAction(final MouseEvent event) {
- Element e = document.getCharacterElement(textPane.viewToModel(event.getPoint()));
- ActionListener action = (ActionListener)e.getAttributes().getAttribute(ACTION_ATTRIBUTE);
+ Element e = document.getCharacterElement(textPane.viewToModel(event
+ .getPoint()));
+ ActionListener action = (ActionListener) e.getAttributes().getAttribute(
+ ACTION_ATTRIBUTE);
return action;
}
/**
* Create an attribute set for stylish text.
- *
- * @param color
- * the color
- * @param italic
- * whether the text should be slanted
- * @param bold
- * whether the text should be bold
- * @param fontName
- * the name of the font to use
- * @param fontSize
- * the font size to use
+ *
+ * @param color the color
+ * @param italic whether the text should be slanted
+ * @param bold whether the text should be bold
+ * @param fontName the name of the font to use
+ * @param fontSize the font size to use
* @return the attribute set
*/
public static SimpleAttributeSet getStyle(Color color, boolean italic,
- boolean bold, String fontName, int fontSize) {
+ boolean bold, String fontName, int fontSize)
+ {
SimpleAttributeSet style = new SimpleAttributeSet();
if (color != null) StyleConstants.setForeground(style, color);
StyleConstants.setItalic(style, italic);
@@ -155,11 +154,9 @@ public static SimpleAttributeSet getStyle(Color color, boolean italic,
/**
* Add stylish text.
- *
- * @param text
- * the text to add
- * @param set
- * the formatting attributes
+ *
+ * @param text the text to add
+ * @param set the formatting attributes
*/
public void styled(String text, AttributeSet set) {
styled(document.getLength(), text, set);
@@ -167,18 +164,16 @@ public void styled(String text, AttributeSet set) {
/**
* Insert some stylish text.
- *
- * @param position
- * the position where to insert the text
- * @param text
- * the text to insert
- * @param set
- * the formatting attributes
+ *
+ * @param position the position where to insert the text
+ * @param text the text to insert
+ * @param set the formatting attributes
*/
public void styled(int position, String text, AttributeSet set) {
try {
document.insertString(position, text, set);
- } catch (BadLocationException e) {
+ }
+ catch (BadLocationException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
@@ -186,9 +181,8 @@ public void styled(int position, String text, AttributeSet set) {
/**
* Add some plain text.
- *
- * @param text
- * the text to add
+ *
+ * @param text the text to add
*/
public void normal(String text) {
styled(text, normal);
@@ -196,9 +190,8 @@ public void normal(String text) {
/**
* Add some warnings.
- *
- * @param warning
- * the text to add
+ *
+ * @param warning the text to add
*/
public void warn(String warning) {
red("Warning: ");
@@ -207,9 +200,8 @@ public void warn(String warning) {
/**
* Add some red text.
- *
- * @param text
- * the text to add
+ *
+ * @param text the text to add
*/
public void red(String text) {
styled(text, red);
@@ -217,9 +209,8 @@ public void red(String text) {
/**
* Add some green text.
- *
- * @param text
- * the text to add
+ *
+ * @param text the text to add
*/
public void green(String text) {
styled(text, green);
@@ -227,9 +218,8 @@ public void green(String text) {
/**
* Insert some red text.
- *
- * @param text
- * the text to insert
+ *
+ * @param text the text to insert
*/
public void red(int position, String text) {
styled(position, text, red);
@@ -237,9 +227,8 @@ public void red(int position, String text) {
/**
* Insert some green text.
- *
- * @param text
- * the text to insert
+ *
+ * @param text the text to insert
*/
public void green(int position, String text) {
styled(position, text, green);
@@ -247,9 +236,8 @@ public void green(int position, String text) {
/**
* Generate an attribute set for links.
- *
- * @param action
- * the action to perform
+ *
+ * @param action the action to perform
* @return the attribute set
*/
public static SimpleAttributeSet getActionStyle(ActionListener action) {
@@ -264,11 +252,9 @@ public static SimpleAttributeSet getActionStyle(ActionListener action) {
/**
* Add a link.
- *
- * @param text
- * the label of the link
- * @param action
- * the action to perform when the link is clicked
+ *
+ * @param text the label of the link
+ * @param action the action to perform when the link is clicked
*/
public void link(String text, ActionListener action) {
final JButton button = new JButton(text);
@@ -279,7 +265,7 @@ public void link(String text, ActionListener action) {
/**
* Get the number of added lines.
- *
+ *
* @return how many lines were added in total
*/
public int getAdds() {
@@ -288,7 +274,7 @@ public int getAdds() {
/**
* Get the number of removed lines.
- *
+ *
* @return how many lines were removed in total
*/
public int getRemoves() {
@@ -297,7 +283,7 @@ public int getRemoves() {
/**
* Get the number of added or removed lines.
- *
+ *
* @return how many lines were added or removed in total
*/
public int getChanges() {
@@ -306,7 +292,7 @@ public int getChanges() {
/**
* Colorize one line of output.
- *
+ *
* @param line the line
*/
public void println(String line) {
@@ -314,8 +300,8 @@ public void println(String line) {
styled(line, bold);
inHeader = false;
}
- else if (line.startsWith(" "))
- styled(line, inHeader && line.startsWith(" ") ? bigBold : normal);
+ else if (line.startsWith(" ")) styled(line, inHeader && line.startsWith(
+ " ") ? bigBold : normal);
else if (line.startsWith("+")) {
adds++;
styled(line, green);
@@ -325,8 +311,7 @@ else if (line.startsWith("-")) {
styled(line, red);
}
else {
- if (line.startsWith("commit"))
- inHeader = true;
+ if (line.startsWith("commit")) inHeader = true;
styled(line, italic);
}
styled("\n", normal);
@@ -334,17 +319,19 @@ else if (line.startsWith("-")) {
/**
* Construct a {@link PrintStream} adapter to this view.
- *
+ *
* @return the print stream
*/
public PrintStream getPrintStream() {
final OutputStream out = new LineOutputStream() {
+
@Override
public void println(String line) {
DiffView.this.println(line);
}
};
return new PrintStream(out) {
+
@Override
public void println(String line) {
DiffView.this.println(line);
@@ -354,7 +341,7 @@ public void println(String line) {
/**
* Access the underlying document.
- *
+ *
* @return the document
*/
protected Document getDocument() {
@@ -363,20 +350,24 @@ protected Document getDocument() {
/**
* A main method for testing.
- *
+ *
* @param args the command line
*/
public static void main(String[] args) {
final DiffView diff = new DiffView();
final Thread thread = new Thread() {
+
@Override
public void run() {
try {
- final String git = System.getProperty("imagej.updater.git.command", "git");
- ProcessUtils.exec(null, diff.getPrintStream(), diff.getPrintStream(), git, "show");
- } catch (RuntimeException e) {
- if (!(e.getCause() instanceof InterruptedException))
- e.printStackTrace();
+ final String git = System.getProperty("imagej.updater.git.command",
+ "git");
+ ProcessUtils.exec(null, diff.getPrintStream(), diff.getPrintStream(),
+ git, "show");
+ }
+ catch (RuntimeException e) {
+ if (!(e.getCause() instanceof InterruptedException)) e
+ .printStackTrace();
}
}
};
@@ -386,6 +377,7 @@ public void run() {
frame.setSize(640, 480);
frame.getContentPane().add(diff);
frame.addWindowListener(new WindowAdapter() {
+
@Override
public void windowClosing(WindowEvent e) {
thread.interrupt();
diff --git a/src/main/java/net/imagej/ui/swing/updater/FileDetails.java b/src/main/java/net/imagej/ui/swing/updater/FileDetails.java
index 61cbca2..a133146 100644
--- a/src/main/java/net/imagej/ui/swing/updater/FileDetails.java
+++ b/src/main/java/net/imagej/ui/swing/updater/FileDetails.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -67,7 +67,7 @@
/**
* TODO
- *
+ *
* @author Johannes Schindelin
*/
@SuppressWarnings("serial")
@@ -86,7 +86,8 @@ public class FileDetails extends JTextPane implements UndoableEditListener {
italic = getStyle(null, true, false, java.awt.Font.SANS_SERIF, size);
bold = getStyle(null, false, true, java.awt.Font.SANS_SERIF, size);
normal = getStyle(null, false, false, java.awt.Font.SANS_SERIF, size);
- title = getStyle(null, false, false, java.awt.Font.SANS_SERIF, (int)1.5 * size);
+ title = getStyle(null, false, false, java.awt.Font.SANS_SERIF, (int) 1.5 *
+ size);
hand = new Cursor(Cursor.HAND_CURSOR);
defaultCursor = new Cursor(Cursor.DEFAULT_CURSOR);
}
@@ -103,9 +104,11 @@ public void mouseClicked(final MouseEvent e) {
// UpdaterUserInterface#openURL() has no implementation!?
getOrInitPlatformService().open(new URL(url));
}
- } catch (final Exception exception) {
+ }
+ catch (final Exception exception) {
updaterFrame.log.error(exception);
- UpdaterUserInterface.get().error("Could not open " + url + ": " + exception.getMessage());
+ UpdaterUserInterface.get().error("Could not open " + url + ": " +
+ exception.getMessage());
}
}
});
@@ -133,7 +136,8 @@ private PlatformService getOrInitPlatformService() {
public void reset() {
setEditable(false);
setText("");
- final Comparator comparator = (p1, p2) -> p1.getOffset() - p2.getOffset();
+ final Comparator comparator = (p1, p2) -> p1.getOffset() - p2
+ .getOffset();
editables = new TreeMap<>(comparator);
dummySpace = null;
}
@@ -154,7 +158,8 @@ protected void setCursor(final Point p) {
}
private AttributeSet getLinkAttribute(final String url) {
- final Style style = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
+ final Style style = StyleContext.getDefaultStyleContext().getStyle(
+ StyleContext.DEFAULT_STYLE);
StyleConstants.setForeground(style, Color.BLUE);
style.addAttribute(LINK_ATTRIBUTE, url);
return style;
@@ -205,14 +210,15 @@ public void title(final String text) {
}
public void description(final String description, final FileObject file) {
- if (!updaterFrame.files.hasUploadableSites() &&
- (description == null || description.trim().equals(""))) return;
+ if (!updaterFrame.files.hasUploadableSites() && (description == null ||
+ description.trim().equals(""))) return;
blankLine();
- bold("Description" + (file.descriptionFromPOM ? " (from pom.xml)" : "") + ":\n");
+ bold("Description" + (file.descriptionFromPOM ? " (from pom.xml)" : "") +
+ ":\n");
final int offset = getCaretPosition();
normal(description);
- if (!file.descriptionFromPOM)
- addEditableRegion(offset, "Description", file);
+ if (!file.descriptionFromPOM) addEditableRegion(offset, "Description",
+ file);
}
public void executable(final FileObject file) {
@@ -235,8 +241,8 @@ public void list(String label, final boolean showLinks,
blankLine();
final String tag = label;
- if (list.size() > 1 && label.endsWith("y")) label =
- label.substring(0, label.length() - 1) + "ie";
+ if (list.size() > 1 && label.endsWith("y")) label = label.substring(0, label
+ .length() - 1) + "ie";
bold(label + (list.size() > 1 ? "s" : "") + ":\n");
final int offset = getCaretPosition();
String delimiter = "";
@@ -268,8 +274,8 @@ public void blankLine() {
String prettyPrintTimestamp(final long timestamp) {
final String t = "" + timestamp + "00000000";
- return t.substring(6, 8) + " " +
- months[Integer.parseInt(t.substring(4, 6))] + " " + t.substring(0, 4);
+ return t.substring(6, 8) + " " + months[Integer.parseInt(t.substring(4,
+ 6))] + " " + t.substring(0, 4);
}
public void showFileDetails(final FileObject file) {
@@ -298,8 +304,8 @@ public void showFileDetails(final FileObject file) {
list("Link", true, file.getLinks(), "\n", file);
list("Dependency", false, file.getDependencies(), ",\n", file);
if (file.executable) executable(file);
- if (file.updateSite != null &&
- !file.updateSite.equals(FilesCollection.DEFAULT_UPDATE_SITE))
+ if (file.updateSite != null && !file.updateSite.equals(
+ FilesCollection.DEFAULT_UPDATE_SITE))
{
blankLine();
bold("Update site:\n");
@@ -375,8 +381,8 @@ boolean handleEdit() {
final Position current = getDocument().createPosition(offset);
final Position last = editables.headMap(current).lastKey();
editable = editables.get(last);
- if (offset > editable.start.getOffset() &&
- offset > editable.end.getOffset()) return false;
+ if (offset > editable.start.getOffset() && offset > editable.end
+ .getOffset()) return false;
}
catch (final NoSuchElementException e) {
return false;
@@ -384,8 +390,7 @@ boolean handleEdit() {
catch (final BadLocationException e) {
return false;
}
- if (!editable.file.isUploadable(updaterFrame.files, true))
- return false;
+ if (!editable.file.isUploadable(updaterFrame.files, true)) return false;
final int start = editable.start.getOffset() + 1;
final int end = editable.end.getOffset();
diff --git a/src/main/java/net/imagej/ui/swing/updater/FileTable.java b/src/main/java/net/imagej/ui/swing/updater/FileTable.java
index 1e47a79..f28ecd2 100644
--- a/src/main/java/net/imagej/ui/swing/updater/FileTable.java
+++ b/src/main/java/net/imagej/ui/swing/updater/FileTable.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -66,7 +66,7 @@
/**
* This class's role is to be in charge of how the Table should be displayed.
- *
+ *
* @author Johannes Schindelin
*/
@SuppressWarnings("serial")
@@ -127,9 +127,10 @@ public void popupMenuCanceled(PopupMenuEvent arg0) {
setModel(fileTableModel);
getModel().addTableModelListener(this);
setColumnWidths();
- TableRowSorter sorter =
- new TableRowSorter<>(fileTableModel);
- sorter.setComparator(ACTION_COLUMN, (o1, o2) -> o1.toString().compareTo(o2.toString()));
+ TableRowSorter sorter = new TableRowSorter<>(
+ fileTableModel);
+ sorter.setComparator(ACTION_COLUMN, (o1, o2) -> o1.toString().compareTo(o2
+ .toString()));
setRowSorter(sorter);
setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
@@ -139,9 +140,8 @@ public Component getTableCellRendererComponent(final JTable table,
final Object value, final boolean isSelected, final boolean hasFocus,
final int row, final int column)
{
- final Component comp =
- super.getTableCellRendererComponent(table, value, isSelected,
- hasFocus, row, column);
+ final Component comp = super.getTableCellRendererComponent(table, value,
+ isSelected, hasFocus, row, column);
setStyle(comp, row, column);
return comp;
}
@@ -155,8 +155,8 @@ public Component getTableCellRendererComponent(final JTable table,
* It also warns loudly when the file is obsolete, but locally
* modified.
*/
- protected void
- setStyle(final Component comp, final int row, final int column)
+ protected void setStyle(final Component comp, final int row,
+ final int column)
{
if (plain == null) {
plain = comp.getFont();
@@ -166,7 +166,8 @@ public Component getTableCellRendererComponent(final JTable table,
if (file == null) return;
comp.setFont(file.actionSpecified() || file.isLocallyModified() ? bold
: plain);
- if (file.getStatus() == Status.OBSOLETE_MODIFIED) comp.setForeground(Color.RED);
+ if (file.getStatus() == Status.OBSOLETE_MODIFIED) comp.setForeground(
+ Color.RED);
}
private void setColumnWidths() {
@@ -174,7 +175,8 @@ private void setColumnWidths() {
final TableColumn actionColumn = getColumnModel().getColumn(ACTION_COLUMN);
final TableColumn siteColumn = getColumnModel().getColumn(SITE_COLUMN);
final FontMetrics fm = getFontMetrics(getFont());
- nameColumn.setPreferredWidth(fm.stringWidth("jars/imagej-plugins-commands"));
+ nameColumn.setPreferredWidth(fm.stringWidth(
+ "jars/imagej-plugins-commands"));
nameColumn.setMinWidth(fm.stringWidth("jars/bij.jar"));
nameColumn.setResizable(true);
actionColumn.setPreferredWidth(fm.stringWidth("Locally modified "));
@@ -199,7 +201,8 @@ public TableCellEditor getCellEditor(final int row, final int col) {
// As we follow FileTableModel, 1st column is filename
if (col == NAME_COLUMN) return super.getCellEditor(row, col);
- final Set actions = files.getValidActions(Collections.singleton(file));
+ final Set actions = files.getValidActions(Collections
+ .singleton(file));
return new DefaultCellEditor(new JComboBox<>(actions.toArray()));
}
@@ -239,9 +242,8 @@ public Iterable getSelectedFiles() {
public Iterable getSelectedFiles(final int fallbackRow) {
int[] rows = getSelectedRows();
- if (fallbackRow >= 0 && getFile(fallbackRow) != null &&
- (rows.length == 0 || indexOf(rows, fallbackRow) < 0)) rows =
- new int[] { fallbackRow };
+ if (fallbackRow >= 0 && getFile(fallbackRow) != null && (rows.length == 0 ||
+ indexOf(rows, fallbackRow) < 0)) rows = new int[] { fallbackRow };
final FileObject[] result = new FileObject[rows.length];
for (int i = 0; i < rows.length; i++)
result[i] = getFile(rows[i]);
@@ -274,16 +276,15 @@ public boolean chooseUpdateSite(final FilesCollection files,
error("No upload site available");
return false;
}
- if (list.size() == 1 &&
- list.get(0).equals(FilesCollection.DEFAULT_UPDATE_SITE))
+ if (list.size() == 1 && list.get(0).equals(
+ FilesCollection.DEFAULT_UPDATE_SITE))
{
file.updateSite = FilesCollection.DEFAULT_UPDATE_SITE;
return true;
}
- final String updateSite =
- SwingTools.getChoice(updaterFrame, list,
- "To which upload site do you want to upload " + file.filename + "?",
- "Upload site");
+ final String updateSite = SwingTools.getChoice(updaterFrame, list,
+ "To which upload site do you want to upload " + file.filename + "?",
+ "Upload site");
if (updateSite == null) return false;
file.updateSite = updateSite;
return true;
@@ -358,12 +359,12 @@ public Object getValueAt(final int row, final int column) {
if (row < 0 || row >= files.size()) return null;
final FileObject file = rowToFile.get(row);
switch (column) {
- case NAME_COLUMN:
- return file.getFilename(true);
- case ACTION_COLUMN:
- return file.getAction();
- case SITE_COLUMN:
- return file.updateSite;
+ case NAME_COLUMN:
+ return file.getFilename(true);
+ case ACTION_COLUMN:
+ return file.getAction();
+ case SITE_COLUMN:
+ return file.updateSite;
}
throw new RuntimeException("Unhandled column: " + column);
}
@@ -374,7 +375,8 @@ public boolean isCellEditable(final int rowIndex, final int columnIndex) {
}
@Override
- public void setValueAt(final Object value, final int row, final int column)
+ public void setValueAt(final Object value, final int row,
+ final int column)
{
if (column == ACTION_COLUMN) {
final GroupAction action = (GroupAction) value;
diff --git a/src/main/java/net/imagej/ui/swing/updater/ImageJUpdater.java b/src/main/java/net/imagej/ui/swing/updater/ImageJUpdater.java
index 39cd189..43b8f6c 100644
--- a/src/main/java/net/imagej/ui/swing/updater/ImageJUpdater.java
+++ b/src/main/java/net/imagej/ui/swing/updater/ImageJUpdater.java
@@ -2,17 +2,17 @@
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
- * Copyright (C) 2009 - 2023 ImageJ developers.
+ * Copyright (C) 2009 - 2024 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -29,64 +29,87 @@
package net.imagej.ui.swing.updater;
-import java.io.DataInputStream;
-import java.io.File;
-import java.io.IOException;
+import java.io.*;
import java.lang.reflect.InvocationTargetException;
-import java.net.Authenticator;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.net.URLConnection;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.List;
+import java.net.*;
+import java.util.*;
+import java.util.concurrent.ExecutionException;
import net.imagej.ui.swing.updater.ViewOptions.Option;
import net.imagej.updater.*;
import net.imagej.updater.Conflicts.Conflict;
import net.imagej.updater.util.*;
+import org.apache.commons.compress.archivers.ArchiveEntry;
+import org.apache.commons.compress.archivers.ArchiveInputStream;
+import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
+import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
import org.scijava.app.StatusService;
import org.scijava.command.CommandService;
+import org.scijava.download.Download;
+import org.scijava.download.DownloadService;
import org.scijava.event.ContextDisposingEvent;
import org.scijava.event.EventHandler;
+import org.scijava.io.location.LocationService;
import org.scijava.log.LogService;
import org.scijava.log.Logger;
import org.scijava.plugin.Menu;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;
+import org.scijava.task.Task;
+import org.scijava.task.TaskService;
+import org.scijava.ui.DialogPrompt;
+import org.scijava.ui.UIService;
import org.scijava.util.AppUtils;
+import org.scijava.util.PropertiesHelper;
import javax.swing.*;
+import static org.scijava.ui.DialogPrompt.MessageType.QUESTION_MESSAGE;
+import static org.scijava.ui.DialogPrompt.OptionType.YES_NO_OPTION;
+
/**
* The Updater. As a command.
*
* Incidentally, this class can be used as an out-of-ImageJ entry point to the
* updater, as it does not *require* a StatusService to run.
- *
+ *
* @author Johannes Schindelin
*/
-@Plugin(type = UpdaterUI.class, menu = { @Menu(label = "Help"),
- @Menu(label = "Update...") })
+@Plugin(type = UpdaterUI.class, menu = { @Menu(label = "Help"), @Menu(
+ label = "Update...") })
public class ImageJUpdater implements UpdaterUI {
+
private UpdaterFrame main;
@Parameter
private StatusService statusService;
+ @Parameter
+ private DownloadService downloadService;
+
+ @Parameter
+ private TaskService taskService;
+
+ @Parameter
+ private LocationService locationService;
+
@Parameter
private LogService log;
+ @Parameter
+ private UIService uiService;
+
@Parameter
private UploaderService uploaderService;
@Parameter
private CommandService commandService;
- private final static String UPDATER_UPDATING_THREAD_NAME = "Updating the Updater itself!";
+ private final static String UPDATER_UPDATING_THREAD_NAME =
+ "Updating the Updater itself!";
@Override
public void run() {
@@ -100,42 +123,53 @@ public void run() {
if (errorIfNetworkInaccessible(log)) return;
String imagejDirProperty = System.getProperty("imagej.dir");
- final File imagejRoot = imagejDirProperty != null ? new File(imagejDirProperty) :
- AppUtils.getBaseDirectory("ij.dir", FilesCollection.class, "updater");
+ final File imagejRoot = imagejDirProperty != null ? new File(
+ imagejDirProperty) : AppUtils.getBaseDirectory("ij.dir",
+ FilesCollection.class, "updater");
+
+ // -- Check for HTTPs support in Java --
+ HTTPSUtil.checkHTTPSSupport(log);
+ if (!HTTPSUtil.supportsHTTPS()) {
+ main.warn(
+ "Your Java might be too old to handle updates via HTTPS. This is a security risk!\n" +
+ "Please download a recent version of this software.\n");
+ }
+
+ // check if there is a new Java update available
+ updateJavaIfNecessary(imagejRoot);
+
+ // -- Determine which files are governed by the updater --
final FilesCollection files = new FilesCollection(log, imagejRoot);
UpdaterUserInterface.set(new SwingUserInterface(log, statusService));
if (!areWeUpdatingTheUpdater() && new File(imagejRoot, "update").exists()) {
- if (!UpdaterUserInterface.get().promptYesNo("It is suggested that you restart ImageJ, then continue the update.\n"
- + "Alternately, you can attempt to continue the upgrade without\n"
- + "restarting, but ImageJ might crash.\n\n"
- + "Do you want to try it?",
- "Restart required to finalize update"))
- return;
+ if (!UpdaterUserInterface.get().promptYesNo(
+ "It is suggested that you restart ImageJ, then continue the update.\n" +
+ "Alternately, you can attempt to continue the upgrade without\n" +
+ "restarting, but ImageJ might crash.\n\n" + "Do you want to try it?",
+ "Restart required to finalize update")) return;
try {
new Installer(files, null).moveUpdatedIntoPlace();
- } catch (IOException e) {
+ }
+ catch (IOException e) {
log.debug(e);
- UpdaterUserInterface.get().error("Could not move files into place: " + e);
+ UpdaterUserInterface.get().error("Could not move files into place: " +
+ e);
return;
}
}
UpdaterUtil.useSystemProxies();
Authenticator.setDefault(new SwingAuthenticator());
- SwingTools.invokeOnEDT(() -> main = new UpdaterFrame(log, uploaderService, files));
+ SwingTools.invokeOnEDT(() -> main = new UpdaterFrame(log, uploaderService,
+ files));
main.setEasyMode(true);
Progress progress = main.getProgress("Starting up...");
try {
files.tryLoadingCollection();
- HTTPSUtil.checkHTTPSSupport(log);
- if(!HTTPSUtil.supportsHTTPS()) {
- main.warn("Your Java might be too old to handle updates via HTTPS. This is a security risk!\n" +
- "Please download a recent version of this software.\n");
- }
refreshUpdateSites(files);
main.updateFilesTable();
String warnings = files.reloadCollectionAndChecksum(progress);
@@ -143,16 +177,17 @@ public void run() {
main.addCustomViewOptions();
if (!warnings.equals("")) main.warn(warnings);
final List conflicts = files.getConflicts();
- if (conflicts != null && conflicts.size() > 0 &&
- !new ConflictDialog(main, "Conflicting Versions") {
- private static final long serialVersionUID = 1L;
+ if (conflicts != null && conflicts.size() > 0 && !new ConflictDialog(main,
+ "Conflicting Versions")
+ {
- @Override
- protected void updateConflictList() {
- conflictList = conflicts;
- }
- }.resolve())
- return;
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void updateConflictList() {
+ conflictList = conflicts;
+ }
+ }.resolve()) return;
}
catch (final UpdateCanceledException e) {
main.error("Canceled");
@@ -168,10 +203,13 @@ protected void updateConflictList() {
return;
}
- if (!areWeUpdatingTheUpdater() && Installer.isTheUpdaterUpdateable(files, commandService)) {
+ if (!areWeUpdatingTheUpdater() && Installer.isTheUpdaterUpdateable(files,
+ commandService))
+ {
try {
// download just the updater
- Installer.updateTheUpdater(files, main.getProgress("Installing the updater..."), commandService);
+ Installer.updateTheUpdater(files, main.getProgress(
+ "Installing the updater..."), commandService);
}
catch (final UpdateCanceledException e) {
main.error("Canceled");
@@ -184,46 +222,56 @@ protected void updateConflictList() {
// make a class path using the updated files
final List classPath = new ArrayList<>();
- for (FileObject component : Installer.getUpdaterFiles(files, commandService, false)) {
+ for (FileObject component : Installer.getUpdaterFiles(files,
+ commandService, false))
+ {
final File updated = files.prefixUpdate(component.getFilename(false));
if (updated.exists()) try {
classPath.add(updated.toURI().toURL());
continue;
- } catch (MalformedURLException e) {
+ }
+ catch (MalformedURLException e) {
log.error(e);
}
final String name = component.getLocalFilename(false);
File file = files.prefix(name);
try {
classPath.add(file.toURI().toURL());
- } catch (MalformedURLException e) {
+ }
+ catch (MalformedURLException e) {
log.error(e);
}
}
try {
log.info("Trying to install and execute the new updater");
final URL[] urls = classPath.toArray(new URL[classPath.size()]);
- URLClassLoader remoteClassLoader = new URLClassLoader(urls, getClass().getClassLoader().getParent());
- Class> runnable = remoteClassLoader.loadClass(ImageJUpdater.class.getName());
- final Thread thread = new Thread((Runnable)runnable.newInstance());
+ URLClassLoader remoteClassLoader = new URLClassLoader(urls, getClass()
+ .getClassLoader().getParent());
+ Class> runnable = remoteClassLoader.loadClass(ImageJUpdater.class
+ .getName());
+ final Thread thread = new Thread((Runnable) runnable.newInstance());
thread.setName(UPDATER_UPDATING_THREAD_NAME);
thread.start();
thread.join();
return;
- } catch (Throwable t) {
+ }
+ catch (Throwable t) {
log.error(t);
}
- main.info("Please restart ImageJ and call Help>Update to continue with the update");
+ main.info(
+ "Please restart ImageJ and call Help>Update to continue with the update");
return;
}
try {
- final String missingUploaders = main.files.protocolsMissingUploaders(main.getUploaderService(), main.getProgress(null));
+ final String missingUploaders = main.files.protocolsMissingUploaders(main
+ .getUploaderService(), main.getProgress(null));
if (missingUploaders != null) {
main.warn(missingUploaders);
}
- } catch (final IllegalArgumentException e) {
+ }
+ catch (final IllegalArgumentException e) {
e.printStackTrace();
}
@@ -245,19 +293,270 @@ protected void updateConflictList() {
main.updateFilesTable();
}
+ /**
+ * Helper method to download and extract the appropriate JDK for this platform
+ * to the corresponding ImageJ java subdirectory.
+ */
+ private boolean updateJava(final Map jdkVersions,
+ final File imagejRoot)
+ {
+ // Download and unzip the new JDK
+ final String platform = UpdaterUtil.getPlatform();
+ final String jdkUrl = jdkVersions.get(platform);
+ final String jdkName = jdkUrl.substring(jdkUrl.lastIndexOf("/") + 1);
+ final File jdkDir = new File(imagejRoot + File.separator + "java" +
+ File.separator + platform);
+
+ if (!jdkDir.exists() && !jdkDir.mkdirs()) {
+ log.error("Unable to create platform Java directory: " + jdkDir);
+ return false;
+ }
+
+ // Download the JDK
+ final File jdkDlLoc = new File(jdkDir.getAbsolutePath() + File.separator +
+ jdkName);
+ jdkDlLoc.deleteOnExit();
+ try {
+ log.debug("Downloading " + locationService.resolve(jdkUrl) + " to " +
+ locationService.resolve(jdkDlLoc.toURI()));
+ Download download = downloadService.download(locationService.resolve(
+ jdkUrl), locationService.resolve(jdkDlLoc.toURI()));
+ download.task().waitFor();
+ }
+ catch (URISyntaxException | ExecutionException | InterruptedException e) {
+ log.error(e);
+ return false;
+ }
+
+ String javaLoc = jdkDlLoc.getAbsolutePath();
+ int extensionLength = 0;
+ int entryCount = 0;
+
+ // Extract the JDK
+ if (jdkDlLoc.toString().endsWith("tar.gz")) {
+ extensionLength = 7;
+ // sadly this is the only way to determine how long extraction
+ try (FileInputStream fis = new FileInputStream(jdkDlLoc);
+ GzipCompressorInputStream gzIn = new GzipCompressorInputStream(fis);
+ TarArchiveInputStream tarIn = new TarArchiveInputStream(gzIn))
+ {
+ entryCount = countArchiveEntries(tarIn);
+ }
+ catch (IOException e) {
+ log.error(e);
+ return false;
+ }
+ // Do the actual extraction
+ try (FileInputStream fis = new FileInputStream(jdkDlLoc);
+ GzipCompressorInputStream gzIn = new GzipCompressorInputStream(fis);
+ TarArchiveInputStream tarIn = new TarArchiveInputStream(gzIn))
+ {
+ doExtraction(jdkDir, tarIn, entryCount);
+ }
+ catch (ExecutionException | InterruptedException | IOException e) {
+ log.error(e);
+ return false;
+ }
+ }
+ else if (jdkDlLoc.toString().endsWith("zip")) {
+ extensionLength = 4;
+ // sadly this is the only way to determine how long extraction will take
+ try (FileInputStream fis = new FileInputStream(jdkDlLoc);
+ ZipArchiveInputStream zis = new ZipArchiveInputStream(fis))
+ {
+ entryCount = countArchiveEntries(zis);
+ }
+ catch (IOException e) {
+ log.error(e);
+ return false;
+ }
+ // Do the actual extraction
+ try (FileInputStream fis = new FileInputStream(jdkDlLoc);
+ ZipArchiveInputStream zis = new ZipArchiveInputStream(fis))
+ {
+ doExtraction(jdkDir, zis, entryCount);
+ }
+ catch (ExecutionException | InterruptedException | IOException e) {
+ log.error(e);
+ return false;
+ }
+ }
+
+ // Notify user of success
+ uiService.showDialog("Java version updated!" +
+ " Please restart to take advantage of the new Java.",
+ DialogPrompt.MessageType.INFORMATION_MESSAGE);
+
+ // Update the app configuration file to use the newly downloaded JDK
+ javaLoc = javaLoc.substring(0, javaLoc.length() - extensionLength);
+ String exeName = System.getProperty("ij.executable");
+ if (exeName != null && !exeName.trim().isEmpty()) {
+ exeName = exeName.substring(exeName.lastIndexOf(File.separator));
+ exeName = exeName.substring(0, exeName.indexOf("-"));
+ final File appCfg = new File(imagejRoot + File.separator + "config" +
+ File.separator + "jaunch" + File.separator + exeName + ".cfg");
+ Map appProps = appCfg.exists() ? PropertiesHelper.get(
+ appCfg) : new HashMap<>();
+ appProps.put("jvm.app-configured", javaLoc);
+ PropertiesHelper.put(appProps, appCfg);
+ }
+ return true;
+ }
+
+ /**
+ * Helper method to count the entries in an archive
+ */
+ private int countArchiveEntries(final ArchiveInputStream ais)
+ throws IOException
+ {
+ int entryCount = 0;
+ ArchiveEntry entry;
+ while ((entry = ais.getNextEntry()) != null) {
+ entryCount++;
+ }
+ return entryCount;
+ }
+
+ /**
+ * Helper method to extract an archive
+ */
+ private void doExtraction(final File jdkDir, final ArchiveInputStream ais,
+ final int entryCount) throws IOException, ExecutionException,
+ InterruptedException
+ {
+ Task task = taskService.createTask("Extracting JDK");
+ task.setProgressMaximum(entryCount);
+ task.setProgressValue(0);
+ task.start();
+ task.run(() -> {
+ try {
+ int currentEntry = 0;
+ ArchiveEntry entry;
+ while ((entry = ais.getNextEntry()) != null) {
+ if (task != null && task.isCanceled()) break;
+ if (entry.isDirectory()) {
+ new File(jdkDir, entry.getName()).mkdirs();
+ }
+ else {
+ byte[] buffer = new byte[1024];
+ File outputFile = new File(jdkDir, entry.getName());
+ OutputStream fos = new FileOutputStream(outputFile);
+ int len;
+ while ((len = ais.read(buffer)) != -1) {
+ fos.write(buffer, 0, len);
+ }
+ fos.close();
+ }
+ task.setProgressValue(++currentEntry);
+ }
+ }
+ catch (IOException e) {
+ task.setStatusMessage("Java extraction failed!");
+ }
+ });
+ task.waitFor();
+ task.finish();
+ }
+
+ /**
+ * Helper method that checks the remote JDK list and compares to a locally
+ * cached version. If the remote list is newer an available Java update is
+ * indicated. If the user agrees, the new JDK is downloaded and extracted to
+ * the appropriate directory.
+ */
+ private void updateJavaIfNecessary(final File imagejRoot) {
+ final File configDir = new File(imagejRoot.getAbsolutePath() +
+ File.separator + "config" + File.separator + "jaunch");
+ final File jdkUrlConf = new File(configDir.getAbsolutePath() +
+ File.separator + "jdk-urls.cfg");
+ final String modifiedKey = "LAST_MODIFIED";
+ final String jdkUrl = "https://downloads.imagej.net/java/jdk-urls.txt";
+ long lastModifiedRemote;
+
+ // Get the last modified time on the remote JDK list
+ try {
+ HttpURLConnection connection = (HttpURLConnection) new URL(jdkUrl)
+ .openConnection();
+ connection.setRequestMethod("HEAD");
+ lastModifiedRemote = connection.getLastModified();
+ }
+ catch (IOException e) {
+ log.error("Unable to read remote JDK list", e);
+ return;
+ }
+
+ // Make the config dir if it doesn't already exist
+ if (!configDir.exists() && !configDir.mkdirs()) {
+ log.error("Unable to create configuration directory: " + configDir);
+ return;
+ }
+
+ // Check if we've already cached a local version of the JDK list
+ if (jdkUrlConf.exists()) {
+ // check when the remote was last modified
+ Map jdkVersionProps = PropertiesHelper.get(jdkUrlConf);
+ if (lastModifiedRemote == 0) { // 0 means "not provided"
+ log.error("No modification date found in jdk-urls.txt");
+ return;
+ }
+ long lastModifiedLocal = Long.parseLong(jdkVersionProps.getOrDefault(
+ modifiedKey, "0"));
+
+ // return if up to date
+ if (lastModifiedLocal == lastModifiedRemote) return;
+
+ // Otherwise delete the conf file and re-download
+ jdkUrlConf.delete();
+ }
+
+ // Download the new properties file
+ try {
+ Download dl = downloadService.download(locationService.resolve(jdkUrl),
+ locationService.resolve(jdkUrlConf.toURI()));
+ dl.task().waitFor();
+ }
+ catch (URISyntaxException e) {
+ log.error("Failed to download the remote JDK url list: bad URI");
+ return;
+ }
+ catch (ExecutionException | InterruptedException e) {
+ log.error(
+ "Failed to download the remote JDK url list: download task failed");
+ return;
+ }
+
+ // Inject the last modification date to the JDK list
+ Map jdkUrlMap = PropertiesHelper.get(jdkUrlConf);
+ jdkUrlMap.put(modifiedKey, Long.toString(lastModifiedRemote));
+
+ // Ask the user if they would like to proceed with a Java update
+ DialogPrompt.Result result = uiService.showDialog(
+ "A newer version of Java is recommended.\n" +
+ "Downloading this may take longer than normal updates, but will " +
+ "eventually be required for continued updates.\n" +
+ "Would you like to update now?", QUESTION_MESSAGE, YES_NO_OPTION);
+
+ // Do the update, if desired
+ if (result == DialogPrompt.Result.YES_OPTION && updateJava(jdkUrlMap,
+ imagejRoot))
+ {
+ // Store the current url list if we updated Java
+ PropertiesHelper.put(jdkUrlMap, jdkUrlConf);
+ }
+ }
+
private void refreshUpdateSites(FilesCollection files)
- throws InterruptedException, InvocationTargetException
+ throws InterruptedException, InvocationTargetException
{
- List
- changes = AvailableSites.initializeAndAddSites(files, (Logger) log);
- if(ReviewSiteURLsDialog.shouldBeDisplayed(changes)) {
+ List changes = AvailableSites.initializeAndAddSites(files,
+ (Logger) log);
+ if (ReviewSiteURLsDialog.shouldBeDisplayed(changes)) {
ReviewSiteURLsDialog dialog = new ReviewSiteURLsDialog(main, changes);
SwingUtilities.invokeAndWait(() -> dialog.setVisible(true));
- if(dialog.isOkPressed())
- AvailableSites.applySitesURLUpdates(files, changes);
+ if (dialog.isOkPressed()) AvailableSites.applySitesURLUpdates(files,
+ changes);
}
- else
- AvailableSites.applySitesURLUpdates(files, changes);
+ else AvailableSites.applySitesURLUpdates(files, changes);
}
@EventHandler
@@ -269,7 +568,8 @@ protected boolean overwriteWithUpdated(final FilesCollection files,
final FileObject file)
{
File downloaded = files.prefix("update/" + file.filename);
- if (!downloaded.exists()) return true; // assume all is well if there is no updated file
+ if (!downloaded.exists()) return true; // assume all is well if there is no
+ // updated file
final File jar = files.prefix(file.filename);
if (!jar.delete() && !moveOutOfTheWay(jar)) return false;
if (!downloaded.renameTo(jar)) return false;
@@ -345,7 +645,7 @@ public static boolean errorIfNetworkInaccessible(final LogService log) {
/**
* Check whether we can connect to the Internet. If we cannot connect, we will
* not be able to update.
- *
+ *
* @throws IOException if anything goes wrong.
*/
private static void testNetworkConnection() throws IOException {
@@ -358,7 +658,7 @@ private static void testNetworkConnection() throws IOException {
final URLConnection urlConn = url.openConnection();
if (!(urlConn instanceof HttpURLConnection)) {
throw new IOException("Unexpected connection type: " + //
- urlConn.getClass().getName());
+ urlConn.getClass().getName());
}
final HttpURLConnection httpConn = (HttpURLConnection) urlConn;
@@ -379,16 +679,16 @@ private static void testNetworkConnection() throws IOException {
// Header looks reasonable; now let's check the content to be sure.
final byte[] content = new byte[(int) length];
try (final DataInputStream din = //
- new DataInputStream(httpConn.getInputStream()))
+ new DataInputStream(httpConn.getInputStream()))
{
din.readFully(content);
}
final String s = new String(content, "UTF-8");
if (!s.matches("(?s).*.*" +
- ".*301 Moved Permanently.*.*" + //
- ".*Moved Permanently
.*" + //
- "" + //
- ".*.*"))
+ ".*301 Moved Permanently.*.*" + //
+ ".*Moved Permanently
.*" + //
+ "" + //
+ ".*