Skip to content

Commit

Permalink
2013.11.22 (1.48h7)
Browse files Browse the repository at this point in the history
  • Loading branch information
rasband committed Nov 22, 2013
1 parent 837c896 commit 16436c5
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 68 deletions.
2 changes: 1 addition & 1 deletion ij/ImageJ.java
Expand Up @@ -77,7 +77,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.48h";
public static final String BUILD = "6";
public static final String BUILD = "7";
public static Color backgroundColor = new Color(220,220,220); //224,226,235
/** SansSerif, 12-point, plain font. */
public static final Font SansSerif12 = new Font("SansSerif", Font.PLAIN, 12);
Expand Down
65 changes: 65 additions & 0 deletions ij/ImagePlus.java
Expand Up @@ -1094,10 +1094,75 @@ public Properties getProperties() {
return properties;
}

/*
String getMetadataAsString() {
ImagePlus imp = getImage();
String metadata = null;
if (imp.getStackSize()>1) {
ImageStack stack = imp.getStack();
String label = stack.getSliceLabel(imp.getCurrentSlice());
if (label!=null && label.indexOf('\n')>0)
metadata = label;
}
if (metadata==null)
metadata = (String)imp.getProperty("Info");
return metadata;
}
*/

/** Returns the value from the "Info" property string that is
associated with 'key', or null if the key is not found. Works
with DICOM tags and Bio-Formats metadata. */
public String getInfo(String key) {
String metadata = null;
if (getStackSize()>1) {
ImageStack stack = getStack();
String label = stack.getSliceLabel(getCurrentSlice());
if (label!=null && label.indexOf('\n')>0) {
String value = getInfo(key, label);
if (value!=null)
return value;
}
}
Object obj = getProperty("Info");
if (obj==null || key==null)
return null;
String info = (String)obj;
return getInfo(key, info);
}

private String getInfo(String key, String info) {
int index1 = -1;
if (key.matches("[0-9]{4},[0-9]{4}")) // DICOM tag?
index1 = findKey(info, key+" ");
if (index1<0) // standard 'key: value' pair?
index1 = findKey(info, key+": ");
if (index1<0) // Bio-Formats metadata?
index1 = findKey(info, key+" = ");
if (index1<0) // otherwise not found
return null;
if (index1==info.length())
return ""; //empty value at the end
int index2 = info.indexOf("\n", index1);
if (index2==-1)
index2=info.length();
String value = info.substring(index1, index2);
return value;
}

/** Find a key in a String (words merely ending with 'key' don't qualify).
* Ê@return index of first character after the key, or -1 if not found
*/
private int findKey(String s, String key) {
int i = s.indexOf(key);
if (i<0)
return -1; //key not found
if (i>0 && Character.isLetterOrDigit(s.charAt(i-1)))
return -1; //found only end of word
return i + key.length();
}

