1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
package ij.plugin;
import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.io.*;
import java.net.URL;
import java.awt.image.*;
/** This plugin implements the Help/About ImageJ command by opening
* about.jpg in ij.jar, scaling it 600% and adding text to an overlay.
*/
public class AboutBox implements PlugIn {
private static final int SMALL_FONT=20, LARGE_FONT=45;
private static final Color TEXT_COLOR = new Color(255,255,80);
public void run(String arg) {
System.gc();
int lines = 7;
String[] text = new String[lines];
text[0] = "ImageJ "+ImageJ.VERSION+ImageJ.BUILD;
text[1] = "Wayne Rasband and contributors";
text[2] = "National Institutes of Health, USA";
text[3] = "http://imagej.org";
text[4] = "Java "+System.getProperty("java.version")+(IJ.is64Bit()?" (64-bit)":" (32-bit)");
text[5] = IJ.freeMemory();
text[6] = "ImageJ is in the public domain";
ImageProcessor ip = null;
ImageJ ij = IJ.getInstance();
URL url = ij .getClass() .getResource("/about.jpg");
if (url!=null) {
Image img = null;
try {img = ij.createImage((ImageProducer)url.getContent());}
catch(Exception e) {}
if (img!=null) {
ImagePlus sImp = new ImagePlus("", img);
ip = sImp.getProcessor();
}
}
if (ip==null)
ip = new ColorProcessor(55,45);
ip = ip.resize(ip.getWidth()*6, ip.getHeight()*6);
ImagePlus imp = new ImagePlus("About ImageJ", ip);
int width = imp.getWidth();
Overlay overlay = new Overlay();
Font font = new Font("SansSerif", Font.PLAIN, LARGE_FONT);
int y = 60;
add(text[0], width-20, y, font, TextRoi.RIGHT, overlay);
int xcenter = 410;
font = new Font("SansSerif", Font.PLAIN, SMALL_FONT);
y += 45;
add(text[1], xcenter, y, font, TextRoi.CENTER, overlay);
y += 27;
add(text[2], xcenter, y, font, TextRoi.CENTER, overlay);
y += 27;
add(text[3], xcenter, y, font, TextRoi.CENTER, overlay);
y += 27;
add(text[4], xcenter, y, font, TextRoi.CENTER, overlay);
if (IJ.maxMemory()>0L) {
y += 27;
add(text[5], xcenter, y, font, TextRoi.CENTER, overlay);
}
add(text[6], width-10, ip.getHeight()-10, font, TextRoi.RIGHT, overlay);
imp.setOverlay(overlay);
ImageWindow.centerNextImage();
imp.show();
}
private void add(String text, int x, int y, Font font, int justification, Overlay overlay) {
TextRoi roi = new TextRoi(text, x, y, font);
roi.setStrokeColor(TEXT_COLOR);
roi.setJustification(justification);
overlay.add(roi);
}
}
|