Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
AboutBox.java
1 package ij.plugin;
2 import ij.*;
3 import ij.process.*;
4 import ij.gui.*;
5 import java.awt.*;
6 import ij.io.*;
7 import java.net.URL;
8 import java.awt.image.*;
9 
12  public class AboutBox implements PlugIn {
13  static final int SMALL_FONT=14, LARGE_FONT=26;
14 
15  public void run(String arg) {
16  int lines = 8;
17  String[] text = new String[lines];
18  text[0] = "Squiz Image Editor";
19  text[1] = "based on ImageJ "+ImageJ.VERSION;
20  text[2] = "by Wayne Rasband from the";
21  text[3] = "National Institutes of Health, USA";
22  text[4] = "http://rsb.info.nih.gov/ij/";
23  text[5] = "Java "+System.getProperty("java.version");
24  text[6] = IJ.freeMemory();
25  text[7] = "ImageJ is in the public domain";
26  ImageProcessor ip = null;
27  ImageJ ij = IJ.getInstance();
28  URL url = ij .getClass() .getResource("/about.jpg");
29  if (url!=null) {
30  Image img = null;
31  try {img = ij.createImage((ImageProducer)url.getContent());}
32  catch(Exception e) {}
33  if (img!=null) {
34  ImagePlus imp = new ImagePlus("", img);
35  ip = imp.getProcessor();
36  }
37  }
38  if (ip==null)
39  ip = new ColorProcessor(70,45);
40  ip = ip.resize(ip.getWidth()*4, ip.getHeight()*4);
41  ip.setFont(new Font("SansSerif", Font.PLAIN, LARGE_FONT));
42  ip.setAntialiasedText(true);
43  int[] widths = new int[lines];
44  widths[0] = ip.getStringWidth(text[0]);
45  ip.setFont(new Font("SansSerif", Font.PLAIN, SMALL_FONT));
46  for (int i=1; i<lines-1; i++)
47  widths[i] = ip.getStringWidth(text[i]);
48  int max = 0;
49  max = ip.getWidth();
50  ip.setColor(new Color(255,255,140));
51  ip.setFont(new Font("SansSerif", Font.PLAIN, LARGE_FONT));
52  int y = 34;
53  ip.drawString(text[0], x(text[0],ip,max), y);
54  ip.setFont(new Font("SansSerif", Font.PLAIN, SMALL_FONT));
55  y += 26;
56  ip.drawString(text[1], x(text[1],ip,max), y);
57  y += 18;
58  ip.drawString(text[2], x(text[2],ip,max), y);
59  y += 18;
60  ip.drawString(text[3], x(text[3],ip,max), y);
61  y += 18;
62  ip.drawString(text[4], x(text[4],ip,max), y);
63  if (IJ.maxMemory()>0L) {
64  y += 18;
65  ip.drawString(text[5], x(text[5],ip,max), y);
66  }
67  y += 18;
68  ip.drawString(text[6], x(text[6],ip,max), y);
69  y += 18;
70  ip.drawString(text[7], x(text[7],ip,max), y);
71  new ImagePlus("About ImageJ", ip).show();
72  }
73 
74  int x(String text, ImageProcessor ip, int max) {
75  return ip.getWidth() - max + (max - ip.getStringWidth(text))/2 - 10;
76  }
77 
78 }