Java Code Examples for org.apache.harmony.awt.internal.nls.Messages

The following are top voted examples for showing how to use org.apache.harmony.awt.internal.nls.Messages. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: AndroidPrefuse   File: ColorModel.java   View source code 6 votes vote down vote up
/**
 * Instantiates a new color model with the specified pixel bit depth. The
 * transferType is chosen based on the pixel bits, and the other data fields
 * are given default values.
 * 
 * @param bits
 *            the array of component masks.
 */
public ColorModel(int bits) {

    if (bits < 1) {
        // awt.271=The number of bits in bits is less than 1
        throw new IllegalArgumentException(Messages.getString("awt.271")); //$NON-NLS-1$
    }

    pixel_bits = bits;
    transferType = getTransferType(bits);
    cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    hasAlpha = true;
    isAlphaPremultiplied = false;
    transparency = Transparency.TRANSLUCENT;

    numColorComponents = 3;
    numComponents = 4;

    this.bits = null;
}
 
Example 2
Project: AndroidPrefuse   File: SampleModel.java   View source code 6 votes vote down vote up
/**
 * Gets the samples of the specified pixel as a double array.
 * 
 * @param x
 *            the X coordinate of pixel.
 * @param y
 *            the Y coordinate of pixel.
 * @param dArray
 *            the double array where result will be stored.
 * @param data
 *            the image data.
 * @return the double array with the samples of the specified pixel.
 */
public double[] getPixel(int x, int y, double dArray[], DataBuffer data) {
    if (x < 0 || y < 0 || x >= this.width || y >= this.height) {
        // awt.63=Coordinates are not in bounds
        throw new ArrayIndexOutOfBoundsException(Messages.getString("awt.63")); //$NON-NLS-1$
    }
    double pixel[];

    if (dArray == null) {
        pixel = new double[numBands];
    } else {
        pixel = dArray;
    }

    for (int i = 0; i < numBands; i++) {
        pixel[i] = getSampleDouble(x, y, i, data);
    }

    return pixel;
}
 
Example 3
Project: android-awt   File: SinglePixelPackedSampleModel.java   View source code 6 votes vote down vote up
@Override
public void setPixels(int x, int y, int w, int h, int iArray[],
        DataBuffer data) {
    if ((x < 0) || (y < 0) || ((long) x + (long) w > this.width)
            || ((long) y + (long) h > this.height)) {
        // awt.63=Coordinates are not in bounds
        throw new ArrayIndexOutOfBoundsException(Messages
                .getString("awt.63")); //$NON-NLS-1$
    }

    int idx = 0;

    for (int i = y; i < y + h; i++) {
        for (int j = x; j < x + w; j++) {
            for (int n = 0; n < this.numBands; n++) {
                setSample(j, i, n, iArray[idx++], data);
            }
        }
    }
}
 
Example 4
Project: android-awt   File: TextLayout.java   View source code 6 votes vote down vote up
public TextLayout(String string, Font font, FontRenderContext frc) {
    if (string == null){
        // awt.01='{0}' parameter is null
        throw new IllegalArgumentException(Messages.getString("awt.01", "string")); //$NON-NLS-1$ //$NON-NLS-2$
    }
    
    if (font == null){
        // awt.01='{0}' parameter is null
        throw new IllegalArgumentException(Messages.getString("awt.01", "font")); //$NON-NLS-1$ //$NON-NLS-2$
    }

    if (string.length() == 0){
        // awt.02='{0}' parameter has zero length
        throw new IllegalArgumentException(Messages.getString("awt.02", "string")); //$NON-NLS-1$ //$NON-NLS-2$
    }

    AttributedString as = new AttributedString(string);
    as.addAttribute(TextAttribute.FONT, font);
    this.breaker = new TextRunBreaker(as.getIterator(), frc);
    caretManager = new CaretManager(breaker);
}
 
Example 5
Project: android-awt   File: CommonGlyphVector.java   View source code 6 votes vote down vote up
/**
 * Returns the position of the specified glyph relative to the origin of
 * this GlyphVector
 * @return a Point2D that the origin of the glyph with specified index
 */
