You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2006/10/06 10:50:10 UTC
svn commit: r453532 [1/2] - in
/incubator/harmony/enhanced/classlib/trunk/modules:
awt/src/main/java/common/java/awt/
awt/src/main/java/linux/org/apache/harmony/awt/wtk/linux/
beans/src/main/java/java/beans/ jndi/src/main/java/javax/naming/
luni/src/ma...
Author: hindessm
Date: Fri Oct 6 01:50:09 2006
New Revision: 453532
URL: http://svn.apache.org/viewvc?view=rev&rev=453532
Log:
Splitting source files that define two classes. As discussed in the
thread "[classlib] Trying to catch patternset errors earlier" on the
-dev list.
Added:
incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaintContext.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GridBagLayoutInfo.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TexturePaintContext.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/wtk/linux/LinuxWindowMap.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/wtk/linux/XServerConnection.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/CustomizedObjectInputStream.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameImpl.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/HexStringParser.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/PermissionsHash.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/pkcs7/AuthenticatedAttributes.java (with props)
incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/main/java/javax/net/ssl/ContextImpl.java (with props)
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaint.java
incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GridBagLayout.java
incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TexturePaint.java
incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/wtk/linux/LinuxWindowFactory.java
incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java
incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Permissions.java
incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/pkcs7/SignerInfo.java
incubator/harmony/enhanced/classlib/trunk/modules/x-net/src/main/java/javax/net/ssl/DefaultSSLContext.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaint.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaint.java?view=diff&rev=453532&r1=453531&r2=453532
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaint.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaint.java Fri Oct 6 01:50:09 2006
@@ -106,179 +106,3 @@
}
}
-
-class GradientPaintContext implements PaintContext {
-
- /**
- * The size of noncyclic part of color lookup table
- */
- static int LOOKUP_SIZE = 256;
-
- /**
- * The index mask to lookup color in the table
- */
- static int LOOKUP_MASK = 0x1FF;
-
- /**
- * The min value equivalent to zero. If absolute value less then ZERO it considered as zero.
- */
- static double ZERO = 1E-10;
-
- /**
- * The ColorModel user defined for PaintContext
- */
- ColorModel cm;
-
- /**
- * The indicator of cycle filling.
- */
- boolean cyclic;
-
- /**
- * The integer color value of the start point
- */
- int c1;
-
- /**
- * The integer color value of the end point
- */
- int c2;
-
- /**
- * The lookup gradient color table
- */
- int[] table;
-
- /**
- * The tempopary pre-calculated value to evalutae color index
- */
- int dx;
-
- /**
- * The tempopary pre-calculated value to evalutae color index
- */
- int dy;
-
- /**
- * The tempopary pre-calculated value to evalutae color index
- */
- int delta;
-
- /**
- * Constructs a new GradientPaintcontext
- * @param cm - not used
- * @param t - the fill transformation
- * @param point1 - the start fill point
- * @param color1 - color of the start point
- * @param point2 - the end fill point
- * @param color2 - color of the end point
- * @param cyclic - the indicator of cycle filling
- */
- GradientPaintContext(ColorModel cm, AffineTransform t, Point2D point1, Color color1, Point2D point2, Color color2, boolean cyclic) {
- this.cyclic = cyclic;
- this.cm = ColorModel.getRGBdefault();
-
- c1 = color1.getRGB();
- c2 = color2.getRGB();
-
- double px = point2.getX() - point1.getX();
- double py = point2.getY() - point1.getY();
-
- Point2D p = t.transform(point1, null);
- Point2D bx = new Point2D.Double(px, py);
- Point2D by = new Point2D.Double(py, -px);
-
- t.deltaTransform(bx, bx);
- t.deltaTransform(by, by);
-
- double vec = bx.getX() * by.getY() - bx.getY() * by.getX();
-
- if (Math.abs(vec) < ZERO) {
- dx = dy = delta = 0;
- table = new int[1];
- table[0] = c1;
- } else {
- double mult = LOOKUP_SIZE * 256 / vec;
- dx = (int)(by.getX() * mult);
- dy = (int)(by.getY() * mult);
- delta = (int)((p.getX() * by.getY() - p.getY() * by.getX()) * mult);
- createTable();
- }
- }
-
- /**
- * Create color index lookup table. Calculate 256 step trasformation from
- * the start point color to the end point color. Colors multiplied by 256 to do integer calculations.
- */
- void createTable() {
- double ca = (c1 >> 24) & 0xFF;
- double cr = (c1 >> 16) & 0xFF;
- double cg = (c1 >> 8) & 0xFF;
- double cb = c1 & 0xFF;
-
- double k = 1.0 / LOOKUP_SIZE;
- double da = (((c2 >> 24) & 0xFF) - ca) * k;
- double dr = (((c2 >> 16) & 0xFF) - cr) * k;
- double dg = (((c2 >> 8) & 0xFF) - cg) * k;
- double db = ((c2 & 0xFF) - cb) * k;
-
- table = new int[cyclic ? LOOKUP_SIZE + LOOKUP_SIZE : LOOKUP_SIZE];
- for(int i = 0; i < LOOKUP_SIZE; i++) {
- table[i] =
- (int)ca << 24 |
- (int)cr << 16 |
- (int)cg << 8 |
- (int)cb;
- ca += da;
- cr += dr;
- cg += dg;
- cb += db;
- }
- if (cyclic) {
- for(int i = 0; i < LOOKUP_SIZE; i++) {
- table[LOOKUP_SIZE + LOOKUP_SIZE - 1 - i] = table[i];
- }
- }
- }
-
- public ColorModel getColorModel() {
- return cm;
- }
-
- public void dispose() {
- }
-
- public Raster getRaster(int x, int y, int w, int h) {
- WritableRaster rast = cm.createCompatibleWritableRaster(w, h);
-
- int[] buf = ((DataBufferInt)rast.getDataBuffer()).getData();
-
- int c = x * dy - y * dx - delta;
- int cx = dy;
- int cy = - w * dy - dx;
- int k = 0;
-
- if (cyclic) {
- for(int j = 0; j < h; j++) {
- for(int i = 0; i < w; i++) {
- buf[k++] = table[(c >> 8) & LOOKUP_MASK];
- c += cx;
- }
- c += cy;
- }
- } else {
- for(int j = 0; j < h; j++) {
- for(int i = 0; i < w; i++) {
- int index = c >> 8;
- buf[k++] = index < 0 ? c1 : index >= LOOKUP_SIZE ? c2 : table[index];
- c += cx;
- }
- c += cy;
- }
- }
-
- return rast;
- }
-
-}
-
Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaintContext.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaintContext.java?view=auto&rev=453532
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaintContext.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaintContext.java Fri Oct 6 01:50:09 2006
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @author Denis M. Kishenko
+ * @version $Revision$
+ */
+package java.awt;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
+import java.awt.image.ColorModel;
+import java.awt.image.DataBufferInt;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+
+class GradientPaintContext implements PaintContext {
+
+ /**
+ * The size of noncyclic part of color lookup table
+ */
+ static int LOOKUP_SIZE = 256;
+
+ /**
+ * The index mask to lookup color in the table
+ */
+ static int LOOKUP_MASK = 0x1FF;
+
+ /**
+ * The min value equivalent to zero. If absolute value less then ZERO it considered as zero.
+ */
+ static double ZERO = 1E-10;
+
+ /**
+ * The ColorModel user defined for PaintContext
+ */
+ ColorModel cm;
+
+ /**
+ * The indicator of cycle filling.
+ */
+ boolean cyclic;
+
+ /**
+ * The integer color value of the start point
+ */
+ int c1;
+
+ /**
+ * The integer color value of the end point
+ */
+ int c2;
+
+ /**
+ * The lookup gradient color table
+ */
+ int[] table;
+
+ /**
+ * The tempopary pre-calculated value to evalutae color index
+ */
+ int dx;
+
+ /**
+ * The tempopary pre-calculated value to evalutae color index
+ */
+ int dy;
+
+ /**
+ * The tempopary pre-calculated value to evalutae color index
+ */
+ int delta;
+
+ /**
+ * Constructs a new GradientPaintcontext
+ * @param cm - not used
+ * @param t - the fill transformation
+ * @param point1 - the start fill point
+ * @param color1 - color of the start point
+ * @param point2 - the end fill point
+ * @param color2 - color of the end point
+ * @param cyclic - the indicator of cycle filling
+ */
+ GradientPaintContext(ColorModel cm, AffineTransform t, Point2D point1, Color color1, Point2D point2, Color color2, boolean cyclic) {
+ this.cyclic = cyclic;
+ this.cm = ColorModel.getRGBdefault();
+
+ c1 = color1.getRGB();
+ c2 = color2.getRGB();
+
+ double px = point2.getX() - point1.getX();
+ double py = point2.getY() - point1.getY();
+
+ Point2D p = t.transform(point1, null);
+ Point2D bx = new Point2D.Double(px, py);
+ Point2D by = new Point2D.Double(py, -px);
+
+ t.deltaTransform(bx, bx);
+ t.deltaTransform(by, by);
+
+ double vec = bx.getX() * by.getY() - bx.getY() * by.getX();
+
+ if (Math.abs(vec) < ZERO) {
+ dx = dy = delta = 0;
+ table = new int[1];
+ table[0] = c1;
+ } else {
+ double mult = LOOKUP_SIZE * 256 / vec;
+ dx = (int)(by.getX() * mult);
+ dy = (int)(by.getY() * mult);
+ delta = (int)((p.getX() * by.getY() - p.getY() * by.getX()) * mult);
+ createTable();
+ }
+ }
+
+ /**
+ * Create color index lookup table. Calculate 256 step trasformation from
+ * the start point color to the end point color. Colors multiplied by 256 to do integer calculations.
+ */
+ void createTable() {
+ double ca = (c1 >> 24) & 0xFF;
+ double cr = (c1 >> 16) & 0xFF;
+ double cg = (c1 >> 8) & 0xFF;
+ double cb = c1 & 0xFF;
+
+ double k = 1.0 / LOOKUP_SIZE;
+ double da = (((c2 >> 24) & 0xFF) - ca) * k;
+ double dr = (((c2 >> 16) & 0xFF) - cr) * k;
+ double dg = (((c2 >> 8) & 0xFF) - cg) * k;
+ double db = ((c2 & 0xFF) - cb) * k;
+
+ table = new int[cyclic ? LOOKUP_SIZE + LOOKUP_SIZE : LOOKUP_SIZE];
+ for(int i = 0; i < LOOKUP_SIZE; i++) {
+ table[i] =
+ (int)ca << 24 |
+ (int)cr << 16 |
+ (int)cg << 8 |
+ (int)cb;
+ ca += da;
+ cr += dr;
+ cg += dg;
+ cb += db;
+ }
+ if (cyclic) {
+ for(int i = 0; i < LOOKUP_SIZE; i++) {
+ table[LOOKUP_SIZE + LOOKUP_SIZE - 1 - i] = table[i];
+ }
+ }
+ }
+
+ public ColorModel getColorModel() {
+ return cm;
+ }
+
+ public void dispose() {
+ }
+
+ public Raster getRaster(int x, int y, int w, int h) {
+ WritableRaster rast = cm.createCompatibleWritableRaster(w, h);
+
+ int[] buf = ((DataBufferInt)rast.getDataBuffer()).getData();
+
+ int c = x * dy - y * dx - delta;
+ int cx = dy;
+ int cy = - w * dy - dx;
+ int k = 0;
+
+ if (cyclic) {
+ for(int j = 0; j < h; j++) {
+ for(int i = 0; i < w; i++) {
+ buf[k++] = table[(c >> 8) & LOOKUP_MASK];
+ c += cx;
+ }
+ c += cy;
+ }
+ } else {
+ for(int j = 0; j < h; j++) {
+ for(int i = 0; i < w; i++) {
+ int index = c >> 8;
+ buf[k++] = index < 0 ? c1 : index >= LOOKUP_SIZE ? c2 : table[index];
+ c += cx;
+ }
+ c += cy;
+ }
+ }
+
+ return rast;
+ }
+
+}
+
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaintContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GradientPaintContext.java
------------------------------------------------------------------------------
svn:executable = *
Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GridBagLayout.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GridBagLayout.java?view=diff&rev=453532&r1=453531&r2=453532
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GridBagLayout.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GridBagLayout.java Fri Oct 6 01:50:09 2006
@@ -23,23 +23,6 @@
import java.io.Serializable;
import java.util.*;
-class GridBagLayoutInfo {
-
- int widths[];
- int heights[];
-
- GridBagLayoutInfo(int widths[], int heights[]) {
- this.widths = widths;
- this.heights = heights;
- }
-
- void update(int widths[], int heights[]) {
- this.widths = widths;
- this.heights = heights;
- }
-
-}
-
public class GridBagLayout implements LayoutManager2, Serializable {
private static final long serialVersionUID = 8838754796412211005L;
Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GridBagLayoutInfo.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GridBagLayoutInfo.java?view=auto&rev=453532
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GridBagLayoutInfo.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GridBagLayoutInfo.java Fri Oct 6 01:50:09 2006
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @author Michael Danilov
+ * @version $Revision$
+ */
+package java.awt;
+
+class GridBagLayoutInfo {
+
+ int widths[];
+ int heights[];
+
+ GridBagLayoutInfo(int widths[], int heights[]) {
+ this.widths = widths;
+ this.heights = heights;
+ }
+
+ void update(int widths[], int heights[]) {
+ this.widths = widths;
+ this.heights = heights;
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GridBagLayoutInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/GridBagLayoutInfo.java
------------------------------------------------------------------------------
svn:executable = *
Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TexturePaint.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TexturePaint.java?view=diff&rev=453532&r1=453531&r2=453532
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TexturePaint.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TexturePaint.java Fri Oct 6 01:50:09 2006
@@ -108,532 +108,3 @@
}
}
-
-class TexturePaintContext implements PaintContext {
-
- /**
- * The ColorModel object of destination raster
- */
- ColorModel cm;
-
- /**
- * The BufferedImage object used as texture
- */
- BufferedImage img;
-
- /**
- * The Rectangle2D bounds of texture piece to be painted
- */
- Rectangle2D anchor;
-
- /**
- * The paint transformation
- */
- AffineTransform t;
-
- /**
- * The AwtImageBackdoorAccessor object to communicate with image DataBuffer
- */
- AwtImageBackdoorAccessor access;
-
- /**
- * The source DataBuffer object of texture image
- */
- DataBuffer srcBuf;
-
- /**
- * The destination DataBuffer object of output rester
- */
- DataBuffer dstBuf;
-
- /**
- * The source WritableRaster object of texture image
- */
- WritableRaster srcRaster;
-
- /**
- * The destination WritableRaster object of texture image
- */
- WritableRaster dstRaster;
-
- /**
- * The width of the texture image
- */
- int srcWidth;
-
- /**
- * The height of the texture image
- */
- int srcHeight;
-
- /**
- * The temporary pre-calculated temporary values
- */
- int sx, sy, hx, hy, vx, vy;
- int m00, m01, m10, m11;
- int imgW, imgH;
- int px, py;
-
- /**
- * The integer array of weight components for bilinear interpolation
- */
- int[] weight = new int[4];
-
- /**
- * The temporary values
- */
- int[] value = new int[4];
-
- static class IntSimple extends TexturePaintContext {
-
- /**
- * Constructs a new IntSimple.TexturePaintContext works with DataBufferInt rasters.
- * This is simple paint context uses NEAREST NEIGHBOUR interpolation.
- * @param img - the BufferedImage object used as texture
- * @param anchor - the Rectangle2D bounds of texture piece to be painted
- * @param t - the AffineTransform applied to texture painting
- */
- public IntSimple(BufferedImage img, Rectangle2D anchor, AffineTransform t) {
- super(img, anchor, t);
- }
-
- @Override
- public Raster getRaster(int dstX, int dstY, int dstWidth, int dstHeight) {
- prepare(dstX, dstY, dstWidth, dstHeight);
- int[] src = access.getDataInt(srcBuf);
- int[] dst = access.getDataInt(dstBuf);
- int k = 0;
- for(int j = 0; j < dstHeight; j++) {
- for(int i = 0; i < dstWidth; i++) {
- dst[k++] = src[(sx >> 8) + (sy >> 8) * srcWidth];
- sx = check(sx + hx, imgW);
- sy = check(sy + hy, imgH);
- }
- sx = check(sx + vx, imgW);
- sy = check(sy + vy, imgH);
- }
- return dstRaster;
- }
-
- }
-
- static class ByteSimple extends TexturePaintContext {
-
- /**
- * Constructs a new ByteSimple.TexturePaintContext works with DataBufferByte rasters.
- * This is simple paint context uses NEAREST NEIGHBOUR interpolation.
- * @param img - the BufferedImage object used as texture
- * @param anchor - the Rectangle2D bounds of texture piece to be painted
- * @param t - the AffineTransform applied to texture painting
- */
- public ByteSimple(BufferedImage img, Rectangle2D anchor, AffineTransform t) {
- super(img, anchor, t);
- }
-
- @Override
- public Raster getRaster(int dstX, int dstY, int dstWidth, int dstHeight) {
- prepare(dstX, dstY, dstWidth, dstHeight);
- byte[] src = access.getDataByte(srcBuf);
- byte[] dst = access.getDataByte(dstBuf);
- int k = 0;
- for(int j = 0; j < dstHeight; j++) {
- for(int i = 0; i < dstWidth; i++) {
- dst[k++] = src[(sx >> 8) + (sy >> 8) * srcWidth];
- sx = check(sx + hx, imgW);
- sy = check(sy + hy, imgH);
- }
- sx = check(sx + vx, imgW);
- sy = check(sy + vy, imgH);
- }
- return dstRaster;
- }
-
- }
-
- static class ShortSimple extends TexturePaintContext {
-
- /**
- * Constructs a new ShortSimple.TexturePaintContext works with DataBufferShort rasters.
- * This is simple paint context uses NEAREST NEIGHBOUR interpolation.
- * @param img - the BufferedImage object used as texture
- * @param anchor - the Rectangle2D bounds of texture piece to be painted
- * @param t - the AffineTransform applied to texture painting
- */
- public ShortSimple(BufferedImage img, Rectangle2D anchor, AffineTransform t) {
- super(img, anchor, t);
- }
-
- @Override
- public Raster getRaster(int dstX, int dstY, int dstWidth, int dstHeight) {
- prepare(dstX, dstY, dstWidth, dstHeight);
- short[] src = access.getDataUShort(srcBuf);
- short[] dst = access.getDataUShort(dstBuf);
- int k = 0;
- for(int j = 0; j < dstHeight; j++) {
- for(int i = 0; i < dstWidth; i++) {
- dst[k++] = src[(sx >> 8) + (sy >> 8) * srcWidth];
- sx = check(sx + hx, imgW);
- sy = check(sy + hy, imgH);
- }
- sx = check(sx + vx, imgW);
- sy = check(sy + vy, imgH);
- }
- return dstRaster;
- }
- }
-
- static class CommonSimple extends TexturePaintContext {
-
- /**
- * Constructs a new CommonSimple.TexturePaintContext works with any raster type.
- * This is simple paint context uses NEAREST NEIGHBOUR interpolation.
- * @param img - the BufferedImage object used as texture
- * @param anchor - the Rectangle2D bounds of texture piece to be painted
- * @param t - the AffineTransform applied to texture painting
- */
- public CommonSimple(BufferedImage img, Rectangle2D anchor, AffineTransform t) {
- super(img, anchor, t);
- }
-
- @Override
- public Raster getRaster(int dstX, int dstY, int dstWidth, int dstHeight) {
- prepare(dstX, dstY, dstWidth, dstHeight);
- for(int j = 0; j < dstHeight; j++) {
- for(int i = 0; i < dstWidth; i++) {
- dstRaster.setDataElements(dstX + i, dstY + j, srcRaster.getDataElements(sx >> 8, sy >> 8, null));
- sx = check(sx + hx, imgW);
- sy = check(sy + hy, imgH);
- }
- sx = check(sx + vx, imgW);
- sy = check(sy + vy, imgH);
- }
- return dstRaster;
- }
-
- }
-
- static class IntBilinear extends TexturePaintContext {
-
- /**
- * Constructs a new IntSimple.TexturePaintContext works with DataBufferInt rasters.
- * This paint context uses BILINEAR interpolation.
- * @param img - the BufferedImage object used as texture
- * @param anchor - the Rectangle2D bounds of texture piece to be painted
- * @param t - the AffineTransform applied to texture painting
- */
- public IntBilinear(BufferedImage img, Rectangle2D anchor, AffineTransform t) {
- super(img, anchor, t);
- }
-
- @Override
- public Raster getRaster(int dstX, int dstY, int dstWidth, int dstHeight) {
- prepare(dstX, dstY, dstWidth, dstHeight);
- int[] src = access.getDataInt(srcBuf);
- int[] dst = access.getDataInt(dstBuf);
- int k = 0;
- for(int j = 0; j < dstHeight; j++) {
- for(int i = 0; i < dstWidth; i++) {
- int wx1 = sx & 0xFF;
- int wy1 = sy & 0xFF;
- int wx0 = 0xFF - wx1;
- int wy0 = 0xFF - wy1;
-
- weight[0] = wx0 * wy0;
- weight[1] = wx1 * wy0;
- weight[2] = wx0 * wy1;
- weight[3] = wx1 * wy1;
-
- int x0 = sx >> 8;
- int y0 = sy >> 8;
- int x1 = check(x0 + 1, srcWidth);
- int y1 = check(y0 + 1, srcHeight);
-
- y0 *= srcWidth;
- y1 *= srcWidth;
-
- value[0] = src[x0 + y0];
- value[1] = src[x1 + y0];
- value[2] = src[x0 + y1];
- value[3] = src[x1 + y1];
-
- int color = 0;
- for(int n = 0; n < 32; n += 8) {
- int comp = 0;
- for(int m = 0; m < 4; m++) {
- comp += ((value[m] >> n) & 0xFF) * weight[m];
- }
- color |= (comp >> 16) << n;
- }
-
- dst[k++] = color;
-
- sx = check(sx + hx, imgW);
- sy = check(sy + hy, imgH);
- }
- sx = check(sx + vx, imgW);
- sy = check(sy + vy, imgH);
- }
- return dstRaster;
- }
-
- }
-
- static class ByteBilinear extends TexturePaintContext {
-
- /**
- * Constructs a new ByteSimple.TexturePaintContext works with DataBufferByte rasters.
- * This paint context uses BILINEAR interpolation.
- * @param img - the BufferedImage object used as texture
- * @param anchor - the Rectangle2D bounds of texture piece to be painted
- * @param t - the AffineTransform applied to texture painting
- */
- public ByteBilinear(BufferedImage img, Rectangle2D anchor, AffineTransform t) {
- super(img, anchor, t);
- }
-
- @Override
- public Raster getRaster(int dstX, int dstY, int dstWidth, int dstHeight) {
- prepare(dstX, dstY, dstWidth, dstHeight);
- byte[] src = access.getDataByte(srcBuf);
- byte[] dst = access.getDataByte(dstBuf);
- int k = 0;
- for(int j = 0; j < dstHeight; j++) {
- for(int i = 0; i < dstWidth; i++) {
- int wx1 = sx & 0xFF;
- int wy1 = sy & 0xFF;
- int wx0 = 0xFF - wx1;
- int wy0 = 0xFF - wy1;
-
- weight[0] = wx0 * wy0;
- weight[1] = wx1 * wy0;
- weight[2] = wx0 * wy1;
- weight[3] = wx1 * wy1;
-
- int x0 = sx >> 8;
- int y0 = sy >> 8;
- int x1 = check(x0 + 1, srcWidth);
- int y1 = check(y0 + 1, srcHeight);
-
- y0 *= dstWidth;
- y1 *= dstWidth;
-
- value[0] = src[x0 + y0];
- value[1] = src[x1 + y0];
- value[2] = src[x0 + y1];
- value[3] = src[x1 + y1];
-
- int comp = 0;
- for(int m = 0; m < 4; m++) {
- comp += value[m] * weight[m];
- }
- dst[k++] = (byte)(comp >> 16);
-
- sx = check(sx + hx, imgW);
- sy = check(sy + hy, imgH);
- }
- sx = check(sx + vx, imgW);
- sy = check(sy + vy, imgH);
- }
- return dstRaster;
- }
-
- }
-
- static class ShortBilinear extends TexturePaintContext {
-
- /**
- * Constructs a new ShortSimple.TexturePaintContext works with DataBufferShort rasters.
- * This paint context uses BILINEAR interpolation.
- * @param img - the BufferedImage object used as texture
- * @param anchor - the Rectangle2D bounds of texture piece to be painted
- * @param t - the AffineTransform applied to texture painting
- */
- public ShortBilinear(BufferedImage img, Rectangle2D anchor, AffineTransform t) {
- super(img, anchor, t);
- }
-
- @Override
- public Raster getRaster(int dstX, int dstY, int dstWidth, int dstHeight) {
- prepare(dstX, dstY, dstWidth, dstHeight);
- short[] src = access.getDataUShort(srcBuf);
- short[] dst = access.getDataUShort(dstBuf);
- int k = 0;
- for(int j = 0; j < dstHeight; j++) {
- for(int i = 0; i < dstWidth; i++) {
- int wx1 = sx & 0xFF;
- int wy1 = sy & 0xFF;
- int wx0 = 0xFF - wx1;
- int wy0 = 0xFF - wy1;
-
- weight[0] = wx0 * wy0;
- weight[1] = wx1 * wy0;
- weight[2] = wx0 * wy1;
- weight[3] = wx1 * wy1;
-
- int x0 = sx >> 8;
- int y0 = sy >> 8;
- int x1 = check(x0 + 1, srcWidth);
- int y1 = check(y0 + 1, srcHeight);
-
- y0 *= dstWidth;
- y1 *= dstWidth;
-
- value[0] = src[x0 + y0];
- value[1] = src[x1 + y0];
- value[2] = src[x0 + y1];
- value[3] = src[x1 + y1];
-
- short color = 0;
- for(int n = 0; n < 16; n += 8) {
- int comp = 0;
- for(int m = 0; m < 4; m++) {
- comp += ((value[m] >> n) & 0xFF) * weight[m];
- }
- color |= (comp >> 16) << n;
- }
- dst[k++] = color;
-
- sx = check(sx + hx, imgW);
- sy = check(sy + hy, imgH);
- }
- sx = check(sx + vx, imgW);
- sy = check(sy + vy, imgH);
- }
- return dstRaster;
- }
-
- }
-
- static class CommonBilinear extends TexturePaintContext {
-
- /**
- * Constructs a new CommonSimple.TexturePaintContext works with any raster type.
- * This paint context uses BILINEAR interpolation.
- * @param img - the BufferedImage object used as texture
- * @param anchor - the Rectangle2D bounds of texture piece to be painted
- * @param t - the AffineTransform applied to texture painting
- */
- public CommonBilinear(BufferedImage img, Rectangle2D anchor, AffineTransform t) {
- super(img, anchor, t);
- }
-
- @Override
- public Raster getRaster(int dstX, int dstY, int dstWidth, int dstHeight) {
- prepare(dstX, dstY, dstWidth, dstHeight);
- for(int j = 0; j < dstHeight; j++) {
- for(int i = 0; i < dstWidth; i++) {
- int wx1 = sx & 0xFF;
- int wy1 = sy & 0xFF;
- int wx0 = 0xFF - wx1;
- int wy0 = 0xFF - wy1;
-
- weight[0] = wx0 * wy0;
- weight[1] = wx1 * wy0;
- weight[2] = wx0 * wy1;
- weight[3] = wx1 * wy1;
-
- int x0 = sx >> 8;
- int y0 = sy >> 8;
- int x1 = check(x0 + 1, srcWidth);
- int y1 = check(y0 + 1, srcHeight);
-
- value[0] = cm.getRGB(srcRaster.getDataElements(x0, y0, null));
- value[1] = cm.getRGB(srcRaster.getDataElements(x1, y0, null));
- value[2] = cm.getRGB(srcRaster.getDataElements(x0, y1, null));
- value[3] = cm.getRGB(srcRaster.getDataElements(x1, y1, null));
-
- int color = 0;
- for(int n = 0; n < 32; n += 8) {
- int comp = 0;
- for(int m = 0; m < 4; m++) {
- comp += ((value[m] >> n) & 0xFF) * weight[m];
- }
- color |= (comp >> 16) << n;
- }
- dstRaster.setDataElements(dstX + i, dstY + j, cm.getDataElements(color, null));
-
- sx = check(sx + hx, imgW);
- sy = check(sy + hy, imgH);
- }
- sx = check(sx + vx, imgW);
- sy = check(sy + vy, imgH);
- }
- return dstRaster;
- }
-
- }
-
- public TexturePaintContext(BufferedImage img, Rectangle2D anchor, AffineTransform t) {
- this.cm = img.getColorModel();
- this.img = img;
- this.anchor = anchor;
- this.t = t;
-
- srcWidth = img.getWidth();
- srcHeight = img.getHeight();
- imgW = srcWidth << 8;
- imgH = srcHeight << 8;
- double det = t.getDeterminant();
- double multW = imgW / (anchor.getWidth() * det);
- double multH = -imgH / (anchor.getHeight() * det);
-
- m11 = (int)(t.getScaleY() * multW);
- m01 = (int)(t.getShearX() * multW);
- m00 = (int)(t.getScaleX() * multH);
- m10 = (int)(t.getShearY() * multH);
- Point2D p = t.transform(new Point2D.Double(anchor.getX(), anchor.getY()), null);
- px = (int)p.getX();
- py = (int)p.getY();
-
- hx = check2(m11, imgW);
- hy = check2(m10, imgH);
-
- srcRaster = img.getRaster();
- srcBuf = srcRaster.getDataBuffer();
- access = AwtImageBackdoorAccessor.getInstance();
- }
-
- /**
- * Prepares pre-calculated values
- */
- void prepare(int dstX, int dstY, int dstWidth, int dstHeight) {
- vx = check2(- m01 - m11 * dstWidth, imgW);
- vy = check2(- m00 - m10 * dstWidth, imgH);
- int dx = dstX - px;
- int dy = dstY - py;
- sx = check2(dx * m11 - dy * m01, imgW);
- sy = check2(dx * m10 - dy * m00, imgH);
- dstRaster = cm.createCompatibleWritableRaster(dstWidth, dstHeight);
- dstBuf = dstRaster.getDataBuffer();
- }
-
- public void dispose() {
- }
-
- public ColorModel getColorModel() {
- return cm;
- }
-
- /**
- * Checks point overrun of texture anchor
- */
- int check(int value, int max) {
- if (value >= max) {
- return value - max;
- }
- return value;
- }
-
- /**
- * Checks point overrun of texture anchor
- */
- int check2(int value, int max) {
- value = value % max;
- return value < 0 ? max + value : value;
- }
-
- public Raster getRaster(int dstX, int dstY, int dstWidth, int dstHeight) {
- return dstRaster;
- }
-
-}
Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TexturePaintContext.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TexturePaintContext.java?view=auto&rev=453532
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TexturePaintContext.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TexturePaintContext.java Fri Oct 6 01:50:09 2006
@@ -0,0 +1,561 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @author Denis M. Kishenko
+ * @version $Revision$
+ */
+package java.awt;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+
+import org.apache.harmony.awt.gl.AwtImageBackdoorAccessor;
+
+class TexturePaintContext implements PaintContext {
+
+ /**
+ * The ColorModel object of destination raster
+ */
+ ColorModel cm;
+
+ /**
+ * The BufferedImage object used as texture
+ */
+ BufferedImage img;
+
+ /**
+ * The Rectangle2D bounds of texture piece to be painted
+ */
+ Rectangle2D anchor;
+
+ /**
+ * The paint transformation
+ */
+ AffineTransform t;
+
+ /**
+ * The AwtImageBackdoorAccessor object to communicate with image DataBuffer
+ */
+ AwtImageBackdoorAccessor access;
+
+ /**
+ * The source DataBuffer object of texture image
+ */
+ DataBuffer srcBuf;
+
+ /**
+ * The destination DataBuffer object of output rester
+ */
+ DataBuffer dstBuf;
+
+ /**
+ * The source WritableRaster object of texture image
+ */
+ WritableRaster srcRaster;
+
+ /**
+ * The destination WritableRaster object of texture image
+ */
+ WritableRaster dstRaster;
+
+ /**
+ * The width of the texture image
+ */
+ int srcWidth;
+
+ /**
+ * The height of the texture image
+ */
+ int srcHeight;
+
+ /**
+ * The temporary pre-calculated temporary values
+ */
+ int sx, sy, hx, hy, vx, vy;
+ int m00, m01, m10, m11;
+ int imgW, imgH;
+ int px, py;
+
+ /**
+ * The integer array of weight components for bilinear interpolation
+ */
+ int[] weight = new int[4];
+
+ /**
+ * The temporary values
+ */
+ int[] value = new int[4];
+
+ static class IntSimple extends TexturePaintContext {
+
+ /**
+ * Constructs a new IntSimple.TexturePaintContext works with DataBufferInt rasters.
+ * This is simple paint context uses NEAREST NEIGHBOUR interpolation.
+ * @param img - the BufferedImage object used as texture
+ * @param anchor - the Rectangle2D bounds of texture piece to be painted
+ * @param t - the AffineTransform applied to texture painting
+ */
+ public IntSimple(BufferedImage img, Rectangle2D anchor, AffineTransform t) {
+ super(img, anchor, t);
+ }
+
+ @Override
+ public Raster getRaster(int dstX, int dstY, int dstWidth, int dstHeight) {
+ prepare(dstX, dstY, dstWidth, dstHeight);
+ int[] src = access.getDataInt(srcBuf);
+ int[] dst = access.getDataInt(dstBuf);
+ int k = 0;
+ for(int j = 0; j < dstHeight; j++) {
+ for(int i = 0; i < dstWidth; i++) {
+ dst[k++] = src[(sx >> 8) + (sy >> 8) * srcWidth];
+ sx = check(sx + hx, imgW);
+ sy = check(sy + hy, imgH);
+ }
+ sx = check(sx + vx, imgW);
+ sy = check(sy + vy, imgH);
+ }
+ return dstRaster;
+ }
+
+ }
+
+ static class ByteSimple extends TexturePaintContext {
+
+ /**
+ * Constructs a new ByteSimple.TexturePaintContext works with DataBufferByte rasters.
+ * This is simple paint context uses NEAREST NEIGHBOUR interpolation.
+ * @param img - the BufferedImage object used as texture
+ * @param anchor - the Rectangle2D bounds of texture piece to be painted
+ * @param t - the AffineTransform applied to texture painting
+ */
+ public ByteSimple(BufferedImage img, Rectangle2D anchor, AffineTransform t) {
+ super(img, anchor, t);
+ }
+
+ @Override
+ public Raster getRaster(int dstX, int dstY, int dstWidth, int dstHeight) {
+ prepare(dstX, dstY, dstWidth, dstHeight);
+ byte[] src = access.getDataByte(srcBuf);
+ byte[] dst = access.getDataByte(dstBuf);
+ int k = 0;
+ for(int j = 0; j < dstHeight; j++) {
+ for(int i = 0; i < dstWidth; i++) {
+ dst[k++] = src[(sx >> 8) + (sy >> 8) * srcWidth];
+ sx = check(sx + hx, imgW);
+ sy = check(sy + hy, imgH);
+ }
+ sx = check(sx + vx, imgW);
+ sy = check(sy + vy, imgH);
+ }
+ return dstRaster;
+ }
+
+ }
+
+ static class ShortSimple extends TexturePaintContext {
+
+ /**
+ * Constructs a new ShortSimple.TexturePaintContext works with DataBufferShort rasters.
+ * This is simple paint context uses NEAREST NEIGHBOUR interpolation.
+ * @param img - the BufferedImage object used as texture
+ * @param anchor - the Rectangle2D bounds of texture piece to be painted
+ * @param t - the AffineTransform applied to texture painting
+ */
+ public ShortSimple(BufferedImage img, Rectangle2D anchor, AffineTransform t) {
+ super(img, anchor, t);
+ }
+
+ @Override
+ public Raster getRaster(int dstX, int dstY, int dstWidth, int dstHeight) {
+ prepare(dstX, dstY, dstWidth, dstHeight);
+ short[] src = access.getDataUShort(srcBuf);
+ short[] dst = access.getDataUShort(dstBuf);
+ int k = 0;
+ for(int j = 0; j < dstHeight; j++) {
+ for(int i = 0; i < dstWidth; i++) {
+ dst[k++] = src[(sx >> 8) + (sy >> 8) * srcWidth];
+ sx = check(sx + hx, imgW);
+ sy = check(sy + hy, imgH);
+ }
+ sx = check(sx + vx, imgW);
+ sy = check(sy + vy, imgH);
+ }
+ return dstRaster;
+ }
+ }
+
+ static class CommonSimple extends TexturePaintContext {
+
+ /**
+ * Constructs a new CommonSimple.TexturePaintContext works with any raster type.
+ * This is simple paint context uses NEAREST NEIGHBOUR interpolation.
+ * @param img - the BufferedImage object used as texture
+ * @param anchor - the Rectangle2D bounds of texture piece to be painted
+ * @param t - the AffineTransform applied to texture painting
+ */
+ public CommonSimple(BufferedImage img, Rectangle2D anchor, AffineTransform t) {
+ super(img, anchor, t);
+ }
+
+ @Override
+ public Raster getRaster(int dstX, int dstY, int dstWidth, int dstHeight) {
+ prepare(dstX, dstY, dstWidth, dstHeight);
+ for(int j = 0; j < dstHeight; j++) {
+ for(int i = 0; i < dstWidth; i++) {
+ dstRaster.setDataElements(dstX + i, dstY + j, srcRaster.getDataElements(sx >> 8, sy >> 8, null));
+ sx = check(sx + hx, imgW);
+ sy = check(sy + hy, imgH);
+ }
+ sx = check(sx + vx, imgW);
+ sy = check(sy + vy, imgH);
+ }
+ return dstRaster;
+ }
+
+ }
+
+ static class IntBilinear extends TexturePaintContext {
+
+ /**
+ * Constructs a new IntSimple.TexturePaintContext works with DataBufferInt rasters.
+ * This paint context uses BILINEAR interpolation.
+ * @param img - the BufferedImage object used as texture
+ * @param anchor - the Rectangle2D bounds of texture piece to be painted
+ * @param t - the AffineTransform applied to texture painting
+ */
+ public IntBilinear(BufferedImage img, Rectangle2D anchor, AffineTransform t) {
+ super(img, anchor, t);
+ }
+
+ @Override
+ public Raster getRaster(int dstX, int dstY, int dstWidth, int dstHeight) {
+ prepare(dstX, dstY, dstWidth, dstHeight);
+ int[] src = access.getDataInt(srcBuf);
+ int[] dst = access.getDataInt(dstBuf);
+ int k = 0;
+ for(int j = 0; j < dstHeight; j++) {
+ for(int i = 0; i < dstWidth; i++) {
+ int wx1 = sx & 0xFF;
+ int wy1 = sy & 0xFF;
+ int wx0 = 0xFF - wx1;
+ int wy0 = 0xFF - wy1;
+
+ weight[0] = wx0 * wy0;
+ weight[1] = wx1 * wy0;
+ weight[2] = wx0 * wy1;
+ weight[3] = wx1 * wy1;
+
+ int x0 = sx >> 8;
+ int y0 = sy >> 8;
+ int x1 = check(x0 + 1, srcWidth);
+ int y1 = check(y0 + 1, srcHeight);
+
+ y0 *= srcWidth;
+ y1 *= srcWidth;
+
+ value[0] = src[x0 + y0];
+ value[1] = src[x1 + y0];
+ value[2] = src[x0 + y1];
+ value[3] = src[x1 + y1];
+
+ int color = 0;
+ for(int n = 0; n < 32; n += 8) {
+ int comp = 0;
+ for(int m = 0; m < 4; m++) {
+ comp += ((value[m] >> n) & 0xFF) * weight[m];
+ }
+ color |= (comp >> 16) << n;
+ }
+
+ dst[k++] = color;
+
+ sx = check(sx + hx, imgW);
+ sy = check(sy + hy, imgH);
+ }
+ sx = check(sx + vx, imgW);
+ sy = check(sy + vy, imgH);
+ }
+ return dstRaster;
+ }
+
+ }
+
+ static class ByteBilinear extends TexturePaintContext {
+
+ /**
+ * Constructs a new ByteSimple.TexturePaintContext works with DataBufferByte rasters.
+ * This paint context uses BILINEAR interpolation.
+ * @param img - the BufferedImage object used as texture
+ * @param anchor - the Rectangle2D bounds of texture piece to be painted
+ * @param t - the AffineTransform applied to texture painting
+ */
+ public ByteBilinear(BufferedImage img, Rectangle2D anchor, AffineTransform t) {
+ super(img, anchor, t);
+ }
+
+ @Override
+ public Raster getRaster(int dstX, int dstY, int dstWidth, int dstHeight) {
+ prepare(dstX, dstY, dstWidth, dstHeight);
+ byte[] src = access.getDataByte(srcBuf);
+ byte[] dst = access.getDataByte(dstBuf);
+ int k = 0;
+ for(int j = 0; j < dstHeight; j++) {
+ for(int i = 0; i < dstWidth; i++) {
+ int wx1 = sx & 0xFF;
+ int wy1 = sy & 0xFF;
+ int wx0 = 0xFF - wx1;
+ int wy0 = 0xFF - wy1;
+
+ weight[0] = wx0 * wy0;
+ weight[1] = wx1 * wy0;
+ weight[2] = wx0 * wy1;
+ weight[3] = wx1 * wy1;
+
+ int x0 = sx >> 8;
+ int y0 = sy >> 8;
+ int x1 = check(x0 + 1, srcWidth);
+ int y1 = check(y0 + 1, srcHeight);
+
+ y0 *= dstWidth;
+ y1 *= dstWidth;
+
+ value[0] = src[x0 + y0];
+ value[1] = src[x1 + y0];
+ value[2] = src[x0 + y1];
+ value[3] = src[x1 + y1];
+
+ int comp = 0;
+ for(int m = 0; m < 4; m++) {
+ comp += value[m] * weight[m];
+ }
+ dst[k++] = (byte)(comp >> 16);
+
+ sx = check(sx + hx, imgW);
+ sy = check(sy + hy, imgH);
+ }
+ sx = check(sx + vx, imgW);
+ sy = check(sy + vy, imgH);
+ }
+ return dstRaster;
+ }
+
+ }
+
+ static class ShortBilinear extends TexturePaintContext {
+
+ /**
+ * Constructs a new ShortSimple.TexturePaintContext works with DataBufferShort rasters.
+ * This paint context uses BILINEAR interpolation.
+ * @param img - the BufferedImage object used as texture
+ * @param anchor - the Rectangle2D bounds of texture piece to be painted
+ * @param t - the AffineTransform applied to texture painting
+ */
+ public ShortBilinear(BufferedImage img, Rectangle2D anchor, AffineTransform t) {
+ super(img, anchor, t);
+ }
+
+ @Override
+ public Raster getRaster(int dstX, int dstY, int dstWidth, int dstHeight) {
+ prepare(dstX, dstY, dstWidth, dstHeight);
+ short[] src = access.getDataUShort(srcBuf);
+ short[] dst = access.getDataUShort(dstBuf);
+ int k = 0;
+ for(int j = 0; j < dstHeight; j++) {
+ for(int i = 0; i < dstWidth; i++) {
+ int wx1 = sx & 0xFF;
+ int wy1 = sy & 0xFF;
+ int wx0 = 0xFF - wx1;
+ int wy0 = 0xFF - wy1;
+
+ weight[0] = wx0 * wy0;
+ weight[1] = wx1 * wy0;
+ weight[2] = wx0 * wy1;
+ weight[3] = wx1 * wy1;
+
+ int x0 = sx >> 8;
+ int y0 = sy >> 8;
+ int x1 = check(x0 + 1, srcWidth);
+ int y1 = check(y0 + 1, srcHeight);
+
+ y0 *= dstWidth;
+ y1 *= dstWidth;
+
+ value[0] = src[x0 + y0];
+ value[1] = src[x1 + y0];
+ value[2] = src[x0 + y1];
+ value[3] = src[x1 + y1];
+
+ short color = 0;
+ for(int n = 0; n < 16; n += 8) {
+ int comp = 0;
+ for(int m = 0; m < 4; m++) {
+ comp += ((value[m] >> n) & 0xFF) * weight[m];
+ }
+ color |= (comp >> 16) << n;
+ }
+ dst[k++] = color;
+
+ sx = check(sx + hx, imgW);
+ sy = check(sy + hy, imgH);
+ }
+ sx = check(sx + vx, imgW);
+ sy = check(sy + vy, imgH);
+ }
+ return dstRaster;
+ }
+
+ }
+
+ static class CommonBilinear extends TexturePaintContext {
+
+ /**
+ * Constructs a new CommonSimple.TexturePaintContext works with any raster type.
+ * This paint context uses BILINEAR interpolation.
+ * @param img - the BufferedImage object used as texture
+ * @param anchor - the Rectangle2D bounds of texture piece to be painted
+ * @param t - the AffineTransform applied to texture painting
+ */
+ public CommonBilinear(BufferedImage img, Rectangle2D anchor, AffineTransform t) {
+ super(img, anchor, t);
+ }
+
+ @Override
+ public Raster getRaster(int dstX, int dstY, int dstWidth, int dstHeight) {
+ prepare(dstX, dstY, dstWidth, dstHeight);
+ for(int j = 0; j < dstHeight; j++) {
+ for(int i = 0; i < dstWidth; i++) {
+ int wx1 = sx & 0xFF;
+ int wy1 = sy & 0xFF;
+ int wx0 = 0xFF - wx1;
+ int wy0 = 0xFF - wy1;
+
+ weight[0] = wx0 * wy0;
+ weight[1] = wx1 * wy0;
+ weight[2] = wx0 * wy1;
+ weight[3] = wx1 * wy1;
+
+ int x0 = sx >> 8;
+ int y0 = sy >> 8;
+ int x1 = check(x0 + 1, srcWidth);
+ int y1 = check(y0 + 1, srcHeight);
+
+ value[0] = cm.getRGB(srcRaster.getDataElements(x0, y0, null));
+ value[1] = cm.getRGB(srcRaster.getDataElements(x1, y0, null));
+ value[2] = cm.getRGB(srcRaster.getDataElements(x0, y1, null));
+ value[3] = cm.getRGB(srcRaster.getDataElements(x1, y1, null));
+
+ int color = 0;
+ for(int n = 0; n < 32; n += 8) {
+ int comp = 0;
+ for(int m = 0; m < 4; m++) {
+ comp += ((value[m] >> n) & 0xFF) * weight[m];
+ }
+ color |= (comp >> 16) << n;
+ }
+ dstRaster.setDataElements(dstX + i, dstY + j, cm.getDataElements(color, null));
+
+ sx = check(sx + hx, imgW);
+ sy = check(sy + hy, imgH);
+ }
+ sx = check(sx + vx, imgW);
+ sy = check(sy + vy, imgH);
+ }
+ return dstRaster;
+ }
+
+ }
+
+ public TexturePaintContext(BufferedImage img, Rectangle2D anchor, AffineTransform t) {
+ this.cm = img.getColorModel();
+ this.img = img;
+ this.anchor = anchor;
+ this.t = t;
+
+ srcWidth = img.getWidth();
+ srcHeight = img.getHeight();
+ imgW = srcWidth << 8;
+ imgH = srcHeight << 8;
+ double det = t.getDeterminant();
+ double multW = imgW / (anchor.getWidth() * det);
+ double multH = -imgH / (anchor.getHeight() * det);
+
+ m11 = (int)(t.getScaleY() * multW);
+ m01 = (int)(t.getShearX() * multW);
+ m00 = (int)(t.getScaleX() * multH);
+ m10 = (int)(t.getShearY() * multH);
+ Point2D p = t.transform(new Point2D.Double(anchor.getX(), anchor.getY()), null);
+ px = (int)p.getX();
+ py = (int)p.getY();
+
+ hx = check2(m11, imgW);
+ hy = check2(m10, imgH);
+
+ srcRaster = img.getRaster();
+ srcBuf = srcRaster.getDataBuffer();
+ access = AwtImageBackdoorAccessor.getInstance();
+ }
+
+ /**
+ * Prepares pre-calculated values
+ */
+ void prepare(int dstX, int dstY, int dstWidth, int dstHeight) {
+ vx = check2(- m01 - m11 * dstWidth, imgW);
+ vy = check2(- m00 - m10 * dstWidth, imgH);
+ int dx = dstX - px;
+ int dy = dstY - py;
+ sx = check2(dx * m11 - dy * m01, imgW);
+ sy = check2(dx * m10 - dy * m00, imgH);
+ dstRaster = cm.createCompatibleWritableRaster(dstWidth, dstHeight);
+ dstBuf = dstRaster.getDataBuffer();
+ }
+
+ public void dispose() {
+ }
+
+ public ColorModel getColorModel() {
+ return cm;
+ }
+
+ /**
+ * Checks point overrun of texture anchor
+ */
+ int check(int value, int max) {
+ if (value >= max) {
+ return value - max;
+ }
+ return value;
+ }
+
+ /**
+ * Checks point overrun of texture anchor
+ */
+ int check2(int value, int max) {
+ value = value % max;
+ return value < 0 ? max + value : value;
+ }
+
+ public Raster getRaster(int dstX, int dstY, int dstWidth, int dstHeight) {
+ return dstRaster;
+ }
+
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TexturePaintContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/TexturePaintContext.java
------------------------------------------------------------------------------
svn:executable = *
Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/wtk/linux/LinuxWindowFactory.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/wtk/linux/LinuxWindowFactory.java?view=diff&rev=453532&r1=453531&r2=453532
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/wtk/linux/LinuxWindowFactory.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/wtk/linux/LinuxWindowFactory.java Fri Oct 6 01:50:09 2006
@@ -211,54 +211,3 @@
}
}
-
-class XServerConnection {
-
- private long display;
-
- private int screen;
-
- private final X11 x11;
-
- public XServerConnection(X11 x11) {
- this.x11 = x11;
- display = x11.XOpenDisplay(0); //0 - we use default display only
- if (display == 0) {
- String name = System.getProperty("DISPLAY");
- throw new InternalError("Cannot open display '" + (name != null ? name : "") + "'");
- }
- screen = x11.XDefaultScreen(display);
- }
-
- public void close() {
- x11.XCloseDisplay(display);
- }
-
- public long getDisplay() {
- return display;
- }
-
- public int getScreen() {
- return screen;
- }
-}
-
-final class LinuxWindowMap {
- private final Map map = Collections.synchronizedMap(new HashMap());
-
- LinuxWindow get(long id) {
- return (LinuxWindow)map.get(new Long(id));
- }
-
- void put(LinuxWindow win) {
- map.put(new Long(win.getId()), win);
- }
-
- void remove(long id) {
- map.remove(new Long(id));
- }
-
- boolean contains(long id) {
- return map.containsKey(new Long(id));
- }
-}
Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/wtk/linux/LinuxWindowMap.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/wtk/linux/LinuxWindowMap.java?view=auto&rev=453532
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/wtk/linux/LinuxWindowMap.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/wtk/linux/LinuxWindowMap.java Fri Oct 6 01:50:09 2006
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @author Michael Danilov
+ * @version $Revision$
+ */
+package org.apache.harmony.awt.wtk.linux;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+final class LinuxWindowMap {
+ private final Map map = Collections.synchronizedMap(new HashMap());
+
+ LinuxWindow get(long id) {
+ return (LinuxWindow)map.get(new Long(id));
+ }
+
+ void put(LinuxWindow win) {
+ map.put(new Long(win.getId()), win);
+ }
+
+ void remove(long id) {
+ map.remove(new Long(id));
+ }
+
+ boolean contains(long id) {
+ return map.containsKey(new Long(id));
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/wtk/linux/LinuxWindowMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/wtk/linux/XServerConnection.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/wtk/linux/XServerConnection.java?view=auto&rev=453532
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/wtk/linux/XServerConnection.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/wtk/linux/XServerConnection.java Fri Oct 6 01:50:09 2006
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @author Michael Danilov
+ * @version $Revision$
+ */
+package org.apache.harmony.awt.wtk.linux;
+
+import org.apache.harmony.awt.nativebridge.linux.X11;
+
+class XServerConnection {
+
+ private long display;
+
+ private int screen;
+
+ private final X11 x11;
+
+ public XServerConnection(X11 x11) {
+ this.x11 = x11;
+ display = x11.XOpenDisplay(0); //0 - we use default display only
+ if (display == 0) {
+ String name = System.getProperty("DISPLAY");
+ throw new InternalError("Cannot open display '" + (name != null ? name : "") + "'");
+ }
+ screen = x11.XDefaultScreen(display);
+ }
+
+ public void close() {
+ x11.XCloseDisplay(display);
+ }
+
+ public long getDisplay() {
+ return display;
+ }
+
+ public int getScreen() {
+ return screen;
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/linux/org/apache/harmony/awt/wtk/linux/XServerConnection.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java?view=diff&rev=453532&r1=453531&r2=453532
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java Fri Oct 6 01:50:09 2006
@@ -155,66 +155,3 @@
}
}
-
-/**
- * Customized object input stream that allows to read objects by specified class
- * loader
- */
-class CustomizedObjectInputStream extends ObjectInputStream {
-
- private ClassLoader cls;
-
- public CustomizedObjectInputStream(InputStream in, ClassLoader cls)
- throws IOException {
- super(in);
- this.cls = cls;
- }
-
- protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException,
- ClassNotFoundException {
- String className = desc.getName();
-
- if (className.startsWith("[")) { //$NON-NLS-1$
- int idx = className.lastIndexOf("["); //$NON-NLS-1$
- String prefix = className.substring(0, idx + 1);
- int[] dimensions = new int[prefix.length()];
- String postfix;
- Class<?> componentType = null;
-
- for (int i = 0; i < dimensions.length; ++i) {
- dimensions[i] = 0;
- }
-
- postfix = className.substring(idx + 1);
- if (postfix.equals("Z")) { //$NON-NLS-1$
- componentType = boolean.class;
- } else if (postfix.equals("B")) { //$NON-NLS-1$
- componentType = byte.class;
- } else if (postfix.equals("C")) { //$NON-NLS-1$
- componentType = char.class;
- } else if (postfix.equals("D")) { //$NON-NLS-1$
- componentType = double.class;
- } else if (postfix.equals("F")) { //$NON-NLS-1$
- componentType = float.class;
- } else if (postfix.equals("I")) { //$NON-NLS-1$
- componentType = int.class;
- } else if (postfix.equals("L")) { //$NON-NLS-1$
- componentType = long.class;
- } else if (postfix.equals("S")) { //$NON-NLS-1$
- componentType = short.class;
- } else if (postfix.equals("V")) { //$NON-NLS-1$
- componentType = null;
- } else if (postfix.startsWith("L")) { //$NON-NLS-1$
- componentType = cls.loadClass(postfix.substring(1, postfix
- .length() - 1));
- } else {
- throw new IllegalArgumentException(Messages.getString(
- "beans.1E", className)); //$NON-NLS-1$
- }
-
- return Array.newInstance(componentType, dimensions).getClass();
- }
-
- return Class.forName(className, true, cls);
- }
-}
Added: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/CustomizedObjectInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/CustomizedObjectInputStream.java?view=auto&rev=453532
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/CustomizedObjectInputStream.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/CustomizedObjectInputStream.java Fri Oct 6 01:50:09 2006
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.beans;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamClass;
+import java.lang.reflect.Array;
+
+import org.apache.harmony.beans.internal.nls.Messages;
+
+/**
+ * Customized object input stream that allows to read objects by specified class
+ * loader
+ */
+class CustomizedObjectInputStream extends ObjectInputStream {
+
+ private ClassLoader cls;
+
+ public CustomizedObjectInputStream(InputStream in, ClassLoader cls)
+ throws IOException {
+ super(in);
+ this.cls = cls;
+ }
+
+ protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException,
+ ClassNotFoundException {
+ String className = desc.getName();
+
+ if (className.startsWith("[")) { //$NON-NLS-1$
+ int idx = className.lastIndexOf("["); //$NON-NLS-1$
+ String prefix = className.substring(0, idx + 1);
+ int[] dimensions = new int[prefix.length()];
+ String postfix;
+ Class<?> componentType = null;
+
+ for (int i = 0; i < dimensions.length; ++i) {
+ dimensions[i] = 0;
+ }
+
+ postfix = className.substring(idx + 1);
+ if (postfix.equals("Z")) { //$NON-NLS-1$
+ componentType = boolean.class;
+ } else if (postfix.equals("B")) { //$NON-NLS-1$
+ componentType = byte.class;
+ } else if (postfix.equals("C")) { //$NON-NLS-1$
+ componentType = char.class;
+ } else if (postfix.equals("D")) { //$NON-NLS-1$
+ componentType = double.class;
+ } else if (postfix.equals("F")) { //$NON-NLS-1$
+ componentType = float.class;
+ } else if (postfix.equals("I")) { //$NON-NLS-1$
+ componentType = int.class;
+ } else if (postfix.equals("L")) { //$NON-NLS-1$
+ componentType = long.class;
+ } else if (postfix.equals("S")) { //$NON-NLS-1$
+ componentType = short.class;
+ } else if (postfix.equals("V")) { //$NON-NLS-1$
+ componentType = null;
+ } else if (postfix.startsWith("L")) { //$NON-NLS-1$
+ componentType = cls.loadClass(postfix.substring(1, postfix
+ .length() - 1));
+ } else {
+ throw new IllegalArgumentException(Messages.getString(
+ "beans.1E", className)); //$NON-NLS-1$
+ }
+
+ return Array.newInstance(componentType, dimensions).getClass();
+ }
+
+ return Class.forName(className, true, cls);
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/CustomizedObjectInputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java?view=diff&rev=453532&r1=453531&r2=453532
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/CompoundName.java Fri Oct 6 01:50:09 2006
@@ -998,15 +998,3 @@
return true;
}
}
-
-/**
- * A useless class required to satisfy the requirement for an 'impl'
- * field (see above).
- */
-class NameImpl {
- protected NameImpl() {
- super();
- }
-}
-
-
Added: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameImpl.java?view=auto&rev=453532
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameImpl.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameImpl.java Fri Oct 6 01:50:09 2006
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.naming;
+
+/**
+ * A useless class required to satisfy the requirement for an 'impl'
+ * field (see CompoundName.java).
+ */
+class NameImpl {
+ protected NameImpl() {
+ super();
+ }
+}
+
+
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/jndi/src/main/java/javax/naming/NameImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java?view=diff&rev=453532&r1=453531&r2=453532
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java Fri Oct 6 01:50:09 2006
@@ -310,309 +310,3 @@
return result;
}
}
-
-/*
- * Parses hex string to a single or double precision floating point number.
- */
-final class HexStringParser {
-
- private static final int DOUBLE_EXPONENT_WIDTH = 11;
-
- private static final int DOUBLE_MANTISSA_WIDTH = 52;
-
- private static final int FLOAT_EXPONENT_WIDTH = 8;
-
- private static final int FLOAT_MANTISSA_WIDTH = 23;
-
- private static final int HEX_RADIX = 16;
-
- private static final int MAX_SIGNIFICANT_LENGTH = 15;
-
- private static final String HEX_SIGNIFICANT = "0[xX](\\p{XDigit}+\\.?|\\p{XDigit}*\\.\\p{XDigit}+)"; //$NON-NLS-1$
-
- private static final String BINARY_EXPONENT = "[pP]([+-]?\\d+)"; //$NON-NLS-1$
-
- private static final String FLOAT_TYPE_SUFFIX = "[fFdD]?"; //$NON-NLS-1$
-
- private static final String HEX_PATTERN = "[\\x00-\\x20]*([+-]?)" + HEX_SIGNIFICANT //$NON-NLS-1$
- + BINARY_EXPONENT + FLOAT_TYPE_SUFFIX + "[\\x00-\\x20]*"; //$NON-NLS-1$
-
- private static final Pattern PATTERN = Pattern.compile(HEX_PATTERN);
-
- private final int EXPONENT_WIDTH;
-
- private final int MANTISSA_WIDTH;
-
- private final long EXPONENT_BASE;
-
- private final long MAX_EXPONENT;
-
- private final long MIN_EXPONENT;
-
- private final long MANTISSA_MASK;
-
- private long sign;
-
- private long exponent;
-
- private long mantissa;
-
- private String abandonedNumber=""; //$NON-NLS-1$
-
- public HexStringParser(int exponent_width, int mantissa_width) {
- this.EXPONENT_WIDTH = exponent_width;
- this.MANTISSA_WIDTH = mantissa_width;
-
- this.EXPONENT_BASE = ~(-1L << (exponent_width - 1));
- this.MAX_EXPONENT = ~(-1L << exponent_width);
- this.MIN_EXPONENT = -(MANTISSA_WIDTH + 1);
- this.MANTISSA_MASK = ~(-1L << mantissa_width);
- }
-
- /*
- * Parses the hex string to a double number.
- */
- public static double parseDouble(String hexString) {
- HexStringParser parser = new HexStringParser(DOUBLE_EXPONENT_WIDTH,
- DOUBLE_MANTISSA_WIDTH);
- long result = parser.parse(hexString);
- return Double.longBitsToDouble(result);
- }
-
- /*
- * Parses the hex string to a float number.
- */
- public static float parseFloat(String hexString) {
- HexStringParser parser = new HexStringParser(FLOAT_EXPONENT_WIDTH,
- FLOAT_MANTISSA_WIDTH);
- int result = (int) parser.parse(hexString);
- return Float.intBitsToFloat(result);
- }
-
- private long parse(String hexString) {
- String[] hexSegments = getSegmentsFromHexString(hexString);
- String signStr = hexSegments[0];
- String significantStr = hexSegments[1];
- String exponentStr = hexSegments[2];
-
- parseHexSign(signStr);
- parseExponent(exponentStr);
- parseMantissa(significantStr);
-
- sign <<= (MANTISSA_WIDTH + EXPONENT_WIDTH);
- exponent <<= MANTISSA_WIDTH;
- return sign | exponent | mantissa;
- }
-
- /*
- * Analyzes the hex string and extracts the sign and digit segments.
- */
- private static String[] getSegmentsFromHexString(String hexString) {
- Matcher matcher = PATTERN.matcher(hexString);
- if (!matcher.matches()) {
- throw new NumberFormatException();
- }
-
- String[] hexSegments = new String[3];
- hexSegments[0] = matcher.group(1);
- hexSegments[1] = matcher.group(2);
- hexSegments[2] = matcher.group(3);
-
- return hexSegments;
- }
-
- /*
- * Parses the sign field.
- */
- private void parseHexSign(String signStr) {
- this.sign = signStr.equals("-") ? 1 : 0; //$NON-NLS-1$
- }
-
- /*
- * Parses the exponent field.
- */
- private void parseExponent(String exponentStr) {
- char leadingChar = exponentStr.charAt(0);
- int expSign = (leadingChar == '-' ? -1 : 1);
- if (!Character.isDigit(leadingChar)) {
- exponentStr = exponentStr.substring(1);
- }
-
- try {
- exponent = expSign * Long.parseLong(exponentStr);
- checkedAddExponent(EXPONENT_BASE);
- } catch (NumberFormatException e) {
- exponent = expSign * Long.MAX_VALUE;
- }
- }
-
- /*
- * Parses the mantissa field.
- */
- private void parseMantissa(String significantStr) {
- String[] strings = significantStr.split("\\."); //$NON-NLS-1$
- String strIntegerPart = strings[0];
- String strDecimalPart = strings.length > 1 ? strings[1] : ""; //$NON-NLS-1$
-
- String significand = getNormalizedSignificand(strIntegerPart,strDecimalPart);
- if (significand.equals("0")) { //$NON-NLS-1$
- setZero();
- return;
- }
-
- int offset = getOffset(strIntegerPart, strDecimalPart);
- checkedAddExponent(offset);
-
- if (exponent >= MAX_EXPONENT) {
- setInfinite();
- return;
- }
-
- if (exponent <= MIN_EXPONENT) {
- setZero();
- return;
- }
-
- if (significand.length() > MAX_SIGNIFICANT_LENGTH) {
- abandonedNumber = significand.substring(MAX_SIGNIFICANT_LENGTH);
- significand = significand.substring(0, MAX_SIGNIFICANT_LENGTH);
- }
-
- mantissa = Long.parseLong(significand, HEX_RADIX);
-
- if (exponent >= 1) {
- processNormalNumber();
- } else{
- processSubNormalNumber();
- }
-
- }
-
- private void setInfinite() {
- exponent = MAX_EXPONENT;
- mantissa = 0;
- }
-
- private void setZero() {
- exponent = 0;
- mantissa = 0;
- }
-
- /*
- * Sets the exponent variable to Long.MAX_VALUE or -Long.MAX_VALUE if
- * overflow or underflow happens.
- */
- private void checkedAddExponent(long offset) {
- long result = exponent + offset;
- int expSign = Long.signum(exponent);
- if (expSign * Long.signum(offset) > 0 && expSign * Long.signum(result) < 0) {
- exponent = expSign * Long.MAX_VALUE;
- } else {
- exponent = result;
- }
- }
-
- private void processNormalNumber(){
- int desiredWidth = MANTISSA_WIDTH + 2;
- fitMantissaInDesiredWidth(desiredWidth);
- round();
- mantissa = mantissa & MANTISSA_MASK;
- }
-
- private void processSubNormalNumber(){
- int desiredWidth = MANTISSA_WIDTH + 1;
- desiredWidth += (int)exponent;//lends bit from mantissa to exponent
- exponent = 0;
- fitMantissaInDesiredWidth(desiredWidth);
- round();
- mantissa = mantissa & MANTISSA_MASK;
- }
-
- /*
- * Adjusts the mantissa to desired width for further analysis.
- */
- private void fitMantissaInDesiredWidth(int desiredWidth){
- int bitLength = countBitsLength(mantissa);
- if (bitLength > desiredWidth) {
- discardTrailingBits(bitLength - desiredWidth);
- } else {
- mantissa <<= (desiredWidth - bitLength);
- }
- }
-
- /*
- * Stores the discarded bits to abandonedNumber.
- */
- private void discardTrailingBits(long num) {
- long mask = ~(-1L << num);
- abandonedNumber += (mantissa & mask);
- mantissa >>= num;
- }
-
- /*
- * The value is rounded up or down to the nearest infinitely precise result.
- * If the value is exactly halfway between two infinitely precise results,
- * then it should be rounded up to the nearest infinitely precise even.
- */
- private void round() {
- String result = abandonedNumber.replaceAll("0+", ""); //$NON-NLS-1$ //$NON-NLS-2$
- boolean moreThanZero = (result.length() > 0 ? true : false);
-
- int lastDiscardedBit = (int) (mantissa & 1L);
- mantissa >>= 1;
- int tailBitInMantissa = (int) (mantissa & 1L);
-
- if (lastDiscardedBit == 1 && (moreThanZero || tailBitInMantissa == 1)) {
- int oldLength = countBitsLength(mantissa);
- mantissa += 1L;
- int newLength = countBitsLength(mantissa);
-
- //Rounds up to exponent when whole bits of mantissa are one-bits.
- if (oldLength >= MANTISSA_WIDTH && newLength > oldLength) {
- checkedAddExponent(1);
- }
- }
- }
-
- /*
- * Returns the normalized significand after removing the leading zeros.
- */
- private String getNormalizedSignificand(String strIntegerPart, String strDecimalPart) {
- String significand = strIntegerPart + strDecimalPart;
- significand = significand.replaceFirst("^0+", ""); //$NON-NLS-1$//$NON-NLS-2$
- if (significand.length() == 0) {
- significand = "0"; //$NON-NLS-1$
- }
- return significand;
- }
-
- /*
- * Calculates the offset between the normalized number and unnormalized
- * number. In a normalized representation, significand is represented by the
- * characters "0x1." followed by a lowercase hexadecimal representation of
- * the rest of the significand as a fraction.
- */
- private int getOffset(String strIntegerPart, String strDecimalPart) {
- strIntegerPart = strIntegerPart.replaceFirst("^0+", ""); //$NON-NLS-1$ //$NON-NLS-2$
-
- //If the Interger part is a nonzero number.
- if (strIntegerPart.length() != 0) {
- String leadingNumber = strIntegerPart.substring(0, 1);
- return (strIntegerPart.length() - 1) * 4 + countBitsLength(Long.parseLong(leadingNumber,HEX_RADIX)) - 1;
- }
-
- //If the Interger part is a zero number.
- int i;
- for (i = 0; i < strDecimalPart.length() && strDecimalPart.charAt(i) == '0'; i++);
- if (i == strDecimalPart.length()) {
- return 0;
- }
- String leadingNumber=strDecimalPart.substring(i,i + 1);
- return (-i - 1) * 4 + countBitsLength(Long.parseLong(leadingNumber, HEX_RADIX)) - 1;
- }
-
- private int countBitsLength(long value) {
- int leadingZeros = Long.numberOfLeadingZeros(value);
- return Long.SIZE - leadingZeros;
- }
-}
\ No newline at end of file