3bd483f2a1
* Makefile.in: Rebuilt. * Makefile.am (awt_java_source_files): Reference files in gnu/java/awt, not gnu/gcj/awt. * java/awt/image/BufferedImage.java: Updated copyright. * java/awt/image/ComponentColorModel.java: Updated copyright. * java/awt/image/ComponentSampleModel.java: Updated copyright. * java/awt/image/DataBuffer.java: Updated copyright. * java/awt/image/DataBufferByte.java: Updated copyright. * java/awt/image/DataBufferInt.java: Updated copyright. * java/awt/image/DataBufferUShort.java: Updated copyright. * java/awt/image/IndexColorModel.java: Updated copyright. * java/awt/image/PackedColorModel.java: Updated copyright. * java/awt/image/Raster.java: Updated copyright. * java/awt/image/RasterOp.java: Updated copyright. * java/awt/image/SampleModel.java: Updated copyright. * java/awt/image/SinglePixelPackedSampleModel.java: Updated copyright. * java/awt/image/WritableRaster.java: Updated copyright. * java/awt/color/ColorSpace.java: Updated copyright. * java/awt/color/ICC_ColorSpace.java: Updated copyright * java/awt/color/ICC_Profile.java: Updated copyright. * java/awt/event/HierarchyBoundsAdapter.java: Updated copyright. * java/awt/event/HierarchyBoundsListener.java: Updated copyright. * java/awt/event/HierarchyEvent.java: Updated copyright. * java/awt/event/HierarchyListener.java: Updated copyright. * java/awt/geom/AffineTransform.java: Updated copyright. * java/awt/geom/Dimension2D.java: Updated copyright. * java/awt/geom/Ellipse2D.java: Updated copyright. * java/awt/geom/IllegalPathStateException.java: Updated copyright. * java/awt/geom/Line2D.java: Updated copyright. * java/awt/geom/NoninvertibleTransformException.java: Updated copyright. * java/awt/geom/PathIterator.java: Updated copyright. * java/awt/geom/Point2D.java: Updated copyright. * java/awt/geom/Rectangle2D.java: Updated copyright. * java/awt/geom/RectangularShape.java: Updated copyright. * java/awt/geom/RoundRectangle2D.java: Updated copyright. * java/awt/Toolkit.java: Updated import for file moves. * java/awt/Rectangle.java: Updated copyright; added javadoc from Classpath. (hashCode): New method from Classpath. * java/awt/Graphics2D.java: Updated copyright. * java/awt/Transparency.java: Updated copyright. * java/awt/Paint.java: Updated copyright. * java/awt/Graphics.java: New version from Classpath. * java/awt/EventDispatchThread.java: Updated copyright. * java/awt/CardLayout.java (layoutContainer): Don't skip invisible children. (gotoComponent): Wrap around on next/previous. * gnu/gcj/awt/BitMaskExtent.java: Removed. * gnu/gcj/awt/Buffers.java: Removed. * gnu/gcj/awt/ComponentDataBlitOp.java: Removed. * gnu/gcj/awt/GLightweightPeer.java: Removed. * gnu/java/awt/BitMaskExtent.java: Added. * gnu/java/awt/Buffers.java: Added. * gnu/java/awt/ComponentDataBlitOp.java: Added. * gnu/java/awt/GLightweightPeer.java: Added. * java/awt/geom/Line2D.java (clone): Ignore CloneNotSupportedException. * gnu/gcj/awt/GLightweightPeer.java (getColorModel): New method. * java/awt/Frame.java: Merged with Classpath. * java/awt/RenderingHints.java: Copyright update. * java/awt/Paint.java: Copyright update. * java/awt/image/DirectColorModel.java: Merged with Classpath. * java/awt/image/ColorModel.java: Merged with Classpath. * java/awt/Window.java (show): New Implementation from Classpath. (isShowing): Use super.isShowing(). * java/awt/EventQueue.java: Merged with Classpath. * java/awt/AWTEventMulticaster.java (save): Throw RuntimeException. (saveInternal): Likewise. * java/awt/AWTEvent.java: Now implements Serializable. * java/awt/Event.java: Copyright update. * java/awt/peer/ComponentPeer.java: Merged with Classpath. * java/awt/image/BufferedImage.java: Copyright update. * java/awt/GraphicsConfiguration.java: Copyright update. * java/awt/Component.java: (addNotify): Don't call addNotifyContainerChildren(). (addNotifyContainerChildren): Removed. (setPeer): New method from Classpath. (setTreeLock): Likewise. (setVisible): Rewrote. (show): Use it. (hide): Likewise. (validate): Set `valid'. (checkImage(Image,ImageObserver)): Implementation from Classpath. (createImage(ImageProducer)): Likewise. (prepareImage): Likewise. * java/awt/Container.java (addImpl): Handle case where constraint is not a String. Post event via system event queue. (remove): Post event via system event queue. (validateTree): Only validate child if it is invalid. (getAlignmentX): Call super method as default. (getAlignmentY): Likewise. (addContainerListener): Now synchronized. (removeContainerListener): Likewise. (addNotifyContainerChildren): Now private. * java/awt/ComponentOrientation.java: Updated copyright. Added @author. * java/awt/FlowLayout.java (serialVersionUID): New field. (setAlignment): Better exception message. (layoutContainer): Don't compute component's preferred size unless we're going to use it. * java/awt/BorderLayout.java (AFTER_LAST_LINE, AFTER_LINE_ENDS, BEFORE_FIRST_LINE, BEFORE_LINE_BEGINS): New constants. (firstLine, lastLine, firstItem, lastItem): New fields. (addLayoutComponent): Handle case where constraints is null. Also, handle relative locations. (removeLayoutComponent): Handle relative locations. (MIN, MAX, PREF): New constants. (calcCompSize): New method. (calcSize): New method. (minimumLayoutSize): Use it. (preferredLayoutSize): Likewise. (maximumLayoutSize): Likewise. (toString): Include more information. (setBounds): New method. (layoutContainer): Use libgcj implementation; extended to handle relative locations. From-SVN: r48896
454 lines
12 KiB
Java
454 lines
12 KiB
Java
/* Copyright (C) 2000, 2001, 2002 Free Software Foundation
|
|
|
|
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., 59 Temple Place, Suite 330, Boston, MA
|
|
02111-1307 USA.
|
|
|
|
As a special exception, if you link this library with other files to
|
|
produce an executable, this library does not by itself cause the
|
|
resulting executable to be covered by the GNU General Public License.
|
|
This exception does not however invalidate any other reasons why the
|
|
executable file might be covered by the GNU General Public License. */
|
|
|
|
package java.awt.image;
|
|
|
|
/**
|
|
* @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
|
|
*/
|
|
public abstract class SampleModel
|
|
{
|
|
/** Width of image described. */
|
|
protected int width;
|
|
|
|
/** Height of image described. */
|
|
protected int height;
|
|
|
|
/** Number of bands in the image described. */
|
|
protected int numBands;
|
|
|
|
/**
|
|
* The DataBuffer type that is used to store the data of the image
|
|
* described.
|
|
*/
|
|
protected int dataType;
|
|
|
|
public SampleModel(int dataType, int w, int h, int numBands)
|
|
{
|
|
if ((w<=0) || (h<=0)) throw new IllegalArgumentException();
|
|
|
|
// FIXME: How can an int be greater than Integer.MAX_VALUE?
|
|
// FIXME: How do we identify an unsupported data type?
|
|
|
|
this.dataType = dataType;
|
|
this.width = w;
|
|
this.height = h;
|
|
this.numBands = numBands;
|
|
}
|
|
|
|
public final int getWidth()
|
|
{
|
|
return width;
|
|
}
|
|
|
|
public final int getHeight()
|
|
{
|
|
return height;
|
|
}
|
|
|
|
public final int getNumBands()
|
|
{
|
|
return numBands;
|
|
}
|
|
|
|
public abstract int getNumDataElements();
|
|
|
|
public final int getDataType()
|
|
{
|
|
return dataType;
|
|
}
|
|
|
|
public int getTransferType()
|
|
{
|
|
// FIXME: Is this a reasonable default implementation?
|
|
return dataType;
|
|
}
|
|
|
|
public int[] getPixel(int x, int y, int[] iArray, DataBuffer data)
|
|
{
|
|
if (iArray == null) iArray = new int[numBands];
|
|
for (int b=0; b<numBands; b++) iArray[b] = getSample(x, y, b, data);
|
|
return iArray;
|
|
}
|
|
|
|
/**
|
|
*
|
|
* This method is provided as a faster alternative to getPixel(),
|
|
* that can be used when there is no need to decode the pixel into
|
|
* separate sample values.
|
|
*
|
|
* @param obj An array to return the pixel data in. If null, an
|
|
* array of the right type and size will be created.
|
|
*
|
|
* @return A single pixel as an array object of a primitive type,
|
|
* based on the transfer type. Eg. if transfer type is
|
|
* DataBuffer.TYPE_USHORT, then a short[] object is returned.
|
|
*/
|
|
public abstract Object getDataElements(int x, int y, Object obj,
|
|
DataBuffer data);
|
|
|
|
|
|
public Object getDataElements(int x, int y, int w, int h, Object obj,
|
|
DataBuffer data)
|
|
{
|
|
int size = w*h;
|
|
int numDataElements = getNumDataElements();
|
|
int dataSize = numDataElements*size;
|
|
|
|
if (obj == null)
|
|
{
|
|
switch (getTransferType())
|
|
{
|
|
case DataBuffer.TYPE_BYTE:
|
|
obj = new byte[dataSize];
|
|
break;
|
|
case DataBuffer.TYPE_USHORT:
|
|
obj = new short[dataSize];
|
|
break;
|
|
case DataBuffer.TYPE_INT:
|
|
obj = new int[dataSize];
|
|
break;
|
|
default:
|
|
// Seems like the only sensible thing to do.
|
|
throw new ClassCastException();
|
|
}
|
|
}
|
|
Object pixelData = null;
|
|
int outOffset = 0;
|
|
for (int yy = y; yy<(y+h); yy++)
|
|
{
|
|
for (int xx = x; xx<(x+w); xx++)
|
|
{
|
|
pixelData = getDataElements(xx, yy, pixelData, data);
|
|
System.arraycopy(pixelData, 0, obj, outOffset,
|
|
numDataElements);
|
|
outOffset += numDataElements;
|
|
}
|
|
}
|
|
return obj;
|
|
}
|
|
|
|
public abstract void setDataElements(int x, int y, Object obj,
|
|
DataBuffer data);
|
|
|
|
public void setDataElements(int x, int y, int w, int h,
|
|
Object obj, DataBuffer data)
|
|
{
|
|
int size = w*h;
|
|
int numDataElements = getNumDataElements();
|
|
int dataSize = numDataElements*size;
|
|
|
|
Object pixelData;
|
|
switch (getTransferType())
|
|
{
|
|
case DataBuffer.TYPE_BYTE:
|
|
pixelData = new byte[numDataElements];
|
|
break;
|
|
case DataBuffer.TYPE_USHORT:
|
|
pixelData = new short[numDataElements];
|
|
break;
|
|
case DataBuffer.TYPE_INT:
|
|
pixelData = new int[numDataElements];
|
|
break;
|
|
default:
|
|
// Seems like the only sensible thing to do.
|
|
throw new ClassCastException();
|
|
}
|
|
int inOffset = 0;
|
|
|
|
for (int yy=y; yy<(y+h); yy++)
|
|
{
|
|
for (int xx=x; xx<(x+w); xx++)
|
|
{
|
|
System.arraycopy(obj, inOffset, pixelData, 0,
|
|
numDataElements);
|
|
setDataElements(xx, yy, pixelData, data);
|
|
inOffset += numDataElements;
|
|
}
|
|
}
|
|
}
|
|
|
|
public float[] getPixel(int x, int y, float[] fArray, DataBuffer data)
|
|
{
|
|
if (fArray == null) fArray = new float[numBands];
|
|
|
|
for (int b=0; b<numBands; b++)
|
|
{
|
|
fArray[b] = getSampleFloat(x, y, b, data);
|
|
}
|
|
return fArray;
|
|
}
|
|
|
|
public double[] getPixel(int x, int y, double[] dArray, DataBuffer data) {
|
|
if (dArray == null) dArray = new double[numBands];
|
|
for (int b=0; b<numBands; b++)
|
|
{
|
|
dArray[b] = getSampleDouble(x, y, b, data);
|
|
}
|
|
return dArray;
|
|
}
|
|
|
|
/* FIXME: Should it return a banded or pixel interleaved array of
|
|
samples? (Assume interleaved.) */
|
|
public int[] getPixels(int x, int y, int w, int h, int[] iArray,
|
|
DataBuffer data)
|
|
{
|
|
int size = w*h;
|
|
int outOffset = 0;
|
|
int[] pixel = null;
|
|
if (iArray == null) iArray = new int[w*h*numBands];
|
|
for (int yy=y; yy<(y+h); yy++)
|
|
{
|
|
for (int xx=x; xx<(x+w); xx++)
|
|
{
|
|
getPixel(xx, yy, pixel, data);
|
|
System.arraycopy(pixel, 0, iArray, outOffset, numBands);
|
|
outOffset += numBands;
|
|
}
|
|
}
|
|
return iArray;
|
|
}
|
|
|
|
/* FIXME: Should it return a banded or pixel interleaved array of
|
|
samples? (Assume interleaved.) */
|
|
public float[] getPixels(int x, int y, int w, int h, float[] fArray,
|
|
DataBuffer data)
|
|
{
|
|
int size = w*h;
|
|
int outOffset = 0;
|
|
float[] pixel = null;
|
|
if (fArray == null) fArray = new float[w*h*numBands];
|
|
for (int yy=y; yy<(y+h); yy++)
|
|
{
|
|
for (int xx=x; xx<(x+w); xx++)
|
|
{
|
|
getPixel(xx, yy, pixel, data);
|
|
System.arraycopy(pixel, 0, fArray, outOffset, numBands);
|
|
outOffset += numBands;
|
|
}
|
|
}
|
|
return fArray;
|
|
}
|
|
|
|
/* FIXME: Should it return a banded or pixel interleaved array of
|
|
samples? (Assume interleaved.) */
|
|
public double[] getPixels(int x, int y, int w, int h, double[] dArray,
|
|
DataBuffer data)
|
|
{
|
|
int size = w*h;
|
|
int outOffset = 0;
|
|
double[] pixel = null;
|
|
if (dArray == null) dArray = new double[w*h*numBands];
|
|
for (int yy=y; yy<(y+h); yy++)
|
|
{
|
|
for (int xx=x; xx<(x+w); xx++)
|
|
{
|
|
getPixel(xx, yy, pixel, data);
|
|
System.arraycopy(pixel, 0, dArray, outOffset, numBands);
|
|
outOffset += numBands;
|
|
}
|
|
}
|
|
return dArray;
|
|
}
|
|
|
|
public abstract int getSample(int x, int y, int b, DataBuffer data);
|
|
|
|
public float getSampleFloat(int x, int y, int b, DataBuffer data)
|
|
{
|
|
return getSample(x, y, b, data);
|
|
}
|
|
|
|
public double getSampleDouble(int x, int y, int b, DataBuffer data)
|
|
{
|
|
return getSampleFloat(x, y, b, data);
|
|
}
|
|
|
|
public int[] getSamples(int x, int y, int w, int h, int b,
|
|
int[] iArray, DataBuffer data)
|
|
{
|
|
int size = w*h;
|
|
int outOffset = 0;
|
|
if (iArray == null) iArray = new int[size];
|
|
for (int yy=y; yy<(y+h); yy++)
|
|
{
|
|
for (int xx=x; xx<(x+w); xx++)
|
|
{
|
|
iArray[outOffset++] = getSample(xx, yy, b, data);
|
|
}
|
|
}
|
|
return iArray;
|
|
}
|
|
|
|
public float[] getSamples(int x, int y, int w, int h, int b,
|
|
float[] fArray, DataBuffer data)
|
|
{
|
|
int size = w*h;
|
|
int outOffset = 0;
|
|
if (fArray == null) fArray = new float[size];
|
|
for (int yy=y; yy<(y+h); yy++)
|
|
{
|
|
for (int xx=x; xx<(x+w); xx++)
|
|
{
|
|
fArray[outOffset++] = getSampleFloat(xx, yy, b, data);
|
|
}
|
|
}
|
|
return fArray;
|
|
}
|
|
|
|
public double[] getSamples(int x, int y, int w, int h, int b,
|
|
double[] dArray, DataBuffer data)
|
|
{
|
|
int size = w*h;
|
|
int outOffset = 0;
|
|
if (dArray == null) dArray = new double[size];
|
|
for (int yy=y; yy<(y+h); yy++)
|
|
{
|
|
for (int xx=x; xx<(x+w); xx++)
|
|
{
|
|
dArray[outOffset++] = getSampleDouble(xx, yy, b, data);
|
|
}
|
|
}
|
|
return dArray;
|
|
}
|
|
|
|
public void setPixel(int x, int y, int[] iArray, DataBuffer data)
|
|
{
|
|
for (int b=0; b<numBands; b++) setSample(x, y, b, iArray[b], data);
|
|
}
|
|
|
|
public void setPixel(int x, int y, float[] fArray, DataBuffer data)
|
|
{
|
|
for (int b=0; b<numBands; b++) setSample(x, y, b, fArray[b], data);
|
|
}
|
|
|
|
public void setPixel(int x, int y, double[] dArray, DataBuffer data)
|
|
{
|
|
for (int b=0; b<numBands; b++) setSample(x, y, b, dArray[b], data);
|
|
}
|
|
|
|
public void setPixels(int x, int y, int w, int h, int[] iArray,
|
|
DataBuffer data)
|
|
{
|
|
int inOffset = 0;
|
|
int[] pixel = new int[numBands];
|
|
for (int yy=y; yy<(y+h); yy++)
|
|
{
|
|
for (int xx=x; xx<(x+w); xx++)
|
|
{
|
|
System.arraycopy(iArray, inOffset, pixel, 0, numBands);
|
|
setPixel(xx, yy, pixel, data);
|
|
inOffset += numBands;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setPixels(int x, int y, int w, int h, float[] fArray,
|
|
DataBuffer data)
|
|
{
|
|
int inOffset = 0;
|
|
float[] pixel = new float[numBands];
|
|
for (int yy=y; yy<(y+h); yy++)
|
|
{
|
|
for (int xx=x; xx<(x+w); xx++)
|
|
{
|
|
System.arraycopy(fArray, inOffset, pixel, 0, numBands);
|
|
setPixel(xx, yy, pixel, data);
|
|
inOffset += numBands;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setPixels(int x, int y, int w, int h, double[] dArray,
|
|
DataBuffer data)
|
|
{
|
|
int inOffset = 0;
|
|
double[] pixel = new double[numBands];
|
|
for (int yy=y; yy<(y+h); yy++)
|
|
{
|
|
for (int xx=x; xx<(x+w); xx++)
|
|
{
|
|
System.arraycopy(dArray, inOffset, pixel, 0, numBands);
|
|
setPixel(xx, yy, pixel, data);
|
|
inOffset += numBands;
|
|
}
|
|
}
|
|
}
|
|
|
|
public abstract void setSample(int x, int y, int b, int s,
|
|
DataBuffer data);
|
|
|
|
public void setSample(int x, int y, int b, float s,
|
|
DataBuffer data)
|
|
{
|
|
setSample(x, y, b, (int) s, data);
|
|
}
|
|
|
|
public void setSample(int x, int y, int b, double s,
|
|
DataBuffer data)
|
|
{
|
|
setSample(x, y, b, (float) s, data);
|
|
}
|
|
|
|
public void setSamples(int x, int y, int w, int h, int b,
|
|
int[] iArray, DataBuffer data)
|
|
{
|
|
int size = w*h;
|
|
int inOffset = 0;
|
|
for (int yy=y; yy<(y+h); yy++)
|
|
for (int xx=x; xx<(x+w); xx++)
|
|
setSample(xx, yy, b, iArray[inOffset++], data);
|
|
}
|
|
|
|
public void setSamples(int x, int y, int w, int h, int b,
|
|
float[] fArray, DataBuffer data)
|
|
{
|
|
int size = w*h;
|
|
int inOffset = 0;
|
|
for (int yy=y; yy<(y+h); yy++)
|
|
for (int xx=x; xx<(x+w); xx++)
|
|
setSample(xx, yy, b, fArray[inOffset++], data);
|
|
|
|
}
|
|
|
|
public void setSamples(int x, int y, int w, int h, int b,
|
|
double[] dArray, DataBuffer data) {
|
|
int size = w*h;
|
|
int inOffset = 0;
|
|
for (int yy=y; yy<(y+h); yy++)
|
|
for (int xx=x; xx<(x+w); xx++)
|
|
setSample(xx, yy, b, dArray[inOffset++], data);
|
|
}
|
|
|
|
public abstract SampleModel createCompatibleSampleModel(int w, int h);
|
|
|
|
public abstract SampleModel createSubsetSampleModel(int[] bands);
|
|
|
|
public abstract DataBuffer createDataBuffer();
|
|
|
|
public abstract int[] getSampleSize();
|
|
|
|
public abstract int getSampleSize(int band);
|
|
}
|