From c191297d1febe4e68c77215726c451c095d9c954 Mon Sep 17 00:00:00 2001 From: Mario Torre Date: Thu, 29 May 2008 16:41:39 +0000 Subject: 2008-05-29 Mario Torre * gnu/java/awt/java2d/AbstractGraphics2D.java (setColor): now set directly the foreground color the application wants to use to draw. On null, behave like OpenJDK, drawing black. (renderScanline): fixed NPE, paintContext never initialized. Correctely retrieve destination raster (getColor): Return the correct type. (static initializer): HashMap now typed. (background): now defaults to black and not null. (getPaintContext): new method. Initialize lazily the PaintContext. (foreground): new field. (isForegroundColorNull): likewise. (getDeviceBounds): made abstract. * gnu/java/awt/java2d/RasterGraphics.java (getDeviceBounds): new method. * gnu/java/awt/java2d/ScanlineConverter.java (renderShape): pass correct value of Y to doScanline. * gnu/java/awt/peer/x/GLGraphics.java (getDeviceBounds): new method. (setBackground): synch with new Escher 2.0 API. * gnu/java/awt/peer/x/XGraphicsConfiguration.java (getDefaultTransform): implemented. (getBounds): new method. * java/awt/AlphaComposite.java (derive(int) and derive(float)): new methods. * java/awt/image/WritableRaster.java (createWritableTranslatedChild): now call createWritableChild. (createWritableChild): reformatted. --- java/awt/AlphaComposite.java | 35 +++++++++++++++++++++++++++++++++++ java/awt/image/WritableRaster.java | 23 ++++++++++------------- 2 files changed, 45 insertions(+), 13 deletions(-) (limited to 'java/awt') diff --git a/java/awt/AlphaComposite.java b/java/awt/AlphaComposite.java index addd1e713..a668fdae6 100644 --- a/java/awt/AlphaComposite.java +++ b/java/awt/AlphaComposite.java @@ -158,18 +158,53 @@ public final class AlphaComposite implements Composite return new AlphaCompositeContext(this, srcColorModel, dstColorModel); } + /** + * Return an AlphaComposite similar to this, + * that uses the specified rule. If rule is the same as + * this.rule, then this is returned. + * + * @since 1.6 + */ + public AlphaComposite derive(int rule) + { + if (this.rule == rule) + return this; + else + return AlphaComposite.getInstance(rule, this.getAlpha()); + } + + /** + * Return an AlphaComposite similar to this, + * that uses the specified alpha. + * + * If alph is the same as this.alpha, + * then this is returned. + * + * @since 1.6 + */ + public AlphaComposite derive(float alpha) + { + if (this.getAlpha() == alpha) + return this; + else + return AlphaComposite.getInstance(this.getRule(), alpha); + } + public float getAlpha() { return alpha; } + public int getRule() { return rule; } + public int hashCode() { return 31 * Float.floatToIntBits(alpha) + rule; } + public boolean equals(Object o) { if (! (o instanceof AlphaComposite)) diff --git a/java/awt/image/WritableRaster.java b/java/awt/image/WritableRaster.java index bf8db140c..02789a3d1 100644 --- a/java/awt/image/WritableRaster.java +++ b/java/awt/image/WritableRaster.java @@ -111,13 +111,8 @@ public class WritableRaster extends Raster public WritableRaster createWritableTranslatedChild(int childMinX, int childMinY) { - // This mirrors the code from the super class - int tcx = sampleModelTranslateX - minX + childMinX; - int tcy = sampleModelTranslateY - minY + childMinY; - - return new WritableRaster(sampleModel, dataBuffer, - new Rectangle(childMinX, childMinY, width, height), - new Point(tcx, tcy), this); + return createWritableChild(minX, minY, width, height, + childMinX, childMinY, null); } /** @@ -143,12 +138,14 @@ public class WritableRaster extends Raster SampleModel sm = (bandList == null) ? sampleModel : sampleModel.createSubsetSampleModel(bandList); - - return new WritableRaster(sm, dataBuffer, - new Rectangle(childMinX, childMinY, w, h), - new Point(sampleModelTranslateX + childMinX - parentX, - sampleModelTranslateY + childMinY - parentY), - this); + + return new WritableRaster(sm, getDataBuffer(), + new Rectangle(childMinX, childMinY, w, h), + new Point(sampleModelTranslateX + childMinX - + parentX, + sampleModelTranslateY + childMinY - + parentY), + this); } public Raster createChild(int parentX, int parentY, int width, -- cgit v1.2.1