@Override
public Point2D getGlyphPosition(int glyphIndex) {
    if ((glyphIndex > vector.length) || (glyphIndex < 0)) {
        // awt.43=glyphIndex is out of vector's limits
        throw new IndexOutOfBoundsException(Messages.getString("awt.43")); //$NON-NLS-1$
    }
    int index = glyphIndex << 1;
    Point2D pos = new Point2D.Float(visualPositions[index], visualPositions[index+1]);

    // For last position we don't have to transform !!
    if(glyphIndex==vector.length){
        return pos;
    }

    AffineTransform at = getGlyphTransform(glyphIndex);
    if ((at == null) || (at.isIdentity())){
        return pos;
    }

    pos.setLocation(pos.getX() + at.getTranslateX(), pos.getY() + at.getTranslateY());

    return pos;
}
 
Example 6
Project: AndroidPrefuse   File: RoundRectangle2D.java   View source code 6 votes vote down vote up
public int currentSegment(double[] coords) {
    if (isDone()) {
        // awt.4B=Iterator out of bounds
        throw new NoSuchElementException(Messages.getString("awt.4B")); //$NON-NLS-1$
    }
    if (index == points.length) {
        return SEG_CLOSE;
    }
    int j = 0;
    double p[] = points[index];
    for (int i = 0; i < p.length; i += 4) {
        coords[j++] = x + p[i + 0] * width + p[i + 1] * aw;
        coords[j++] = y + p[i + 2] * height + p[i + 3] * ah;
    }
    if (t != null) {
        t.transform(coords, 0, coords, 0, j / 2);
    }
    return types[index];
}
 
Example 7
Project: android-awt   File: SampleModel.java   View source code 6 votes vote down vote up
public double[] getPixel(int x, int y, double dArray[], DataBuffer data) {
    if (x < 0 || y < 0 || x >= this.width || y >= this.height) {
        // awt.63=Coordinates are not in bounds
        throw new ArrayIndexOutOfBoundsException(Messages.getString("awt.63")); //$NON-NLS-1$
    }
    double pixel[];

    if (dArray == null) {
        pixel = new double[numBands];
    } else {
        pixel = dArray;
    }

    for (int i = 0; i < numBands; i++) {
        pixel[i] = getSampleDouble(x, y, i, data);
    }

    return pixel;
}
 
Example 8
Project: android-awt   File: PageAttributes.java   View source code 6 votes vote down vote up
public void setPrintQuality(int iprintQuality) {
    if (iprintQuality == 3) {
        setPrintQuality(PrintQualityType.DRAFT);
        return;
    }
    if (iprintQuality == 4) {
        setPrintQuality(PrintQualityType.NORMAL);
        return;
    }
    if (iprintQuality == 5) {
        setPrintQuality(PrintQualityType.HIGH);
        return;
    }
    // awt.11A=Invalid value for printQuality
    throw new IllegalArgumentException(Messages.getString("awt.11A")); //$NON-NLS-1$
}
 
Example 9
Project: android-awt   File: FlatteningPathIterator.java   View source code 6 votes vote down vote up
public int currentSegment(double[] coords) {
    if (isDone()) {
        // awt.4B=Iterator out of bounds
        throw new NoSuchElementException(Messages.getString("awt.4B")); //$NON-NLS-1$
    }
    evaluate();
    int type = bufType;
    if (type != SEG_CLOSE) {
        coords[0] = px;
        coords[1] = py;
        if (type != SEG_MOVETO) {
            type = SEG_LINETO;
        }
    }
    return type;
}
 
Example 10
Project: android-awt   File: SampleModel.java   View source code 6 votes vote down vote up
public double[] getPixels(int x, int y, int w, int h, double dArray[],
        DataBuffer data) {
    if (x < 0 || y < 0 || x + w > this.width || y + h > this.height) {
        // awt.63=Coordinates are not in bounds
        throw new ArrayIndexOutOfBoundsException(Messages.getString("awt.63")); //$NON-NLS-1$
    }
    double pixels[];
    int idx = 0;

    if (dArray == null) {
        pixels = new double[w * h * numBands];
    } else {
        pixels = dArray;
    }

    for (int i = y; i < y + h; i++) {
        for (int j = x; j < x + w; j++) {
            for (int n = 0; n < numBands; n++) {
                pixels[idx++] = getSampleDouble(j, i, n, data);
            }
        }
    }
    return pixels;
}
 
