Skip to content

Commit

Permalink
2024.10.15 (1.54m9; getLine)
Browse files Browse the repository at this point in the history
  • Loading branch information
rasband committed Oct 15, 2024
1 parent 7d8d18b commit 49a6eb9
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ij/ImageJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,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.54m";
public static final String BUILD = "1";
public static final String BUILD = "9";
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: 4 additions & 2 deletions ij/gui/GenericDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,7 @@ private void addSlider(String label, double minValue, double maxValue, double de
sliderDigits = new Vector(5);
}
Scrollbar s = new Scrollbar(Scrollbar.HORIZONTAL, (int)defaultValue, 1, (int)minValue, (int)maxValue+1);
if (IJ.debugMode) IJ.log("Scrollbar: "+scale+" "+defaultValue+" "+minValue+" "+maxValue);
GUI.fixScrollbar(s);
slider.addElement(s);
s.addAdjustmentListener(this);
Expand Down Expand Up @@ -1731,7 +1732,7 @@ public void textValueChanged(TextEvent e) {
if (!Double.isNaN(value)) {
Scrollbar sb = (Scrollbar)slider.elementAt(i);
double scale = ((Double)sliderScales.get(i)).doubleValue();
sb.setValue((int)(value*scale));
sb.setValue((int)Math.round(value*scale));
}
}
}
Expand Down Expand Up @@ -1821,7 +1822,8 @@ public Insets getInsets() {
return new Insets(i.top+10, i.left+10, i.bottom+10, i.right+10);
}

public synchronized void adjustmentValueChanged(AdjustmentEvent e) {
/** Callback for sliders */
public void adjustmentValueChanged(AdjustmentEvent e) {
Object source = e.getSource();
for (int i=0; i<slider.size(); i++) {
if (source==slider.elementAt(i)) {
Expand Down
5 changes: 3 additions & 2 deletions ij/gui/Line.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected void drawLine(int sx, int sy) {
double xend = offScreenXD(sx);
double yend = offScreenYD(sy);
if (xend<0.0) xend=0.0; if (yend<0.0) yend=0.0;
if (xend>xMax) xend=xMax; if (yend>yMax) yend=yMax;
if (xend>xMax-1) xend=xMax-1; if (yend>yMax-1) yend=yMax-1;
double xstart=getXBase()+x1R, ystart=getYBase()+y1R;
if (constrain) {
int i=0;
Expand Down Expand Up @@ -442,7 +442,8 @@ public double getRawLength() {
}

/** Returns the pixel values along this line.
* The line roi must have an associated ImagePlus */
* The line roi must have an associated ImagePlus.
*/
public double[] getPixels() {
double[] profile;
if (getStrokeWidth()<=1) {
Expand Down
2 changes: 1 addition & 1 deletion ij/gui/ProfilePlot.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public static double[] getColumnAverageProfile(Rectangle rect, ImageProcessor ip
ip.setInterpolate(false);
for (int y=rect.y; y<rect.y+rect.height; y++) {
aLine = ip.getLine(rect.x, y, rect.x+rect.width-1, y);
for (int i=0; i<rect.width; i++) {
for (int i=0; i<aLine.length; i++) {
if (!Double.isNaN(aLine[i])) {
profile[i] += aLine[i];
counts[i]++;
Expand Down
4 changes: 1 addition & 3 deletions ij/process/ImageProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1114,11 +1114,9 @@ private void process(int op, double value) {
public double[] getLine(double x1, double y1, double x2, double y2) {
double dx = x2-x1;
double dy = y2-y1;
int n = (int)Math.round(Math.sqrt(dx*dx + dy*dy));
int n = (int)Math.round(Math.sqrt(dx*dx + dy*dy)) + 1;
double xinc = n>0?dx/n:0;
double yinc = n>0?dy/n:0;
if (!((xinc==0&&n==height) || (yinc==0&&n==width)))
n++;
double[] data = new double[n];
double rx = x1;
double ry = y1;
Expand Down
19 changes: 19 additions & 0 deletions ij/util/Tools.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,25 @@ public static int indexOf(int[] array, int key) {
return -1;
}

/** Returns the index of the first array element equal to the key,
* or -1 if no such element. If the key is null, returns the index
* of the first array element that is null, otherwise -1.
* This function can be also used as 'contains' by checking for
* the return value being >= 0.
*/
public static int indexOf(Object[] array, Object key) {
if (key != null) {
for (int i=0; i<array.length; i++)
if (key.equals(array[i]))
return i;
} else { // if key == null
for (int i=0; i<array.length; i++)
if (array[i] == null)
return i;
}
return -1;
}

/** Converts carriage returns to line feeds. */
public static String fixNewLines(String s) {
if (s==null)
Expand Down
10 changes: 9 additions & 1 deletion release-notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<body>


<li> <u>1.54m1 24 September 2024</u>
<li> <u>1.54m9 15 October 2024</u>
<ul>
<li> Thanks to Kevin Terretaz, CommandFinder
(<i>Plugins&gt;Utilities&gt;Find Commands</i>) filtering is more
Expand All @@ -15,6 +15,14 @@
name or the menu path.
<li> Thanks to Bram van den Broek, fixed bug with duplicating hyperstacks when
the selection was outside the image border.
<li> Thanks to Giovanni Cardone and Michael Schmid, fixed bug with
right arrow in dialox box sliders not working as expected on
Linux and Windows.
<li> Thanks to Giovanni Cardone and Michael Schmid, fixed bug where
the ImageProcessor.getLine() method returned a smaller than
expected array with horizontal lines with a width equal
to the image width or vertical lines with a length equal to
the image height.
</ul>

<li> <u>1.54k 15 September 2024</u>
Expand Down

0 comments on commit 49a6eb9

Please sign in to comment.