public String getInfo2(String key) {
Object obj = getProperty("Info");
if (obj==null || key==null) return null;
String info = (String)obj;
Expand Down
4 changes: 2 additions & 2 deletions ij/gui/Toolbar.java
Expand Up @@ -235,13 +235,13 @@ private void drawButton(Graphics g, int tool) {
if (IJ.debugMode) IJ.log("drawButton: "+tool+" "+g);
if (g==null) return;
int index = toolIndex(tool);
int x = index * SIZE + 1;
int x = index*SIZE + 1;
if (tool>=SPARE2)
x -= SIZE-GAP_SIZE;
if (tool!=SPARE1)
fill3DRect(g, x, 1, SIZE, SIZE-1, !down[tool]);
g.setColor(toolColor);
x = index * SIZE + OFFSET;
x = index*SIZE + OFFSET;
if (tool>=SPARE2)
x -= SIZE-GAP_SIZE;
int y = OFFSET;
Expand Down
78 changes: 21 additions & 57 deletions ij/macro/Functions.java
Expand Up @@ -1430,79 +1430,77 @@ String getInfo() {
}

String getInfo(String key) {
key = key.toLowerCase(Locale.US);
int len = key.length();
if (len==9 && key.charAt(4)==',') {
String tag = DicomTools.getTag(getImage(), key);

This comment has been minimized.

Copy link
@dscho

dscho Dec 6, 2013

Contributor

This line is responsible for the regression pointed out in http://fiji.sc/bugzilla/show_bug.cgi?id=681

return tag!=null?tag:"";
} else if (key.equals("command.name")) {
String lowercaseKey = key.toLowerCase(Locale.US);
int len = lowercaseKey.length();
if (lowercaseKey.equals("command.name")) {
return ImageJ.getCommandName();
} else if (key.equals("overlay")) {
} else if (lowercaseKey.equals("overlay")) {
Overlay overlay = getImage().getOverlay();
if (overlay==null)
return "";
else
return overlay.toString();
} else if (key.equals("log")) {
} else if (lowercaseKey.equals("log")) {
String log = IJ.getLog();
return log!=null?log:"";
} else if (key.indexOf(".")==-1) {
String value = getMetadataValue(key);
ImagePlus imp = getImage();
String value = imp.getInfo(key);
if (value!=null) return value;
} else if (key.equals("micrometer.abbreviation"))
} else if (lowercaseKey.equals("micrometer.abbreviation"))
return "\u00B5m";
else if (key.equals("image.subtitle")) {
else if (lowercaseKey.equals("image.subtitle")) {
ImagePlus imp = getImage();
ImageWindow win = imp.getWindow();
return win!=null?win.createSubtitle():"";
} else if (key.equals("slice.label")) {
} else if (lowercaseKey.equals("slice.label")) {
ImagePlus imp = getImage();
String label = null;
if (imp.getStackSize()==1)
label = (String)imp.getProperty("Label");
else
label = imp.getStack().getShortSliceLabel(imp.getCurrentSlice());
return label!=null?label:"";
} else if (key.equals("window.contents")) {
} else if (lowercaseKey.equals("window.contents")) {
return getWindowContents();
} else if (key.equals("image.description")) {
} else if (lowercaseKey.equals("image.description")) {
String description = "";
FileInfo fi = getImage().getOriginalFileInfo();
if (fi!=null) description = fi.description;
if (description==null) description = "";
return description;
} else if (key.equals("image.filename")) {
} else if (lowercaseKey.equals("image.filename")) {
String name= "";
FileInfo fi = getImage().getOriginalFileInfo();
if (fi!=null && fi.fileName!=null) name= fi.fileName;
return name;
} else if (key.equals("image.directory")) {
} else if (lowercaseKey.equals("image.directory")) {
String dir= "";
FileInfo fi = getImage().getOriginalFileInfo();
if (fi!=null && fi.directory!=null) dir= fi.directory;
return dir;
} else if (key.equals("selection.name")||key.equals("roi.name")) {
} else if (lowercaseKey.equals("selection.name")||lowercaseKey.equals("roi.name")) {
ImagePlus imp = getImage();
Roi roi = imp.getRoi();
String name = roi!=null?roi.getName():null;
return name!=null?name:"";
} else if (key.equals("selection.color")||key.equals("roi.color")) {
} else if (lowercaseKey.equals("selection.color")||lowercaseKey.equals("roi.color")) {
ImagePlus imp = getImage();
Roi roi = imp.getRoi();
if (roi==null)
interp.error("No selection");
Color color = roi.getStrokeColor();
return Colors.colorToString(color);
} else if (key.equals("font.name")) {
} else if (lowercaseKey.equals("font.name")) {
resetImage();
ImageProcessor ip = getProcessor();
setFont(ip);
return ip.getFont().getName();
} else if (key.equals("threshold.method")) {
} else if (lowercaseKey.equals("threshold.method")) {
return ThresholdAdjuster.getMethod();
} else if (key.equals("threshold.mode")) {
} else if (lowercaseKey.equals("threshold.mode")) {
return ThresholdAdjuster.getMode();
} else if (key.equals("window.type")) {
} else if (lowercaseKey.equals("window.type")) {
return getWindowType();
} else {
String value = "";
Expand Down Expand Up @@ -1540,41 +1538,7 @@ else if (win instanceof ij.gui.ImageWindow)
}
return type;
}

String getMetadataValue(String key) {
String metadata = getMetadataAsString();
if (metadata==null) return null;
int index1 = metadata.indexOf(key+" =");
if (index1!=-1)
index1 += key.length() + 2;
else {
index1 = metadata.indexOf(key+":");
if (index1!=-1)
index1 += key.length() + 1;
else
return null;
}
int index2 = metadata.indexOf("\n", index1);
if (index2==-1) return null;
String value = metadata.substring(index1+1, index2);
if (value.startsWith(" ")) value = value.substring(1, value.length());
return value;
}

String getMetadataAsString() {
ImagePlus imp = getImage();
String metadata = null;
if (imp.getStackSize()>1) {
ImageStack stack = imp.getStack();
String label = stack.getSliceLabel(imp.getCurrentSlice());
if (label!=null && label.indexOf('\n')>0)
metadata = label;
}
if (metadata==null)
metadata = (String)imp.getProperty("Info");
return metadata;
}


String getWindowContents() {
Frame frame = WindowManager.getFrontWindow();
if (frame!=null && frame instanceof TextWindow) {
Expand Down
12 changes: 6 additions & 6 deletions ij/plugin/MacroInstaller.java
Expand Up @@ -163,12 +163,12 @@ else if (!name.endsWith("Tool Selected")) {
if (toolCount==1)
tb.addMacroTool((String)tools.get(0), this);
else {
int index = 0;
String firstTool = (String)tools.get(0);
if (!firstTool.startsWith("Unused") && tools.size()<=7) {
tb.addMacroTool("Unused Tool", this, 0);
index = 1;
}
int index = 0;
String firstTool = (String)tools.get(0);
if (!firstTool.startsWith("Unused") && tools.size()<=7) {
tb.addMacroTool("Unused Tool", this, 0);
index = 1;
}
for (int i=0; i<tools.size(); i++)
tb.addMacroTool((String)tools.get(i), this, index++);
}
Expand Down
4 changes: 3 additions & 1 deletion ij/plugin/filter/ParticleAnalyzer.java
Expand Up @@ -159,6 +159,7 @@ public class ParticleAnalyzer implements PlugInFilter, Measurements {
private Color fontColor = nextFontColor;
private int lineWidth = nextLineWidth;
private boolean noThreshold;
private boolean calledFromPlugin;


/** Constructs a ParticleAnalyzer.
Expand Down Expand Up @@ -200,6 +201,7 @@ public ParticleAnalyzer(int options, int measurements, ResultsTable rt, double m
nextFontSize = defaultFontSize;
nextFontColor = defaultFontColor;
nextLineWidth = 1;
calledFromPlugin = true;
}

/** Constructs a ParticleAnalyzer using the default min and max circularity values (0 and 1). */
Expand Down Expand Up @@ -1020,7 +1022,7 @@ else if (showChoice == ROI_MASKS)
Analyzer.lastParticle = Analyzer.getCounter()-1;
} else
Analyzer.firstParticle = Analyzer.lastParticle = 0;
if (showResults && rt.getCounter()==0 && !IJ.isMacro() && (!processStack||slice==imp.getStackSize())) {
if (showResults && rt.getCounter()==0 && !(IJ.isMacro()||calledFromPlugin) && (!processStack||slice==imp.getStackSize())) {
int digits = (int)level1==level1&&(int)level2==level2?0:2;
String range = IJ.d2s(level1,digits)+"-"+IJ.d2s(level2,digits);
String assummed = noThreshold?"assumed":"";
Expand Down
4 changes: 3 additions & 1 deletion release-notes.html
Expand Up @@ -5,7 +5,7 @@
</head>
<body>

<li> <u>1.48g 20 November 2013</u>
<li> <u>1.48g 22 November 2013</u>
<ul>
<li> Replaced the blank "Unused Tool" slot in the toolbar with a 9 pixel gap.
<li> Added "Insert", "Info" and "Close" buttons to the dialog opened by the
Expand All @@ -16,6 +16,8 @@
<li> Thanks to Michael Schmid, fixed bugs in the macro interpreter that caused expressions in
the form s+"abc", where 's' is a string variable, to cause macros to abort when used
as a function argument or used in a 'return' statement.
<li> Thanks to Patrick Page-McCaw, fixed a bug that sometimes caused the particle
analyser, when run from a plugin, to display a "No particles were detected..." dialog.
</ul>

<a href="http://imagej.nih.gov/ij">Home</a>
Expand Down

0 comments on commit 16436c5

Please sign in to comment.