X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fplat%2FJava12.java;fp=src%2Forg%2Fxwt%2Fplat%2FJava2.java;h=a159eae7b53412fc2d1b275239c8fba020b3d249;hb=bb86c946d2aab0cdb43515e4c8e55e16d3ec567d;hp=1ff8764d3672419a2a25206cba098401b6d6df6a;hpb=bc199d84016367dfa1ea731e2420935cf3edb87f;p=org.ibex.core.git diff --git a/src/org/xwt/plat/Java2.java b/src/org/xwt/plat/Java12.java similarity index 76% rename from src/org/xwt/plat/Java2.java rename to src/org/xwt/plat/Java12.java index 1ff8764..a159eae 100644 --- a/src/org/xwt/plat/Java2.java +++ b/src/org/xwt/plat/Java12.java @@ -14,7 +14,7 @@ import org.xwt.*; // FEATURE: Java 1.4 allows undecorated frames and can maximize windows /** Platform class for most reasonable Java1.2+ JVMs */ -public class Java2 extends AWT { +public class Java12 extends AWT { protected Socket __getSocket(String host, int port, boolean ssl) throws IOException { return super._getSocket(host, port, ssl); } protected Socket _getSocket(final String host, final int port, final boolean ssl) throws IOException { @@ -23,28 +23,33 @@ public class Java2 extends AWT { try { return __getSocket(host, port, ssl); } catch (Exception e) { - if (Log.on) Log.log(Java2.class, "Error attempting to create socket"); - if (Log.on) Log.log(Java2.class, e); + if (Log.on) Log.log(Java12.class, "Error attempting to create socket"); + if (Log.on) Log.log(Java12.class, e); return null; } } }); } - protected DoubleBuffer _createDoubleBuffer(int w, int h, Surface owner) { return new Java2DoubleBuffer(w, h); } + protected DoubleBuffer _createDoubleBuffer(int w, int h, Surface owner) { return new Java12DoubleBuffer(w, h); } protected Surface _createSurface(final Box root, final boolean framed) { return (Surface)java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() { - public Object run() { return new Java2Surface(root, framed); } + public Object run() { return new Java12Surface(root, framed); } }); } // Inner Classes ////////////////////////////////////////////////////////////////// - protected static class Java2Surface extends AWTSurface { + protected static class Java12Surface extends AWTSurface { - public Java2Surface(Box root, boolean framed) { super(root, framed); } + public Java12Surface(Box root, boolean framed) { super(root, framed); } public void blit(DoubleBuffer s, int sx, int sy, int dx, int dy, int dx2, int dy2) { - if (ourGraphics == null) ourGraphics = window.getGraphics(); + if (ourGraphics == null) { + ourGraphics = window.getGraphics(); + + // sometimes jdk1.4 doesn't set the clip properly when we're in the middle of a resize + ourGraphics.setClip(insets.left, insets.top, width + insets.left, height + insets.top); + } _doDrawImage(ourGraphics, ((AWTDoubleBuffer)s).i, dx + insets.left, dy + insets.top, dx2 + insets.left, dy2 + insets.top, sx, sy, sx + (dx2 - dx), sy + (dy2 - dy), null); } @@ -59,7 +64,7 @@ public class Java2 extends AWT { } } - protected static class Java2DoubleBuffer extends AWTDoubleBuffer { + protected static class Java12DoubleBuffer extends AWTDoubleBuffer { private static ColorModel cm = Toolkit.getDefaultToolkit().getColorModel(); private static Hashtable emptyHashtable = new Hashtable(); private static short[] sbank = null; @@ -71,42 +76,42 @@ public class Java2 extends AWT { _doDrawImage(g, ((AWTPicture)source).i, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null); } - public Java2DoubleBuffer(int w, int h) { - super(w, h); + public Java12DoubleBuffer(int w, int h) { SampleModel sm = cm.createCompatibleSampleModel(w, h); + int numSamples = w * h * sm.getNumDataElements(); DataBuffer buf = null; if (sm.getDataType() == DataBuffer.TYPE_USHORT) { - if (sbank == null || w * h > 512 * 512 / 3) { - buf = new DataBufferUShort(w * h); + if (sbank == null || numSamples > 512 * 512 / 3) { + buf = new DataBufferUShort(numSamples); } else { - if (w * h > sbank.length - bank_start) { + if (numSamples > sbank.length - bank_start) { bank_start = 0; sbank = new short[512 * 512]; } - buf = new DataBufferUShort(sbank, w * h, bank_start); - bank_start += w * h; + buf = new DataBufferUShort(sbank, numSamples, bank_start); + bank_start += numSamples; } } else if (sm.getDataType() == DataBuffer.TYPE_BYTE) { - if (bbank == null || w * h > 512 * 512 / 3) { - buf = new DataBufferByte(w * h); + if (bbank == null || numSamples > 512 * 512 / 3) { + buf = new DataBufferByte(numSamples); } else { - if (w * h > bbank.length - bank_start) { + if (numSamples > bbank.length - bank_start) { bank_start = 0; bbank = new byte[512 * 512]; } - buf = new DataBufferByte(bbank, w * h, bank_start); - bank_start += w * h; + buf = new DataBufferByte(bbank, numSamples, bank_start); + bank_start += numSamples; } } else if (sm.getDataType() == DataBuffer.TYPE_INT) { - if (ibank == null || w * h > 512 * 512 / 3) { - buf = new DataBufferInt(w * h); + if (ibank == null || numSamples > 512 * 512 / 3) { + buf = new DataBufferInt(numSamples); } else { - if (w * h > ibank.length - bank_start) { + if (numSamples > ibank.length - bank_start) { bank_start = 0; ibank = new int[512 * 512]; } - buf = new DataBufferInt(ibank, w * h, bank_start); - bank_start += w * h; + buf = new DataBufferInt(ibank, numSamples, bank_start); + bank_start += numSamples; } } i = new BufferedImage(cm, Raster.createWritableRaster(sm, buf, null), false, emptyHashtable); @@ -154,9 +159,9 @@ public class Java2 extends AWT { } } - protected org.xwt.Weak _getWeak(Object o) { return new Java2Weak(o); } - private static class Java2Weak extends java.lang.ref.WeakReference implements org.xwt.Weak { - public Java2Weak(Object o) { super(o); } + protected org.xwt.Weak _getWeak(Object o) { return new Java12Weak(o); } + private static class Java12Weak extends java.lang.ref.WeakReference implements org.xwt.Weak { + public Java12Weak(Object o) { super(o); } } private String __getClipBoard() { return super._getClipBoard(); }