java.awt.PaintContext Java Examples

The following examples show how to use java.awt.PaintContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Type4ShadingPaint.java    From sambox with Apache License 2.0 5 votes vote down vote up
@Override
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds,
                                  AffineTransform xform, RenderingHints hints)
{
    try
    {
        return new Type4ShadingContext(shading, cm, xform, matrix, deviceBounds);
    }
    catch (IOException e)
    {
        LOG.error("An error occurred while painting", e);
        return new Color(0, 0, 0, 0).createContext(cm, deviceBounds, userBounds, xform, hints);
    }
}
 
Example #2
Source File: DiamondGradientPaint.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public PaintContext createContext(ColorModel cm,
                                  Rectangle deviceBounds, Rectangle2D userBounds,
                                  AffineTransform xform, RenderingHints hints) {
    int numComponents = cm.getNumComponents();

    if (numComponents == 1) {
        return new GrayDiamondGradientPaintContext(imDrag,
                startColor, endColor, cm, cycleMethod);
    }

    return new DiamondGradientPaintContext(imDrag,
            startColor, endColor, cm, cycleMethod);
}
 
Example #3
Source File: AlphaPaintPipe.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR,
                            int[] abox) {
    PaintContext paintContext =
        sg.paint.createContext(sg.getDeviceColorModel(),
                               devR,
                               s.getBounds2D(),
                               sg.cloneTransform(),
                               sg.getRenderingHints());
    return new TileContext(sg, paintContext);
}
 
Example #4
Source File: Type7ShadingPaint.java    From sambox with Apache License 2.0 5 votes vote down vote up
@Override
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds,
        AffineTransform xform, RenderingHints hints)
{
    try
    {
        return new Type7ShadingContext(shading, cm, xform, matrix, deviceBounds);
    }
    catch (IOException e)
    {
        LOG.error("An error occurred while painting", e);
        return new Color(0, 0, 0, 0).createContext(cm, deviceBounds, userBounds, xform, hints);
    }
}
 
Example #5
Source File: AlphaPaintPipe.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR,
                            int[] abox) {
    PaintContext paintContext =
        sg.paint.createContext(sg.getDeviceColorModel(),
                               devR,
                               s.getBounds2D(),
                               sg.cloneTransform(),
                               sg.getRenderingHints());
    return new TileContext(sg, paintContext);
}
 
Example #6
Source File: BiLinearGradientPaint.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public PaintContext createContext(final ColorModel COLOR_MODEL,
                                           final Rectangle DEVICE_BOUNDS,
                                           final Rectangle2D USER_BOUNDS,
                                           final AffineTransform TRANSFORM,
                                           final RenderingHints HINTS) {
    return new BiLinearGradientPaintContext();
}
 
Example #7
Source File: ConicalGradientPaint.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public java.awt.PaintContext createContext(final ColorModel COLOR_MODEL,
                                           final Rectangle DEVICE_BOUNDS,
                                           final Rectangle2D USER_BOUNDS,
                                           final AffineTransform TRANSFORM,
                                           final RenderingHints HINTS) {
    final Point2D TRANSFORMED_CENTER = TRANSFORM.transform(CENTER, null);
    return new ConicalGradientPaintContext(TRANSFORMED_CENTER);
}
 
Example #8
Source File: PgramUserBoundsTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public PaintContext createContext(ColorModel cm,
                                  Rectangle deviceBounds,
                                  Rectangle2D userBounds,
                                  AffineTransform xform,
                                  RenderingHints hints)
{
    System.out.println("user bounds = "+userBounds);
    if (!userBounds.equals(expectedBounds)) {
        throw new RuntimeException("bounds fail to match");
    }
    return c.createContext(cm, deviceBounds, userBounds, xform, hints);
}
 
Example #9
Source File: GeneralCompositePipe.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR,
                            int[] abox) {
    RenderingHints hints = sg.getRenderingHints();
    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);
}
 
Example #10
Source File: GeneralCompositePipe.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public TileContext(SunGraphics2D sg, PaintContext pCtx,
                   CompositeContext cCtx, ColorModel cModel) {
    sunG2D = sg;
    paintCtxt = pCtx;
    compCtxt = cCtx;
    compModel = cModel;
}
 
