use of ij.text.TextWindow in project imagej1 by imagej.
the class Prefs method savePreferences.
/**
* Saves user preferences in the IJ_Prefs.txt properties file.
*/
public static void savePreferences() {
String path = null;
try {
Properties prefs = new Properties();
String dir = OpenDialog.getDefaultDirectory();
if (dir != null)
prefs.put(DIR_IMAGE, dir);
prefs.put(ROICOLOR, Tools.c2hex(Roi.getColor()));
prefs.put(SHOW_ALL_COLOR, Tools.c2hex(ImageCanvas.getShowAllColor()));
prefs.put(FCOLOR, Tools.c2hex(Toolbar.getForegroundColor()));
prefs.put(BCOLOR, Tools.c2hex(Toolbar.getBackgroundColor()));
prefs.put(JPEG, Integer.toString(FileSaver.getJpegQuality()));
prefs.put(FPS, Double.toString(Animator.getFrameRate()));
prefs.put(DIV_BY_ZERO_VALUE, Double.toString(FloatBlitter.divideByZeroValue));
prefs.put(NOISE_SD, Double.toString(Filters.getSD()));
if (threads > 1)
prefs.put(THREADS, Integer.toString(threads));
if (IJ.isMacOSX())
useJFileChooser = false;
if (!IJ.isLinux())
dialogCancelButtonOnRight = false;
saveOptions(prefs);
savePluginPrefs(prefs);
IJ.getInstance().savePreferences(prefs);
Menus.savePreferences(prefs);
ParticleAnalyzer.savePreferences(prefs);
Analyzer.savePreferences(prefs);
ImportDialog.savePreferences(prefs);
PlotWindow.savePreferences(prefs);
NewImage.savePreferences(prefs);
String prefsDir = getPrefsDir();
path = prefsDir + separator + PREFS_NAME;
if (prefsDir.endsWith(".imagej")) {
File f = new File(prefsDir);
// create .imagej directory
if (!f.exists())
f.mkdir();
}
if (resetPreferences) {
File f = new File(path);
if (!f.exists())
IJ.error("Edit>Options>Reset", "Unable to reset preferences. File not found at\n" + path);
boolean rtn = f.delete();
resetPreferences = false;
} else
savePrefs(prefs, path);
} catch (Throwable t) {
String msg = t.getMessage();
if (msg == null)
msg = "" + t;
int delay = 4000;
try {
new TextWindow("Error Saving Preferences:\n" + path, msg, 500, 200);
IJ.wait(delay);
} catch (Throwable t2) {
}
}
}
use of ij.text.TextWindow in project imagej1 by imagej.
the class WindowManager method closeAllWindows.
/**
* Closes all windows. Stops and returns false if an image or Editor "save changes" dialog is canceled.
*/
public static synchronized boolean closeAllWindows() {
Prefs.closingAll = true;
while (imageList.size() > 0) {
if (!((ImageWindow) imageList.get(0)).close()) {
Prefs.closingAll = false;
return false;
}
if (!quittingViaMacro())
IJ.wait(100);
}
Prefs.closingAll = false;
Frame[] nonImages = getNonImageWindows();
for (int i = 0; i < nonImages.length; i++) {
Frame frame = nonImages[i];
if (frame != null && (frame instanceof Editor)) {
((Editor) frame).close();
if (((Editor) frame).fileChanged())
return false;
if (!quittingViaMacro())
IJ.wait(100);
}
}
ImageJ ij = IJ.getInstance();
if (ij != null && ij.quitting() && IJ.getApplet() == null)
return true;
for (int i = 0; i < nonImages.length; i++) {
Frame frame = nonImages[i];
if ((frame instanceof PlugInFrame) && !(frame instanceof Editor))
((PlugInFrame) frame).close();
else if (frame instanceof TextWindow)
((TextWindow) frame).close();
else {
// frame.setVisible(false);
frame.dispose();
}
}
return true;
}
use of ij.text.TextWindow in project imagej1 by imagej.
the class Opener method open.
/**
* Opens and displays the specified tiff, dicom, fits, pgm, jpeg,
* bmp, gif, lut, roi, or text file. Displays an error message if
* the file is not in a supported format.
* @see ij.IJ#open(String)
* @see ij.IJ#openImage(String)
*/
public void open(String path) {
boolean isURL = path.indexOf("://") > 0;
if (isURL && isText(path)) {
openTextURL(path);
return;
}
if (path.endsWith(".jar") || path.endsWith(".class")) {
(new PluginInstaller()).install(path);
return;
}
boolean fullPath = path.startsWith("/") || path.startsWith("\\") || path.indexOf(":\\") == 1 || path.indexOf(":/") == 1 || isURL;
if (!fullPath) {
String defaultDir = OpenDialog.getDefaultDirectory();
if (defaultDir != null)
path = defaultDir + path;
else
path = (new File(path)).getAbsolutePath();
}
if (!silentMode)
IJ.showStatus("Opening: " + path);
long start = System.currentTimeMillis();
ImagePlus imp = null;
if (path.endsWith(".txt"))
fileType = JAVA_OR_TEXT;
else
imp = openImage(path);
if (imp == null && isURL)
return;
if (imp != null) {
WindowManager.checkForDuplicateName = true;
if (isRGB48)
openRGB48(imp);
else
imp.show(getLoadRate(start, imp));
} else {
switch(fileType) {
case LUT:
imp = (ImagePlus) IJ.runPlugIn("ij.plugin.LutLoader", path);
if (imp.getWidth() != 0)
imp.show();
break;
case ROI:
IJ.runPlugIn("ij.plugin.RoiReader", path);
break;
case JAVA_OR_TEXT:
case TEXT:
if (IJ.altKeyDown()) {
// open in TextWindow if alt key down
new TextWindow(path, 400, 450);
IJ.setKeyUp(KeyEvent.VK_ALT);
break;
}
File file = new File(path);
int maxSize = 250000;
long size = file.length();
if (size >= 28000) {
String osName = System.getProperty("os.name");
if (osName.equals("Windows 95") || osName.equals("Windows 98") || osName.equals("Windows Me"))
maxSize = 60000;
}
if (size < maxSize) {
Editor ed = (Editor) IJ.runPlugIn("ij.plugin.frame.Editor", "");
if (ed != null)
ed.open(getDir(path), getName(path));
} else
new TextWindow(path, 400, 450);
break;
case // ObjectJ project
OJJ:
IJ.runPlugIn("ObjectJ_", path);
break;
case // ImageJ Results table
TABLE:
openResultsTable(path);
break;
case RAW:
IJ.runPlugIn("ij.plugin.Raw", path);
break;
case UNKNOWN:
String msg = "File is not in a supported format, a reader\n" + "plugin is not available, or it was not found.";
if (path != null) {
if (path.length() > 64)
path = (new File(path)).getName();
if (path.length() <= 64) {
if (IJ.redirectingErrorMessages())
msg += " \n " + path;
else
msg += " \n \n" + path;
}
}
if (openUsingPlugins)
msg += "\n \nNOTE: The \"OpenUsingPlugins\" option is set.";
// work around for OS X thread deadlock problem
IJ.wait(IJ.isMacro() ? 500 : 100);
IJ.error("Opener", msg);
error = true;
break;
}
}
}
use of ij.text.TextWindow in project imagej1 by imagej.
the class Commands method close.
void close() {
ImagePlus imp = WindowManager.getCurrentImage();
Window win = WindowManager.getActiveWindow();
if (win == null || (Interpreter.isBatchMode() && win instanceof ImageWindow))
closeImage(imp);
else if (win instanceof PlugInFrame)
((PlugInFrame) win).close();
else if (win instanceof PlugInDialog)
((PlugInDialog) win).close();
else if (win instanceof TextWindow)
((TextWindow) win).close();
else
closeImage(imp);
}
use of ij.text.TextWindow in project TrakEM2 by trakem2.
the class Graph method extractAndShowGraph.
/**
* Extract the graph based on connectors; leave @param only null to include all types.
*/
public static final <T extends Displayable> void extractAndShowGraph(final LayerSet ls, final Set<Class<T>> only) {
final Map<String, StringBuilder> m = Graph.extractGraph(ls, only);
if (null == m)
return;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new TextWindow("Graph", m.get("xml").toString(), 500, 500);
TextWindow tw = new TextWindow("SIF", m.get("sif").toString(), 500, 500);
Point p = tw.getLocation();
tw.setLocation(p.x + 50, p.y + 50);
tw = new TextWindow("Names", m.get("names").toString(), 500, 500);
tw.setLocation(p.x + 100, p.y + 100);
}
});
}
Aggregations