Example 11
Project: AndroidPrefuse   File: QuadCurve2D.java   View source code 6 votes vote down vote up
public int currentSegment(float[] coords) {
    if (isDone()) {
        // awt.4B=Iterator out of bounds
        throw new NoSuchElementException(Messages.getString("awt.4B")); //$NON-NLS-1$
    }
    int type;
    int count;
    if (index == 0) {
        type = SEG_MOVETO;
        coords[0] = (float)c.getX1();
        coords[1] = (float)c.getY1();
        count = 1;
    } else {
        type = SEG_QUADTO;
        coords[0] = (float)c.getCtrlX();
        coords[1] = (float)c.getCtrlY();
        coords[2] = (float)c.getX2();
        coords[3] = (float)c.getY2();
        count = 2;
    }
    if (t != null) {
        t.transform(coords, 0, coords, 0, count);
    }
    return type;
}
 
Example 12
Project: AndroidPrefuse   File: Line2D.java   View source code 6 votes vote down vote up
public int currentSegment(float[] coords) {
    if (isDone()) {
        // awt.4B=Iterator out of bounds
        throw new NoSuchElementException(Messages.getString("awt.4B")); //$NON-NLS-1$
    }
    int type;
    if (index == 0) {
        type = SEG_MOVETO;
        coords[0] = (float)x1;
        coords[1] = (float)y1;
    } else {
        type = SEG_LINETO;
        coords[0] = (float)x2;
        coords[1] = (float)y2;
    }
    if (t != null) {
        t.transform(coords, 0, coords, 0, 1);
    }
    return type;
}
 
Example 13
Project: android-awt   File: Line2D.java   View source code 6 votes vote down vote up
public int currentSegment(double[] coords) {
    if (isDone()) {
        // awt.4B=Iterator out of bounds
        throw new NoSuchElementException(Messages.getString("awt.4B")); //$NON-NLS-1$
    }
    int type;
    if (index == 0) {
        type = SEG_MOVETO;
        coords[0] = x1;
        coords[1] = y1;
    } else {
        type = SEG_LINETO;
        coords[0] = x2;
        coords[1] = y2;
    }
    if (t != null) {
        t.transform(coords, 0, coords, 0, 1);
    }
    return type;
}
 
Example 14
Project: android-awt   File: IndexColorModel.java   View source code 6 votes vote down vote up
@Override
public int[] getComponents(Object pixel, int components[], int offset) {
    int pixIdx = -1;
    if (pixel instanceof byte[]) {
        byte ba[] = (byte[]) pixel;
        pixIdx = ba[0] & 0xff;
    } else if (pixel instanceof short[]) {
        short sa[] = (short[]) pixel;
        pixIdx = sa[0] & 0xffff;
    } else if (pixel instanceof int[]) {
        int ia[] = (int[]) pixel;
        pixIdx = ia[0];
    } else {
        // awt.219=This transferType is not supported by this color model
        throw new UnsupportedOperationException(Messages.getString("awt.219")); //$NON-NLS-1$
    }

    return getComponents(pixIdx, components, offset);
}
 
Example 15
Project: AndroidPrefuse   File: SinglePixelPackedSampleModel.java   View source code 6 votes vote down vote up
@Override
public void setPixels(int x, int y, int w, int h, int iArray[], DataBuffer data) {
    if ((x < 0) || (y < 0) || ((long)x + (long)w > this.width)
            || ((long)y + (long)h > this.height)) {
        // awt.63=Coordinates are not in bounds
        throw new ArrayIndexOutOfBoundsException(Messages.getString("awt.63")); //$NON-NLS-1$
    }

    int idx = 0;

    for (int i = y; i < y + h; i++) {
        for (int j = x; j < x + w; j++) {
            for (int n = 0; n < this.numBands; n++) {
                setSample(j, i, n, iArray[idx++], data);
            }
        }
    }
}
 
Example 16
Project: AndroidPrefuse   File: SampleModel.java   View source code 6 votes vote down vote up
/**
 * Gets the samples of the specified pixel as an integer array.
 * 
 * @param x
 *            the X coordinate of pixel.
 * @param y
 *            the Y coordinate of pixel.
 * @param iArray
 *            the integer array where result will be stored.
 * @param data
 *            the image data.
 * @return the integer array with the samples of the specified pixel.
 */
