Skip to content
Commits on Source (6)
......@@ -378,8 +378,9 @@ macros01="Install...",ij.plugin.MacroInstaller
macros02="Run...",ij.plugin.Macro_Runner
macros03="Edit...",ij.plugin.Compiler("edit")
macros04="Startup Macros...",ij.plugin.Commands("startup")
macros05="Record...",ij.plugin.frame.Recorder
macros06=-
macros05="Interactive Interpreter...[j]",ij.plugin.SimpleCommands("interactive")
macros06="Record...",ij.plugin.frame.Recorder
macros07=-
# Plugins installed in the Plugins/Shortcuts submenu
shortcuts01="Add Shortcut... ",ij.plugin.Hotkeys("install")
......
imagej (1.52j-1) unstable; urgency=medium
* Team upload.
* New upstream version
* debhelper 12
* Standards-Version: 4.3.0
-- Andreas Tille <tille@debian.org> Sat, 26 Jan 2019 07:51:10 +0100
imagej (1.52i-2) unstable; urgency=medium
* Team upload.
......
......@@ -3,13 +3,13 @@ Maintainer: Debian Med Packaging Team <debian-med-packaging@lists.alioth.debian.
Uploaders: David Miguel Susano Pinto <carandraug+dev@gmail.com>
Section: science
Priority: optional
Build-Depends: debhelper (>= 11~)
Build-Depends: debhelper (>= 12~)
Build-Depends-Indep: ant,
default-jdk-doc,
default-jdk-headless,
javahelper,
maven-repo-helper
Standards-Version: 4.2.1
Standards-Version: 4.3.0
Vcs-Browser: https://salsa.debian.org/med-team/imagej
Vcs-Git: https://salsa.debian.org/med-team/imagej.git
Homepage: https://imagej.nih.gov/ij
......
......@@ -70,6 +70,7 @@ public class IJ {
private static DecimalFormatSymbols dfs;
private static boolean trustManagerCreated;
private static String smoothMacro;
private static Interpreter macroInterpreter;
static {
osname = System.getProperty("os.name");
......@@ -151,7 +152,7 @@ public class IJ {
The file is assumed to be in the macros folder
unless <code>name</code> is a full path.
The optional string argument (<code>arg</code>) can be retrieved in the called
macro or script (v1.42k or later) using the getArgument() function.
macro or script using the getArgument() function.
Returns any string value returned by the macro, or null. Scripts always return null.
The equivalent macro function is runMacro(). */
public static String runMacroFile(String name, String arg) {
......@@ -309,9 +310,17 @@ public class IJ {
macroRunning = false;
Macro.setOptions(null);
testAbort();
macroInterpreter = null;
//IJ.log("run2: "+command+" "+Thread.currentThread().hashCode());
}
/** The macro interpreter uses this method to run commands. */
public static void run(Interpreter interpreter, String command, String options) {
macroInterpreter = interpreter;
run(command, options);
macroInterpreter = null;
}
/** Converts commands that have been renamed so
macros using the old names continue to work. */
private static String convert(String command) {
......@@ -572,7 +581,12 @@ public class IJ {
/**Displays a "no images are open" dialog box.*/
public static void noImage() {
error("No Image", "There are no images open.");
String msg = "There are no images open.";
if (macroInterpreter!=null) {
macroInterpreter.abort(msg);
macroInterpreter = null;
} else
error("No Image", msg);
}
/** Displays an "out of memory" message to the "Log" window. */
......@@ -645,6 +659,11 @@ public class IJ {
macro or JavaScript is running, it is aborted. Writes to the
Java console if the ImageJ window is not present.*/
public static void error(String msg) {
if (macroInterpreter!=null) {
macroInterpreter.abort(msg);
macroInterpreter = null;
return;
}
error(null, msg);
if (Thread.currentThread().getName().endsWith("JavaScript"))
throw new RuntimeException(Macro.MACRO_CANCELED);
......@@ -914,7 +933,6 @@ public class IJ {
break;
case KeyEvent.VK_SHIFT:
shiftDown=true;
updateStatus();
if (debugMode) beep();
break;
case KeyEvent.VK_SPACE: {
......@@ -936,7 +954,7 @@ public class IJ {
case KeyEvent.VK_CONTROL: controlDown=false; break;
case KeyEvent.VK_META: if (isMacintosh()) controlDown=false; break;
case KeyEvent.VK_ALT: altDown=false; updateStatus(); break;
case KeyEvent.VK_SHIFT: shiftDown=false; updateStatus(); if (debugMode) beep(); break;
case KeyEvent.VK_SHIFT: shiftDown=false; if (debugMode) beep(); break;
case KeyEvent.VK_SPACE:
spaceDown=false;
ImageWindow win = WindowManager.getCurrentWindow();
......@@ -951,10 +969,9 @@ public class IJ {
private static void updateStatus() {
ImagePlus imp = WindowManager.getCurrentImage();
if (imp!=null) {
ImageCanvas ic = imp.getCanvas();
if (ic!=null && imp.getCalibration().scaled()) {
Point p = ic.getCursorLoc();
imp.mouseMoved(p.x, p.y);
Roi roi = imp.getRoi();
if (roi!=null && imp.getCalibration().scaled()) {
roi.showStatus();
}
}
}
......@@ -2237,7 +2254,7 @@ public class IJ {
}
static void abort() {
if (ij!=null || Interpreter.isBatchMode())
if ((ij!=null || Interpreter.isBatchMode()) && macroInterpreter==null)
throw new RuntimeException(Macro.MACRO_CANCELED);
}
......
......@@ -78,8 +78,8 @@ public class ImageJ extends Frame implements ActionListener,
MouseListener, KeyListener, WindowListener, ItemListener, Runnable {
/** Plugins should call IJ.getVersion() or IJ.getFullVersion() to get the version string. */
public static final String VERSION = "1.52i";
public static final String BUILD = ""; //52
public static final String VERSION = "1.52j";
public static final String BUILD = ""; //42
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);
......
......@@ -172,7 +172,6 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
return false;
} else {
locked = true;
if (IJ.debugMode) IJ.log(title + ": lock");
return true;
}
}
......@@ -192,7 +191,6 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
/** Unlocks the image. */
public synchronized void unlock() {
locked = false;
if (IJ.debugMode) IJ.log(title + ": unlock");
}
private void waitForImage(Image image) {
......@@ -556,7 +554,7 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
if (newProperties!=null)
newProperties = (Properties)(newProperties.clone());
if (imp.getWindow()!=null)
imp = imp.duplicateAll();
imp = imp.duplicate();
ImageStack stack2 = imp.getStack();
if (imp.isHyperStack())
setOpenAsHyperStack(true);
......@@ -964,32 +962,33 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
}
/** Returns an ImageStatistics object generated using the
specified measurement options and histogram bin count.
Note: except for float images, the number of bins
is currently fixed at 256.
*/
specified measurement options and histogram bin count. */
public ImageStatistics getStatistics(int mOptions, int nBins) {
return getStatistics(mOptions, nBins, 0.0, 0.0);
}
/** Returns an ImageStatistics object generated using the
specified measurement options, histogram bin count and histogram range.
Note: for 8-bit and RGB images, the number of bins
is fixed at 256 and the histogram range is always 0-255.
*/
specified measurement options, histogram bin count
and histogram range. */
public ImageStatistics getStatistics(int mOptions, int nBins, double histMin, double histMax) {
ImageProcessor ip2 = ip;
int bitDepth = getBitDepth();
if (nBins!=256 && (bitDepth==8||bitDepth==24))
ip2 =ip.convertToShort(false);
if (roi!=null && roi.isArea())
ip.setRoi(roi);
ip2.setRoi(roi);
else
ip.resetRoi();
ip.setHistogramSize(nBins);
ip2.resetRoi();
ip2.setHistogramSize(nBins);
Calibration cal = getCalibration();
if (getType()==GRAY16&& !(histMin==0.0&&histMax==0.0))
{histMin=cal.getRawValue(histMin); histMax=cal.getRawValue(histMax);}
ip.setHistogramRange(histMin, histMax);
ImageStatistics stats = ImageStatistics.getStatistics(ip, mOptions, cal);
ip.setHistogramSize(256);
ip.setHistogramRange(0.0, 0.0);
if (getType()==GRAY16&& !(histMin==0.0&&histMax==0.0)) {
histMin = cal.getRawValue(histMin);
histMax=cal.getRawValue(histMax);
}
ip2.setHistogramRange(histMin, histMax);
ImageStatistics stats = ImageStatistics.getStatistics(ip2, mOptions, cal);
ip2.setHistogramSize(256);
ip2.setHistogramRange(0.0, 0.0);
return stats;
}
......@@ -2142,20 +2141,11 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
}
/** Returns a copy of this image or stack, cropped if there is an ROI.
* @see #duplicateAll
/** Returns a copy of this image or stack.
* @see #crop
* @see ij.plugin.Duplicator#run
*/
public ImagePlus duplicate() {
return (new Duplicator()).run(this);
}
/** Returns a copy of this image or stack.
* @see #duplicate
* @see #crop
*/
public ImagePlus duplicateAll() {
Roi roi = getRoi();
deleteRoi();
ImagePlus imp2 =(new Duplicator()).run(this);
......@@ -2165,7 +2155,6 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
/** Returns a copy this image or stack slice, cropped if there is an ROI.
* @see #duplicate
* @see #duplicateAll
* @see ij.plugin.Duplicator#crop
*/
public ImagePlus crop() {
......@@ -2866,6 +2855,34 @@ public class ImagePlus implements ImageObserver, Measurements, Cloneable {
}
}
/** Plots a 256 bin histogram of this image and returns the PlotWindow. */
public PlotWindow plotHistogram() {
return plotHistogram(256);
}
/** Plots a histogram of this image using the specified
number of bins and returns the PlotWindow. */
public PlotWindow plotHistogram(int bins) {
ImageStatistics stats = getStatistics(AREA+MEAN+MODE+MIN_MAX, bins);
Plot plot = new Plot("Hist_"+getTitle(), "Value", "Frequency");
plot.setColor("black", "#999999");
plot.setFont(new Font("SansSerif",Font.PLAIN,14));
double[] y = stats.histogram();
int n = y.length;
double[] x = new double[n];
int bits = getBitDepth();
boolean eightBit = bits==8 || bits==24;
double min = !eightBit?stats.min:0;
for (int i=0; i<n; i++)
x[i] = min+i*stats.binSize;
plot.add("bar", x, y);
if (bins!=256)
plot.addLegend(bins+" bins", "auto");
if (eightBit)
plot.setLimits(0,256,0,Double.NaN);
return plot.show();
}
public String toString() {
return "img[\""+getTitle()+"\" ("+getID()+"), "+getBitDepth()+"-bit, "+width+"x"+height+"x"+getNChannels()+"x"+getNSlices()+"x"+getNFrames()+"]";
}
......
......@@ -315,6 +315,7 @@ public class Menus {
addExample(submenu, "Dynamic Plot", "Dynamic_Plot.js");
addExample(submenu, "Plot Styles", "Plot_Styles.js");
addExample(submenu, "Plot Random Data", "Plot_Random_Data.js");
addExample(submenu, "Histogram Plots", "Histogram_Plots.js");
addExample(submenu, "Process Folder", "Batch_Process_Folder.js");
addExample(submenu, "Sine/Cosine Table", "Sine_Cosine_Table.js");
addExample(submenu, "Non-numeric Table", "Non-numeric_Table.js");
......
......@@ -56,7 +56,7 @@ public class Prefs {
SUBPIXEL_RESOLUTION=1<<2, ENHANCED_LINE_TOOL=1<<3, SKIP_RAW_DIALOG=1<<4,
REVERSE_NEXT_PREVIOUS_ORDER=1<<5, AUTO_RUN_EXAMPLES=1<<6, SHOW_ALL_POINTS=1<<7,
DO_NOT_SAVE_WINDOW_LOCS=1<<8, JFILE_CHOOSER_CHANGED=1<<9,
CANCEL_BUTTON_ON_RIGHT=1<<10;
CANCEL_BUTTON_ON_RIGHT=1<<10, IGNORE_RESCALE_SLOPE=1<<11;
public static final String OPTIONS2 = "prefs.options2";
/** file.separator system property */
......@@ -117,6 +117,8 @@ public class Prefs {
public static boolean multiPointMode;
/** Open DICOMs as 32-bit float images */
public static boolean openDicomsAsFloat;
/** Ignore Rescale Slope when opening DICOMs */
public static boolean ignoreRescaleSlope;
/** Plot rectangular selectons vertically */
public static boolean verticalProfile;
/** Rotate YZ orthogonal views 90 degrees */
......@@ -496,6 +498,7 @@ public class Prefs {
doNotSaveWindowLocations = (options2&DO_NOT_SAVE_WINDOW_LOCS)!=0;
jFileChooserSettingChanged = (options2&JFILE_CHOOSER_CHANGED)!=0;
dialogCancelButtonOnRight = (options2&CANCEL_BUTTON_ON_RIGHT)!=0;
ignoreRescaleSlope = (options2&IGNORE_RESCALE_SLOPE)!=0;
}
static void saveOptions(Properties prefs) {
......@@ -524,7 +527,8 @@ public class Prefs {
+ (autoRunExamples?AUTO_RUN_EXAMPLES:0) + (showAllPoints?SHOW_ALL_POINTS:0)
+ (doNotSaveWindowLocations?DO_NOT_SAVE_WINDOW_LOCS:0)
+ (jFileChooserSettingChanged?JFILE_CHOOSER_CHANGED:0)
+ (dialogCancelButtonOnRight?CANCEL_BUTTON_ON_RIGHT:0);
+ (dialogCancelButtonOnRight?CANCEL_BUTTON_ON_RIGHT:0)
+ (ignoreRescaleSlope?IGNORE_RESCALE_SLOPE:0);
prefs.put(OPTIONS2, Integer.toString(options2));
}
......
......@@ -55,7 +55,7 @@ public class Undo {
calCopy = (Calibration)imp.getCalibration().clone();
} else if (what==TRANSFORM) {
if ((!IJ.macroRunning()||Prefs.supportMacroUndo) && (imp.getStackSize()==1||imp.getDisplayMode()==IJ.COMPOSITE) && imp.getSizeInBytes()<209715200)
impCopy = imp.duplicateAll();
impCopy = imp.duplicate();
else
reset();
} else if (what==MACRO) {
......
package ij.gui;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import ij.*;
import ij.plugin.frame.Recorder;
import ij.process.FloatPolygon;
......@@ -77,6 +78,45 @@ public class EllipseRoi extends PolygonRoi {
}
makePolygonRelative();
cachedMask = null;
showStatus();
}
public void showStatus() {
double[] p = getParams();
double dx = p[2] - p[0];
double dy = p[3] - p[1];
double major = Math.sqrt(dx*dx+dy*dy);
double minor = major*p[4];
double angle = getFloatAngle(p[0], p[1], p[2], p[3]);
if (imp!=null && !IJ.altKeyDown()) {
Calibration cal = imp.getCalibration();
if (cal.scaled()) {
dx *= cal.pixelWidth;
dy *= cal.pixelHeight;
major = Math.sqrt(dx*dx+dy*dy);
minor = major*p[4];
}
}
IJ.showStatus("major=" + IJ.d2s(major)+", minor=" + IJ.d2s(minor)+", angle=" + IJ.d2s(angle));
}
public void nudgeCorner(int key) {
if (ic==null) return;
double x1 = xpf[handle[2]]+x;
double y1 = ypf[handle[2]]+y;
double x2 = xpf[handle[0]]+x;
double y2 = ypf[handle[0]]+y;
double inc = 1.0/ic.getMagnification();
switch(key) {
case KeyEvent.VK_UP: y2-=inc; break;
case KeyEvent.VK_DOWN: y2+=inc; break;
case KeyEvent.VK_LEFT: x2-=inc; break;
case KeyEvent.VK_RIGHT: x2+=inc; break;
}
makeEllipse(x1, y1, x2, y2);
imp.draw();
notifyListeners(RoiListener.MOVED);
showStatus();
}
void makePolygonRelative() {
......
......@@ -206,7 +206,7 @@ public class ImageCanvas extends Canvas implements MouseListener, MouseMotionLis
}
public void paint(Graphics g) {
if (IJ.debugMode) IJ.log("ImageCanvas.paint: "+imp);
//if (IJ.debugMode) IJ.log("ImageCanvas.paint: "+imp);
painted = true;
Roi roi = imp.getRoi();
if (roi!=null || overlay!=null || showAllOverlay!=null || Prefs.paintDoubleBuffered || (IJ.isLinux() && magnification<0.25)) {
......@@ -237,7 +237,7 @@ public class ImageCanvas extends Canvas implements MouseListener, MouseMotionLis
if (roi!=null) drawRoi(roi, g);
if (srcRect.width<imageWidth || srcRect.height<imageHeight)
drawZoomIndicator(g);
if (IJ.debugMode) showFrameRate(g);
//if (IJ.debugMode) showFrameRate(g);
}
catch(OutOfMemoryError e) {IJ.outOfMemory("Paint");}
setPaintPending(false);
......@@ -297,7 +297,7 @@ public class ImageCanvas extends Canvas implements MouseListener, MouseMotionLis
if (labelColor==null) labelColor = Color.white;
initGraphics(overlay, g, labelColor, Roi.getColor());
int n = overlay.size();
if (IJ.debugMode) IJ.log("drawOverlay: "+n);
//if (IJ.debugMode) IJ.log("drawOverlay: "+n);
int currentImage = imp!=null?imp.getCurrentSlice():-1;
int stackSize = imp.getStackSize();
if (stackSize==1)
......@@ -368,9 +368,11 @@ public class ImageCanvas extends Canvas implements MouseListener, MouseMotionLis
}
if (textColor!=null) {
labelColor = textColor;
if (overlay!=null && overlay.getDrawBackgrounds())
bgColor = new Color(255-labelColor.getRed(), 255-labelColor.getGreen(), 255-labelColor.getBlue());
else
if (overlay!=null && overlay.getDrawBackgrounds()) {
double brightness = (labelColor.getRed()+labelColor.getGreen()+labelColor.getBlue())/3.0;
if (labelColor==Color.green) brightness = 255;
bgColor = brightness<=85?Color.white:Color.black;
} else
bgColor = null;
} else {
int red = defaultColor.getRed();
......@@ -383,6 +385,9 @@ public class ImageCanvas extends Canvas implements MouseListener, MouseMotionLis
bgColor = defaultColor;
}
this.defaultColor = defaultColor;
Font font = overlay!=null?overlay.getLabelFont():null;
if (font!=null && font.getSize()>12)
((Graphics2D)g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g.setColor(defaultColor);
}
......@@ -459,8 +464,11 @@ public class ImageCanvas extends Canvas implements MouseListener, MouseMotionLis
yoffset = h - 6 + pointSize;
}
if (bgColor!=null) {
int h2 = h;
if (font!=null && font.getSize()>14)
h2 = (int)(h2*0.8);
g.setColor(bgColor);
g.fillRoundRect(x-1+xoffset, y-h+2+yoffset, w+1, h-3, 5, 5);
g.fillRoundRect(x-1+xoffset, y-h2+2+yoffset, w+1, h2-2, 5, 5);
}
if (labelRects!=null && index<labelRects.length) {
if (pointRoi) {
......@@ -536,7 +544,7 @@ public class ImageCanvas extends Canvas implements MouseListener, MouseMotionLis
drawRoi(roi, offScreenGraphics);
if (srcRect.width<imageWidth || srcRect.height<imageHeight)
drawZoomIndicator(offScreenGraphics);
if (IJ.debugMode) showFrameRate(offScreenGraphics);
//if (IJ.debugMode) showFrameRate(offScreenGraphics);
g.drawImage(offScreenImage, 0, 0, null);
}
catch(OutOfMemoryError e) {IJ.outOfMemory("Paint");}
......
......@@ -11,7 +11,6 @@ import java.util.NoSuchElementException;
import java.awt.event.*;
import java.awt.geom.*;
/** This class represents a straight line selection. */
public class Line extends Roi {
......@@ -381,11 +380,15 @@ public class Line extends Roi {
drawHandle(g, sx3-size2, sy3-size2);
}
if (state!=NORMAL)
IJ.showStatus(imp.getLocationAsString(x2,y2)+", angle=" + IJ.d2s(getAngle()) + ", length=" + IJ.d2s(getLength()));
showStatus();
if (updateFullWindow)
{updateFullWindow = false; imp.draw();}
}
public void showStatus() {
IJ.showStatus(imp.getLocationAsString(x2,y2)+", angle=" + IJ.d2s(getAngle()) + ", length=" + IJ.d2s(getLength()));
}
public double getAngle() {
return getFloatAngle(x1d, y1d, x2d, y2d);
}
......@@ -613,6 +616,7 @@ public class Line extends Roi {
}
grow(ic.screenXD(x+x2R), ic.screenYD(y+y2R));
notifyListeners(RoiListener.MOVED);
showStatus();
}
public boolean getDrawOffset() {
......
......@@ -5,6 +5,7 @@ import java.awt.geom.Rectangle2D;
import ij.*;
import ij.process.ImageProcessor;
import ij.plugin.filter.Analyzer;
import ij.plugin.Colors;
import ij.measure.ResultsTable;
/** An Overlay is a list of ROIs that can be drawn non-destructively on an Image. */
......@@ -133,6 +134,13 @@ public class Overlay {
rois[i].setStrokeColor(color);
}
/** Sets the stroke width of all the ROIs in this overlay. */
public void setStrokeWidth(Double width) {
Roi[] rois = toArray();
for (int i=0; i<rois.length; i++)
rois[i].setStrokeWidth(width);
}
/** Sets the fill color of all the ROIs in this overlay. */
public void setFillColor(Color color) {
Roi[] rois = toArray();
......@@ -291,7 +299,7 @@ public class Overlay {
overlay2.drawNames(drawNames);
overlay2.drawBackgrounds(drawBackgrounds);
overlay2.setLabelColor(labelColor);
overlay2.setLabelFont(labelFont);
overlay2.setLabelFont(labelFont, scalableLabels);
overlay2.setIsCalibrationBar(isCalibrationBar);
overlay2.selectable(selectable);
return overlay2;
......@@ -306,10 +314,6 @@ public class Overlay {
return overlay2;
}
public String toString() {
return "Overlay[size="+size()+"]";
}
public void drawLabels(boolean b) {
label = b;
}
......@@ -354,6 +358,23 @@ public class Overlay {
scalableLabels = scalable;
}
/** Set the label font size with options. The options string can contain
* 'scale' (enlarge labels when image zoomed), 'bold'
* (display bold labels) or 'background' (display labels
* with contrasting background.
*/
public void setLabelFontSize(int size, String options) {
int style = Font.PLAIN;
if (options!=null) {
scalableLabels = options.contains("scale");
if (options.contains("bold"))
style = Font.BOLD;
drawBackgrounds = options.contains("back");
}
labelFont = new Font("SansSerif", style, size);
drawLabels(true);
}
public Font getLabelFont() {
return labelFont;
}
......@@ -386,4 +407,8 @@ public class Overlay {
return scalableLabels;
}
public String toString() {
return "Overlay[size="+size()+" "+(scalableLabels?"scale":"")+" "+Colors.colorToString(getLabelColor())+"]";
}
}
......@@ -454,6 +454,7 @@ public class PlotWindow extends ImageWindow implements ActionListener, ItemListe
}
//arrows for modifying the plot range
if (plot==null) return;
if (x < plot.leftMargin || y > plot.topMargin + plot.frameHeight) {
if (!rangeArrowsVisible && !plot.isFrozen())
showRangeArrows();
......
......@@ -1386,7 +1386,7 @@ public class Roi extends Object implements Cloneable, java.io.Serializable, Iter
previousRoi.modState = NO_MODS;
}
protected void showStatus() {
public void showStatus() {
if (imp==null)
return;
String value;
......@@ -1754,7 +1754,7 @@ public class Roi extends Object implements Cloneable, java.io.Serializable, Iter
prototypeOverlay.drawNames(overlay.getDrawNames());
prototypeOverlay.drawBackgrounds(overlay.getDrawBackgrounds());
prototypeOverlay.setLabelColor(overlay.getLabelColor());
prototypeOverlay.setLabelFont(overlay.getLabelFont());
prototypeOverlay.setLabelFont(overlay.getLabelFont(), overlay.scalableLabels());
}
// Used by the FileOpener and RoiDecoder to restore overlay settings. */
......
......@@ -151,11 +151,10 @@ public class RoiProperties {
if (showListCoordinates) {
if ((roi instanceof PointRoi) && Toolbar.getMultiPointMode())
showPointCounts = true;
int n = roi.getFloatPolygon().npoints;
if (showPointCounts)
gd.addCheckbox("Show point counts (shortcut: alt+y)", listCoordinates);
else
gd.addCheckbox("List coordinates ("+n+")", listCoordinates);
gd.addCheckbox("List coordinates ("+roi.size()+")", listCoordinates);
if (nProperties>0)
gd.addCheckbox("List properties ("+nProperties+")", listProperties);
else {
......
package ij.gui;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import ij.*;
import ij.plugin.frame.Recorder;
import ij.process.FloatPolygon;
......@@ -97,6 +98,46 @@ public class RotatedRectRoi extends PolygonRoi {
makePolygonRelative();
cachedMask = null;
DefaultRectWidth = rectWidth;
showStatus();
}
public void showStatus() {
double[] p = getParams();
double dx = p[2] - p[0];
double dy = p[3] - p[1];
double length = Math.sqrt(dx*dx+dy*dy);
double width = p[4];
if (imp!=null && !IJ.altKeyDown()) {
Calibration cal = imp.getCalibration();
if (cal.scaled() && cal.pixelWidth==cal.pixelHeight) {
dx *= cal.pixelWidth;
dy *= cal.pixelHeight;
length = Math.sqrt(dx*dx+dy*dy);
width = p[4]*cal.pixelWidth;
}
}
double angle = getFloatAngle(p[0], p[1], p[2], p[3]);
IJ.showStatus("length=" + IJ.d2s(length)+", width=" + IJ.d2s(width)+", angle=" + IJ.d2s(angle));
}
public void nudgeCorner(int key) {
if (ic==null) return;
double[] p = getParams();
double x1 = p[0];
double y1 = p[1];
double x2 = p[2];
double y2 = p[3];
double inc = 1.0/ic.getMagnification();
switch(key) {
case KeyEvent.VK_UP: y2-=inc; break;
case KeyEvent.VK_DOWN: y2+=inc; break;
case KeyEvent.VK_LEFT: x2-=inc; break;
case KeyEvent.VK_RIGHT: x2+=inc; break;
}
makeRectangle(x1, y1, x2, y2);
imp.draw();
notifyListeners(RoiListener.MOVED);
showStatus();
}
void makePolygonRelative() {
......
......@@ -613,29 +613,30 @@ public class ShapeRoi extends Roi {
double cx = r.getX() + r.getWidth()/2;
double cy = r.getY() + r.getHeight()/2;
AffineTransform at = new AffineTransform();
at.translate(cx, cy);
for (int i=0; i<181; i++) {
at.rotate(Math.PI/180.0);
if (pw != ph)
at.scale(1.0, ph/pw); //correct for pixel aspect ratio
at.translate(-cx, -cy); //shift to origin for better accuracy
double angleInc = 0.5;
AffineTransform rotator = AffineTransform.getRotateInstance(angleInc*Math.PI/180.0);
for (double rotAngle=0; rotAngle<90; rotAngle+=angleInc) { //rotate in 0.5 deg increments
if (rotAngle > 0)
at.preConcatenate(rotator); //'pre-'applying the rotation matrix means rotating as the last step
s = at.createTransformedShape(shape);
r = s.getBounds2D();
double max2 = Math.max(r.getWidth(), r.getHeight());
if (max2>diameter) {
diameter = max2*pw;
//angle = i;
if (r.getWidth() > diameter) {
diameter = r.getWidth();
angle = rotAngle;
}
if (r.getHeight() > diameter) {
diameter = r.getHeight();
angle = rotAngle + 90;
}
double min2 = Math.min(r.getWidth(), r.getHeight());
min = Math.min(min, min2);
}
if (pw!=ph) {
diameter = 0.0;
angle = 0.0;
}
if (pw==ph)
min *= pw;
else {
min = 0.0;
angle = 0.0;
}
diameter *= pw;
double[] a = new double[5];
a[0] = diameter;
a[1] = angle;
......@@ -1021,7 +1022,7 @@ public class ShapeRoi extends Roi {
basex=r.x; basey=r.y;
}
aTx.setTransform(mag, 0.0, 0.0, mag, -basex*mag, -basey*mag);
aTx.translate(x, y);
aTx.translate(getXBase(), getYBase());
if (fillColor!=null) {
if (isActiveOverlayRoi) {
g2d.setColor(Color.cyan);
......
......@@ -181,7 +181,7 @@ public class FileOpener {
overlay.drawNames(proto.getDrawNames());
overlay.drawBackgrounds(proto.getDrawBackgrounds());
overlay.setLabelColor(proto.getLabelColor());
overlay.setLabelFont(proto.getLabelFont());
overlay.setLabelFont(proto.getLabelFont(), proto.scalableLabels());
}
overlay.add(roi);
}
......