summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/awt/AlphaComposite.java35
-rw-r--r--java/awt/image/WritableRaster.java23
2 files changed, 45 insertions, 13 deletions
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 <code>AlphaComposite</code> similar to <code>this</code>,
+ * that uses the specified rule. If <code>rule</code> is the same as
+ * <code>this.rule</code>, then <code>this</code> 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 <code>AlphaComposite</code> similar to <code>this</code>,
+ * that uses the specified <code>alpha</code>.
+ *
+ * If <code>alph</code> is the same as <code>this.alpha</code>,
+ * then <code>this</code> 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,