JLayeredPane.java: Rewrite to accomodate djee@redhat.com's recent inverse ordering of Container...
2004-01-08 Graydon Hoare <graydon@redhat.com> * javax/swing/JLayeredPane.java: Rewrite to accomodate djee@redhat.com's recent inverse ordering of Container elements. From-SVN: r75745
This commit is contained in:
parent
1c48f4be22
commit
55db8fa9e7
3 changed files with 316 additions and 75 deletions
libjava/gnu/java/awt/peer/gtk
|
@ -66,7 +66,9 @@ public class GdkGraphics2D extends Graphics2D
|
|||
{
|
||||
System.loadLibrary("gtkpeer");
|
||||
}
|
||||
initStaticState ();
|
||||
|
||||
if (GtkToolkit.useGraphics2D ())
|
||||
initStaticState ();
|
||||
}
|
||||
native static void initStaticState ();
|
||||
private final int native_state = GtkGenericPeer.getUniqueInteger();
|
||||
|
@ -125,7 +127,7 @@ public class GdkGraphics2D extends Graphics2D
|
|||
clip = new Rectangle (g.getClipBounds ());
|
||||
|
||||
if (g.transform == null)
|
||||
transform = AffineTransform.getTranslateInstance (0.5, 0.5);
|
||||
transform = new AffineTransform ();
|
||||
else
|
||||
transform = new AffineTransform (g.transform);
|
||||
|
||||
|
@ -150,7 +152,7 @@ public class GdkGraphics2D extends Graphics2D
|
|||
setBackground (Color.black);
|
||||
setPaint (getColor());
|
||||
setFont (new Font("SansSerif", Font.PLAIN, 12));
|
||||
setTransform (AffineTransform.getTranslateInstance (0.5, 0.5));
|
||||
setTransform (new AffineTransform ());
|
||||
setStroke (new BasicStroke ());
|
||||
|
||||
stateStack = new Stack();
|
||||
|
@ -165,7 +167,7 @@ public class GdkGraphics2D extends Graphics2D
|
|||
setBackground (new Color (rgb[3], rgb[4], rgb[5]));
|
||||
setPaint (getColor());
|
||||
setFont (new Font("SansSerif", Font.PLAIN, 12));
|
||||
setTransform (AffineTransform.getTranslateInstance (0.5, 0.5));
|
||||
setTransform (new AffineTransform ());
|
||||
setStroke (new BasicStroke ());
|
||||
|
||||
stateStack = new Stack ();
|
||||
|
@ -546,7 +548,7 @@ public class GdkGraphics2D extends Graphics2D
|
|||
|
||||
public void setXORMode (Color c)
|
||||
{
|
||||
setComposite (new BitwiseXorComposite (c));
|
||||
setComposite (new gnu.java.awt.BitwiseXORComposite(c));
|
||||
}
|
||||
|
||||
public void setColor (Color c)
|
||||
|
@ -978,76 +980,6 @@ public class GdkGraphics2D extends Graphics2D
|
|||
}
|
||||
|
||||
|
||||
private class BitwiseXorComposite implements Composite
|
||||
{
|
||||
// this is a special class which does a bitwise XOR composite, for
|
||||
// backwards compatibility sake. it does *not* implement the
|
||||
// porter-duff XOR operator. the porter-duff XOR is unrelated to
|
||||
// bitwise XOR; it just happens to have a similar name but it
|
||||
// represents a desire to composite the exclusive or of overlapping
|
||||
// subpixel regions. bitwise XOR is for drawing "highlights" such as
|
||||
// cursors (in a cheap oldskool bitblit fashion) by inverting colors
|
||||
// temporarily and then inverting them back.
|
||||
|
||||
Color xorColor;
|
||||
|
||||
class BitwiseXorCompositeContext implements CompositeContext
|
||||
{
|
||||
ColorModel srcColorModel;
|
||||
ColorModel dstColorModel;
|
||||
|
||||
public BitwiseXorCompositeContext (ColorModel s,
|
||||
ColorModel d)
|
||||
{
|
||||
srcColorModel = s;
|
||||
dstColorModel = d;
|
||||
}
|
||||
|
||||
public void dispose ()
|
||||
{
|
||||
}
|
||||
|
||||
public void compose (Raster src,
|
||||
Raster dstIn,
|
||||
WritableRaster dstOut)
|
||||
{
|
||||
Rectangle srcRect = src.getBounds ();
|
||||
Rectangle dstInRect = dstIn.getBounds ();
|
||||
Rectangle dstOutRect = dstOut.getBounds ();
|
||||
|
||||
int xp = xorColor.getRGB ();
|
||||
int x = 0, y = 0;
|
||||
int w = Math.min (Math.min (srcRect.width, dstOutRect.width), dstInRect.width);
|
||||
int h = Math.min (Math.min (srcRect.height, dstOutRect.height), dstInRect.height);
|
||||
Object srcPix = null, dstPix = null;
|
||||
|
||||
for (y = 0; y < h; y++)
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
srcPix = src.getDataElements (x + srcRect.x, y + srcRect.y, srcPix);
|
||||
dstPix = dstIn.getDataElements (x + dstInRect.x, y + dstInRect.y, dstPix);
|
||||
int sp = srcColorModel.getRGB (srcPix);
|
||||
int dp = dstColorModel.getRGB (dstPix);
|
||||
int rp = sp ^ xp ^ dp;
|
||||
dstOut.setDataElements (x + dstOutRect.x, y + dstOutRect.y,
|
||||
dstColorModel.getDataElements (rp, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BitwiseXorComposite (Color c)
|
||||
{
|
||||
xorColor = c;
|
||||
}
|
||||
|
||||
public CompositeContext createContext (ColorModel srcColorModel,
|
||||
ColorModel dstColorModel,
|
||||
RenderingHints hints)
|
||||
{
|
||||
return new BitwiseXorCompositeContext (srcColorModel, dstColorModel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////
|
||||
////// Unimplemented Stubs and Overloads //////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue