summaryrefslogtreecommitdiff
path: root/libjava/gnu/awt/j2d
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/gnu/awt/j2d')
-rw-r--r--libjava/gnu/awt/j2d/AbstractGraphicsState.h90
-rw-r--r--libjava/gnu/awt/j2d/AbstractGraphicsState.java141
-rw-r--r--libjava/gnu/awt/j2d/DirectRasterGraphics.h71
-rw-r--r--libjava/gnu/awt/j2d/DirectRasterGraphics.java85
-rw-r--r--libjava/gnu/awt/j2d/Graphics2DImpl.h157
-rw-r--r--libjava/gnu/awt/j2d/Graphics2DImpl.java545
-rw-r--r--libjava/gnu/awt/j2d/IntegerGraphicsState$ScreenCoupledImage.h39
-rw-r--r--libjava/gnu/awt/j2d/IntegerGraphicsState.h94
-rw-r--r--libjava/gnu/awt/j2d/IntegerGraphicsState.java427
-rw-r--r--libjava/gnu/awt/j2d/MappedRaster.h49
-rw-r--r--libjava/gnu/awt/j2d/MappedRaster.java72
11 files changed, 1770 insertions, 0 deletions
diff --git a/libjava/gnu/awt/j2d/AbstractGraphicsState.h b/libjava/gnu/awt/j2d/AbstractGraphicsState.h
new file mode 100644
index 000000000..973d9106a
--- /dev/null
+++ b/libjava/gnu/awt/j2d/AbstractGraphicsState.h
@@ -0,0 +1,90 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_awt_j2d_AbstractGraphicsState__
+#define __gnu_awt_j2d_AbstractGraphicsState__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace awt
+ {
+ namespace j2d
+ {
+ class AbstractGraphicsState;
+ class Graphics2DImpl;
+ }
+ }
+ }
+ namespace java
+ {
+ namespace awt
+ {
+ class Color;
+ class Font;
+ class FontMetrics;
+ class Image;
+ class Rectangle;
+ class Shape;
+ namespace image
+ {
+ class ImageObserver;
+ }
+ }
+ }
+}
+
+class gnu::awt::j2d::AbstractGraphicsState : public ::java::lang::Object
+{
+
+public:
+ AbstractGraphicsState();
+ virtual void setFrontend(::gnu::awt::j2d::Graphics2DImpl *);
+ virtual void dispose();
+ virtual void setColor(::java::awt::Color *) = 0;
+ virtual void setPaintMode() = 0;
+ virtual void setXORMode(::java::awt::Color *) = 0;
+ virtual void setFont(::java::awt::Font *) = 0;
+ virtual ::java::awt::FontMetrics * getFontMetrics(::java::awt::Font *) = 0;
+ virtual void setClip(::java::awt::Shape *) = 0;
+ virtual ::java::awt::Shape * getClip() = 0;
+ virtual ::java::awt::Rectangle * getClipBounds() = 0;
+ virtual void copyArea(jint, jint, jint, jint, jint, jint) = 0;
+ virtual void drawLine(jint, jint, jint, jint) = 0;
+ virtual void fillRect(jint, jint, jint, jint) = 0;
+ virtual void clearRect(jint, jint, jint, jint) = 0;
+ virtual void drawRoundRect(jint, jint, jint, jint, jint, jint) = 0;
+ virtual void fillRoundRect(jint, jint, jint, jint, jint, jint) = 0;
+ virtual void drawOval(jint, jint, jint, jint) = 0;
+ virtual void fillOval(jint, jint, jint, jint) = 0;
+ virtual void drawArc(jint, jint, jint, jint, jint, jint) = 0;
+ virtual void fillArc(jint, jint, jint, jint, jint, jint) = 0;
+ virtual void drawPolyline(JArray< jint > *, JArray< jint > *, jint) = 0;
+ virtual void drawPolygon(JArray< jint > *, JArray< jint > *, jint) = 0;
+ virtual void fillPolygon(JArray< jint > *, JArray< jint > *, jint) = 0;
+ virtual jboolean drawImage(::java::awt::Image *, jint, jint, ::java::awt::image::ImageObserver *) = 0;
+ virtual void draw(::java::awt::Shape *) = 0;
+ virtual void fill(::java::awt::Shape *) = 0;
+ virtual jboolean hit(::java::awt::Rectangle *, ::java::awt::Shape *, jboolean) = 0;
+ virtual void drawString(::java::lang::String *, jint, jint) = 0;
+ virtual void drawString(::java::lang::String *, jfloat, jfloat) = 0;
+ virtual void translate(jint, jint) = 0;
+ virtual void translate(jdouble, jdouble) = 0;
+ virtual void rotate(jdouble) = 0;
+ virtual void rotate(jdouble, jdouble, jdouble) = 0;
+ virtual void scale(jdouble, jdouble) = 0;
+ virtual void shear(jdouble, jdouble) = 0;
+ virtual ::java::lang::Object * clone();
+public: // actually package-private
+ ::gnu::awt::j2d::Graphics2DImpl * __attribute__((aligned(__alignof__( ::java::lang::Object)))) frontend;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_awt_j2d_AbstractGraphicsState__
diff --git a/libjava/gnu/awt/j2d/AbstractGraphicsState.java b/libjava/gnu/awt/j2d/AbstractGraphicsState.java
new file mode 100644
index 000000000..038bc9c6c
--- /dev/null
+++ b/libjava/gnu/awt/j2d/AbstractGraphicsState.java
@@ -0,0 +1,141 @@
+/* Copyright (C) 2000, 2001 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package gnu.awt.j2d;
+
+import java.awt.Color;
+import java.awt.Image;
+import java.awt.Shape;
+import java.awt.Rectangle;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.image.ImageObserver;
+
+/**
+ * Base class for graphics state objects (State pattern, GOF book)
+ * that represents the current pipeline configuration. The Graphics2D
+ * object forwards most of the requests to the state object. The
+ * Graphics2D object itself only administers properties that are not
+ * specific for a certain state.
+ */
+public abstract class AbstractGraphicsState implements Cloneable
+{
+ Graphics2DImpl frontend;
+
+ public void setFrontend(Graphics2DImpl frontend)
+ {
+ this.frontend = frontend;
+ }
+
+ public void dispose()
+ {
+ frontend = null;
+ }
+
+ // -------- Graphics methods:
+
+ public abstract void setColor(Color color);
+
+ public abstract void setPaintMode();
+
+ public abstract void setXORMode(Color altColor);
+
+ public abstract void setFont(Font font);
+
+ public abstract FontMetrics getFontMetrics(Font font);
+
+ public abstract void setClip(Shape clip);
+
+ public abstract Shape getClip();
+ public abstract Rectangle getClipBounds();
+
+ public abstract void copyArea(int x, int y,
+ int width, int height,
+ int dx, int dy);
+
+ public abstract void drawLine(int x1, int y1,
+ int x2, int y2);
+
+ public abstract void fillRect(int x, int y,
+ int width, int height);
+
+ public abstract void clearRect(int x, int y,
+ int width, int height);
+
+ public abstract void drawRoundRect(int x, int y,
+ int width, int height,
+ int arcWidth, int arcHeight);
+
+ public abstract void fillRoundRect(int x, int y,
+ int width, int height,
+ int arcWidth, int arcHeight);
+
+ public abstract void drawOval(int x, int y,
+ int width, int height);
+
+ public abstract void fillOval(int x, int y,
+ int width, int height);
+
+ public abstract void drawArc(int x, int y,
+ int width, int height,
+ int startAngle, int arcAngle);
+
+ public abstract void fillArc(int x, int y,
+ int width, int height,
+ int startAngle, int arcAngle);
+
+ public abstract void drawPolyline(int[] xPoints, int[] yPoints,int nPoints);
+
+ public abstract void drawPolygon(int[] xPoints, int[] yPoints, int nPoints);
+
+ public abstract void fillPolygon(int[] xPoints, int[] yPoints, int nPoints);
+
+ public abstract boolean drawImage(Image image, int x, int y,
+ ImageObserver observer);
+
+
+ // -------- Graphics2D methods:
+
+ public abstract void draw(Shape shape);
+
+ public abstract void fill(Shape shape);
+
+ public abstract boolean hit(Rectangle rect, Shape text, boolean onStroke);
+
+ public abstract void drawString(String text, int x, int y);
+
+ public abstract void drawString(String text, float x, float y);
+
+ public abstract void translate(int x, int y);
+
+ public abstract void translate(double tx, double ty);
+
+ public abstract void rotate(double theta);
+
+ public abstract void rotate(double theta, double x, double y);
+
+ public abstract void scale(double scaleX, double scaleY);
+
+ public abstract void shear(double shearX, double shearY);
+
+ public Object clone ()
+ {
+ try
+ {
+ return super.clone ();
+ }
+ catch (CloneNotSupportedException ex)
+ {
+ // This should never happen.
+ throw new InternalError ();
+ }
+ }
+}
diff --git a/libjava/gnu/awt/j2d/DirectRasterGraphics.h b/libjava/gnu/awt/j2d/DirectRasterGraphics.h
new file mode 100644
index 000000000..4cb63f7f7
--- /dev/null
+++ b/libjava/gnu/awt/j2d/DirectRasterGraphics.h
@@ -0,0 +1,71 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_awt_j2d_DirectRasterGraphics__
+#define __gnu_awt_j2d_DirectRasterGraphics__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace awt
+ {
+ namespace j2d
+ {
+ class DirectRasterGraphics;
+ class MappedRaster;
+ }
+ }
+ }
+ namespace java
+ {
+ namespace awt
+ {
+ class Color;
+ class Font;
+ class FontMetrics;
+ class Image;
+ class Rectangle;
+ class Shape;
+ namespace image
+ {
+ class ImageObserver;
+ }
+ }
+ }
+}
+
+class gnu::awt::j2d::DirectRasterGraphics : public ::java::lang::Object
+{
+
+public:
+ virtual void dispose() = 0;
+ virtual void setColor(::java::awt::Color *) = 0;
+ virtual void setPaintMode() = 0;
+ virtual void setXORMode(::java::awt::Color *) = 0;
+ virtual void setFont(::java::awt::Font *) = 0;
+ virtual ::java::awt::FontMetrics * getFontMetrics(::java::awt::Font *) = 0;
+ virtual void setClip(::java::awt::Shape *) = 0;
+ virtual void copyArea(jint, jint, jint, jint, jint, jint) = 0;
+ virtual void drawLine(jint, jint, jint, jint) = 0;
+ virtual void drawRect(jint, jint, jint, jint) = 0;
+ virtual void fillRect(jint, jint, jint, jint) = 0;
+ virtual void drawArc(jint, jint, jint, jint, jint, jint) = 0;
+ virtual void fillArc(jint, jint, jint, jint, jint, jint) = 0;
+ virtual void drawPolyline(JArray< jint > *, JArray< jint > *, jint) = 0;
+ virtual void drawPolygon(JArray< jint > *, JArray< jint > *, jint) = 0;
+ virtual void fillPolygon(JArray< jint > *, JArray< jint > *, jint, jint, jint) = 0;
+ virtual void drawString(::java::lang::String *, jint, jint) = 0;
+ virtual jboolean drawImage(::java::awt::Image *, jint, jint, ::java::awt::image::ImageObserver *) = 0;
+ virtual ::gnu::awt::j2d::MappedRaster * mapRaster(::java::awt::Rectangle *) = 0;
+ virtual void unmapRaster(::gnu::awt::j2d::MappedRaster *) = 0;
+ virtual ::java::lang::Object * clone() = 0;
+ static ::java::lang::Class class$;
+} __attribute__ ((java_interface));
+
+#endif // __gnu_awt_j2d_DirectRasterGraphics__
diff --git a/libjava/gnu/awt/j2d/DirectRasterGraphics.java b/libjava/gnu/awt/j2d/DirectRasterGraphics.java
new file mode 100644
index 000000000..d7248b9d8
--- /dev/null
+++ b/libjava/gnu/awt/j2d/DirectRasterGraphics.java
@@ -0,0 +1,85 @@
+/* Copyright (C) 2000, 2003 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package gnu.awt.j2d;
+
+import java.awt.Color;
+import java.awt.Image;
+import java.awt.Shape;
+import java.awt.Rectangle;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.image.Raster;
+import java.awt.image.ImageObserver;
+
+/**
+ * Interface for a simple pixel based backend graphics object that
+ * does not handle translation/transforms, curves, nor advanced
+ * compositing.
+ */
+public interface DirectRasterGraphics extends Cloneable
+{
+ void dispose();
+
+ void setColor(Color color);
+
+ void setPaintMode();
+
+ void setXORMode(Color altColor);
+
+ void setFont(Font font);
+
+ FontMetrics getFontMetrics(Font font);
+
+ // supports rects, multi-rects and polygons
+ void setClip(Shape clip);
+
+ void copyArea(int x, int y, int width, int height,
+ int dx, int dy);
+
+ void drawLine(int x1, int y1, int x2, int y2);
+
+ void drawRect(int x, int y, int width, int height);
+
+ void fillRect(int x, int y, int width, int height);
+
+ void drawArc(int x, int y, int width, int height,
+ int startAngle, int arcAngle);
+
+ void fillArc(int x, int y, int width, int height,
+ int startAngle, int arcAngle);
+
+ void drawPolyline(int[] xPoints, int[] yPoints, int nPoints);
+
+ void drawPolygon(int[] xPoints, int[] yPoints, int nPoints);
+
+ void fillPolygon(int[] xPoints, int[] yPoints, int nPoints,
+ int translateX, int translateY);
+
+ void drawString(String str, int x, int y);
+
+ boolean drawImage(Image image, int x, int y,
+ ImageObserver observer);
+
+ /**
+ * Map the data for screen pixels in the requested bounds to a
+ * raster object. This gives read/write access to the screen
+ * pixels, allowing neat alpha and composite tricks.
+ */
+ MappedRaster mapRaster(Rectangle bounds);
+
+ /**
+ * Detach previously mapped pixel data from a raster object.
+ */
+ void unmapRaster(MappedRaster mappedRaster);
+
+ Object clone();
+}
diff --git a/libjava/gnu/awt/j2d/Graphics2DImpl.h b/libjava/gnu/awt/j2d/Graphics2DImpl.h
new file mode 100644
index 000000000..c7e8a8c1d
--- /dev/null
+++ b/libjava/gnu/awt/j2d/Graphics2DImpl.h
@@ -0,0 +1,157 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_awt_j2d_Graphics2DImpl__
+#define __gnu_awt_j2d_Graphics2DImpl__
+
+#pragma interface
+
+#include <java/awt/Graphics2D.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace awt
+ {
+ namespace j2d
+ {
+ class AbstractGraphicsState;
+ class Graphics2DImpl;
+ }
+ }
+ }
+ namespace java
+ {
+ namespace awt
+ {
+ class Color;
+ class Composite;
+ class Font;
+ class FontMetrics;
+ class Graphics;
+ class GraphicsConfiguration;
+ class Image;
+ class Paint;
+ class Rectangle;
+ class RenderingHints;
+ class RenderingHints$Key;
+ class Shape;
+ class Stroke;
+ namespace font
+ {
+ class FontRenderContext;
+ class GlyphVector;
+ }
+ namespace geom
+ {
+ class AffineTransform;
+ }
+ namespace image
+ {
+ class BufferedImage;
+ class BufferedImageOp;
+ class ImageObserver;
+ class RenderedImage;
+ namespace renderable
+ {
+ class RenderableImage;
+ }
+ }
+ }
+ namespace text
+ {
+ class AttributedCharacterIterator;
+ }
+ }
+}
+
+class gnu::awt::j2d::Graphics2DImpl : public ::java::awt::Graphics2D
+{
+
+public:
+ Graphics2DImpl(::java::awt::GraphicsConfiguration *);
+ virtual void setState(::gnu::awt::j2d::AbstractGraphicsState *);
+ virtual ::java::lang::Object * clone();
+ virtual ::java::awt::Graphics * create();
+ virtual ::java::awt::Color * getColor();
+ virtual void setColor(::java::awt::Color *);
+ virtual void setPaintMode();
+ virtual void setXORMode(::java::awt::Color *);
+ virtual ::java::awt::Font * getFont();
+ virtual void setFont(::java::awt::Font *);
+ virtual ::java::awt::FontMetrics * getFontMetrics(::java::awt::Font *);
+ virtual ::java::awt::Rectangle * getClipBounds();
+ virtual void clipRect(jint, jint, jint, jint);
+ virtual void setClip(jint, jint, jint, jint);
+ virtual ::java::awt::Shape * getClip();
+ virtual void setClip(::java::awt::Shape *);
+ virtual void copyArea(jint, jint, jint, jint, jint, jint);
+ virtual void drawLine(jint, jint, jint, jint);
+ virtual void fillRect(jint, jint, jint, jint);
+ virtual void clearRect(jint, jint, jint, jint);
+ virtual void drawRoundRect(jint, jint, jint, jint, jint, jint);
+ virtual void fillRoundRect(jint, jint, jint, jint, jint, jint);
+ virtual void drawOval(jint, jint, jint, jint);
+ virtual void fillOval(jint, jint, jint, jint);
+ virtual void drawArc(jint, jint, jint, jint, jint, jint);
+ virtual void fillArc(jint, jint, jint, jint, jint, jint);
+ virtual void drawPolyline(JArray< jint > *, JArray< jint > *, jint);
+ virtual void drawPolygon(JArray< jint > *, JArray< jint > *, jint);
+ virtual void fillPolygon(JArray< jint > *, JArray< jint > *, jint);
+ virtual jboolean drawImage(::java::awt::Image *, jint, jint, ::java::awt::image::ImageObserver *);
+ virtual jboolean drawImage(::java::awt::Image *, jint, jint, jint, jint, ::java::awt::image::ImageObserver *);
+ virtual jboolean drawImage(::java::awt::Image *, jint, jint, ::java::awt::Color *, ::java::awt::image::ImageObserver *);
+ virtual jboolean drawImage(::java::awt::Image *, jint, jint, jint, jint, ::java::awt::Color *, ::java::awt::image::ImageObserver *);
+ virtual jboolean drawImage(::java::awt::Image *, jint, jint, jint, jint, jint, jint, jint, jint, ::java::awt::image::ImageObserver *);
+ virtual jboolean drawImage(::java::awt::Image *, jint, jint, jint, jint, jint, jint, jint, jint, ::java::awt::Color *, ::java::awt::image::ImageObserver *);
+ virtual void dispose();
+ virtual void draw(::java::awt::Shape *);
+ virtual jboolean drawImage(::java::awt::Image *, ::java::awt::geom::AffineTransform *, ::java::awt::image::ImageObserver *);
+ virtual void drawString(::java::lang::String *, jint, jint);
+ virtual void drawString(::java::lang::String *, jfloat, jfloat);
+ virtual void fill(::java::awt::Shape *);
+ virtual jboolean hit(::java::awt::Rectangle *, ::java::awt::Shape *, jboolean);
+ virtual ::java::awt::GraphicsConfiguration * getDeviceConfiguration();
+ virtual void setPaint(::java::awt::Paint *);
+ virtual void setRenderingHint(::java::awt::RenderingHints$Key *, ::java::lang::Object *);
+ virtual ::java::lang::Object * getRenderingHint(::java::awt::RenderingHints$Key *);
+ virtual ::java::awt::RenderingHints * getRenderingHints();
+ virtual void translate(jint, jint);
+ virtual void translate(jdouble, jdouble);
+ virtual void rotate(jdouble);
+ virtual void rotate(jdouble, jdouble, jdouble);
+ virtual void scale(jdouble, jdouble);
+ virtual void shear(jdouble, jdouble);
+ virtual void transform(::java::awt::geom::AffineTransform *);
+ virtual void setTransform(::java::awt::geom::AffineTransform *);
+ virtual ::java::awt::geom::AffineTransform * getTransform();
+ virtual ::java::awt::Paint * getPaint();
+ virtual void setBackground(::java::awt::Color *);
+ virtual ::java::awt::Color * getBackground();
+ virtual void clip(::java::awt::Shape *);
+ virtual void drawImage(::java::awt::image::BufferedImage *, ::java::awt::image::BufferedImageOp *, jint, jint);
+ virtual void drawRenderedImage(::java::awt::image::RenderedImage *, ::java::awt::geom::AffineTransform *);
+ virtual void drawRenderableImage(::java::awt::image::renderable::RenderableImage *, ::java::awt::geom::AffineTransform *);
+ virtual void drawString(::java::text::AttributedCharacterIterator *, jint, jint);
+ virtual void drawString(::java::text::AttributedCharacterIterator *, jfloat, jfloat);
+ virtual void setComposite(::java::awt::Composite *);
+ virtual void setStroke(::java::awt::Stroke *);
+ virtual void setRenderingHints(::java::util::Map *);
+ virtual void addRenderingHints(::java::util::Map *);
+ virtual ::java::awt::Composite * getComposite();
+ virtual ::java::awt::Stroke * getStroke();
+ virtual ::java::awt::font::FontRenderContext * getFontRenderContext();
+ virtual void drawGlyphVector(::java::awt::font::GlyphVector *, jfloat, jfloat);
+public: // actually package-private
+ ::java::awt::GraphicsConfiguration * __attribute__((aligned(__alignof__( ::java::awt::Graphics2D)))) config;
+ ::gnu::awt::j2d::AbstractGraphicsState * state;
+ ::java::awt::Color * fg;
+ ::java::awt::Color * bg;
+ ::java::awt::Font * font;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_awt_j2d_Graphics2DImpl__
diff --git a/libjava/gnu/awt/j2d/Graphics2DImpl.java b/libjava/gnu/awt/j2d/Graphics2DImpl.java
new file mode 100644
index 000000000..5091af69f
--- /dev/null
+++ b/libjava/gnu/awt/j2d/Graphics2DImpl.java
@@ -0,0 +1,545 @@
+/* Copyright (C) 2000, 2002, 2003 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package gnu.awt.j2d;
+
+import java.awt.Color;
+import java.awt.Composite;
+import java.awt.Image;
+import java.awt.Shape;
+import java.awt.Rectangle;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Paint;
+import java.awt.RenderingHints;
+import java.awt.Stroke;
+import java.awt.font.FontRenderContext;
+import java.awt.font.GlyphVector;
+import java.awt.geom.AffineTransform;
+import java.awt.image.ImageObserver;
+import java.awt.image.BufferedImage;
+import java.awt.image.BufferedImageOp;
+import java.awt.image.RenderedImage;
+import java.awt.image.renderable.RenderableImage;
+import java.text.AttributedCharacterIterator;
+import java.util.Map;
+
+/**
+ * Delegates almost all work to a state object, that allows us to
+ * hot-swap rendering strategies based on state changes inflicted on
+ * this Graphics object. This class keeps track of properties that are
+ * not affected by the state, (such as clip shape,
+ * foreground/background color, font, etc.).
+ *
+ * <p>The far front-end of the rendering pipeline consists of the
+ * Graphics2D API. In the far back-end, lies the native graphics
+ * libraries. In most cases the native graphics libraries only have
+ * direct support for a subset of the properties of Graphics2D. To
+ * make up missing features in the native graphics libraries, the
+ * pipeline between the front-end and the back-end need to translate
+ * drawing request to primitive operations that are supported by the
+ * back-end. E.g. for X11, drawing a straight line will translate to
+ * an XDrawLine, drawing a bezier curve will trigger flattening of the
+ * curve and will result in a call to XDrawLines.
+ *
+ * <p>This is the basic strategy for the rendering pipeline: Whenever
+ * a graphics property change occurs, that causes the current pipeline
+ * to be insufficient, amend or replace parts of the pipeline so that
+ * the pipeline will once again be able to translate requests to the
+ * set of primitives supported by the native graphics library.
+ *
+ * <p>Most graphics libraries share common subsets of
+ * functionality. To be able to reuse pieces of the rendering pipeline
+ * for several backends, we define interfaces that describe subsets of
+ * characteristics supported by the backends. A wrapper for the native
+ * library can implement several interfaces to describe its range of
+ * functionality.
+ *
+ * <p>Typically, most painting is done with a graphics object with
+ * simple properties. Unless one is using a complex Look & Feel, the
+ * painting of Swing components will never require affine transforms,
+ * alpha blending, non-rectangular clipping, etc. When graphics
+ * objects are created, they start off in a state where all the
+ * properties are simple. Most graphics objects experience only
+ * trivial property changes, and never leave this simple state. It is
+ * therefore wise to ensure that the rendering pipeline for this
+ * initial state is lean and as much as possible plugs directly into
+ * the backend.
+ *
+ * <p>The initial state for graphics object of most raster displays
+ * would call for two levels of indirection:
+ *
+ * <pre>
+ * Graphics2D object ---> IntegerGraphicsState ---> DirectRasterGraphics
+ * </pre>
+ */
+public class Graphics2DImpl extends Graphics2D implements Cloneable
+{
+ GraphicsConfiguration config;
+
+ AbstractGraphicsState state;
+
+ Color fg;
+ Color bg;
+
+ Font font;
+
+ public Graphics2DImpl(GraphicsConfiguration config)
+ {
+ this.config = config;
+ }
+
+ public void setState(AbstractGraphicsState state)
+ {
+ this.state = state;
+ this.state.setFrontend(this);
+ }
+
+ public Object clone()
+ {
+ try
+ {
+ Graphics2DImpl gfxCopy = (Graphics2DImpl) super.clone();
+ AbstractGraphicsState stateCopy =
+ (AbstractGraphicsState) state.clone();
+ gfxCopy.setState(stateCopy);
+
+ return gfxCopy;
+ }
+ catch (CloneNotSupportedException ex)
+ {
+ // This should never happen.
+ throw new InternalError ();
+ }
+ }
+
+
+ // -------- Graphics methods:
+
+ public Graphics create()
+ {
+ Graphics2DImpl gfxCopy = (Graphics2DImpl) clone();
+ return gfxCopy;
+ }
+
+ public Color getColor()
+ {
+ return fg;
+ }
+
+ public void setColor(Color color)
+ {
+ fg = color;
+ state.setColor(color);
+ }
+
+ public void setPaintMode()
+ {
+ state.setPaintMode();
+ }
+
+ public void setXORMode(Color altColor)
+ {
+ state.setXORMode(altColor);
+ }
+
+ public Font getFont()
+ {
+ return font;
+ }
+
+ public void setFont(Font font)
+ {
+ this.font = font;
+ state.setFont(font);
+ }
+
+ public FontMetrics getFontMetrics(Font font)
+ {
+ return state.getFontMetrics(font);
+ }
+
+ public Rectangle getClipBounds()
+ {
+ return state.getClipBounds();
+ }
+
+ public void clipRect(int x, int y, int width, int height)
+ {
+ Shape clip = state.getClip();
+ if (clip == null)
+ {
+ clip = new Rectangle (x,y,width,height);
+ setClip (clip);
+ return;
+ }
+ if (clip instanceof Rectangle)
+ {
+ Rectangle clipRect = (Rectangle) clip;
+ clip = clipRect.intersection(new Rectangle(x, y, width, height));
+ setClip(clip);
+ return;
+ }
+
+ String msg =
+ "intersecting current clip shape " + clip + " with new rectangle " +
+ "has not been implemented yet";
+ throw new UnsupportedOperationException(msg);
+ }
+
+ public void setClip(int x, int y, int width, int height)
+ {
+ Rectangle clip = new Rectangle(x, y, width, height);
+ setClip(clip);
+ }
+
+ public Shape getClip()
+ {
+ return state.getClip();
+ }
+
+ public void setClip(Shape clip)
+ {
+ state.setClip(clip);
+ }
+
+ public void copyArea(int x, int y, int width, int height,
+ int dx, int dy)
+ {
+ state.copyArea(x, y, width, height, dx, dy);
+ }
+
+ public void drawLine(int x1, int y1, int x2, int y2)
+ {
+ state.drawLine(x1, y1, x2, y2);
+ }
+
+ public void fillRect(int x, int y, int width, int height)
+ {
+ state.fillRect(x, y, width, height);
+ }
+
+ public void clearRect(int x, int y, int width, int height)
+ {
+ state.clearRect(x, y, width, height);
+ }
+
+ public void drawRoundRect(int x, int y, int width, int height,
+ int arcWidth, int arcHeight)
+ {
+ state.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
+ }
+
+ public void fillRoundRect(int x, int y, int width, int height,
+ int arcWidth, int arcHeight)
+ {
+ state.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
+ }
+
+ public void drawOval(int x, int y, int width, int height)
+ {
+ state.drawOval(x, y, width, height);
+ }
+
+ public void fillOval(int x, int y, int width, int height)
+ {
+ state.fillOval(x, y, width, height);
+ }
+
+ public void drawArc(int x, int y, int width, int height,
+ int startAngle, int arcAngle)
+ {
+ state.drawArc(x, y, width, height, startAngle, arcAngle);
+ }
+
+ public void fillArc(int x, int y, int width, int height,
+ int startAngle, int arcAngle)
+ {
+ state.fillArc(x, y, width, height, startAngle, arcAngle);
+ }
+
+ public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
+ {
+ state.drawPolyline(xPoints, yPoints, nPoints);
+ }
+
+ public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
+ {
+ state.drawPolygon(xPoints, yPoints, nPoints);
+ }
+
+ public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
+ {
+ state.fillPolygon(xPoints, yPoints, nPoints);
+ }
+
+ public boolean drawImage(Image image, int x, int y,
+ ImageObserver observer)
+ {
+ return state.drawImage(image, x, y, observer);
+ }
+
+ public boolean drawImage(Image img, int x, int y,
+ int width, int height,
+ ImageObserver observer)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public boolean drawImage(Image img, int x, int y, Color bgcolor,
+ ImageObserver observer)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public boolean drawImage(Image img, int x, int y,
+ int width, int height, Color bgcolor,
+ ImageObserver observer)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public boolean drawImage(Image img,
+ int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2,
+ ImageObserver observer)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public boolean drawImage(Image img,
+ int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2,
+ Color bgcolor, ImageObserver observer)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public void dispose()
+ {
+ AbstractGraphicsState lState = state;
+
+ state = null;
+ config = null;
+ font = null;
+ fg = null;
+ bg = null;
+
+ if (lState != null)
+ lState.dispose();
+ }
+
+
+
+ // -------- Graphics2D methods:
+
+ public void draw(Shape shape)
+ {
+ state.draw(shape);
+ }
+
+ public boolean drawImage(Image image, AffineTransform xform,
+ ImageObserver obs)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+
+ public void drawString(String text, int x, int y)
+ {
+ state.drawString(text, x, y);
+ }
+
+ public void drawString(String text, float x, float y)
+ {
+ state.drawString(text, x, y);
+ }
+
+ public void fill(Shape shape)
+ {
+ state.fill(shape);
+ }
+
+ public boolean hit(Rectangle rect, Shape text, boolean onStroke)
+ {
+ return state.hit(rect, text, onStroke);
+ }
+
+ public GraphicsConfiguration getDeviceConfiguration()
+ {
+ return config;
+ }
+
+ public void setPaint(Paint paint)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public void setRenderingHint(RenderingHints.Key hintKey,
+ Object hintValue)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public Object getRenderingHint(RenderingHints.Key hintKey)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public RenderingHints getRenderingHints()
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public void translate(int x, int y)
+ {
+ state.translate(x, y);
+ }
+
+ public void translate(double tx, double ty)
+ {
+ state.translate(tx, ty);
+ }
+
+ public void rotate(double theta)
+ {
+ state.rotate(theta);
+ }
+
+ public void rotate(double theta, double x, double y)
+ {
+ state.rotate(theta, x, y);
+ }
+
+ public void scale(double scaleX, double scaleY)
+ {
+ state.scale(scaleX, scaleY);
+ }
+
+ public void shear(double shearX, double shearY)
+ {
+ state.shear(shearX, shearY);
+ }
+
+ public void transform(AffineTransform Tx)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public void setTransform(AffineTransform Tx)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public AffineTransform getTransform()
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public Paint getPaint()
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public void setBackground(Color color)
+ {
+ bg = color;
+ }
+
+ public Color getBackground()
+ {
+ return bg;
+ }
+
+ public void clip(Shape shape)
+ {
+ Shape clip = state.getClip();
+
+ if ((shape instanceof Rectangle) && (clip instanceof Rectangle))
+ {
+ clip = ((Rectangle) clip).intersection((Rectangle) shape);
+ state.setClip(clip);
+ return;
+ }
+
+ String msg =
+ "intersecting current clip shape " + clip + " with new shape " + shape +
+ "has not been implemented yet";
+ throw new UnsupportedOperationException(msg);
+ }
+
+ public void drawImage(BufferedImage image, BufferedImageOp op, int x, int y)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public void drawRenderedImage(RenderedImage image, AffineTransform xform)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public void drawRenderableImage(RenderableImage image, AffineTransform xform)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public void drawString(AttributedCharacterIterator iterator,
+ int x, int y)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public void drawString(AttributedCharacterIterator iterator, float x,
+ float y)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public void setComposite(Composite comp)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public void setStroke(Stroke stroke)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public void setRenderingHints(Map hints)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public void addRenderingHints(Map hints)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public Composite getComposite()
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public Stroke getStroke()
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public FontRenderContext getFontRenderContext ()
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public void drawGlyphVector (GlyphVector g, float x, float y)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+}
diff --git a/libjava/gnu/awt/j2d/IntegerGraphicsState$ScreenCoupledImage.h b/libjava/gnu/awt/j2d/IntegerGraphicsState$ScreenCoupledImage.h
new file mode 100644
index 000000000..eaa7c93a8
--- /dev/null
+++ b/libjava/gnu/awt/j2d/IntegerGraphicsState$ScreenCoupledImage.h
@@ -0,0 +1,39 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_awt_j2d_IntegerGraphicsState$ScreenCoupledImage__
+#define __gnu_awt_j2d_IntegerGraphicsState$ScreenCoupledImage__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace awt
+ {
+ namespace j2d
+ {
+ class IntegerGraphicsState$ScreenCoupledImage;
+ }
+ }
+ }
+ namespace java
+ {
+ namespace awt
+ {
+ class GraphicsConfiguration;
+ }
+ }
+}
+
+class gnu::awt::j2d::IntegerGraphicsState$ScreenCoupledImage : public ::java::lang::Object
+{
+
+public:
+ virtual ::java::awt::GraphicsConfiguration * getGraphicsConfiguration() = 0;
+ static ::java::lang::Class class$;
+} __attribute__ ((java_interface));
+
+#endif // __gnu_awt_j2d_IntegerGraphicsState$ScreenCoupledImage__
diff --git a/libjava/gnu/awt/j2d/IntegerGraphicsState.h b/libjava/gnu/awt/j2d/IntegerGraphicsState.h
new file mode 100644
index 000000000..9a2260993
--- /dev/null
+++ b/libjava/gnu/awt/j2d/IntegerGraphicsState.h
@@ -0,0 +1,94 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_awt_j2d_IntegerGraphicsState__
+#define __gnu_awt_j2d_IntegerGraphicsState__
+
+#pragma interface
+
+#include <gnu/awt/j2d/AbstractGraphicsState.h>
+#include <gcj/array.h>
+
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace awt
+ {
+ namespace j2d
+ {
+ class DirectRasterGraphics;
+ class IntegerGraphicsState;
+ }
+ }
+ }
+ namespace java
+ {
+ namespace awt
+ {
+ class Color;
+ class Font;
+ class FontMetrics;
+ class Image;
+ class Rectangle;
+ class Shape;
+ namespace image
+ {
+ class ImageObserver;
+ }
+ }
+ }
+}
+
+class gnu::awt::j2d::IntegerGraphicsState : public ::gnu::awt::j2d::AbstractGraphicsState
+{
+
+public:
+ IntegerGraphicsState(::gnu::awt::j2d::DirectRasterGraphics *);
+ virtual ::java::lang::Object * clone();
+ virtual void dispose();
+ virtual void setColor(::java::awt::Color *);
+ virtual void setPaintMode();
+ virtual void setXORMode(::java::awt::Color *);
+ virtual void setFont(::java::awt::Font *);
+ virtual ::java::awt::FontMetrics * getFontMetrics(::java::awt::Font *);
+ virtual void setClip(::java::awt::Shape *);
+ virtual ::java::awt::Shape * getClip();
+ virtual ::java::awt::Rectangle * getClipBounds();
+ virtual void copyArea(jint, jint, jint, jint, jint, jint);
+ virtual void drawLine(jint, jint, jint, jint);
+ virtual void fillRect(jint, jint, jint, jint);
+ virtual void clearRect(jint, jint, jint, jint);
+ virtual void drawRoundRect(jint, jint, jint, jint, jint, jint);
+ virtual void fillRoundRect(jint, jint, jint, jint, jint, jint);
+ virtual void drawOval(jint, jint, jint, jint);
+ virtual void fillOval(jint, jint, jint, jint);
+ virtual void drawArc(jint, jint, jint, jint, jint, jint);
+ virtual void fillArc(jint, jint, jint, jint, jint, jint);
+ virtual void drawPolyline(JArray< jint > *, JArray< jint > *, jint);
+ virtual void drawPolygon(JArray< jint > *, JArray< jint > *, jint);
+ virtual void fillPolygon(JArray< jint > *, JArray< jint > *, jint);
+ virtual jboolean drawImage(::java::awt::Image *, jint, jint, ::java::awt::image::ImageObserver *);
+ virtual void draw(::java::awt::Shape *);
+ virtual void fill(::java::awt::Shape *);
+ virtual jboolean hit(::java::awt::Rectangle *, ::java::awt::Shape *, jboolean);
+ virtual void drawString(::java::lang::String *, jint, jint);
+ virtual void drawString(::java::lang::String *, jfloat, jfloat);
+ virtual void translate(jint, jint);
+ virtual void translate(jdouble, jdouble);
+ virtual void rotate(jdouble);
+ virtual void rotate(jdouble, jdouble, jdouble);
+ virtual void scale(jdouble, jdouble);
+ virtual void shear(jdouble, jdouble);
+private:
+ void needAffineTransform();
+public: // actually package-private
+ jint __attribute__((aligned(__alignof__( ::gnu::awt::j2d::AbstractGraphicsState)))) tx;
+ jint ty;
+ ::gnu::awt::j2d::DirectRasterGraphics * directGfx;
+ ::java::awt::Shape * clip;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_awt_j2d_IntegerGraphicsState__
diff --git a/libjava/gnu/awt/j2d/IntegerGraphicsState.java b/libjava/gnu/awt/j2d/IntegerGraphicsState.java
new file mode 100644
index 000000000..bcfacd008
--- /dev/null
+++ b/libjava/gnu/awt/j2d/IntegerGraphicsState.java
@@ -0,0 +1,427 @@
+/* Copyright (C) 2000, 2003 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package gnu.awt.j2d;
+
+import java.awt.Color;
+import java.awt.Image;
+import java.awt.Shape;
+import java.awt.Rectangle;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsConfiguration;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.image.BufferedImage;
+import java.awt.image.ImageObserver;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+import java.awt.image.ColorModel;
+
+/**
+ * IntegerGraphicsState is one of several graphics state
+ * implementations. This graphics state is used when the graphics
+ * object has simple properties, (coordinate translation only, no
+ * transform) and the backend supports integer coordinates (pixel
+ * based). For primitive paint operations, this object translates the
+ * coordinates and forwards the request to the backend. For requests
+ * to draw arbitrary shapes and paths, this object translates the
+ * requests to primitive drawing operations supported by the
+ * backend. IntegerGraphicsState is meant to support the most common
+ * state of an graphics object. The degree of functionality is roughly
+ * equivalent with the old java.awt.Graphics API.
+ */
+public class IntegerGraphicsState extends AbstractGraphicsState
+{
+ int tx;
+ int ty;
+
+ DirectRasterGraphics directGfx;
+ Shape clip;
+
+ /** Interface for images which are coupled to a GraphicsConfiguration,
+ * as is typically the case for an off-screen buffer used in
+ * double-buffering. Any image which implements this interface is
+ * rendered directly by DirectRasterGraphics (i.e. by directGfx.drawImage)
+ */
+ public interface ScreenCoupledImage
+ {
+ /** Get the GraphicsConfiguration to which this image is coupled
+ * @return the GraphicsConfiguration
+ */
+ GraphicsConfiguration getGraphicsConfiguration ();
+ }
+
+ public IntegerGraphicsState(DirectRasterGraphics directGfx)
+ {
+ this.directGfx = directGfx;
+ }
+
+ public Object clone()
+ {
+ IntegerGraphicsState clone = (IntegerGraphicsState) super.clone();
+ clone.directGfx = (DirectRasterGraphics) directGfx.clone();
+
+ return clone;
+ }
+
+ public void dispose()
+ {
+ DirectRasterGraphics lDeviceGfx = directGfx;
+
+ directGfx = null;
+
+ if (lDeviceGfx != null)
+ lDeviceGfx.dispose();
+
+ super.dispose();
+ }
+
+ // -------- Graphics methods:
+
+ public void setColor(Color color)
+ {
+ directGfx.setColor(color);
+ }
+
+ public void setPaintMode()
+ {
+ directGfx.setPaintMode();
+ }
+
+ public void setXORMode(Color altColor)
+ {
+ directGfx.setXORMode(altColor);
+ }
+
+ public void setFont(Font font)
+ {
+ directGfx.setFont(font);
+ }
+
+ public FontMetrics getFontMetrics(Font font)
+ {
+ return directGfx.getFontMetrics(font);
+ }
+
+ public void setClip(Shape clip)
+ {
+ if (clip instanceof Rectangle)
+ {
+ Rectangle clipRect = (Rectangle) ((Rectangle) clip).clone();
+ clipRect.x += tx;
+ clipRect.y += ty;
+
+ this.clip = clipRect;
+
+ directGfx.setClip(clipRect);
+ return;
+ }
+
+ String msg =
+ "translating clip shape " + clip + " into device " +
+ "coordinate space has not been implemented yet";
+
+ throw new UnsupportedOperationException(msg);
+ }
+
+ public Shape getClip()
+ {
+ if (clip == null)
+ return null;
+ if (clip instanceof Rectangle)
+ {
+ Rectangle clipRect = (Rectangle) ((Rectangle) clip).clone();
+ clipRect.x -= tx;
+ clipRect.y -= ty;
+ return clipRect;
+ }
+
+ String msg =
+ "translating clip shape " + clip + " into user " +
+ "coordinate space has not been implemented yet";
+
+ throw new UnsupportedOperationException(msg);
+ }
+
+ public Rectangle getClipBounds()
+ {
+ if (clip == null)
+ return null;
+ Rectangle clipRect = clip.getBounds();
+
+ clipRect.x -= tx;
+ clipRect.y -= ty;
+ return clipRect;
+ }
+
+ public void copyArea(int x, int y,
+ int width, int height,
+ int dx, int dy)
+ {
+ directGfx.copyArea(x+tx, y+ty, width, height, dx, dy);
+ }
+
+ public void drawLine(int x1, int y1,
+ int x2, int y2)
+ {
+ directGfx.drawLine(x1+tx, y1+ty, x2+tx, y2+ty);
+ }
+
+ public void fillRect(int x, int y,
+ int width, int height)
+ {
+ directGfx.fillRect(x+tx, y+ty, width, height);
+ }
+
+ public void clearRect(int x, int y,
+ int width, int height)
+ {
+ directGfx.setColor(frontend.getBackground());
+ directGfx.fillRect(x+tx, y+ty, width, height);
+ directGfx.setColor(frontend.getColor());
+ }
+
+ public void drawRoundRect(int x, int y,
+ int width, int height,
+ int arcWidth, int arcHeight)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public void fillRoundRect(int x, int y,
+ int width, int height,
+ int arcWidth, int arcHeight)
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+
+ public void drawOval(int x, int y,
+ int width, int height)
+ {
+ drawArc (x, y, width, height, 0, 360);
+ }
+
+ public void fillOval(int x, int y,
+ int width, int height)
+ {
+ fillArc (x, y, width, height, 0, 360);
+ }
+
+ public void drawArc(int x, int y,
+ int width, int height,
+ int startAngle, int arcAngle)
+ {
+ directGfx.drawArc(x+tx, y+ty, width, height, startAngle, arcAngle);
+ }
+
+ public void fillArc(int x, int y,
+ int width, int height,
+ int startAngle, int arcAngle)
+ {
+ directGfx.fillArc(x+tx, y+ty, width, height, startAngle, arcAngle);
+ }
+
+ public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
+ {
+ if ((tx == 0) && (ty == 0))
+ {
+ directGfx.drawPolyline(xPoints, yPoints, nPoints);
+ return;
+ }
+
+ throw new UnsupportedOperationException("translate not implemented");
+ }
+
+ public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
+ {
+ if ((tx == 0) && (ty == 0))
+ {
+ directGfx.drawPolygon(xPoints, yPoints, nPoints);
+ return;
+ }
+
+ throw new UnsupportedOperationException("translate not implemented");
+ }
+
+ public void fillPolygon (int[] xPoints, int[] yPoints, int nPoints)
+ {
+ // FIXME: remove tx & ty args once translation via AffineTransform
+ // is implemented.
+ directGfx.fillPolygon (xPoints, yPoints, nPoints, tx, ty);
+ }
+
+ public boolean drawImage(Image image, int x, int y,
+ ImageObserver observer)
+ {
+ x += tx;
+ y += ty;
+
+ if (image instanceof ScreenCoupledImage)
+ {
+ GraphicsConfiguration config
+ = ((ScreenCoupledImage)image).getGraphicsConfiguration ();
+ if (config == frontend.config)
+ return directGfx.drawImage (image, x, y, observer);
+ }
+ if (image instanceof BufferedImage)
+ {
+ BufferedImage bImage = (BufferedImage) image;
+ // FIXME: eliminate? ScreenCoupledImage is probably more efficient
+ Object config = bImage.getProperty ("java.awt.GraphicsConfiguration");
+ if (config == frontend.config)
+ return directGfx.drawImage (image, x, y, observer);
+
+ int width = image.getWidth (null);
+ int height = image.getHeight (null);
+
+ Rectangle bounds = new Rectangle (x, y, width, height);
+
+ MappedRaster mr = directGfx.mapRaster (bounds);
+
+ // manipulate raster here...
+ ColorModel colorModel = mr.getColorModel ();
+ WritableRaster raster = mr.getRaster ();
+
+ int xEnd = x + width;
+ int yEnd = y + height;
+
+ // FIXME: Use the following code only as a fallback. It's SLOW!
+
+ Object rgbElem = null;
+ for (int yy=0; yy<height; yy++)
+ {
+ for (int xx=0; xx<width; xx++)
+ {
+ int srgb = bImage.getRGB (xx, yy);
+ int sa = ((srgb >>> 24) & 0xff) + 1;
+ int sr = ((srgb >>> 16) & 0xff) + 1;
+ int sg = ((srgb >>> 8) & 0xff) + 1;
+ int sb = (srgb & 0xff) + 1;
+
+ rgbElem = raster.getDataElements (xx+x, yy+y, rgbElem);
+ int drgb = colorModel.getRGB (rgbElem);
+ int dr = ((drgb >>> 16) & 0xff) + 1;
+ int dg = ((drgb >>> 8) & 0xff) + 1;
+ int db = (drgb & 0xff) + 1;
+ int da = 256 - sa;
+
+ dr = ((sr*sa + dr*da) >>> 8) - 1;
+ dg = ((sg*sa + dg*da) >>> 8) - 1;
+ db = ((sb*sa + db*da) >>> 8) - 1;
+
+ drgb = (dr<<16) | (dg<<8) | db;
+
+ rgbElem = colorModel.getDataElements (drgb, rgbElem);
+
+ raster.setDataElements (xx+x, yy+y, rgbElem);
+ }
+ }
+ directGfx.unmapRaster (mr);
+ return true;
+
+ }
+ throw new UnsupportedOperationException ("drawing image " + image +
+ "not implemented");
+ }
+
+
+ // -------- Graphics2D methods:
+
+ public void draw(Shape shape)
+ {
+ if (shape instanceof Rectangle)
+ {
+ Rectangle rect = (Rectangle) shape;
+ directGfx.drawRect(rect.x+tx, rect.y+ty, rect.width, rect.height);
+ return;
+ }
+
+ throw new UnsupportedOperationException("shape not implemented");
+ }
+
+ public void fill(Shape shape)
+ {
+ if (shape instanceof Rectangle)
+ {
+ Rectangle rect = (Rectangle) shape;
+ directGfx.fillRect(rect.x+tx, rect.y+ty, rect.width, rect.height);
+ return;
+ }
+
+ throw new UnsupportedOperationException("not implemented");
+ }
+
+ public boolean hit(Rectangle rect, Shape text,
+ boolean onStroke)
+ {
+ throw new UnsupportedOperationException("not implemented");
+ }
+
+ public void drawString(String text, int x, int y)
+ {
+ directGfx.drawString(text, x+tx, y+ty);
+ }
+
+ public void drawString(String text, float x, float y)
+ {
+ drawString(text, (int) x, (int) y);
+ }
+
+ public void translate(int x, int y)
+ {
+ tx += x;
+ ty += y;
+ }
+
+ public void translate(double tx, double ty)
+ {
+ if ((tx == 0) && (ty == 0))
+ return;
+
+ needAffineTransform();
+ }
+
+ public void rotate(double theta)
+ {
+ if (theta == 0)
+ return;
+
+ needAffineTransform();
+ }
+
+ public void rotate(double theta, double x, double y)
+ {
+ if (theta == 0)
+ return;
+
+ needAffineTransform();
+ }
+
+ public void scale(double scaleX, double scaleY)
+ {
+ if ((scaleX == 1) && (scaleY == 1))
+ return;
+
+ needAffineTransform();
+ }
+
+ public void shear(double shearX, double shearY)
+ {
+ if ((shearX == 0) && (shearY == 0))
+ return;
+
+ needAffineTransform();
+ }
+
+ private void needAffineTransform()
+ {
+ throw new UnsupportedOperationException("state with affine " +
+ "transform not implemented");
+ }
+}
diff --git a/libjava/gnu/awt/j2d/MappedRaster.h b/libjava/gnu/awt/j2d/MappedRaster.h
new file mode 100644
index 000000000..ab5a81e4b
--- /dev/null
+++ b/libjava/gnu/awt/j2d/MappedRaster.h
@@ -0,0 +1,49 @@
+
+// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
+
+#ifndef __gnu_awt_j2d_MappedRaster__
+#define __gnu_awt_j2d_MappedRaster__
+
+#pragma interface
+
+#include <java/lang/Object.h>
+extern "Java"
+{
+ namespace gnu
+ {
+ namespace awt
+ {
+ namespace j2d
+ {
+ class MappedRaster;
+ }
+ }
+ }
+ namespace java
+ {
+ namespace awt
+ {
+ namespace image
+ {
+ class ColorModel;
+ class WritableRaster;
+ }
+ }
+ }
+}
+
+class gnu::awt::j2d::MappedRaster : public ::java::lang::Object
+{
+
+public:
+ MappedRaster(::java::awt::image::WritableRaster *, ::java::awt::image::ColorModel *);
+ virtual ::java::awt::image::WritableRaster * getRaster();
+ virtual ::java::awt::image::ColorModel * getColorModel();
+public: // actually package-private
+ ::java::awt::image::WritableRaster * __attribute__((aligned(__alignof__( ::java::lang::Object)))) raster;
+ ::java::awt::image::ColorModel * cm;
+public:
+ static ::java::lang::Class class$;
+};
+
+#endif // __gnu_awt_j2d_MappedRaster__
diff --git a/libjava/gnu/awt/j2d/MappedRaster.java b/libjava/gnu/awt/j2d/MappedRaster.java
new file mode 100644
index 000000000..eb41eecf9
--- /dev/null
+++ b/libjava/gnu/awt/j2d/MappedRaster.java
@@ -0,0 +1,72 @@
+/* Copyright (C) 2000 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+package gnu.awt.j2d;
+
+import java.awt.image.WritableRaster;
+import java.awt.image.ColorModel;
+
+/* The raster and associated properties of a mapped screen region.
+ * The compositing capabilities of backends are often insufficient.
+ * The backend may not support alpha blending, or may not support some
+ * other special compositing rule. This means that compositing must
+ * sometimes be done within the rendering pipeline. The general
+ * compositing operation consists of combining new color and alpha
+ * values with existing color values on the drawing surface, to find
+ * the new color values for the drawing surface. The way the values
+ * are combined, determines what kind of compositing operation that is
+ * performed. The default compositing operation is alpha compositing.
+ *
+ * <p>In order to perform alpha compositing and other compositing
+ * operations, we need access to the color values of the imagery that
+ * has already been drawn on the drawing surface. The
+ * DirectRasterGraphics interface must therefore contain methods that
+ * makes it possible to gain access to the pixel values of the drawing
+ * surface. The methods are modeled after the POSIX mmap() and
+ * munmap() functions. But, instead of mapping and unmapping portions
+ * of data from a file descriptor to memory, the methods in
+ * DirectRasterGraphics maps and unmaps portions of the drawing
+ * surface to data arrays within writable raster objects. A call to
+ * mapRaster() will return a writable raster object, encapsulating the
+ * image data of the drawing surface in the requested domain. The data
+ * encapsulated by this raster object can be modified using the
+ * WritableRaster API, or the data buffers can be retrieved from the
+ * raster, so that the data arrays can be manipulated directly. When
+ * the raster image has been modified as desired, the data can be
+ * resynchronized with the drawing surface by calling mapRaster().
+ *
+ * <p>As with mmap() and munmap() the methods may work by direct
+ * manipulation of shared memory, (i.e. the raster object directly
+ * wraps the actual image data of the drawing surface), or may make a
+ * private copy that is resynched when the raster is unmapped. The
+ * backend may choose to implement either mechanism, and the pipeline
+ * code should not care what mechanism is actually used. This design
+ * allows us to make full use of speedups such as X shared memory
+ * extentions when available.
+ */
+public class MappedRaster
+{
+ WritableRaster raster;
+ ColorModel cm;
+
+ public MappedRaster(WritableRaster raster, ColorModel cm)
+ {
+ this.raster = raster;
+ this.cm = cm;
+ }
+
+ public final WritableRaster getRaster()
+ {
+ return raster;
+ }
+
+ public final ColorModel getColorModel()
+ {
+ return cm;
+ }
+}