// Inner Classes /////////////////////////////////////////////////////////////////////////////////////
- protected static class AWTPicture implements Picture {
+ protected static class AWTPicture extends Picture {
public int getHeight() { return i.getHeight(null); }
public int getWidth() { return i.getWidth(null); }
public int[] getData() { return data; }
int[] data = null;
public Image i = null;
- private static MediaTracker mediatracker = new MediaTracker(new Canvas());
private static ColorModel cmodel = new DirectColorModel(32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
public AWTPicture(int[] b, int w, int h) {
data = b;
Image img = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(w, h, cmodel, b, 0, w));
+ MediaTracker mediatracker = new MediaTracker(new Canvas());
mediatracker.addImage(img, 1);
try { mediatracker.waitForAll(); } catch (InterruptedException e) { }
mediatracker.removeImage(img);
}
}
- protected static class AWTDoubleBuffer implements DoubleBuffer {
+ protected static class AWTDoubleBuffer extends DoubleBuffer {
protected Image i = null;
protected Graphics g = null;
// IMPORTANT: this must be called before render() to ensure
// that our peer has been created
- window.setVisible(true);
-
+ makeVisible();
}
+
+ protected void makeVisible() { window.setVisible(true); }
public void _dispose() {
window.removeMouseListener(this);
public void windowDeiconified(WindowEvent e) { dirty(0, 0, width, height); Minimized(false); }
public void windowActivated(WindowEvent e) { Focused(true); }
public void windowDeactivated(WindowEvent e) { Focused(false); }
- public void componentMoved(ComponentEvent e) { PosChange(window.getLocation().x, window.getLocation().y); }
+ public void componentMoved(ComponentEvent e) { PosChange(window.getLocation().x + insets.left, window.getLocation().y + insets.top); }
public void componentResized(ComponentEvent e) {
// we have to periodically do this; I don't know why
}
}
+ protected ImageDecoder _decodeJPEG(InputStream is, String name) {
+ try {
+ Image i = Toolkit.getDefaultToolkit().createImage(org.xwt.Resources.isToByteArray(is));
+ MediaTracker mediatracker = new MediaTracker(new Canvas());
+ mediatracker.addImage(i, 1);
+ try { mediatracker.waitForAll(); } catch (InterruptedException e) { }
+ mediatracker.removeImage(i);
+ final int width = i.getWidth(null);
+ final int height = i.getHeight(null);
+ final int[] data = new int[width * height];
+ PixelGrabber pg = new PixelGrabber(i, 0, 0, width, height, data, 0, width);
+ pg.grabPixels();
+ if ((pg.getStatus() & ImageObserver.ABORT) != 0) {
+ Log.log(this, "PixelGrabber reported an error while decoding JPEG image " + name);
+ return null;
+ }
+ return new ImageDecoder() {
+ public int getWidth() { return width; }
+ public int getHeight() { return height; }
+ public int[] getData() { return data; }
+ };
+ } catch (Exception e) {
+ Log.log(this, "Exception caught while decoding JPEG image " + name);
+ Log.log(this, e);
+ return null;
+ }
+ }
+
// Font Handling Stuff //////////////////////////////////////////////////////////
protected String[] _listFonts() { return fontList; }