Skip to content
Permalink
Browse files

2018.03.19 (1.52a7)

  • Loading branch information...
rasband committed Mar 20, 2018
1 parent 05e1250 commit 25f883a799613acbe26a0d4d1540347111c95f6d
Showing with 55 additions and 10 deletions.
  1. +1 −1 ij/ImageJ.java
  2. +35 −3 ij/gui/GenericDialog.java
  3. +11 −2 ij/macro/Functions.java
  4. +2 −1 ij/measure/ResultsTable.java
  5. +1 −1 ij/plugin/filter/ImageMath.java
  6. +5 −2 release-notes.html
@@ -79,7 +79,7 @@ Runs a macro or script (JavaScript, BeanShell or Python) in

/** Plugins should call IJ.getVersion() or IJ.getFullVersion() to get the version string. */
public static final String VERSION = "1.52a";
public static final String BUILD = "6";
public static final String BUILD = "7";
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);
@@ -602,8 +602,8 @@ public void addTextAreas(String text1, String text2, int rows, int columns) {

/**
* Adds a slider (scroll bar) to the dialog box.
* Floating point values will be used if (maxValue-minValue)<=5.0
* and either minValue or maxValue are non-integer.
* Floating point values are used if (maxValue-minValue)<=5.0
* and either defaultValue or minValue are non-integer.
* @param label the label
* @param minValue the minimum value of the slider
* @param maxValue the maximum value of the slider
@@ -612,7 +612,6 @@ public void addTextAreas(String text1, String text2, int rows, int columns) {
public void addSlider(String label, double minValue, double maxValue, double defaultValue) {
if (defaultValue<minValue) defaultValue=minValue;
if (defaultValue>maxValue) defaultValue=maxValue;
int columns = 4;
int digits = 0;
double scale = 1.0;
if ((maxValue-minValue)<=5.0 && (minValue!=(int)minValue||maxValue!=(int)maxValue||defaultValue!=(int)defaultValue)) {
@@ -622,6 +621,39 @@ public void addSlider(String label, double minValue, double maxValue, double def
defaultValue *= scale;
digits = 2;
}
addSlider( label, minValue, maxValue, defaultValue, scale, digits);
}

public void addSlider(String label, double minValue, double maxValue, double defaultValue, double stepSize) {
if ( stepSize <= 0 ) stepSize = 1;
int digits = digits(stepSize);
double scale = 1.0 / Math.abs( stepSize );
if ( scale <= 0 ) scale = 1;
if ( defaultValue < minValue ) defaultValue = minValue;
if ( defaultValue > maxValue ) defaultValue = maxValue;
minValue *= scale;
maxValue *= scale;
defaultValue *= scale;
addSlider(label, minValue, maxValue, defaultValue, scale, digits);
}

private int digits( double d ) {
if ( d == (int) d ) return 0;
String s = Double.toString(d);
s = s.substring(s.indexOf(".") + 1);
return s.length();
}

private int preDigits( double d ) {
int value = (int) d;
return (int) Math.abs( Math.log10( value==0 ? 1 : value ) ) + 1;
}

private void addSlider(String label, double minValue, double maxValue, double defaultValue, double scale, int digits) {
int columns = preDigits(maxValue/scale) + digits;
//IJ.log("scale " + scale + " columns " + columns + " digits " + digits);
if ( columns < 4 ) columns = 4;
if (minValue<0.0) columns++;
String label2 = label;
if (label2.indexOf('_')!=-1)
label2 = label2.replace('_', ' ');
@@ -3725,8 +3725,17 @@ String doDialog() {
String label = getFirstString();
double minValue = getNextArg();
double maxValue = getNextArg();
double defaultValue = getLastArg();
gd.addSlider(label, minValue, maxValue, defaultValue);
double defaultValue = getNextArg();
double stepSize = 0.0;
if (interp.nextToken()==',') {
interp.getComma();
stepSize = interp.getExpression();
}
interp.getRightParen();
if (stepSize==0.0)
gd.addSlider(label, minValue, maxValue, defaultValue);
else
gd.addSlider(label, minValue, maxValue, defaultValue, stepSize);
} else if (name.equals("addCheckbox")) {
gd.addCheckbox(getFirstString(), getLastArg()==1?true:false);
} else if (name.equals("addCheckboxGroup")) {
@@ -1149,6 +1149,7 @@ public String toString() {
* There is also a variable 'rowNumber' available.
* @return false in case of a macro error */
public boolean applyMacro(String macro) {
String[] headings = getHeadings();
String[] columnNames = getHeadingsAsVariableNames();
Program pgm = (new Tokenizer()).tokenize(macro);
StringBuilder sb = new StringBuilder(1000);
@@ -1186,7 +1187,7 @@ else if (Character.isUpperCase(variable.charAt(0))) {
for (int row=0; row<counter; row++) { // apply macro to each row
for (int col=0; col<columnNames.length; col++) {
if (columnInUse[col]) {
double v = getValueAsDouble(col, row);
double v = getValue(headings[col], row);
interp.setVariable(columnNames[col], v);
}
}
@@ -159,7 +159,7 @@ void getBinaryValue (String title, String prompt, String defaultValue) {

void getGammaValue (double defaultValue) {
gd = new GenericDialog("Gamma");
gd.addSlider("Value:", 0.05, 5.0, defaultValue);
gd.addSlider("Value:", 0.0, 5.0, defaultValue, 0.02);
gd.addPreviewCheckbox(pfr);
gd.addDialogListener(this);
gd.showDialog();
@@ -5,9 +5,12 @@
</head>
<body>

<li> <u>1.52a 18 March 2018</u>
<li> <u>1.52a 19 March 2018</u>
<ul>
<li> Thanks to Michael Schmid, add the ResultsTable.applyMacro() method
<li> Thanks to Michael Kaul, added an optional 'stepSize' argument to
the addSlider macro function
(<a href="http://wsr.imagej.net/macros/SliderDemo.txt">example</a>).
<li> Thanks to Michael Schmid, added the ResultsTable.applyMacro() method
(<a href="http://wsr.imagej.net/macros/ResultsTableMacro.js">JavaScript example</a>).
<li> Thanks to Gabriel Landini, on Linux, added the
“Cancel button on right” option to the <i>Edit&gt;Options&gt;Appearance</i>

0 comments on commit 25f883a

Please sign in to comment.
You can’t perform that action at this time.