public int[] getPixel(int x, int y, int iArray[], DataBuffer data) {
    if (x < 0 || y < 0 || x >= this.width || y >= this.height) {
        // awt.63=Coordinates are not in bounds
        throw new ArrayIndexOutOfBoundsException(Messages.getString("awt.63")); //$NON-NLS-1$
    }
    int pixel[];

    if (iArray == null) {
        pixel = new int[numBands];
    } else {
        pixel = iArray;
    }

    for (int i = 0; i < numBands; i++) {
        pixel[i] = getSample(x, y, i, data);
    }

    return pixel;
}
 
Example 17
Project: android-awt   File: CommonGlyphVector.java   View source code 6 votes vote down vote up
/**
 * Sets new position to the specified glyph.
 */
@Override
public void setGlyphPosition(int glyphIndex, Point2D newPos) {
    if ((glyphIndex > vector.length) || (glyphIndex < 0)) {
        // awt.43=glyphIndex is out of vector's limits
        throw new IndexOutOfBoundsException(Messages.getString("awt.43")); //$NON-NLS-1$
    }
    float x = (float)newPos.getX();
    float y = (float)newPos.getY();
    int index = glyphIndex << 1;

    if ((x != visualPositions[index]) || (y != visualPositions[index + 1])){
        visualPositions[index] = x;
        visualPositions[index+1] = y;
        layoutFlags = layoutFlags | FLAG_HAS_POSITION_ADJUSTMENTS;
    }

}
 
Example 18
Project: android-awt   File: ICC_ColorSpace.java   View source code 6 votes vote down vote up
public ICC_ColorSpace(ICC_Profile pf) {
    super(pf.getColorSpaceType(), pf.getNumComponents());

    int pfClass = pf.getProfileClass();

    switch (pfClass) {
        case ICC_Profile.CLASS_COLORSPACECONVERSION:
        case ICC_Profile.CLASS_DISPLAY:
        case ICC_Profile.CLASS_OUTPUT:
        case ICC_Profile.CLASS_INPUT:
            break; // OK, it is color conversion profile
        default:
            // awt.168=Invalid profile class.
            throw new IllegalArgumentException(Messages.getString("awt.168")); //$NON-NLS-1$
    }

    profile = pf;
    fillMinMaxValues();
}
 
Example 19
Project: android-awt   File: QuadCurve2D.java   View source code 6 votes vote down vote up
public int currentSegment(float[] coords) {
    if (isDone()) {
        // awt.4B=Iterator out of bounds
        throw new NoSuchElementException(Messages.getString("awt.4B")); //$NON-NLS-1$
    }
    int type;
    int count;
    if (index == 0) {
        type = SEG_MOVETO;
        coords[0] = (float)c.getX1();
        coords[1] = (float)c.getY1();
        count = 1;
    } else {
        type = SEG_QUADTO;
        coords[0] = (float)c.getCtrlX();
        coords[1] = (float)c.getCtrlY();
        coords[2] = (float)c.getX2();
        coords[3] = (float)c.getY2();
        count = 2;
    }
    if (t != null) {
        t.transform(coords, 0, coords, 0, count);
    }
    return type;
}
 
Example 20
Project: android-awt   File: DirectColorModel.java   View source code 6 votes vote down vote up
@Override
public int getRGB(Object inData) {
    int pixel = 0;
    switch (transferType) {
    case DataBuffer.TYPE_BYTE:
        byte ba[] = (byte[]) inData;
        pixel = ba[0] & 0xff;
        break;

    case DataBuffer.TYPE_USHORT:
        short sa[] = (short[]) inData;
        pixel = sa[0] & 0xffff;
        break;

    case DataBuffer.TYPE_INT:
        int ia[] = (int[]) inData;
        pixel = ia[0];
        break;

    default:
        // awt.214=This Color Model doesn't support this transferType
        throw new UnsupportedOperationException(Messages.getString("awt.214")); //$NON-NLS-1$
    }
    return getRGB(pixel);
}
 
Example 21
Project: android-awt   File: SampleModel.java   View source code 6 votes vote down vote up
public int[] getPixel(int x, int y, int iArray[], DataBuffer data) {
    if (x < 0 || y < 0 || x >= this.width || y >= this.height) {
        // awt.63=Coordinates are not in bounds
        throw new ArrayIndexOutOfBoundsException(Messages.getString("awt.63")); //$NON-NLS-1$
    }
    int pixel[];

    if (iArray == null) {
        pixel = new int[numBands];
    } else {
        pixel = iArray;
    }

    for (int i = 0; i < numBands; i++) {
        pixel[i] = getSample(x, y, i, data);
    }

    return pixel;
}
 
