Skip to content

Commit 3c3e5ee

Browse files
committed
2020.08.31 (1.53e10; Copy to System)
1 parent 6037ff7 commit 3c3e5ee

File tree

6 files changed

+63
-25
lines changed

6 files changed

+63
-25
lines changed

ij/ImageJ.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ Runs a macro or script (JavaScript, BeanShell or Python) in
7171
-debug
7272
Runs ImageJ in debug mode
7373
</pre>
74-
@author Wayne Rasband ([email protected])
74+
@author Wayne Rasband ([email protected])
7575
*/
7676
public class ImageJ extends Frame implements ActionListener,
7777
MouseListener, KeyListener, WindowListener, ItemListener, Runnable {
7878

7979
/** Plugins should call IJ.getVersion() or IJ.getFullVersion() to get the version string. */
8080
public static final String VERSION = "1.53e";
81-
public static final String BUILD = "8";
81+
public static final String BUILD = "10";
8282
public static Color backgroundColor = new Color(237,237,237);
8383
/** SansSerif, 12-point, plain font. */
8484
public static final Font SansSerif12 = new Font("SansSerif", Font.PLAIN, 12);

ij/ImagePlus.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -2726,6 +2726,12 @@ private String getValueAsString(int x, int y) {
27262726
}
27272727
}
27282728

2729+
/** Copies the contents of the current selection to the internal
2730+
clipboard and then clears the selection. */
2731+
public void cut() {
2732+
copy(true);
2733+
}
2734+
27292735
/** Copies the contents of the current selection, or the entire
27302736
image if there is no selection, to the internal clipboard. */
27312737
public void copy() {
@@ -2774,8 +2780,7 @@ public void copy(boolean cut) {
27742780
}
27752781
}
27762782

