Skip to content

Commit

Permalink
2020.05.20 (1.53b26; Tool icons)
Browse files Browse the repository at this point in the history
  • Loading branch information
rasband committed May 21, 2020
1 parent fbb954f commit 64f956a
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 68 deletions.
2 changes: 1 addition & 1 deletion ij/ImageJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class ImageJ extends Frame implements ActionListener,

/** Plugins should call IJ.getVersion() or IJ.getFullVersion() to get the version string. */
public static final String VERSION = "1.53b";
public static final String BUILD = "21";
public static final String BUILD = "26";
public static Color backgroundColor = new Color(237,237,237);
/** SansSerif, 12-point, plain font. */
public static final Font SansSerif12 = new Font("SansSerif", Font.PLAIN, 12);
Expand Down
6 changes: 3 additions & 3 deletions ij/ImagePlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -1412,9 +1412,9 @@ private int findKey(String s, String key) {
/** Adds a key-value pair to this image's string properties.
* The key-value pair is removed if 'value' is null. The
* properties persist if the image is saved in TIFF format.
* Add a "ShowInfo" property (e.g. set("ShowInfo","true")) and
* the property list will be displayed by the Image/Show Info
* command.
* Add a "HideInfo" property (e.g. set("HideInfo","true")) to
* prevent the properties from being displayed by the
* Image/Show Info command.
*/
public void setProp(String key, String value) {
if (key==null)
Expand Down
77 changes: 77 additions & 0 deletions ij/gui/RoiDefaultsDialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package ij.gui;
import ij.*;
import ij.plugin.*;
import java.awt.*;
import java.util.Vector;

/** This plugin implements the Edit/Options/Roi Defaults command. */
public class RoiDefaultsDialog implements PlugIn, DialogListener {
private boolean nameChanges;

public void run(String arg) {
showDialog();
}

private void showDialog() {
String groupNames = Roi.getGroupNames();
Color color = Roi.getColor();
String cname = Colors.getColorName(color, "yellow");
int group = Roi.getDefaultGroup();
int strokeWidth = (int)Roi.getDefaultStrokeWidth();
String gname = getGroupName(group);
GenericDialog gd = new GenericDialog("ROI Defaults");
gd.addChoice("Color:", Colors.colors, cname);
gd.addNumericField("Stroke width:", strokeWidth, 0, 3, "");
gd.setInsets(18, 0, 5);
gd.addNumericField("Group:", group, 0, 3, "");
gd.setInsets(2, 0, 5);
gd.addStringField("Name:", gname, 15);
gd.setInsets(2, 50, 5);
gd.addMessage("Color predefined if group>0", null, Color.gray);
gd.addDialogListener(this);
gd.showDialog();
if (gd.wasCanceled()) {
Roi.setGroupNames(groupNames);
Roi.setColor(color);
Roi.setDefaultStrokeWidth(strokeWidth);
Roi.setDefaultGroup(group);
return;
}
if (nameChanges)
Roi.saveGroupNames();
}

public boolean dialogItemChanged(GenericDialog gd, AWTEvent e) {
int currentGroup = Roi.getDefaultGroup();
String cname = gd.getNextChoice();
Color color = Colors.getColor(cname, Color.yellow);
Roi.setColor(color);
Roi.setDefaultStrokeWidth(gd.getNextNumber());
int group = (int)gd.getNextNumber();
Vector stringFields = gd.getStringFields();
TextField nameField = (TextField)(stringFields.get(0));
if (group>=0 && group<=255 && group!=currentGroup) {
Roi.setDefaultGroup(group);
String name = getGroupName(group);
nameField.setText(name);
} else {
String name = getGroupName(group);
String name2 = nameField.getText();
if (name2!=null && !name2.equals(name)) {
Roi.setGroupName(group, name2);
nameChanges = true;
}
}
return true;
}

private String getGroupName(int group) {
String gname = Roi.getGroupName(group);
if (group==0)
gname = "0 = no group";
else if (gname==null)
gname = "unnamed";
return gname;
}

}
124 changes: 68 additions & 56 deletions ij/gui/Toolbar.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.File;
import java.util.*;
import ij.*;
Expand Down Expand Up @@ -446,63 +448,73 @@ void drawIcon(Graphics g, int tool, int x, int y) {
this.icon = icon;
int x1, y1, x2, y2;
pc = 0;
while (true) {
char command = icon.charAt(pc++);
if (pc>=icon.length()) break;
switch (command) {
case 'B': x+=v(); y+=v(); break; // reset base
case 'R': g.drawRect(x+v(), y+v(), v(), v()); break; // rectangle
case 'F': g.fillRect(x+v(), y+v(), v(), v()); break; // filled rectangle
case 'O': g.drawOval(x+v(), y+v(), v(), v()); break; // oval
case 'V': case 'o': g.fillOval(x+v(), y+v(), v(), v()); break; // filled oval
case 'C': // set color
int saveScale = scale;
scale = 1;
int v1=v(), v2=v(), v3=v();
int red=v1*16, green=v2*16, blue=v3*16;
if (red>255) red=255; if (green>255) green=255; if (blue>255) blue=255;
Color color = v1==1&&v2==2&&v3==3?foregroundColor:new Color(red,green,blue);
g.setColor(color);
scale = saveScale;
break;
case 'L': g.drawLine(x+v(), y+v(), x+v(), y+v()); break; // line
case 'D': g.fillRect(x+v(), y+v(), scale, scale); break; // dot
case 'P': // polyline
Polygon p = new Polygon();
p.addPoint(x+v(), y+v());
while (true) {
x2=v(); if (x2==0) break;
y2=v(); if (y2==0) break;
p.addPoint(x+x2, y+y2);
}
g.drawPolyline(p.xpoints, p.ypoints, p.npoints);
break;
case 'G': case 'H':// polygon or filled polygon
p = new Polygon();
p.addPoint(x+v(), y+v());
while (true) {
x2=v(); y2=v();
if (x2==0 && y2==0 && p.npoints>2)
break;
p.addPoint(x+x2, y+y2);
}
if (command=='G')
g.drawPolygon(p.xpoints, p.ypoints, p.npoints);
else
g.fillPolygon(p.xpoints, p.ypoints, p.npoints);
break;
case 'T': // text (one character)
x2 = x+v()-1;
y2 = y+v();
int size = v()*10+v()+1;
char[] c = new char[1];
c[0] = pc<icon.length()?icon.charAt(pc++):'e';
g.setFont(new Font("SansSerif", Font.PLAIN, size));
g.drawString(new String(c), x2, y2);
break;
default: break;
if (icon.trim().startsWith("icon:")) {
String path = IJ.getDir("macros")+"toolsets/icons/"+icon.substring(icon.indexOf(":")+1);
try {
BufferedImage bi = ImageIO.read(new File(path));
((Graphics2D)g).drawImage(bi,null, x-5,y-5);
} catch (Exception e) {
IJ.error("Toolbar", "Error reading tool icon:\n"+path);
}
} else {
while (true) {
char command = icon.charAt(pc++);
if (pc>=icon.length()) break;
switch (command) {
case 'B': x+=v(); y+=v(); break; // reset base
case 'R': g.drawRect(x+v(), y+v(), v(), v()); break; // rectangle
case 'F': g.fillRect(x+v(), y+v(), v(), v()); break; // filled rectangle
case 'O': g.drawOval(x+v(), y+v(), v(), v()); break; // oval
case 'V': case 'o': g.fillOval(x+v(), y+v(), v(), v()); break; // filled oval
case 'C': // set color
int saveScale = scale;
scale = 1;
int v1=v(), v2=v(), v3=v();
int red=v1*16, green=v2*16, blue=v3*16;
if (red>255) red=255; if (green>255) green=255; if (blue>255) blue=255;
Color color = v1==1&&v2==2&&v3==3?foregroundColor:new Color(red,green,blue);
g.setColor(color);
scale = saveScale;
break;
case 'L': g.drawLine(x+v(), y+v(), x+v(), y+v()); break; // line
case 'D': g.fillRect(x+v(), y+v(), scale, scale); break; // dot
case 'P': // polyline
Polygon p = new Polygon();
p.addPoint(x+v(), y+v());
while (true) {
x2=v(); if (x2==0) break;
y2=v(); if (y2==0) break;
p.addPoint(x+x2, y+y2);
}
g.drawPolyline(p.xpoints, p.ypoints, p.npoints);
break;
case 'G': case 'H':// polygon or filled polygon
p = new Polygon();
p.addPoint(x+v(), y+v());
while (true) {
x2=v(); y2=v();
if (x2==0 && y2==0 && p.npoints>2)
break;
p.addPoint(x+x2, y+y2);
}
if (command=='G')
g.drawPolygon(p.xpoints, p.ypoints, p.npoints);
else
g.fillPolygon(p.xpoints, p.ypoints, p.npoints);
break;
case 'T': // text (one character)
x2 = x+v()-1;
y2 = y+v();
int size = v()*10+v()+1;
char[] c = new char[1];
c[0] = pc<icon.length()?icon.charAt(pc++):'e';
g.setFont(new Font("SansSerif", Font.PLAIN, size));
g.drawString(new String(c), x2, y2);
break;
default: break;
}
if (pc>=icon.length()) break;
}
if (pc>=icon.length()) break;
}
if (menus[tool]!=null && menus[tool].getItemCount()>0) {
xOffset = x; yOffset = y;
Expand Down
6 changes: 6 additions & 0 deletions ij/macro/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -7400,6 +7400,12 @@ private Variable doRoi() {
} else if (name.equals("setDefaultGroup")) {
Roi.setDefaultGroup((int)getArg());
return null;
} else if (name.equals("getGroupNames")) {
String names = Roi.getGroupNames();
return new Variable(names!=null?names:"");
} else if (name.equals("setGroupNames")) {
Roi.setGroupNames(getStringArg());
return null;
}
ImagePlus imp = getImage();
if (name.equals("paste")) {
Expand Down
3 changes: 2 additions & 1 deletion ij/macro/Interpreter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,8 @@ private boolean isString(int pcLoc) {
|| name.equals("getType") || name.equals("getString") || name.equals("title")
|| name.equals("headings") || name.equals("allHeadings")
|| name.equals("get") || name.equals("getInfo") || name.equals("getSliceLabel")
|| name.equals("getDicomTag") || name.equals("getList"))
|| name.equals("getDicomTag") || name.equals("getList")
|| name.equals("getGroupNames"))
return true;
}
}
Expand Down
1 change: 0 additions & 1 deletion ij/plugin/FFT.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ void doForwardTransform(FHT fht) {
}

private void setImageProperties(ImagePlus imp, String type) {
imp.setProp("ShowInfo", "true"); // Image>Show Info will display these properties
imp.setProp(" ", type);
imp.setProp("Original width", originalWidth);
imp.setProp("Original height", originalHeight);
Expand Down
4 changes: 2 additions & 2 deletions ij/plugin/ImageInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public String getImageInfo(ImagePlus imp) {
if (infoProperty==null)
infoProperty = getExifData(imp);
}
if (imp.getProp("ShowInfo")!=null) {
if (imp.getProp("HideInfo")==null) {
String properties = getImageProperties(imp);
if (properties!=null) {
if (infoProperty!=null)
Expand Down Expand Up @@ -504,7 +504,7 @@ private String getImageProperties(ImagePlus imp) {
String key = props[i];
String value = props[i+1];
if (key!=null && value!=null && !key.equals("ShowInfo")) {
if (value.length()<60)
if (value.length()<80)
s += key + ": " + value + "\n";
else
s += key + ": <" + value.length() + " characters>\n";
Expand Down
2 changes: 1 addition & 1 deletion ij/plugin/filter/Analyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ void measurePoint(Roi roi) {
ip = stack.getProcessor(position);
else
ip = imp2.getProcessor();
ip.setRoi((int)p.xpoints[i], (int)p.ypoints[i], 1, 1);
ip.setRoi((int)Math.round(p.xpoints[i]), (int)Math.round(p.ypoints[i]), 1, 1);
ImageStatistics stats = ImageStatistics.getStatistics(ip, measurements, imp2.getCalibration());
stats.xCenterOfMass = p.xpoints[i];
stats.yCenterOfMass = p.ypoints[i];
Expand Down
2 changes: 1 addition & 1 deletion ij/plugin/frame/RoiManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@ void setProperties(Color color, int lineWidth, Color fillColor) {
if (n>1)
rpRoi.setName("range: "+(indexes[0]+1)+"-"+(indexes[n-1]+1));
rpRoi.setFillColor(fillColor);
RoiProperties rp = new RoiProperties("Properties", rpRoi);
RoiProperties rp = new RoiProperties("Properties ", rpRoi); // " "=show "List coordinates"
if (!rp.showDialog())
return;
// Recover parameters of the Property window that were stored in the "transient" roi
Expand Down
13 changes: 11 additions & 2 deletions release-notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,37 @@
</head>
<body>

<li> <u>1.53b21 19 May 2020</u>
<li> <u>1.53b26 20 May 2020</u>
<ul>
<li> Thanks to Jerome Mutterer, added the "Label Maker" tool to
the toolbar's "&gt;&gt;" menu. Shift click on "Label Maker" in
the menu to view the macro source code.
<li> Thanks to Laurent Thomas, added the
<i>Edit&gt;Options&gt;Roi Defaults</i> command, which
provides support for group names. Double
adds support for ROI group names. Double
click on the rectangle tool to run this command.
<li> Thanks to Jerome Mutterer, added support for
tool icons read from image files located in the
IJ.getDir("macros")+"toolsets/icons/" folder. Example:
<i>macro "Test Tool - icon:833.png" {...)</i>.
<li> Thanks to Erod Baybay, added the Roi.setPosition(slice) macro function.
<li> Thanks to Jerome Mutterer, added the Overlay.indexAt(x,y),
Overlay.removeRois(name) and Overlay.getBounds(index,x,y,width,height)
macro functions. DOCUMENT
<li> Thanks to Stein Rorvik, added the Roi.setJustification(str),
Roi.setFontSize(size), Property.setList(str) and Property.getList
macro functions. DOCUMENT
<li> Thanks to Laurent Thomas, added the Roi.getGroupNames
and Roi.setGroupNames() and macro functions. DOCUMENT
<li> Thanks to Jan Eglinger, moved initialization of the okay and cancel
buttons in GenericDialog into the constructors.
<li> Thanks to Hidenao Yamada, fixed a bug that caused the
FileInfoVirtualStack.deleteLastSlice() method to not work.
<li> Thanks to Tom Kazimiers, fixed spelling of the ARTIST tag
in the TiffDecoder.
<li> Thanks to Jerome Mutterer and Michael Schmid, fixed a rounding
error that caused the <i>Measure</i> command to not correctly
measure point selectons with non-integer corrdinates.
<li> Thanks to Madison Williams, fixed a 1.52o regression that caused tables
created by the Cell Counter plugin to be empty.
<li> Thanks to Ron DeSpain, fixed a 1.52u regression that caused
Expand Down

0 comments on commit 64f956a

Please sign in to comment.