Example 22
Project: android-awt   File: ICC_Profile.java   View source code 6 votes vote down vote up
public int getProfileClass() {
    int deviceClassSignature = getIntFromHeader(icHdrDeviceClass);

    switch (deviceClassSignature) {
        case icSigColorSpaceClass:
            return CLASS_COLORSPACECONVERSION;
        case icSigDisplayClass:
            return CLASS_DISPLAY;
        case icSigOutputClass:
            return CLASS_OUTPUT;
        case icSigInputClass:
            return CLASS_INPUT;
        case icSigLinkClass:
            return CLASS_DEVICELINK;
        case icSigAbstractClass:
            return CLASS_ABSTRACT;
        case icSigNamedColorClass:
            return CLASS_NAMEDCOLOR;
        default:
    }

    // Not an ICC profile class
    // awt.15F=Profile class does not comply with ICC specification
    throw new IllegalArgumentException(Messages.getString("awt.15F")); //$NON-NLS-1$
    
}
 
Example 23
Project: android-awt   File: FontMetrics.java   View source code 6 votes vote down vote up
public int charsWidth(char[] data, int off , int len){
    int width = 0;
    if ((off >= data.length) || (off < 0)){
        // awt.13B=offset off is out of range
        throw new IllegalArgumentException(Messages.getString("awt.13B")); //$NON-NLS-1$
    }

    if ((off+len > data.length)){
        // awt.13C=number of elements len is out of range
        throw new IllegalArgumentException(Messages.getString("awt.13C")); //$NON-NLS-1$
    }

    for (int i = off; i < off+len; i++){
        width += charWidth(data[i]);
    }

    return width;
}
 
Example 24
Project: android-awt   File: CommonGlyphVector.java   View source code 6 votes vote down vote up
/**
 * Set numEntries elements of the visualPositions array from beginGlyphIndex
 * of numEntries glyphs positions from beginGlyphIndex glyph in Glyph Vector.
 * 
 * @param beginGlyphIndex the start index
 * @param numEntries the number of glyph codes to get
 * @param setPositions the array of positions to set
 */
public void setGlyphPositions(int beginGlyphIndex, int numEntries,
        float[] setPositions) {

    int len = (this.getNumGlyphs()+1) << 1;
    beginGlyphIndex *= 2;
    numEntries *= 2;

    if ((beginGlyphIndex < 0) || ((numEntries + beginGlyphIndex) > len)) {
        // awt.44=beginGlyphIndex is out of vector's range
        throw new IndexOutOfBoundsException(Messages.getString("awt.44")); //$NON-NLS-1$
    }

    if (numEntries < 0) {
        // awt.45=numEntries is out of vector's range
        throw new IllegalArgumentException(Messages.getString("awt.45")); //$NON-NLS-1$
    }

    System.arraycopy(setPositions, 0, visualPositions, beginGlyphIndex, numEntries);
    layoutFlags = layoutFlags & FLAG_HAS_POSITION_ADJUSTMENTS;

}
 
Example 25
Project: AndroidPrefuse   File: PackedColorModel.java   View source code 6 votes vote down vote up
/**
 * Instantiates a new packed color model.
 * 
 * @param space
 *            the color space.
 * @param bits
 *            the array of component masks.
 * @param colorMaskArray
 *            the array that gives the bitmask corresponding to each color
 *            band (red, green, and blue).
 * @param alphaMask
 *            the bitmask corresponding to the alpha band.
 * @param isAlphaPremultiplied
 *            whether the alpha is pre-multiplied in this color model.
 * @param trans
 *            the transparency strategy, @see java.awt.Transparency.
 * @param transferType
 *            the transfer type (primitive java type to use for the
 *            components).
 * @throws IllegalArgumentException
 *             if the number of bits in the combined bitmasks for the color
 *             bands is less than one or greater than 32.
 */
