summaryrefslogtreecommitdiff
path: root/java/awt/TexturePaint.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/awt/TexturePaint.java')
-rw-r--r--java/awt/TexturePaint.java55
1 files changed, 47 insertions, 8 deletions
diff --git a/java/awt/TexturePaint.java b/java/awt/TexturePaint.java
index 57d7574c3..387ccb0fd 100644
--- a/java/awt/TexturePaint.java
+++ b/java/awt/TexturePaint.java
@@ -38,42 +38,81 @@ exception statement from your version. */
package java.awt;
-import gnu.classpath.NotImplementedException;
+import gnu.java.awt.java2d.TexturePaintContext;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
-/** STUB CLASS ONLY */
+/**
+ * This class provides a way to fill a Shape with a texture that is
+ * specified by a BufferedImage.
+ */
public class TexturePaint implements Paint
{
private final BufferedImage texture;
private final Rectangle2D anchor;
+
+ /**
+ * Constructor.
+ *
+ * @param texture - the texture
+ * @param anchor - the shape
+ */
public TexturePaint(BufferedImage texture, Rectangle2D anchor)
{
this.texture = texture;
this.anchor = anchor;
}
+
+ /**
+ * Gets the texture image.
+ *
+ * @return the texture
+ */
public BufferedImage getImage()
{
return texture;
}
+
+ /**
+ * Gets the shape anchor.
+ *
+ * @return the shape anchor
+ */
public Rectangle2D getAnchorRect()
{
return anchor;
}
+
+ /**
+ * Creates the context used to paint the texture.
+ *
+ * @param cm - the ColorModel that receives the Paint data. Used only as a hint.
+ * @param deviceBounds - the device space being rendered.
+ * @param userBounds - the user space being rendered
+ * @param xform - the AffineTransform from user space into device space
+ * @param hints - a RenderingHints object that is used to specify how the
+ * pattern is rendered
+ * @return the paint context used to paint the texture
+ */
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds,
Rectangle2D userBounds,
- AffineTransform xform,
- RenderingHints hints)
- throws NotImplementedException
+ AffineTransform xform, RenderingHints hints)
{
- throw new Error("not implemented");
+ // TODO: Maybe add some hook for providing alternative/accelerated
+ // implementations of this.
+ return new TexturePaintContext(this, deviceBounds, userBounds, xform);
}
+
+ /**
+ * Returns the transparency mode.
+ *
+ * @return the transparency mode.
+ */
public int getTransparency()
- throws NotImplementedException
{
- throw new Error("not implemented");
+ return texture.getTransparency();
}
} // class TexturePaint