Package java.awt

Examples of java.awt.CompositeContext


    }

    @Test
    public void testCreateContext() throws Exception {

        CompositeContext ctx = composite.createContext(srcColorModel, destColorModel, hints);
        assertNotNull(ctx);
        verifyZeroInteractions(srcColorModel, destColorModel, hints);
    }
View Full Code Here


        boolean isAlphaComp = false;
        int rule = 0;
        float alpha = 0;
        boolean isXORComp = false;
        Color xorcolor = null;
        CompositeContext cont = null;

        if(comp instanceof AlphaComposite){
            isAlphaComp = true;
            AlphaComposite ac = (AlphaComposite) comp;
            rule = ac.getRule();
            alpha = ac.getAlpha();
        }else if(comp instanceof XORComposite){
            isXORComp = true;
            XORComposite xcomp = (XORComposite) comp;
            xorcolor = xcomp.getXORColor();
        }else{
            cont = comp.createContext(srcCM, dstCM, null);
        }

        for(int i = 1; i < clipRects[0]; i += 4){
            int _sx = srcX;
            int _sy = srcY;

            int _dx = dstX;
            int _dy = dstY;

            int _w = width;
            int _h = height;

            int cx = clipRects[i];          // Clipping left top X
            int cy = clipRects[i + 1];      // Clipping left top Y
            int cx2 = clipRects[i + 2];     // Clipping right bottom X
            int cy2 = clipRects[i + 3];     // Clipping right bottom Y

            if(_dx > cx2 || _dy > cy2 || dstX2 < cx || dstY2 < cy) {
                continue;
            }

            if(cx > _dx){
                int shx = cx - _dx;
                _w -= shx;
                _dx = cx;
                _sx += shx;
            }

            if(cy > _dy){
                int shy = cy - _dy;
                _h -= shy;
                _dy = cy;
                _sy += shy;
            }

            if(_dx + _w > cx2 + 1){
                _w = cx2 - _dx + 1;
            }

            if(_dy + _h > cy2 + 1){
                _h = cy2 - _dy + 1;
            }

            if(_sx > srcX2 || _sy > srcY2) {
                continue;
            }

            if(isAlphaComp){
                alphaCompose(_sx, _sy, srcCM, srcRast, _dx, _dy,
                        dstCM, dstRast, _w, _h, rule, alpha, bgcolor);
            }else if(isXORComp){
                xorCompose(_sx, _sy, srcCM, srcRast, _dx, _dy,
                        dstCM, dstRast, _w, _h, xorcolor);
            }else{
                Raster sr = srcRast.createChild(_sx, _sy, _w, _h, 0, 0, null);
                WritableRaster dr = dstRast.createWritableChild(_dx, _dy,
                        _w, _h, 0, 0, null);
                cont.compose(sr, dr, dr);
            }
        }
    }
View Full Code Here

        boolean isAlphaComp = false;
        int rule = 0;
        float alpha = 0;
        boolean isXORComp = false;
        Color xorcolor = null;
        CompositeContext cont = null;

        if(comp instanceof AlphaComposite){
            isAlphaComp = true;
            AlphaComposite ac = (AlphaComposite) comp;
            rule = ac.getRule();
            alpha = ac.getAlpha();
        }else if(comp instanceof XORComposite){
            isXORComp = true;
            XORComposite xcomp = (XORComposite) comp;
            xorcolor = xcomp.getXORColor();
        }else{
            cont = comp.createContext(srcCM, dstCM, null);
        }

        for(int i = 1; i < clipRects[0]; i += 4){
            int _sx = srcX;
            int _sy = srcY;

            int _dx = dstX;
            int _dy = dstY;

            int _w = width;
            int _h = height;

            int cx = clipRects[i];          // Clipping left top X
            int cy = clipRects[i + 1];      // Clipping left top Y
            int cx2 = clipRects[i + 2];     // Clipping right bottom X
            int cy2 = clipRects[i + 3];     // Clipping right bottom Y

            if(_dx > cx2 || _dy > cy2 || dstX2 < cx || dstY2 < cy) {
                continue;
            }

            if(cx > _dx){
                int shx = cx - _dx;
                _w -= shx;
                _dx = cx;
                _sx += shx;
            }

            if(cy > _dy){
                int shy = cy - _dy;
                _h -= shy;
                _dy = cy;
                _sy += shy;
            }

            if(_dx + _w > cx2 + 1){
                _w = cx2 - _dx + 1;
            }

            if(_dy + _h > cy2 + 1){
                _h = cy2 - _dy + 1;
            }

            if(_sx > srcX2 || _sy > srcY2) {
                continue;
            }

            if(isAlphaComp){
                alphaCompose(_sx, _sy, srcCM, srcRast, _dx, _dy,
                        dstCM, dstRast, _w, _h, rule, alpha, bgcolor);
            }else if(isXORComp){
                xorCompose(_sx, _sy, srcCM, srcRast, _dx, _dy,
                        dstCM, dstRast, _w, _h, xorcolor);
            }else{
                Raster sr = srcRast.createChild(_sx, _sy, _w, _h, 0, 0, null);
                WritableRaster dr = dstRast.createWritableChild(_dx, _dy,
                        _w, _h, 0, 0, null);
                cont.compose(sr, dr, dr);
            }
        }
    }