Example #11
Source File: ContourGradientPaint.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public java.awt.PaintContext createContext(final ColorModel COLOR_MODEL,
                                           final Rectangle DEVICE_BOUNDS,
                                           final Rectangle2D USER_BOUNDS,
                                           final AffineTransform TRANSFORM,
                                           final RenderingHints HINTS) {
    return new ContourGradientPaintContext();
}
 
Example #12
Source File: GeneralCompositePipe.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public TileContext(SunGraphics2D sg, PaintContext pCtx,
                   CompositeContext cCtx, ColorModel cModel) {
    sunG2D = sg;
    paintCtxt = pCtx;
    compCtxt = cCtx;
    compModel = cModel;
}
 
Example #13
Source File: AlphaPaintPipe.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR,
                            int[] abox) {
    PaintContext paintContext =
        sg.paint.createContext(sg.getDeviceColorModel(),
                               devR,
                               s.getBounds2D(),
                               sg.cloneTransform(),
                               sg.getRenderingHints());
    return new TileContext(sg, paintContext);
}
 
Example #14
Source File: AlphaPaintPipe.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public TileContext(SunGraphics2D sg, PaintContext pc) {
    sunG2D = sg;
    paintCtxt = pc;
    paintModel = pc.getColorModel();
    dstData = sg.getSurfaceData();
    synchronized (AlphaPaintPipe.class) {
        if (cachedLastColorModel != null &&
            cachedLastColorModel.get() == paintModel)
        {
            this.lastRaster = cachedLastRaster;
            this.lastData = cachedLastData;
        }
    }
}
 
Example #15
Source File: PgramUserBoundsTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public PaintContext createContext(ColorModel cm,
                                  Rectangle deviceBounds,
                                  Rectangle2D userBounds,
                                  AffineTransform xform,
                                  RenderingHints hints)
{
    System.out.println("user bounds = "+userBounds);
    if (!userBounds.equals(expectedBounds)) {
        throw new RuntimeException("bounds fail to match");
    }
    return c.createContext(cm, deviceBounds, userBounds, xform, hints);
}
 
Example #16
Source File: GeneralCompositePipe.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR,
                            int[] abox) {
    RenderingHints hints = sg.getRenderingHints();
    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);
}
 
Example #17
Source File: GeneralCompositePipe.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public TileContext(SunGraphics2D sg, PaintContext pCtx,
                   CompositeContext cCtx, ColorModel cModel) {
    sunG2D = sg;
    paintCtxt = pCtx;
    compCtxt = cCtx;
    compModel = cModel;
}
 
Example #18
Source File: AlphaPaintPipe.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR,
                            int[] abox) {
    PaintContext paintContext =
        sg.paint.createContext(sg.getDeviceColorModel(),
                               devR,
                               s.getBounds2D(),
                               sg.cloneTransform(),
                               sg.getRenderingHints());
    return new TileContext(sg, paintContext);
}
 
Example #19
Source File: AlphaPaintPipe.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public TileContext(SunGraphics2D sg, PaintContext pc) {
    sunG2D = sg;
    paintCtxt = pc;
    paintModel = pc.getColorModel();
    dstData = sg.getSurfaceData();
    synchronized (AlphaPaintPipe.class) {
        if (cachedLastColorModel != null &&
            cachedLastColorModel.get() == paintModel)
        {
            this.lastRaster = cachedLastRaster;
            this.lastData = cachedLastData;
        }
    }
}
 
Example #20
Source File: SoftMask.java    From sambox with Apache License 2.0 5 votes vote down vote up
@Override
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds,
        AffineTransform xform, RenderingHints hints)
{
    PaintContext ctx = paint.createContext(cm, deviceBounds, userBounds, xform, hints);
    return new SoftPaintContext(ctx);
}
 
Example #21
Source File: AlphaPaintPipe.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public TileContext(SunGraphics2D sg, PaintContext pc) {
    sunG2D = sg;
    paintCtxt = pc;
    paintModel = pc.getColorModel();
    dstData = sg.getSurfaceData();
    synchronized (AlphaPaintPipe.class) {
        if (cachedLastColorModel != null &&
            cachedLastColorModel.get() == paintModel)
        {
            this.lastRaster = cachedLastRaster;
            this.lastData = cachedLastData;
        }
    }
}
 
