summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2006-05-07 13:33:22 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2006-05-07 13:33:22 +0000
commitc4be634aa844b6a8771d11a441d515ce27db5de7 (patch)
tree7ce7728950f5061d3031cfbdcbd7504c63111a86
parent1b6001f3823317cffe0aa3e79d0abb1e44457497 (diff)
downloadclasspath-c4be634aa844b6a8771d11a441d515ce27db5de7.tar.gz
2006-05-07 Roman Kennke <kennke@aicas.com>
* gnu/java/awt/java2d/RasterGraphics.java: New file. 2006-05-07 Roman Kennke <kennke@aicas.com> * gnu/java/awt/java2d/AbstractGraphics2D.java (fillShape): Determine user space bounds of shape and feed them into the actual rendering pipeline. (rawSetPixel): Made non-abstract for now. Maybe remove later. (rawSetForeground): Likewise. (getDestinationColorModel): Removed. (getDeviceBounds): Made non-abstract. Provide useful default impl. (rawFillShape): Handle paint context. (fillScanline): Implement painting and compositing. (fillShapeAntialias): Handle paint context. (fillScanlineAA): Implemented preliminary antialiasing based on composite context. Not working yet. (fillScanlineAlpha): Removed. (init): Fetch destination raster. (getDestinationRaster): New abstract method. (updateRaster): New backend method. 2006-05-07 Roman Kennke <kennke@aicas.com> * gnu/java/awt/java2d/AlphaCompositeContext.java (compose): Fixed loops, conditions and logic to make compositing work correctly. 2006-05-05 Roman Kennke <kennke@aicas.com> * java/awt/image/ColorModel.java (getNormalizedComponents): Implemented. 2006-05-05 Roman Kennke <kennke@aicas.com> * javax/swing/plaf/basic/BasicRadioButtonUI.java (paint): Query the button model for it's state, not the button itself. 2006-05-05 Roman Kennke <kennke@aicas.com> * javax/swing/JTable.java (tableChanged): Sync selection model with table model changes. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/plaf/basic/BasicButtonListener.java (mouseEntered): Fixed conditions for changing states. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/JOptionPane.java (AccessibleJOptionPane.getAccessibleRole): Implemented method. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/JLabel.java (AccessibleJLabel.getSelectedText): Return null instead of "". (AccessibleJLabel.getSelectionStart): Added comment why return -1 is correct here. (AccessibleJLabel.getSelectionEnd): Added comment why return -1 is correct here. (AccessibleJLabel.getCharacterAttribute): Added comment about what to do here. (AccessibleJLabel.getCharCount): Added comment about what to do here. (AccessibleJLabel.getCharacterBounds): Tagged as not implemented. (AccessibleJLabel.getIndexAtPoint): Tagged as not implemented. (paramString): Return super.paramString() here, this provides a more meaningful output. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/JComponent.java (paint): Added null check to avoid NPE when clip == null. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/AbstractButton.java (addImpl): New method. Installs an OverlayLayout if no other layout has been installed before. (setLayout): New method. Detect if a client app installs a custom layout. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/table/DefaultTableCellModel.java (noFocusBorder): Fixed width of empty border to 1. (getTableCellRendererComponent): Don't change the colors for focuses cells. Fixed border for focused cells. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/JTable.java (moveToCellBeingEdited): Adjust bounding box of editing component to exactly cover the grid. * javax/swing/plaf/basic/BasicTableUI.java (paint): Paint grid to the bottom and right of the cells instead of left and top. Adjust bounding box of cells accordingly. * javax/swing/plaf/metal/MetalLookAndFeel.java (initComponentDefaults): Fixed color of JTable selection border. * javax/swing/plaf/metal/OceanTheme.java (addCustomEntriesToTable): Fixed color of JTable selection border.
-rw-r--r--ChangeLog109
-rw-r--r--gnu/java/awt/java2d/AbstractGraphics2D.java202
-rw-r--r--gnu/java/awt/java2d/AlphaCompositeContext.java58
-rw-r--r--gnu/java/awt/java2d/RasterGraphics.java101
-rw-r--r--java/awt/image/ColorModel.java4
-rw-r--r--javax/swing/JLabel.java23
-rw-r--r--javax/swing/JOptionPane.java17
-rw-r--r--javax/swing/plaf/basic/BasicRadioButtonUI.java12
8 files changed, 370 insertions, 156 deletions
diff --git a/ChangeLog b/ChangeLog
index d01e0d25f..5cbcdd254 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,112 @@
+2006-05-07 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/java2d/RasterGraphics.java: New file.
+
+2006-05-07 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/java2d/AbstractGraphics2D.java
+ (fillShape): Determine user space bounds of shape and feed them
+ into the actual rendering pipeline.
+ (rawSetPixel): Made non-abstract for now. Maybe remove later.
+ (rawSetForeground): Likewise.
+ (getDestinationColorModel): Removed.
+ (getDeviceBounds): Made non-abstract. Provide useful default impl.
+ (rawFillShape): Handle paint context.
+ (fillScanline): Implement painting and compositing.
+ (fillShapeAntialias): Handle paint context.
+ (fillScanlineAA): Implemented preliminary antialiasing based on
+ composite context. Not working yet.
+ (fillScanlineAlpha): Removed.
+ (init): Fetch destination raster.
+ (getDestinationRaster): New abstract method.
+ (updateRaster): New backend method.
+
+2006-05-07 Roman Kennke <kennke@aicas.com>
+
+ * gnu/java/awt/java2d/AlphaCompositeContext.java
+ (compose): Fixed loops, conditions and logic to make compositing
+ work correctly.
+
+2006-05-05 Roman Kennke <kennke@aicas.com>
+
+ * java/awt/image/ColorModel.java
+ (getNormalizedComponents): Implemented.
+
+2006-05-05 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicRadioButtonUI.java
+ (paint): Query the button model for it's state, not the
+ button itself.
+
+2006-05-05 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JTable.java
+ (tableChanged): Sync selection model with table model changes.
+
+2006-05-04 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/plaf/basic/BasicButtonListener.java
+ (mouseEntered): Fixed conditions for changing states.
+
+2006-05-04 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JOptionPane.java
+ (AccessibleJOptionPane.getAccessibleRole): Implemented method.
+
+2006-05-04 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JLabel.java
+ (AccessibleJLabel.getSelectedText): Return null instead of "".
+ (AccessibleJLabel.getSelectionStart): Added comment why
+ return -1 is correct here.
+ (AccessibleJLabel.getSelectionEnd): Added comment why
+ return -1 is correct here.
+ (AccessibleJLabel.getCharacterAttribute): Added comment about
+ what to do here.
+ (AccessibleJLabel.getCharCount): Added comment about what
+ to do here.
+ (AccessibleJLabel.getCharacterBounds): Tagged as not
+ implemented.
+ (AccessibleJLabel.getIndexAtPoint): Tagged as not implemented.
+ (paramString): Return super.paramString() here, this provides
+ a more meaningful output.
+
+2006-05-04 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (paint): Added null check to avoid NPE when clip == null.
+
+2006-05-04 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/AbstractButton.java
+ (addImpl): New method. Installs an OverlayLayout if no
+ other layout has been installed before.
+ (setLayout): New method. Detect if a client app installs a
+ custom layout.
+
+2006-05-04 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/table/DefaultTableCellModel.java
+ (noFocusBorder): Fixed width of empty border to 1.
+ (getTableCellRendererComponent): Don't change the colors for
+ focuses cells. Fixed border for focused cells.
+
+2006-05-04 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JTable.java
+ (moveToCellBeingEdited): Adjust bounding box
+ of editing component to exactly cover the grid.
+ * javax/swing/plaf/basic/BasicTableUI.java
+ (paint): Paint grid to the bottom and right of
+ the cells instead of left and top. Adjust bounding
+ box of cells accordingly.
+ * javax/swing/plaf/metal/MetalLookAndFeel.java
+ (initComponentDefaults): Fixed color of JTable
+ selection border.
+ * javax/swing/plaf/metal/OceanTheme.java
+ (addCustomEntriesToTable): Fixed color of JTable
+ selection border.
+
2006-05-04 Raif S. Naffah <raif@swiftdsl.com.au>
* tools/gnu/classpath/tools/keytool/ExportCmd.java (setup):
diff --git a/gnu/java/awt/java2d/AbstractGraphics2D.java b/gnu/java/awt/java2d/AbstractGraphics2D.java
index d89158c5e..e93c43e08 100644
--- a/gnu/java/awt/java2d/AbstractGraphics2D.java
+++ b/gnu/java/awt/java2d/AbstractGraphics2D.java
@@ -42,12 +42,14 @@ import java.awt.AlphaComposite;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Composite;
+import java.awt.CompositeContext;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Paint;
+import java.awt.PaintContext;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.RenderingHints;
@@ -73,6 +75,7 @@ import java.awt.image.ColorModel;
import java.awt.image.ImageObserver;
import java.awt.image.Raster;
import java.awt.image.RenderedImage;
+import java.awt.image.WritableRaster;
import java.awt.image.renderable.RenderableImage;
import java.text.AttributedCharacterIterator;
import java.util.ArrayList;
@@ -148,6 +151,12 @@ public abstract class AbstractGraphics2D
private int[] pixel;
/**
+ * The raster of the destination surface. This is where the painting is
+ * performed.
+ */
+ private WritableRaster destinationRaster;
+
+ /**
* Stores the alpha values for a scanline in the anti-aliasing shape
* renderer.
*/
@@ -1154,6 +1163,8 @@ public abstract class AbstractGraphics2D
antialias = (v == RenderingHints.VALUE_ANTIALIAS_ON);
}
+ Rectangle2D userBounds = s.getBounds2D();
+
// Flatten the path. TODO: Determine the best flattening factor
// wrt to speed and quality.
PathIterator path = s.getPathIterator(getTransform(), 1.0);
@@ -1210,9 +1221,9 @@ public abstract class AbstractGraphics2D
if (segs.size() > 0)
{
if (antialias)
- fillShapeAntialias(segs, minX, minY, maxX, maxY);
+ fillShapeAntialias(segs, minX, minY, maxX, maxY, userBounds);
else
- rawFillShape(segs, minX, minY, maxX, maxY);
+ rawFillShape(segs, minX, minY, maxX, maxY, userBounds);
}
}
@@ -1243,14 +1254,20 @@ public abstract class AbstractGraphics2D
* @param x the x coordinate
* @param y the y coordinate
*/
- protected abstract void rawSetPixel(int x, int y);
+ protected void rawSetPixel(int x, int y)
+ {
+ // FIXME: Provide default implementation or remove method.
+ }
/**
* Sets the foreground color for drawing.
*
* @param c the color to set
*/
- protected abstract void rawSetForeground(Color c);
+ protected void rawSetForeground(Color c)
+ {
+ // Probably remove method.
+ }
protected void rawSetForeground(int r, int g, int b)
{
@@ -1265,18 +1282,14 @@ public abstract class AbstractGraphics2D
protected abstract ColorModel getColorModel();
/**
- * Returns the color model of the target device.
- *
- * @return the color model of the target device
- */
- protected abstract ColorModel getDestinationColorModel();
-
- /**
* Returns the bounds of the target.
*
* @return the bounds of the target
*/
- protected abstract Rectangle getDeviceBounds();
+ protected Rectangle getDeviceBounds()
+ {
+ return destinationRaster.getBounds();
+ }
/**
* Returns the bounds of the drawing area in user space.
@@ -1391,7 +1404,7 @@ public abstract class AbstractGraphics2D
* The polygon is already clipped when this method is called.
*/
protected void rawFillShape(ArrayList segs, double minX, double minY,
- double maxX, double maxY)
+ double maxX, double maxY, Rectangle2D userBounds)
{
// This is an implementation of a polygon scanline conversion algorithm
// described here:
@@ -1399,6 +1412,13 @@ public abstract class AbstractGraphics2D
// Create table of all edges.
// The edge buckets, sorted and indexed by their Y values.
+
+ Rectangle deviceBounds = new Rectangle((int) minX, (int) minY,
+ (int) Math.ceil(maxX) - (int) minX,
+ (int) Math.ceil(maxY) - (int) minY);
+ PaintContext pCtx = paint.createContext(getColorModel(), deviceBounds,
+ userBounds, transform, renderingHints);
+
ArrayList[] edgeTable = new ArrayList[(int) Math.ceil(maxY)
- (int) Math.ceil(minY) + 1];
@@ -1492,7 +1512,7 @@ public abstract class AbstractGraphics2D
{
int x0 = (int) previous.xIntersection;
int x1 = (int) edge.xIntersection;
- fillScanline(x0, x1, y);
+ fillScanline(pCtx, x0, x1, y);
previous = edge;
active = false;
}
@@ -1507,6 +1527,7 @@ public abstract class AbstractGraphics2D
}
}
}
+ pCtx.dispose();
}
/**
@@ -1516,16 +1537,16 @@ public abstract class AbstractGraphics2D
* @param x1 the right offset
* @param y the scanline
*/
- protected void fillScanline(int x0, int x1, int y)
+ protected void fillScanline(PaintContext pCtx, int x0, int x1, int y)
{
- if (paint instanceof Color && composite == AlphaComposite.SrcOver)
- {
- rawDrawLine(x0, y, x1, y);
- }
- else
- {
- throw new UnsupportedOperationException("Not yet implemented.");
- }
+ Raster paintRaster = pCtx.getRaster(x0, y, x1 - x0, 1);
+ ColorModel paintColorModel = pCtx.getColorModel();
+ CompositeContext cCtx = composite.createContext(paintColorModel,
+ getColorModel(),
+ renderingHints);
+ cCtx.compose(paintRaster, destinationRaster, destinationRaster);
+ updateRaster(destinationRaster, x0, y, x1 - x0, 1);
+ cCtx.dispose();
}
/**
@@ -1538,14 +1559,22 @@ public abstract class AbstractGraphics2D
* @param maxY the bounding box, lower Y
*/
private void fillShapeAntialias(ArrayList segs, double minX, double minY,
- double maxX, double maxY)
+ double maxX, double maxY,
+ Rectangle2D userBounds)
{
// This is an implementation of a polygon scanline conversion algorithm
// described here:
// http://www.cs.berkeley.edu/~ug/slide/pipeline/assignments/scan/
// The antialiasing is implemented using a sampling technique, we do
// not scan whole lines but fractions of the line.
-
+
+ Rectangle deviceBounds = new Rectangle((int) minX, (int) minY,
+ (int) Math.ceil(maxX) - (int) minX,
+ (int) Math.ceil(maxY) - (int) minY);
+ PaintContext pCtx = paint.createContext(getColorModel(), deviceBounds,
+ userBounds, transform,
+ renderingHints);
+
// This array will contain the oversampled transparency values for
// each pixel in the scanline.
int numScanlines = (int) Math.ceil(maxY) - (int) minY;
@@ -1701,10 +1730,12 @@ public abstract class AbstractGraphics2D
firstSubline = 0;
// Render full scanline.
//System.err.println("scanline: " + y);
- fillScanlineAA(alpha, (int) minX, (int) y, numScanlinePixels);
+ fillScanlineAA(alpha, (int) minX, (int) y, numScanlinePixels, pCtx);
}
if (paint instanceof Color && composite == AlphaComposite.SrcOver)
rawSetForeground((Color) paint);
+
+ pCtx.dispose();
}
/**
@@ -1716,69 +1747,45 @@ public abstract class AbstractGraphics2D
* @param x0 the beginning of the scanline
* @param y the y coordinate of the line
*/
- private void fillScanlineAA(int[] alpha, int x0, int y, int numScanlinePixels)
- {
- int lastX = x0;
- int lastAlpha = 0;
- for (int i = 0; i < numScanlinePixels; i++)
+ private void fillScanlineAA(int[] alpha, int x0, int y, int numScanlinePixels,
+ PaintContext pCtx)
+ {
+ // FIXME: This doesn't work. Fixit.
+ CompositeContext cCtx = composite.createContext(pCtx.getColorModel(),
+ getColorModel(),
+ renderingHints);
+ Raster paintRaster = pCtx.getRaster(x0, y, numScanlinePixels, 1);
+ System.err.println("paintColorModel: " + pCtx.getColorModel());
+ WritableRaster aaRaster = paintRaster.createCompatibleWritableRaster();
+ int numBands = paintRaster.getNumBands();
+ int[] pixels = new int[numScanlinePixels + paintRaster.getNumBands()];
+ pixels = paintRaster.getPixels(x0, y, numScanlinePixels, 1, pixels);
+ ColorModel cm = pCtx.getColorModel();
+
+ double lastAlpha = 0.;
+ int lastAlphaInt = 0;
+ int[] components = new int[4];
+
+ for (int i = 0; i < pixels.length; i++)
{
- if (alpha[i] == 0)
- continue;
- if (lastAlpha > 0)
+ if (alpha[i] != 0)
{
- //System.err.println("rawDrawScanline: " + lastX + ", " + (i+x0) + ", " + lastAlpha);
- // TODO: Avoid double arithmetic.
- fillScanlineAlpha(lastX, i + x0, y, lastAlpha);
+ lastAlphaInt += alpha[i];
+ lastAlpha = lastAlphaInt / AA_SAMPLING;
}
- lastAlpha += alpha[i];
- alpha[i] = 0;
- lastX = i + x0;
+ components = cm.getComponents(pixel[i], components, 0);
+ components[0] = (int) (components[0] * lastAlpha);
+ pixel[i] = cm.getDataElement(components, 0);
}
- if (lastAlpha > 0)
- // TODO: Avoid double arithmetic.
- fillScanlineAlpha(lastX, x0 + numScanlinePixels, y, lastAlpha);
- }
- /**
- * Renders one scanline with alpha sampling for anti-aliased shape rendering.
- *
- * @param x0 the start offset
- * @param x1 the end offset
- * @param y the scanline
- * @param sample the sample value, relative to AA_SAMPLING
- */
- private void fillScanlineAlpha(int x0, int x1, int y, int sample)
- {
- if (paint instanceof Color && composite == AlphaComposite.SrcOver)
- {
- // FIXME: We should composite over current pixels, not over the
- // background color.
- Color fg = (Color) paint;
- if (sample < AA_SAMPLING)
- {
- Color bg = background;
- int bgShare = (AA_SAMPLING - sample);
- int red = (fg.getRed() * sample + bg.getRed() * bgShare)
- / AA_SAMPLING;
- int green = (fg.getGreen() * sample + bg.getGreen() * bgShare)
- / AA_SAMPLING;
- int blue = (fg.getBlue() * sample + bg.getBlue() * bgShare)
- / AA_SAMPLING;
- rawSetForeground(red, green, blue);
- fillScanline(x0, x1 - 1, y);
- }
- else
- {
- rawSetForeground(fg);
- fillScanline(x0, x1 - 1, y);
- }
- }
- else
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
+ aaRaster.setPixels(0, 0, numScanlinePixels, 1, pixels);
+ cCtx.compose(aaRaster, destinationRaster, destinationRaster);
+ updateRaster(destinationRaster, x0, y, numScanlinePixels, 1);
+
+ cCtx.dispose();
}
+
/**
* Initializes this graphics object. This must be called by subclasses in
* order to correctly initialize the state of this object.
@@ -1792,9 +1799,38 @@ public abstract class AbstractGraphics2D
// FIXME: Should not be necessary. A clip of null should mean
// 'clip against device bounds.
clip = getDeviceBounds();
+ destinationRaster = getDestinationRaster();
}
- //protected abstract Raster getDestinationRaster(int x, int y, int w, int h);
+ /**
+ * Returns a WritableRaster that is used by this class to perform the
+ * rendering in. It is not necessary that the target surface immediately
+ * reflects changes in the raster. Updates to the raster are notified via
+ * {@link #updateRaster}.
+ *
+ * @return the destination raster
+ */
+ protected abstract WritableRaster getDestinationRaster();
+
+ /**
+ * Notifies the backend that the raster has changed in the specified
+ * rectangular area. The raster that is provided in this method is always
+ * the same as the one returned in {@link #getDestinationRaster}.
+ * Backends that reflect changes to this raster directly don't need to do
+ * anything here.
+ *
+ * @param raster the updated raster, identical to the raster returned
+ * by {@link #getDestinationRaster()}
+ * @param x the upper left corner of the updated region, X coordinate
+ * @param y the upper lef corner of the updated region, Y coordinate
+ * @param w the width of the updated region
+ * @param h the height of the updated region
+ */
+ protected void updateRaster(Raster raster, int x, int y, int w, int h)
+ {
+ // Nothing to do here. Backends that need to update their surface
+ // to reflect the change should override this method.
+ }
// Some helper methods.
diff --git a/gnu/java/awt/java2d/AlphaCompositeContext.java b/gnu/java/awt/java2d/AlphaCompositeContext.java
index e01296f2d..e67c92148 100644
--- a/gnu/java/awt/java2d/AlphaCompositeContext.java
+++ b/gnu/java/awt/java2d/AlphaCompositeContext.java
@@ -42,7 +42,6 @@ import java.awt.AWTError;
import java.awt.AlphaComposite;
import java.awt.CompositeContext;
import java.awt.image.ColorModel;
-import java.awt.image.DataBuffer;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
@@ -180,7 +179,7 @@ public class AlphaCompositeContext
int width = src.getWidth();
int height = src.getHeight();
int x1 = x0 + width;
- int y1 = x0 + height;
+ int y1 = y0 + height;
Object srcPixel = null;
Object dstPixel = null;
@@ -213,36 +212,9 @@ public class AlphaCompositeContext
for (int x = x0; x < x1; x++)
{
// Fetch source pixel.
- switch (srcTransferType)
- {
- case DataBuffer.TYPE_INT:
- srcPixel = src.getPixel(x, y, (int[]) srcPixel);
- break;
- case DataBuffer.TYPE_FLOAT:
- srcPixel = src.getPixel(x, y, (float[]) srcPixel);
- break;
- case DataBuffer.TYPE_DOUBLE:
- srcPixel = src.getPixel(x, y, (double[]) srcPixel);
- break;
- default:
- throw new AWTError("Invalid transfer type for source raster");
- }
+ srcPixel = src.getDataElements(x, y, (int[]) srcPixel);
// Fetch destination pixel.
- switch (dstTransferType)
- {
- case DataBuffer.TYPE_INT:
- dstPixel = dstIn.getPixel(x, y, (int[]) dstPixel);
- break;
- case DataBuffer.TYPE_FLOAT:
- dstPixel = dstIn.getPixel(x, y, (float[]) dstPixel);
- break;
- case DataBuffer.TYPE_DOUBLE:
- dstPixel = dstIn.getPixel(x, y, (double[]) dstPixel);
- break;
- default:
- throw new AWTError("Invalid transfer type for source raster");
- }
-
+ dstPixel = dstIn.getDataElements(x, y, dstPixel);
// Get normalized components. This is the only type that is
// guaranteed to be supported by all ColorModels.
srcComponents =
@@ -250,7 +222,7 @@ public class AlphaCompositeContext
if (! srcColorModel.hasAlpha())
srcComponents[srcComponentsLength - 1] = 1.0F;
dstComponents =
- dstColorModel.getNormalizedComponents(dstPixel, srcComponents, 0);
+ dstColorModel.getNormalizedComponents(dstPixel, dstComponents, 0);
if (! dstColorModel.hasAlpha())
dstComponents[dstComponentsLength - 1] = 1.0F;
@@ -259,17 +231,17 @@ public class AlphaCompositeContext
srcComponents[srcComponentsLength - 1] *= compositeAlpha;
if (srcColorModel.isAlphaPremultiplied())
{
- for (int i = srcComponentsLength - 2; i >= 0; i++)
+ for (int i = srcComponentsLength - 2; i >= 0; i--)
srcComponents[i] *= compositeAlpha;
}
else
{
- for (int i = srcComponentsLength - 2; i >= 0; i++)
+ for (int i = srcComponentsLength - 1; i >= 0; i--)
srcComponents[i] *= srcComponents[srcComponentsLength - 1];
}
if (! dstColorModel.isAlphaPremultiplied())
{
- for (int i = dstComponentsLength - 2; i >= 0; i++)
+ for (int i = dstComponentsLength - 2; i >= 0; i--)
dstComponents[i] *= dstComponents[dstComponents.length - 1];
}
@@ -319,7 +291,7 @@ public class AlphaCompositeContext
for (int i = 0; i < srcComponentsLength; i++)
{
dstComponents[i] = srcComponents[i] * fs
- + dstComponents[i] * fd;
+ + dstComponents[i] * fd;
}
// Convert the result back when the destination is not
@@ -336,19 +308,7 @@ public class AlphaCompositeContext
// Store the result in the destination raster.
dstPixel = dstColorModel.getDataElements(dstComponents, 0,
dstPixel);
- switch (dstTransferType)
- {
- case DataBuffer.TYPE_INT:
- dstOut.setPixel(x, y, (int[] ) dstPixel);
- break;
- case DataBuffer.TYPE_FLOAT:
- dstOut.setPixel(x, y, (float[] ) dstPixel);
- break;
- case DataBuffer.TYPE_DOUBLE:
- dstOut.setPixel(x, y, (double[] ) dstPixel);
- break;
- }
-
+ dstOut.setDataElements(x, y, dstPixel);
} // End X loop.
} // End Y loop.
}
diff --git a/gnu/java/awt/java2d/RasterGraphics.java b/gnu/java/awt/java2d/RasterGraphics.java
new file mode 100644
index 000000000..4de8035c6
--- /dev/null
+++ b/gnu/java/awt/java2d/RasterGraphics.java
@@ -0,0 +1,101 @@
+/* RasterGraphics.java -- A Graphics2D impl for Rasters
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.java2d;
+
+import java.awt.GraphicsConfiguration;
+import java.awt.image.ColorModel;
+import java.awt.image.WritableRaster;
+
+/**
+ * A Graphics2D implementation that operates on Raster objects. This is
+ * primarily used for BufferedImages, but can theoretically be used on
+ * arbitrary WritableRasters.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class RasterGraphics
+ extends AbstractGraphics2D
+{
+
+ /**
+ * The raster on which we operate.
+ */
+ private WritableRaster raster;
+
+ /**
+ * The color model of this Graphics instance.
+ */
+ private ColorModel colorModel;
+
+ public RasterGraphics(WritableRaster r, ColorModel cm)
+ {
+ raster = r;
+ colorModel = cm;
+ }
+
+ /**
+ * Returns the color model of this Graphics object.
+ *
+ * @return the color model of this Graphics object
+ */
+ protected ColorModel getColorModel()
+ {
+ return colorModel;
+ }
+
+ /**
+ * Returns a WritableRaster that is used by this class to perform the
+ * rendering in. It is not necessary that the target surface immediately
+ * reflects changes in the raster. Updates to the raster are notified via
+ * {@link AbstractGraphics2D#updateRaster}.
+ *
+ * @return the destination raster
+ */
+ protected WritableRaster getDestinationRaster()
+ {
+ return raster;
+ }
+
+ public GraphicsConfiguration getDeviceConfiguration()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/java/awt/image/ColorModel.java b/java/awt/image/ColorModel.java
index ec97416ae..40307f2b9 100644
--- a/java/awt/image/ColorModel.java
+++ b/java/awt/image/ColorModel.java
@@ -527,8 +527,8 @@ public abstract class ColorModel implements Transparency
float[] normComponents,
int normOffset)
{
- // subclasses has to implement this method.
- throw new UnsupportedOperationException();
+ int[] components = getComponents(pixel, null, 0);
+ return getNormalizedComponents(components, 0, normComponents, normOffset);
}
/**
diff --git a/javax/swing/JLabel.java b/javax/swing/JLabel.java
index 01badd333..a993fb8f3 100644
--- a/javax/swing/JLabel.java
+++ b/javax/swing/JLabel.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing;
+import gnu.classpath.NotImplementedException;
+
import java.awt.Component;
import java.awt.Font;
import java.awt.Image;
@@ -67,15 +69,15 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
implements AccessibleText, AccessibleExtendedComponent
{
/**
- * Returns the selected text. This is an empty string since JLabels
+ * Returns the selected text. This is null since JLabels
* are not selectable.
*
- * @return the selected text
+ * @return <code>null</code> because JLabels cannot have selected text
*/
public String getSelectedText()
{
- // We return "" here since JLabel's text is not selectable.
- return "";
+ // We return null here since JLabel's text is not selectable.
+ return null;
}
/**
@@ -85,8 +87,7 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
*/
public int getSelectionStart()
{
- // TODO: Figure out what should be returned here, because JLabels don't
- // allow selection. I guess -1 for now.
+ // JLabel don't have selected text, so we return -1 here.
return -1;
}
@@ -97,8 +98,7 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
*/
public int getSelectionEnd()
{
- // TODO: Figure out what should be returned here, because JLabels don't
- // allow selection. I guess -1 for now.
+ // JLabel don't have selected text, so we return -1 here.
return -1;
}
@@ -115,6 +115,8 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
*/
public AttributeSet getCharacterAttribute(int index)
{
+ // FIXME: Return null here for simple labels, and query the HTML
+ // view for HTML labels.
return new SimpleAttributeSet();
}
@@ -259,6 +261,7 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
*/
public int getCharCount()
{
+ // FIXME: Query HTML view for HTML labels.
return text.length();
}
@@ -271,6 +274,7 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
* @return the bounding box of the character at the specified index
*/
public Rectangle getCharacterBounds(int index)
+ throws NotImplementedException
{
// FIXME: Implement this correctly.
return new Rectangle();
@@ -286,6 +290,7 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
* point
*/
public int getIndexAtPoint(Point point)
+ throws NotImplementedException
{
// FIXME: Implement this correctly.
return 0;
@@ -454,7 +459,7 @@ public class JLabel extends JComponent implements Accessible, SwingConstants
*/
protected String paramString()
{
- return "JLabel";
+ return super.paramString();
}
/**
diff --git a/javax/swing/JOptionPane.java b/javax/swing/JOptionPane.java
index 36f4a867d..0bef12b61 100644
--- a/javax/swing/JOptionPane.java
+++ b/javax/swing/JOptionPane.java
@@ -1,5 +1,5 @@
/* JOptionPane.java
- Copyright (C) 2004, 2005, 2006, Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -57,15 +57,17 @@ import javax.swing.plaf.OptionPaneUI;
public class JOptionPane extends JComponent implements Accessible
{
/**
- * Provides the accessibility features for the <code>JOptionPane</code>
- * component.
+ * DOCUMENT ME!
*/
+ // FIXME: This inner class is a complete stub and needs to be implemented
+ // properly.
protected class AccessibleJOptionPane extends JComponent.AccessibleJComponent
{
+ /** DOCUMENT ME! */
private static final long serialVersionUID = 686071432213084821L;
/**
- * Creates a new <code>AccessibleJOptionPane</code> instance.
+ * Creates a new AccessibleJOptionPane object.
*/
protected AccessibleJOptionPane()
{
@@ -84,6 +86,7 @@ public class JOptionPane extends JComponent implements Accessible
}
}
+ /** DOCUMENT ME! */
private static final long serialVersionUID = 5231143276678566796L;
/** The value returned when cancel option is selected. */
@@ -428,11 +431,9 @@ public class JOptionPane extends JComponent implements Accessible
}
/**
- * Returns the object that provides accessibility features for this
- * <code>JOptionPane</code> component.
+ * DOCUMENT ME!
*
- * @return The accessible context (an instance of
- * {@link AccessibleJOptionPane}).
+ * @return DOCUMENT ME!
*/
public AccessibleContext getAccessibleContext()
{
diff --git a/javax/swing/plaf/basic/BasicRadioButtonUI.java b/javax/swing/plaf/basic/BasicRadioButtonUI.java
index 66e538037..a66fa28e6 100644
--- a/javax/swing/plaf/basic/BasicRadioButtonUI.java
+++ b/javax/swing/plaf/basic/BasicRadioButtonUI.java
@@ -45,6 +45,7 @@ import java.awt.Graphics;
import java.awt.Rectangle;
import javax.swing.AbstractButton;
+import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
@@ -142,14 +143,15 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
g.setFont(f);
+ ButtonModel m = b.getModel();
Icon currentIcon = null;
- if (b.isSelected() && b.isEnabled())
+ if (m.isSelected() && m.isEnabled())
currentIcon = b.getSelectedIcon();
- else if (!b.isSelected() && b.isEnabled())
+ else if (! m.isSelected() && m.isEnabled())
currentIcon = b.getIcon();
- else if (b.isSelected() && !b.isEnabled())
+ else if (m.isSelected() && ! m.isEnabled())
currentIcon = b.getDisabledSelectedIcon();
- else // (!b.isSelected() && !b.isEnabled())
+ else // (!m.isSelected() && ! m.isEnabled())
currentIcon = b.getDisabledIcon();
SwingUtilities.calculateInnerArea(b, vr);
@@ -166,7 +168,7 @@ public class BasicRadioButtonUI extends BasicToggleButtonUI
if (text != null)
paintText(g, b, tr, text);
// TODO: Figure out what is the size parameter?
- if (b.hasFocus() && b.isFocusPainted() && b.isEnabled())
+ if (b.hasFocus() && b.isFocusPainted() && m.isEnabled())
paintFocus(g, tr, null);
}