View Full Code Here

        ColorModel model = sg.getDeviceColorModel();
        PaintContext paintContext =
            sg.paint.createContext(model, devR, s.getBounds2D(),
                                   sg.cloneTransform(),
                                   hints);
        CompositeContext compositeContext =
            sg.composite.createContext(paintContext.getColorModel(), model,
                                       hints);
        return new TileContext(sg, paintContext, compositeContext, model);
    }
View Full Code Here

    public void renderPathTile(Object ctx,
                               byte[] atile, int offset, int tilesize,
                               int x, int y, int w, int h) {
        TileContext context = (TileContext) ctx;
        PaintContext paintCtxt = context.paintCtxt;
        CompositeContext compCtxt = context.compCtxt;
        SunGraphics2D sg = context.sunG2D;

        Raster srcRaster = paintCtxt.getRaster(x, y, w, h);
        ColorModel paintModel = paintCtxt.getColorModel();

        Raster dstRaster;
        Raster dstIn;
        WritableRaster dstOut;

        SurfaceData sd = sg.getSurfaceData();
        dstRaster = sd.getRaster(x, y, w, h);
        if (dstRaster instanceof WritableRaster && atile == null) {
            dstOut = (WritableRaster) dstRaster;
            dstOut = dstOut.createWritableChild(x, y, w, h, 0, 0, null);
            dstIn = dstOut;
        } else {
            dstIn = dstRaster.createChild(x, y, w, h, 0, 0, null);
            dstOut = dstIn.createCompatibleWritableRaster();
        }

        compCtxt.compose(srcRaster, dstIn, dstOut);

        if (dstRaster != dstOut && dstOut.getParent() != dstRaster) {
            if (dstRaster instanceof WritableRaster && atile == null) {
                ((WritableRaster) dstRaster).setDataElements(x, y, dstOut);
            } else {
View Full Code Here

      MultiPixelPackedSampleModel localMultiPixelPackedSampleModel2 = new MultiPixelPackedSampleModel(0, 4, 2, 1, 1073741789 - (this._is64 ? 16 : 0),
          288 + (this._is64 ? 128 : 0));
      WritableRaster localWritableRaster2 = Raster.createWritableRaster(localMultiPixelPackedSampleModel2, localDataBufferByte1, null);
      byte[] arrayOfByte = { 0, -1 };
      IndexColorModel localIndexColorModel = new IndexColorModel(1, 2, arrayOfByte, arrayOfByte, arrayOfByte);
      CompositeContext localCompositeContext = AlphaComposite.Src.createContext(localIndexColorModel, localIndexColorModel, null);
      localCompositeContext.compose(localWritableRaster1, localWritableRaster2, localWritableRaster2);
      int k = arrayOfInt.length;
      if (k == i)
        return 1;
      int m = 0;
      int n = arrayOfObject2.length;
View Full Code Here

        boolean isAlphaComp = false;
        int rule = 0;
        float alpha = 0;
        boolean isXORComp = false;
        Color xorcolor = null;
        CompositeContext cont = null;

        if(comp instanceof AlphaComposite){
            isAlphaComp = true;
            AlphaComposite ac = (AlphaComposite) comp;
            rule = ac.getRule();
            alpha = ac.getAlpha();
        }else if(comp instanceof XORComposite){
            isXORComp = true;
            XORComposite xcomp = (XORComposite) comp;
            xorcolor = xcomp.getXORColor();
        }else{
            cont = comp.createContext(srcCM, dstCM, null);
        }

        for(int i = 1; i < clipRects[0]; i += 4){
            int _sx = srcX;
            int _sy = srcY;

            int _dx = dstX;
            int _dy = dstY;

            int _w = width;
            int _h = height;

            int cx = clipRects[i];          // Clipping left top X
            int cy = clipRects[i + 1];      // Clipping left top Y
            int cx2 = clipRects[i + 2];     // Clipping right bottom X
            int cy2 = clipRects[i + 3];     // Clipping right bottom Y

            if(_dx > cx2 || _dy > cy2 || dstX2 < cx || dstY2 < cy) {
                continue;
            }

            if(cx > _dx){
                int shx = cx - _dx;
                _w -= shx;
                _dx = cx;
                _sx += shx;
            }

            if(cy > _dy){
                int shy = cy - _dy;
                _h -= shy;
                _dy = cy;
                _sy += shy;
            }

            if(_dx + _w > cx2 + 1){
                _w = cx2 - _dx + 1;
            }

            if(_dy + _h > cy2 + 1){
                _h = cy2 - _dy + 1;
            }

            if(_sx > srcX2 || _sy > srcY2) {
                continue;
            }

            if(isAlphaComp){
                alphaCompose(_sx, _sy, srcCM, srcRast, _dx, _dy,
                        dstCM, dstRast, _w, _h, rule, alpha, bgcolor);
            }else if(isXORComp){
                xorCompose(_sx, _sy, srcCM, srcRast, _dx, _dy,
                        dstCM, dstRast, _w, _h, xorcolor);
            }else{
                Raster sr = srcRast.createChild(_sx, _sy, _w, _h, 0, 0, null);
                WritableRaster dr = dstRast.createWritableChild(_dx, _dy,
                        _w, _h, 0, 0, null);
                cont.compose(sr, dr, dr);
            }
        }
    }
View Full Code Here

        boolean isAlphaComp = false;
        int rule = 0;
        float alpha = 0;
        boolean isXORComp = false;
        Color xorcolor = null;
        CompositeContext cont = null;

        if(comp instanceof AlphaComposite){
            isAlphaComp = true;
            AlphaComposite ac = (AlphaComposite) comp;
            rule = ac.getRule();
            alpha = ac.getAlpha();
        }else if(comp instanceof XORComposite){
            isXORComp = true;
            XORComposite xcomp = (XORComposite) comp;
            xorcolor = xcomp.getXORColor();
        }else{
            cont = comp.createContext(srcCM, dstCM, null);
        }

        for(int i = 1; i < clipRects[0]; i += 4){
            int _sx = srcX;
            int _sy = srcY;

            int _dx = dstX;
            int _dy = dstY;

            int _w = width;
            int _h = height;

            int cx = clipRects[i];          // Clipping left top X
            int cy = clipRects[i + 1];      // Clipping left top Y
            int cx2 = clipRects[i + 2];     // Clipping right bottom X
            int cy2 = clipRects[i + 3];     // Clipping right bottom Y

            if(_dx > cx2 || _dy > cy2 || dstX2 < cx || dstY2 < cy) {
                continue;
            }

            if(cx > _dx){
                int shx = cx - _dx;
                _w -= shx;
                _dx = cx;
                _sx += shx;
            }

            if(cy > _dy){
                int shy = cy - _dy;
                _h -= shy;
                _dy = cy;
                _sy += shy;
            }

            if(_dx + _w > cx2 + 1){
                _w = cx2 - _dx + 1;
            }

            if(_dy + _h > cy2 + 1){
                _h = cy2 - _dy + 1;
            }

            if(_sx > srcX2 || _sy > srcY2) {
                continue;
            }

            if(isAlphaComp){
                alphaCompose(_sx, _sy, srcCM, srcRast, _dx, _dy,
                        dstCM, dstRast, _w, _h, rule, alpha, bgcolor);
            }else if(isXORComp){
                xorCompose(_sx, _sy, srcCM, srcRast, _dx, _dy,
                        dstCM, dstRast, _w, _h, xorcolor);
            }else{
                Raster sr = srcRast.createChild(_sx, _sy, _w, _h, 0, 0, null);
                WritableRaster dr = dstRast.createWritableChild(_dx, _dy,
                        _w, _h, 0, 0, null);
                cont.compose(sr, dr, dr);
            }
        }
    }
View Full Code Here

        boolean isAlphaComp = false;
        int rule = 0;
        float alpha = 0;
        boolean isXORComp = false;
        Color xorcolor = null;
        CompositeContext cont = null;

        if(comp instanceof AlphaComposite){
            isAlphaComp = true;
            AlphaComposite ac = (AlphaComposite) comp;
            rule = ac.getRule();
            alpha = ac.getAlpha();
        }else if(comp instanceof XORComposite){
            isXORComp = true;
            XORComposite xcomp = (XORComposite) comp;
            xorcolor = xcomp.getXORColor();
        }else{
            cont = comp.createContext(srcCM, dstCM, null);
        }

        for(int i = 1; i < clipRects[0]; i += 4){
            int _sx = srcX;
            int _sy = srcY;

            int _dx = dstX;
            int _dy = dstY;

            int _w = width;
            int _h = height;

            int cx = clipRects[i];          // Clipping left top X
            int cy = clipRects[i + 1];      // Clipping left top Y
            int cx2 = clipRects[i + 2];     // Clipping right bottom X
            int cy2 = clipRects[i + 3];     // Clipping right bottom Y

            if(_dx > cx2 || _dy > cy2 || dstX2 < cx || dstY2 < cy) {
                continue;
            }

            if(cx > _dx){
                int shx = cx - _dx;
                _w -= shx;
                _dx = cx;
                _sx += shx;
            }

            if(cy > _dy){
                int shy = cy - _dy;
                _h -= shy;
                _dy = cy;
                _sy += shy;
            }

            if(_dx + _w > cx2 + 1){
                _w = cx2 - _dx + 1;
            }

            if(_dy + _h > cy2 + 1){
                _h = cy2 - _dy + 1;
            }

            if(_sx > srcX2 || _sy > srcY2) {
                continue;
            }

            if(isAlphaComp){
                alphaCompose(_sx, _sy, srcCM, srcRast, _dx, _dy,
                        dstCM, dstRast, _w, _h, rule, alpha, bgcolor);
            }else if(isXORComp){
                xorCompose(_sx, _sy, srcCM, srcRast, _dx, _dy,
                        dstCM, dstRast, _w, _h, xorcolor);
            }else{
                Raster sr = srcRast.createChild(_sx, _sy, _w, _h, 0, 0, null);
                WritableRaster dr = dstRast.createWritableChild(_dx, _dy,
                        _w, _h, 0, 0, null);
                cont.compose(sr, dr, dr);
            }
        }
    }