Example #22
Source File: Type1ShadingPaint.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds,
                                  AffineTransform xform, RenderingHints hints)
{
    try
    {
        return new Type1ShadingContext(shading, cm, xform, matrix);
    }
    catch (IOException e)
    {
        LOG.error("An error occurred while painting", e);
        return new Color(0, 0, 0, 0).createContext(cm, deviceBounds, userBounds, xform, hints);
    }
}
 
Example #23
Source File: Type5ShadingPaint.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds,
                                  AffineTransform xform, RenderingHints hints)
{
    try
    {
        return new Type5ShadingContext(shading, cm, xform, matrix, deviceBounds);
    }
    catch (IOException e)
    {
        LOG.error("An error occurred while painting", e);
        return new Color(0, 0, 0, 0).createContext(cm, deviceBounds, userBounds, xform, hints);
    }
}
 
Example #24
Source File: Type4ShadingPaint.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds,
                                  AffineTransform xform, RenderingHints hints)
{
    try
    {
        return new Type4ShadingContext(shading, cm, xform, matrix, deviceBounds);
    }
    catch (IOException e)
    {
        LOG.error("An error occurred while painting", e);
        return new Color(0, 0, 0, 0).createContext(cm, deviceBounds, userBounds, xform, hints);
    }
}
 
Example #25
Source File: SpiralGradientPaint.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public PaintContext createContext(ColorModel cm,
                                  Rectangle deviceBounds, Rectangle2D userBounds,
                                  AffineTransform xform, RenderingHints hints) {
    int numComponents = cm.getNumComponents();

    if (numComponents == 1) {
        return new GraySpiralGradientPaintContext(clockwise, imDrag, startColor, endColor, cm, cycleMethod);
    }

    return new SpiralGradientPaintContext(clockwise, imDrag, startColor, endColor, cm, cycleMethod);
}
 
Example #26
Source File: RadialShadingPaint.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds,
                                  AffineTransform xform, RenderingHints hints)
{
    try
    {
        return new RadialShadingContext(shading, cm, xform, matrix, deviceBounds);
    }
    catch (IOException e)
    {
        LOG.error("An error occurred while painting", e);
        return new Color(0, 0, 0, 0).createContext(cm, deviceBounds, userBounds, xform, hints);
    }
}
 
Example #27
Source File: SoftMask.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds,
                                  Rectangle2D userBounds, AffineTransform xform,
                                  RenderingHints hints)
{
    PaintContext ctx = paint.createContext(cm, deviceBounds, userBounds, xform, hints);
    return new SoftPaintContext(ctx);
}
 
Example #28
Source File: TilingPaint.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Not called in TexturePaint subclasses, which is why we wrap TexturePaint.
 */
@Override
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds,
                                  AffineTransform xform, RenderingHints hints)
{
    AffineTransform xformPattern = (AffineTransform)xform.clone();

    // applies the pattern matrix with scaling removed
    AffineTransform patternNoScale = patternMatrix.createAffineTransform();
    patternNoScale.scale(1 / patternMatrix.getScalingFactorX(),
                         1 / patternMatrix.getScalingFactorY());
    xformPattern.concatenate(patternNoScale);

    return paint.createContext(cm, deviceBounds, userBounds, xformPattern, hints);
}
 
Example #29
Source File: AlphaPaintPipe.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public TileContext(SunGraphics2D sg, PaintContext pc) {
    sunG2D = sg;
    paintCtxt = pc;
    paintModel = pc.getColorModel();
    dstData = sg.getSurfaceData();
    synchronized (AlphaPaintPipe.class) {
        if (cachedLastColorModel != null &&
            cachedLastColorModel.get() == paintModel)
        {
            this.lastRaster = cachedLastRaster;
            this.lastData = cachedLastData;
        }
    }
}
 
Example #30
Source File: GeneralCompositePipe.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR,
                            int[] abox) {
    RenderingHints hints = sg.getRenderingHints();
    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);
}