Methods Summary |
---|
public static java.awt.Image | blockingLoad(java.lang.String path)
Image image = Toolkit.getDefaultToolkit().getImage(path);
if (waitForImage(image) == false) return null;
return image;
|
public static java.awt.Image | blockingLoad(java.net.URL url)
Image image = Toolkit.getDefaultToolkit().getImage(url);
if (waitForImage(image) == false) return null;
return image;
|
public static void | centerFrame(java.awt.Frame f)
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
Dimension d = f.getSize();
int x = (screen.width - d.width) / 2;
int y = (screen.height - d.height) / 2;
f.setLocation(x, y);
|
public static java.awt.Frame | getNonClearingFrame(java.lang.String name, java.awt.Component c)
final Frame f = new Frame(name) {
public void update(Graphics g) { paint(g); }
};
sizeContainerToComponent(f, c);
centerFrame(f);
f.setLayout(new BorderLayout());
f.add(c, BorderLayout.CENTER);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) { f.dispose(); }
});
return f;
|
public static java.awt.image.BufferedImage | makeBufferedImage(java.awt.Image image)
return makeBufferedImage(image, BufferedImage.TYPE_INT_RGB);
|
public static java.awt.image.BufferedImage | makeBufferedImage(java.awt.Image image, int imageType)
if (waitForImage(image) == false) return null;
BufferedImage bufferedImage = new BufferedImage(
image.getWidth(null), image.getHeight(null),
imageType);
Graphics2D g2 = bufferedImage.createGraphics();
g2.drawImage(image, null, null);
return bufferedImage;
|
public static void | sizeContainerToComponent(java.awt.Container container, java.awt.Component component)
if (container.isDisplayable() == false) container.addNotify();
Insets insets = container.getInsets();
Dimension size = component.getPreferredSize();
int width = insets.left + insets.right + size.width;
int height = insets.top + insets.bottom + size.height;
container.setSize(width, height);
|
public static boolean | waitForImage(java.awt.Image image)
int id;
synchronized(sComponent) { id = sID++; }
sTracker.addImage(image, id);
try { sTracker.waitForID(id); }
catch (InterruptedException ie) { return false; }
if (sTracker.isErrorID(id)) return false;
return true;
|