public PackedColorModel(ColorSpace space, int bits, int colorMaskArray[], int alphaMask,
        boolean isAlphaPremultiplied, int trans, int transferType) {

    super(bits, createBits(colorMaskArray, alphaMask), space, (alphaMask == 0 ? false : true),
            isAlphaPremultiplied, trans, validateTransferType(transferType));

    if (pixel_bits < 1 || pixel_bits > 32) {
        // awt.236=The bits is less than 1 or greater than 32
        throw new IllegalArgumentException(Messages.getString("awt.236")); //$NON-NLS-1$
    }

    componentMasks = new int[numComponents];
    for (int i = 0; i < numColorComponents; i++) {
        componentMasks[i] = colorMaskArray[i];
    }

    if (hasAlpha) {
        componentMasks[numColorComponents] = alphaMask;
        if (this.bits[numColorComponents] == 1) {
            transparency = Transparency.BITMASK;
        }
    }

    parseComponents();
}
 
Example 26
Project: AndroidPrefuse   File: DirectColorModel.java   View source code 6 votes vote down vote up
@Override
public int getRGB(Object inData) {
    int pixel = 0;
    switch (transferType) {
        case DataBuffer.TYPE_BYTE:
            byte ba[] = (byte[])inData;
            pixel = ba[0] & 0xff;
            break;

        case DataBuffer.TYPE_USHORT:
            short sa[] = (short[])inData;
            pixel = sa[0] & 0xffff;
            break;

        case DataBuffer.TYPE_INT:
            int ia[] = (int[])inData;
            pixel = ia[0];
            break;

        default:
            // awt.214=This Color Model doesn't support this transferType
            throw new UnsupportedOperationException(Messages.getString("awt.214")); //$NON-NLS-1$
    }
    return getRGB(pixel);
}
 
Example 27
Project: android-awt   File: CommonGlyphVector.java   View source code 6 votes vote down vote up
/**
 * Returns an array of glyphcodes for the specified glyphs.
 * 
 * @param beginGlyphIndex the start index
 * @param numEntries the number of glyph codes to get
 * @param codeReturn the array that receives glyph codes' values
 * @return an array that receives glyph codes' values
 */
@Override
public int[] getGlyphCodes(int beginGlyphIndex, int numEntries,
        int[] codeReturn) {

    if ((beginGlyphIndex < 0) || ((numEntries + beginGlyphIndex) > this.getNumGlyphs())) {
        // awt.44=beginGlyphIndex is out of vector's range
        throw new IndexOutOfBoundsException(Messages.getString("awt.44")); //$NON-NLS-1$
    }

    if (numEntries < 0) {
        // awt.45=numEntries is out of vector's range
        throw new IllegalArgumentException(Messages.getString("awt.45")); //$NON-NLS-1$
    }

    if (codeReturn == null) {
        codeReturn = new int[numEntries];
    }

    for (int i = beginGlyphIndex; i < beginGlyphIndex + numEntries; i++) {
        codeReturn[i-beginGlyphIndex] = this.vector[i].getGlyphCode();
    }

    return codeReturn;
}
 
Example 28
Project: AndroidPrefuse   File: PixelGrabber.java   View source code 6 votes vote down vote up
public synchronized void imageComplete(int status) {
    switch(status){
    case IMAGEABORTED:
        grabberStatus |= ImageObserver.ABORT;
        break;
    case IMAGEERROR:
        grabberStatus |= ImageObserver.ERROR | ImageObserver.ABORT;
        break;
    case SINGLEFRAMEDONE:
        grabberStatus |= ImageObserver.FRAMEBITS;
        break;
    case STATICIMAGEDONE:
        grabberStatus |= ImageObserver.ALLBITS;
        break;
    default:
        // awt.26A=Incorrect ImageConsumer completion status
        throw new IllegalArgumentException(Messages.getString("awt.26A")); //$NON-NLS-1$
    }
    isGrabbing = false;
    producer.removeConsumer(this);
    notifyAll();
}
 
Example 29
Project: AndroidPrefuse   File: MemoryImageSource.java   View source code 6 votes vote down vote up
/**
 * Sets the pixels.
 * 
 * @param con
 *            the con.
 * @param x
 *            the x.
 * @param y
 *            the y.
 * @param w
 *            the w.
 * @param h
 *            the h.
 */
