Example usage for java.awt Graphics setXORMode

List of usage examples for java.awt Graphics setXORMode

Introduction

In this page you can find the example usage for java.awt Graphics setXORMode.

Prototype

public abstract void setXORMode(Color c1);

Source Link

Document

Sets the paint mode of this graphics context to alternate between this graphics context's current color and the new specified color.

Usage

From source file:com.jcraft.weirdx.DDXWindowImp.java

public final Graphics getGraphics(GC gc, int mask) {
    if (!isVisible()) {
        return null;
    }// w w  w  .j  a  v a 2 s  .  c  om
    if (offg == null)
        allocImage();
    Graphics graphics = offg;
    if ((mask & GC.GCSubwindowMode) != 0 && (gc.attr & GC.IncludeInferiors) != 0) {
        graphics = getGraphics();
        window.currentGC = null;
    } else {
        if (gc == window.currentGC && gc.time == window.gctime && (mask & ~window.gmask) == 0) {
            //System.out.println("DDXWindow skip");
            return graphics;
        }
        window.gctime = gc.time;
        window.currentGC = gc;
        window.gmask = mask;
    }

    if (gc.clip_mask != null && gc.clip_mask instanceof ClipRectangles) {
        java.awt.Rectangle rec = (Rectangle) (gc.clip_mask.getMask());
        if (rec != null) {
            graphics = offg;
        }

        if (rec == null
                || (rec.x == 0 && rec.y == 0 && rec.width == window.width && rec.height == window.height)) {
            //   return graphics;
        } else {
            graphics.setClip(rec.x, rec.y, rec.width, rec.height);
        }
    }

    if ((mask & GC.GCFunction) != 0) {
        Color color = window.getColormap().getColor(gc.fgPixel);
        if (gc.function == GC.GXxor) {
            window.gmask &= ~GC.GCFunction;
            graphics.setXORMode(new Color((color.getRGB() ^ graphics.getColor().getRGB()) & 0xffffff));
        } else if (gc.function == GC.GXinvert) {
            window.gmask &= ~GC.GCFunction;
            graphics.setXORMode(window.screen.defaultColormap.getColor(window.background.pixel));
        } else {
            graphics.setColor(color);
        }
    }

    if ((mask & GC.GCFont) != 0) {
        XFont font = gc.font;
        graphics.setFont(font.getFont());
    }

    if ((mask & GC.GCLineWidth) != 0 || (mask & GC.GCLineStyle) != 0 || (mask & GC.GCCapStyle) != 0
            || (mask & GC.GCJoinStyle) != 0) {
    }
    return graphics;
}

From source file:com.jcraft.weirdx.XPixmap.java

Graphics getGraphics(GC gc, int mask) {
    Graphics graphics = imgg;
    if (gc == currentGC && gc.time == gctime && (mask & ~gmask) == 0) {
        return graphics;
    }/*from  www .  j a va2  s.c  o m*/
    gctime = gc.time;
    currentGC = gc;
    gmask = mask;
    if (gc.clip_mask != null && gc.clip_mask instanceof ClipRectangles) {
        java.awt.Rectangle rec = (Rectangle) (gc.clip_mask.getMask());
        if (rec == null) {
            return graphics;
        }
        graphics.setClip(rec.x, rec.y, rec.width, rec.height);
    }
    if ((mask & GC.GCFunction) != 0) {
        Color color = getColormap().getColor(gc.fgPixel);
        if (gc.function == GC.GXxor) {
            gmask &= ~GC.GCFunction;
            graphics.setXORMode(new Color((color.getRGB() ^ graphics.getColor().getRGB()) & 0xffffff));
        } else if (gc.function == GC.GXinvert) {
            //System.out.println("Pimxpa: GXinvert");
        } else {
            graphics.setColor(color);
        }
    }
    if ((mask & GC.GCFont) != 0) {
        XFont font = gc.font;
        graphics.setFont(font.getFont());
    }
    if ((mask & GC.GCLineWidth) != 0 || (mask & GC.GCLineStyle) != 0 || (mask & GC.GCCapStyle) != 0
            || (mask & GC.GCJoinStyle) != 0) {
    }
    return graphics;
}