View Full Code Here

                         int width, int height)
        {
            ColorModel srcCM = srcData.getColorModel();
            ColorModel dstCM = dstData.getColorModel();
            // REMIND: Should get RenderingHints from sg2d
            CompositeContext ctx = comp.createContext(srcCM, dstCM,
                                                      new RenderingHints(null));
            Raster srcRas = srcData.getRaster(srcx, srcy, width, height);
            WritableRaster dstRas =
                (WritableRaster) dstData.getRaster(dstx, dsty, width, height);

            if (clip == null) {
                clip = Region.getInstanceXYWH(dstx, dsty, width, height);
            }
            int span[] = {dstx, dsty, dstx+width, dsty+height};
            SpanIterator si = clip.getSpanIterator(span);
            srcx -= dstx;
            srcy -= dsty;
            while (si.nextSpan(span)) {
                int w = span[2] - span[0];
                int h = span[3] - span[1];
                srcRas = srcRas.createChild(srcx + span[0], srcy + span[1],
                                            w, h, 0, 0, null);
                dstRas = dstRas.createWritableChild(span[0], span[1],
                                                    w, h, 0, 0, null);
                ctx.compose(srcRas, dstRas, dstRas);
            }
            ctx.dispose();
        }
View Full Code Here

TOP

Related Classes of java.awt.CompositeContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.