private void setPixels(ImageConsumer con, int x, int y, int w, int h) {
    int pixelOff = scanline * y + offset + x;

    switch (dataType) {
        case DATA_TYPE_BYTE:
            con.setPixels(x, y, w, h, cm, bData, pixelOff, scanline);
            break;
        case DATA_TYPE_INT:
            con.setPixels(x, y, w, h, cm, iData, pixelOff, scanline);
            break;
        default:
            // awt.22A=Wrong type of pixels array
            throw new IllegalArgumentException(Messages.getString("awt.22A")); //$NON-NLS-1$
    }
}
 
Example 30
Project: android-awt   File: RoundRectangle2D.java   View source code 6 votes vote down vote up
public int currentSegment(double[] coords) {
    if (isDone()) {
        // awt.4B=Iterator out of bounds
        throw new NoSuchElementException(Messages.getString("awt.4B")); //$NON-NLS-1$
    }
    if (index == points.length) {
        return SEG_CLOSE;
    }
    int j = 0;
    double p[] = points[index];
    for (int i = 0; i < p.length; i += 4) {
        coords[j++] = x + p[i + 0] * width + p[i + 1] * aw;
        coords[j++] = y + p[i + 2] * height + p[i + 3] * ah;
    }
    if (t != null) {
        t.transform(coords, 0, coords, 0, j / 2);
    }
    return types[index];
}
 
Example 31
Project: android-awt   File: ComponentSampleModel.java   View source code 6 votes vote down vote up
@Override
public void setPixels(int x, int y, int w, int h, int iArray[],
        DataBuffer data) {
    if (x < 0 || y < 0 || x + w > this.width || y + h > this.height) {
        // awt.63=Coordinates are not in bounds
        throw new ArrayIndexOutOfBoundsException(Messages.getString("awt.63")); //$NON-NLS-1$
    }
    int idx = 0;
    for (int i = y; i < y + h; i++) {
        for (int j = x; j < x + w; j++) {
            for (int n = 0; n < numBands; n++) {
                setSample(j, i, n, iArray[idx++], data);
            }
        }
    }
}
 
Example 32
Project: AndroidPrefuse   File: IndexColorModel.java   View source code 6 votes vote down vote up
@Override
public WritableRaster createCompatibleWritableRaster(int w, int h) {
    WritableRaster raster;
    if (pixel_bits == 1 || pixel_bits == 2 || pixel_bits == 4) {
        raster = Raster.createPackedRaster(DataBuffer.TYPE_BYTE, w, h, 1, pixel_bits, null);
    } else if (pixel_bits <= 8) {
        raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, w, h, 1, null);
    } else if (pixel_bits <= 16) {
        raster = Raster.createInterleavedRaster(DataBuffer.TYPE_USHORT, w, h, 1, null);
    } else {
        // awt.266=The number of bits in a pixel is greater than 16
        throw new UnsupportedOperationException(Messages.getString("awt.266")); //$NON-NLS-1$
    }

    return raster;
}
 
Example 33
Project: android-awt   File: ImageSurface.java   View source code 5 votes vote down vote up
public ImageSurface(ColorModel cm, WritableRaster raster, int type){
    if (!cm.isCompatibleRaster(raster)) {
        // awt.4D=The raster is incompatible with this ColorModel
        throw new IllegalArgumentException(Messages.getString("awt.4D")); //$NON-NLS-1$
    }
    this.cm = cm;
    this.raster = raster;
    surfaceType = type;

    DataBuffer db = raster.getDataBuffer();
    data = ba.getData(db);
    ba.addDataBufferListener(db, this);
    ColorSpace cs = cm.getColorSpace();
    transparency = cm.getTransparency();
    width = raster.getWidth();
    height = raster.getHeight();
    addDirtyRegion(new Rectangle(0, 0, width, height));

    // For the moment we can build natively only images which have 
    // sRGB, Linear_RGB, Linear_Gray Color Space and type different
    // from BufferedImage.TYPE_CUSTOM
    if(cs == LUTColorConverter.sRGB_CS){
        csType = sRGB_CS;
    }else if(cs == LUTColorConverter.LINEAR_RGB_CS){
        csType = Linear_RGB_CS;
    }else if(cs == LUTColorConverter.LINEAR_GRAY_CS){
        csType = Linear_Gray_CS;
    }else{
        csType = Custom_CS;
    }
}
 
Example 34
Project: android-awt   File: JobAttributes.java   View source code 5 votes vote down vote up
public void setCopies(int copies) {
    if(copies <= 0) {
        // awt.152=Invalid number of copies
        throw new IllegalArgumentException(Messages.getString("awt.152")); //$NON-NLS-1$
    }
    this.copies = copies;
}
 