2777-
2778-
/** Inserts the contents of the internal clipboard into the active image. If there
2783+
/** Inserts the contents of the internal clipboard into this image. If there
27792784
is a selection the same size as the image on the clipboard, the image is inserted
27802785
into that selection, otherwise the selection is inserted into the center of the image.*/
27812786
public void paste() {
@@ -2843,6 +2848,12 @@ public static void resetClipboard() {
28432848
clipboard = null;
28442849
}
28452850

2851+
/** Copies the contents of the current selection, or the entire
2852+
image if there is no selection, to the system clipboard. */
2853+
public void copyToSystem() {
2854+
Clipboard.copyToSystem(this);
2855+
}
2856+
28462857
protected void notifyListeners(final int id) {
28472858
final ImagePlus imp = this;
28482859
EventQueue.invokeLater(new Runnable() {

ij/macro/MacroRunner.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public MacroRunner(String macro, Editor editor) {
3737
thread.start();
3838
}
3939

40-
/** Interprets macro source in a separate thread using a string argument. */
40+
/** Interprets macro source in a separate thread, passing a string argument. */
4141
public MacroRunner(String macro, String argument) {
4242
this.macro = macro;
4343
this.argument = argument;

ij/plugin/Clipboard.java

+26-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
import ij.process.*;
99
import ij.gui.*;
1010
import ij.plugin.frame.Editor;
11+
import ij.plugin.frame.Recorder;
1112
import ij.text.TextWindow;
1213
import ij.util.Tools;
1314

1415
/** Copies/pastes images to/from the system clipboard. */
1516
public class Clipboard implements PlugIn, Transferable {
1617
static java.awt.datatransfer.Clipboard clipboard;
18+
private ImagePlus gImp;
1719

1820
public void run(String arg) {
1921
if (IJ.altKeyDown()) {
@@ -36,6 +38,16 @@ else if (arg.equals("show"))
3638
showInternalClipboard();
3739
}
3840

41+
/** Copies the contents of the specified image, or selection, to the system clicpboard. */
42+
public static void copyToSystem(ImagePlus imp) {
43+
Clipboard cplugin = new Clipboard();
44+
cplugin.gImp = imp;
45+
cplugin.setup();
46+
try {
47+
cplugin.clipboard.setContents(cplugin, null);
48+
} catch (Throwable t) {}
49+
}
50+
3951
void copy(boolean cut) {
4052
ImagePlus imp = WindowManager.getCurrentImage();
4153
if (imp!=null) {
@@ -44,6 +56,12 @@ void copy(boolean cut) {
4456
imp.changes = true;
4557
} else
4658
IJ.noImage();
59+
if (Recorder.scriptMode()) {
60+
if (cut)
61+
Recorder.recordCall("imp.cut();");
62+
else
63+
Recorder.recordCall("imp.copy();");
64+
}
4765
}
4866

4967
private ImagePlus flatten(ImagePlus imp) {
@@ -67,9 +85,11 @@ void paste() {
6785
showSystemClipboard();
6886
else {
6987
ImagePlus imp = WindowManager.getCurrentImage();
70-
if (imp!=null)
88+
if (imp!=null) {
7189
imp.paste();
72-
else
90+
if (Recorder.scriptMode())
91+
Recorder.recordCall("imp.paste();");
92+
} else
7393
showInternalClipboard ();
7494
}
7595
}
@@ -80,10 +100,13 @@ void setup() {
80100
}
81101

82102
void copyToSystem() {
103+
this.gImp = WindowManager.getCurrentImage();
83104
setup();
84105
try {
85106
clipboard.setContents(this, null);
86107
} catch (Throwable t) {}
108+
if (Recorder.scriptMode())
109+
Recorder.recordCall("imp.copyToSystem();");
87110
}
88111

89112
void showSystemClipboard() {
@@ -134,7 +157,7 @@ public boolean isDataFlavorSupported(DataFlavor flavor) {
134157
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
135158
if (!isDataFlavorSupported(flavor))
136159
throw new UnsupportedFlavorException(flavor);
137-
ImagePlus imp = WindowManager.getCurrentImage();
160+
ImagePlus imp = gImp!=null?gImp:WindowManager.getCurrentImage();
138161
if (imp==null)
139162
return null;
140163
Roi roi = imp.getRoi();

module-info.java

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
module ij {
2-
requires java.desktop;
2+
requires java.desktop;
33
requires java.rmi;
4-
requires java.compiler;
5-
requires java.scripting;
6-
exports ij;
7-
exports ij.gui;
8-
exports ij.io;
9-
exports ij.macro;
10-
exports ij.measure;
11-
exports ij.plugin;
12-
exports ij.plugin.filter;
13-
exports ij.plugin.frame;
14-
exports ij.plugin.tool;
15-
exports ij.process;
16-
exports ij.text;
17-
exports ij.util;
4+
requires java.compiler;
5+
requires java.scripting;
6+
exports ij;
7+
exports ij.gui;
8+
exports ij.io;
9+
exports ij.macro;
10+
exports ij.measure;
11+
exports ij.plugin;
12+
exports ij.plugin.filter;
13+
exports ij.plugin.frame;
14+
exports ij.plugin.tool;
15+
exports ij.process;
16+
exports ij.text;
17+
exports ij.util;
1818
}

release-notes.html

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</head>
66
<body>x
77

8-
<li> <u>1.53e8 30 August 2020</u>
8+
<li> <u>1.53e10 31 August 2020</u>
99
<ul>
1010
<li> The "Black background" option is set 'true' on startup and
1111
is not saved in the preferences file. Add
@@ -19,13 +19,17 @@
1919
function, which returns the number of selected ROIs in the
2020
ROI Manager
2121
(<a href="http://wsr.imagej.net/macros/SetGroupDemo.txt">example</a>).
22+
<li>Thanks to Fred Damen, added the ImagePlus.copyToSystem() method.
2223
<li> Thanks to Philippe Carl, fixed a bug that allowed multiple copies
2324
of the Color Picker to be opened.
2425
<li> Thanks to 'Ben', fixed a bug that caused the Table.get()
2526
macro function to return strings instead of numbers.
27+
<li>Thanks to Fred Damen and Michael chmid, fixed a bug
28+
that caused the run("Copy to System") macro function to
29+
sometimes copy the wrong image to the system clipboard.
2630
<li> Thanks to Martin Hohne, fixed a 1.53c regression that caused
2731
the Counter popup menu in the Point Tool options Dialog
28-
to not work as expected .after switching to a different image.
32+
to not work as expected after switching to a different image.
2933
</ul>
3034

3135
<li> <u>1.53d 20 August 2020</u>

0 commit comments

Comments
 (0)