Example 35
Project: AndroidPrefuse   File: Polygon.java   View source code 5 votes vote down vote up
public int currentSegment(double[] coords) {
    if (isDone()) {
        // awt.110=Iterator out of bounds
        throw new NoSuchElementException(Messages.getString("awt.110")); //$NON-NLS-1$
    }
    if (index == p.npoints) {
        return SEG_CLOSE;
    }
    coords[0] = p.xpoints[index];
    coords[1] = p.ypoints[index];
    if (t != null) {
        t.transform(coords, 0, coords, 0, 1);
    }
    return index == 0 ? SEG_MOVETO : SEG_LINETO;
}
 
Example 36
Project: AndroidPrefuse   File: Polygon.java   View source code 5 votes vote down vote up
public int currentSegment(float[] coords) {
    if (isDone()) {
        // awt.110=Iterator out of bounds
        throw new NoSuchElementException(Messages.getString("awt.110")); //$NON-NLS-1$
    }
    if (index == p.npoints) {
        return SEG_CLOSE;
    }
    coords[0] = p.xpoints[index];
    coords[1] = p.ypoints[index];
    if (t != null) {
        t.transform(coords, 0, coords, 0, 1);
    }
    return index == 0 ? SEG_MOVETO : SEG_LINETO;
}
 
Example 37
Project: AndroidPrefuse   File: AlphaComposite.java   View source code 5 votes vote down vote up
/**
 * Instantiates a new alpha composite. Creates a context for the compositing
 * operation. The context contains state that is used in performing the
 * compositing operation.
 * 
 * @param rule
 *            the rule.
 * @param alpha
 *            the alpha.
 */
private AlphaComposite(int rule, float alpha) {
    if (rule < CLEAR || rule > XOR) {
        // awt.11D=Unknown rule
        throw new IllegalArgumentException(Messages.getString("awt.11D")); //$NON-NLS-1$
    }
    if (alpha < 0.0f || alpha > 1.0f) {
        // awt.11E=Wrong alpha value
        throw new IllegalArgumentException(Messages.getString("awt.11E")); //$NON-NLS-1$
    }

    this.rule = rule;
    this.alpha = alpha;
}
 
Example 38
Project: android-awt   File: ColorSpace.java   View source code 5 votes vote down vote up
public float getMinValue(int component) {
    if (component < 0 || component > numComponents - 1) {
        // awt.16A=Invalid component index: {0}
        throw new IllegalArgumentException(Messages.getString("awt.16A", component)); //$NON-NLS-1$
    }
    return 0;
}
 
Example 39
Project: android-awt   File: ColorConvertOp.java   View source code 5 votes vote down vote up
public ColorConvertOp(ColorSpace srcCS, ColorSpace dstCS, RenderingHints hints) {
    if (srcCS == null || dstCS == null) {
        throw new NullPointerException(Messages.getString("awt.25B")); //$NON-NLS-1$
    }
    
    renderingHints = hints;
    
    boolean srcICC = srcCS instanceof ICC_ColorSpace;
    boolean dstICC = dstCS instanceof ICC_ColorSpace;
    
    if (srcICC && dstICC) {
        conversionSequence = new ICC_Profile[2];
    } else {
        conversionSequence = new Object[2];
        isICC = false;
    }
    
    if (srcICC) {
        conversionSequence[0] = ((ICC_ColorSpace) srcCS).getProfile();
    } else {
        conversionSequence[0] = srcCS;
    }
    
    if (dstICC) {
        conversionSequence[1] = ((ICC_ColorSpace) dstCS).getProfile();
    } else {
        conversionSequence[1] = dstCS;
    }
}
 
Example 40
Project: android-awt   File: IndexColorModel.java   View source code 5 votes vote down vote up
private static int validateTransferType(int transferType) {
    if (transferType != DataBuffer.TYPE_BYTE &&
           transferType != DataBuffer.TYPE_USHORT) {
        // awt.269=The transferType is not one of DataBuffer.TYPE_BYTE or DataBuffer.TYPE_USHORT
        throw new IllegalArgumentException(Messages.getString("awt.269")); //$NON-NLS-1$
    }
    return transferType;
}