Java Code Examples for java.awt.MultipleGradientPaint.ColorSpaceType

The following examples show how to use java.awt.MultipleGradientPaint.ColorSpaceType. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: hottub   Source File: MultiGradientTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();

    if (source == cmbPaint) {
        paintType = (PaintType)cmbPaint.getSelectedItem();
    } else if (source == cmbCycle) {
        cycleMethod = (CycleMethod)cmbCycle.getSelectedItem();
    } else if (source == cmbSpace) {
        colorSpace = (ColorSpaceType)cmbSpace.getSelectedItem();
    } else if (source == cmbShape) {
        shapeType = (ShapeType)cmbShape.getSelectedItem();
    } else if (source == cmbXform) {
        xformType = (XformType)cmbXform.getSelectedItem();
    } else if (source == cbAntialias) {
        antialiasHint = cbAntialias.isSelected() ?
            RenderingHints.VALUE_ANTIALIAS_ON :
            RenderingHints.VALUE_ANTIALIAS_OFF;
    } else if (source == cbRender) {
        renderHint = cbRender.isSelected() ?
            RenderingHints.VALUE_RENDER_QUALITY :
            RenderingHints.VALUE_RENDER_SPEED;
    }

    gradientPanel.updatePaint();
}
 
Example 2
public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();

    if (source == cmbPaint) {
        paintType = (PaintType)cmbPaint.getSelectedItem();
    } else if (source == cmbCycle) {
        cycleMethod = (CycleMethod)cmbCycle.getSelectedItem();
    } else if (source == cmbSpace) {
        colorSpace = (ColorSpaceType)cmbSpace.getSelectedItem();
    } else if (source == cmbShape) {
        shapeType = (ShapeType)cmbShape.getSelectedItem();
    } else if (source == cmbXform) {
        xformType = (XformType)cmbXform.getSelectedItem();
    } else if (source == cbAntialias) {
        antialiasHint = cbAntialias.isSelected() ?
            RenderingHints.VALUE_ANTIALIAS_ON :
            RenderingHints.VALUE_ANTIALIAS_OFF;
    } else if (source == cbRender) {
        renderHint = cbRender.isSelected() ?
            RenderingHints.VALUE_RENDER_QUALITY :
            RenderingHints.VALUE_RENDER_SPEED;
    }

    gradientPanel.updatePaint();
}
 
Example 3
Source Project: openjdk-jdk9   Source File: D3DPaints.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint;

    if (paint.getFractions().length == 2 &&
        paint.getCycleMethod() != CycleMethod.REPEAT &&
        paint.getColorSpace() != ColorSpaceType.LINEAR_RGB)
    {
        D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
        D3DGraphicsDevice gd = (D3DGraphicsDevice)
            dstData.getDeviceConfiguration().getDevice();
        if (gd.isCapPresent(CAPS_LCD_SHADER)) {
            // we can delegate to the optimized two-color gradient
            // codepath, which should be faster
            return true;
        }
    }

    return super.isPaintValid(sg2d);
}
 
Example 4
Source Project: dragonwell8_jdk   Source File: D3DPaints.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint;

    if (paint.getFractions().length == 2 &&
        paint.getCycleMethod() != CycleMethod.REPEAT &&
        paint.getColorSpace() != ColorSpaceType.LINEAR_RGB)
    {
        D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
        D3DGraphicsDevice gd = (D3DGraphicsDevice)
            dstData.getDeviceConfiguration().getDevice();
        if (gd.isCapPresent(CAPS_LCD_SHADER)) {
            // we can delegate to the optimized two-color gradient
            // codepath, which should be faster
            return true;
        }
    }

    return super.isPaintValid(sg2d);
}
 
Example 5
public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();

    if (source == cmbPaint) {
        paintType = (PaintType)cmbPaint.getSelectedItem();
    } else if (source == cmbCycle) {
        cycleMethod = (CycleMethod)cmbCycle.getSelectedItem();
    } else if (source == cmbSpace) {
        colorSpace = (ColorSpaceType)cmbSpace.getSelectedItem();
    } else if (source == cmbShape) {
        shapeType = (ShapeType)cmbShape.getSelectedItem();
    } else if (source == cmbXform) {
        xformType = (XformType)cmbXform.getSelectedItem();
    } else if (source == cbAntialias) {
        antialiasHint = cbAntialias.isSelected() ?
            RenderingHints.VALUE_ANTIALIAS_ON :
            RenderingHints.VALUE_ANTIALIAS_OFF;
    } else if (source == cbRender) {
        renderHint = cbRender.isSelected() ?
            RenderingHints.VALUE_RENDER_QUALITY :
            RenderingHints.VALUE_RENDER_SPEED;
    }

    gradientPanel.updatePaint();
}
 
Example 6
Source Project: openjdk-8   Source File: MultiGradientTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();

    if (source == cmbPaint) {
        paintType = (PaintType)cmbPaint.getSelectedItem();
    } else if (source == cmbCycle) {
        cycleMethod = (CycleMethod)cmbCycle.getSelectedItem();
    } else if (source == cmbSpace) {
        colorSpace = (ColorSpaceType)cmbSpace.getSelectedItem();
    } else if (source == cmbShape) {
        shapeType = (ShapeType)cmbShape.getSelectedItem();
    } else if (source == cmbXform) {
        xformType = (XformType)cmbXform.getSelectedItem();
    } else if (source == cbAntialias) {
        antialiasHint = cbAntialias.isSelected() ?
            RenderingHints.VALUE_ANTIALIAS_ON :
            RenderingHints.VALUE_ANTIALIAS_OFF;
    } else if (source == cbRender) {
        renderHint = cbRender.isSelected() ?
            RenderingHints.VALUE_RENDER_QUALITY :
            RenderingHints.VALUE_RENDER_SPEED;
    }

    gradientPanel.updatePaint();
}
 
Example 7
public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();

    if (source == cmbPaint) {
        paintType = (PaintType)cmbPaint.getSelectedItem();
    } else if (source == cmbCycle) {
        cycleMethod = (CycleMethod)cmbCycle.getSelectedItem();
    } else if (source == cmbSpace) {
        colorSpace = (ColorSpaceType)cmbSpace.getSelectedItem();
    } else if (source == cmbShape) {
        shapeType = (ShapeType)cmbShape.getSelectedItem();
    } else if (source == cmbXform) {
        xformType = (XformType)cmbXform.getSelectedItem();
    } else if (source == cbAntialias) {
        antialiasHint = cbAntialias.isSelected() ?
            RenderingHints.VALUE_ANTIALIAS_ON :
            RenderingHints.VALUE_ANTIALIAS_OFF;
    } else if (source == cbRender) {
        renderHint = cbRender.isSelected() ?
            RenderingHints.VALUE_RENDER_QUALITY :
            RenderingHints.VALUE_RENDER_SPEED;
    }

    gradientPanel.updatePaint();
}
 
Example 8
Source Project: TencentKona-8   Source File: D3DPaints.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint;

    if (paint.getFractions().length == 2 &&
        paint.getCycleMethod() != CycleMethod.REPEAT &&
        paint.getColorSpace() != ColorSpaceType.LINEAR_RGB)
    {
        D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
        D3DGraphicsDevice gd = (D3DGraphicsDevice)
            dstData.getDeviceConfiguration().getDevice();
        if (gd.isCapPresent(CAPS_LCD_SHADER)) {
            // we can delegate to the optimized two-color gradient
            // codepath, which should be faster
            return true;
        }
    }

    return super.isPaintValid(sg2d);
}
 
Example 9
Source Project: jdk8u60   Source File: D3DPaints.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint;

    if (paint.getFractions().length == 2 &&
        paint.getCycleMethod() != CycleMethod.REPEAT &&
        paint.getColorSpace() != ColorSpaceType.LINEAR_RGB)
    {
        D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
        D3DGraphicsDevice gd = (D3DGraphicsDevice)
            dstData.getDeviceConfiguration().getDevice();
        if (gd.isCapPresent(CAPS_LCD_SHADER)) {
            // we can delegate to the optimized two-color gradient
            // codepath, which should be faster
            return true;
        }
    }

    return super.isPaintValid(sg2d);
}
 
Example 10
Source Project: jdk8u-jdk   Source File: D3DPaints.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint;

    if (paint.getFractions().length == 2 &&
        paint.getCycleMethod() != CycleMethod.REPEAT &&
        paint.getColorSpace() != ColorSpaceType.LINEAR_RGB)
    {
        D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
        D3DGraphicsDevice gd = (D3DGraphicsDevice)
            dstData.getDeviceConfiguration().getDevice();
        if (gd.isCapPresent(CAPS_LCD_SHADER)) {
            // we can delegate to the optimized two-color gradient
            // codepath, which should be faster
            return true;
        }
    }

    return super.isPaintValid(sg2d);
}
 
Example 11
Source Project: openjdk-jdk8u   Source File: D3DPaints.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint;

    if (paint.getFractions().length == 2 &&
        paint.getCycleMethod() != CycleMethod.REPEAT &&
        paint.getColorSpace() != ColorSpaceType.LINEAR_RGB)
    {
        D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
        D3DGraphicsDevice gd = (D3DGraphicsDevice)
            dstData.getDeviceConfiguration().getDevice();
        if (gd.isCapPresent(CAPS_LCD_SHADER)) {
            // we can delegate to the optimized two-color gradient
            // codepath, which should be faster
            return true;
        }
    }

    return super.isPaintValid(sg2d);
}
 
Example 12
Source Project: jdk8u_jdk   Source File: MultiGradientTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();

    if (source == cmbPaint) {
        paintType = (PaintType)cmbPaint.getSelectedItem();
    } else if (source == cmbCycle) {
        cycleMethod = (CycleMethod)cmbCycle.getSelectedItem();
    } else if (source == cmbSpace) {
        colorSpace = (ColorSpaceType)cmbSpace.getSelectedItem();
    } else if (source == cmbShape) {
        shapeType = (ShapeType)cmbShape.getSelectedItem();
    } else if (source == cmbXform) {
        xformType = (XformType)cmbXform.getSelectedItem();
    } else if (source == cbAntialias) {
        antialiasHint = cbAntialias.isSelected() ?
            RenderingHints.VALUE_ANTIALIAS_ON :
            RenderingHints.VALUE_ANTIALIAS_OFF;
    } else if (source == cbRender) {
        renderHint = cbRender.isSelected() ?
            RenderingHints.VALUE_RENDER_QUALITY :
            RenderingHints.VALUE_RENDER_SPEED;
    }

    gradientPanel.updatePaint();
}
 
Example 13
Source Project: jdk8u-jdk   Source File: D3DPaints.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint;

    if (paint.getFractions().length == 2 &&
        paint.getCycleMethod() != CycleMethod.REPEAT &&
        paint.getColorSpace() != ColorSpaceType.LINEAR_RGB)
    {
        D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
        D3DGraphicsDevice gd = (D3DGraphicsDevice)
            dstData.getDeviceConfiguration().getDevice();
        if (gd.isCapPresent(CAPS_LCD_SHADER)) {
            // we can delegate to the optimized two-color gradient
            // codepath, which should be faster
            return true;
        }
    }

    return super.isPaintValid(sg2d);
}
 
Example 14
public void actionPerformed(ActionEvent e) {
    Object source = e.getSource();

    if (source == cmbPaint) {
        paintType = (PaintType)cmbPaint.getSelectedItem();
    } else if (source == cmbCycle) {
        cycleMethod = (CycleMethod)cmbCycle.getSelectedItem();
    } else if (source == cmbSpace) {
        colorSpace = (ColorSpaceType)cmbSpace.getSelectedItem();
    } else if (source == cmbShape) {
        shapeType = (ShapeType)cmbShape.getSelectedItem();
    } else if (source == cmbXform) {
        xformType = (XformType)cmbXform.getSelectedItem();
    } else if (source == cbAntialias) {
        antialiasHint = cbAntialias.isSelected() ?
            RenderingHints.VALUE_ANTIALIAS_ON :
            RenderingHints.VALUE_ANTIALIAS_OFF;
    } else if (source == cbRender) {
        renderHint = cbRender.isSelected() ?
            RenderingHints.VALUE_RENDER_QUALITY :
            RenderingHints.VALUE_RENDER_SPEED;
    }

    gradientPanel.updatePaint();
}
 
Example 15
Source Project: openjdk-8-source   Source File: D3DPaints.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint;

    if (paint.getFractions().length == 2 &&
        paint.getCycleMethod() != CycleMethod.REPEAT &&
        paint.getColorSpace() != ColorSpaceType.LINEAR_RGB)
    {
        D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
        D3DGraphicsDevice gd = (D3DGraphicsDevice)
            dstData.getDeviceConfiguration().getDevice();
        if (gd.isCapPresent(CAPS_LCD_SHADER)) {
            // we can delegate to the optimized two-color gradient
            // codepath, which should be faster
            return true;
        }
    }

    return super.isPaintValid(sg2d);
}
 
Example 16
Source Project: Bytecoder   Source File: OGLPaints.java    License: Apache License 2.0 5 votes vote down vote up
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint;

    if (paint.getFractions().length == 2 &&
        paint.getCycleMethod() != CycleMethod.REPEAT &&
        paint.getColorSpace() != ColorSpaceType.LINEAR_RGB)
    {
        // we can delegate to the optimized two-color gradient
        // codepath, which does not require fragment shader support
        return true;
    }

    return super.isPaintValid(sg2d);
}
 
Example 17
/**
 * SLOW LOOKUP METHOD
 *
 * This method calculates the gradient color values for each interval and
 * places each into its own 255 size array.  The arrays are stored in
 * gradients[][].  (255 is used because this is the maximum number of
 * unique colors between 2 arbitrary colors in a 24 bit color system.)
 *
 * This method uses the minimum amount of space (only 255 * number of
 * intervals), but it aggravates the lookup procedure, because now we
 * have to find out which interval to select, then calculate the index
 * within that interval.  This causes a significant performance hit,
 * because it requires this calculation be done for every point in
 * the rendering loop.
 *
 * For those of you who are interested, this is a classic example of the
 * time-space tradeoff.
 */
private void calculateMultipleArrayGradient(Color[] colors) {
    // set the flag so we know later it is a non-simple lookup
    isSimpleLookup = false;

    // 2 colors to interpolate
    int rgb1, rgb2;

    // for every interval (transition between 2 colors)
    for (int i = 0; i < gradients.length; i++){
        // create an array of the maximum theoretical size for
        // each interval
        gradients[i] = new int[GRADIENT_SIZE];

        // get the the 2 colors
        rgb1 = colors[i].getRGB();
        rgb2 = colors[i+1].getRGB();

        // fill this array with the colors in between rgb1 and rgb2
        interpolate(rgb1, rgb2, gradients[i]);

        // if the colors are opaque, transparency should still
        // be 0xff000000
        transparencyTest &= rgb1;
        transparencyTest &= rgb2;
    }

    // if interpolation occurred in Linear RGB space, convert the
    // gradients back to SRGB using the lookup table
    if (colorSpace == ColorSpaceType.LINEAR_RGB) {
        for (int j = 0; j < gradients.length; j++) {
            for (int i = 0; i < gradients[j].length; i++) {
                gradients[j][i] =
                    convertEntireColorLinearRGBtoSRGB(gradients[j][i]);
            }
        }
    }
}
 
Example 18
private LinearGradientPaint createLinearGradientPaint(LinearGradient grad)
{
    Point2D start = new Point2D.Float(grad.getX1(), grad.getY1());
    Point2D end = new Point2D.Float(grad.getEfficientX2(), grad.getEfficientY2());
    float[] dists = new float[grad.getStops().size()];
    java.awt.Color[] colors = new java.awt.Color[grad.getStops().size()];
    stopsToPaintValues(grad, dists, colors);
    return new LinearGradientPaint(start, end, dists, colors,
            grad.isRepeating() ? CycleMethod.REPEAT : CycleMethod.NO_CYCLE,
            ColorSpaceType.SRGB, 
            new AffineTransform());
}
 
Example 19
Source Project: jdk8u-dev-jdk   Source File: GradientPaints.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void testOne(BufferedImage refImg, VolatileImage testImg) {
    Graphics2D gref  = refImg.createGraphics();
    Graphics2D gtest = testImg.createGraphics();
    Paint paint =
        makePaint(PaintType.RADIAL, CycleMethod.REPEAT,
                  ColorSpaceType.SRGB, XformType.IDENTITY, 7);
    Object aahint = hints[0];
    renderTest(gref,  paint, aahint);
    renderTest(gtest, paint, aahint);
    Toolkit.getDefaultToolkit().sync();
    compareImages(refImg, testImg.getSnapshot(),
                  TOLERANCE, 0, "");
    gref.dispose();
    gtest.dispose();
}
 
Example 20
Source Project: Java8CN   Source File: MultipleGradientPaintContext.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * SLOW LOOKUP METHOD
 *
 * This method calculates the gradient color values for each interval and
 * places each into its own 255 size array.  The arrays are stored in
 * gradients[][].  (255 is used because this is the maximum number of
 * unique colors between 2 arbitrary colors in a 24 bit color system.)
 *
 * This method uses the minimum amount of space (only 255 * number of
 * intervals), but it aggravates the lookup procedure, because now we
 * have to find out which interval to select, then calculate the index
 * within that interval.  This causes a significant performance hit,
 * because it requires this calculation be done for every point in
 * the rendering loop.
 *
 * For those of you who are interested, this is a classic example of the
 * time-space tradeoff.
 */
private void calculateMultipleArrayGradient(Color[] colors) {
    // set the flag so we know later it is a non-simple lookup
    isSimpleLookup = false;

    // 2 colors to interpolate
    int rgb1, rgb2;

    // for every interval (transition between 2 colors)
    for (int i = 0; i < gradients.length; i++){
        // create an array of the maximum theoretical size for
        // each interval
        gradients[i] = new int[GRADIENT_SIZE];

        // get the the 2 colors
        rgb1 = colors[i].getRGB();
        rgb2 = colors[i+1].getRGB();

        // fill this array with the colors in between rgb1 and rgb2
        interpolate(rgb1, rgb2, gradients[i]);

        // if the colors are opaque, transparency should still
        // be 0xff000000
        transparencyTest &= rgb1;
        transparencyTest &= rgb2;
    }

    // if interpolation occurred in Linear RGB space, convert the
    // gradients back to SRGB using the lookup table
    if (colorSpace == ColorSpaceType.LINEAR_RGB) {
        for (int j = 0; j < gradients.length; j++) {
            for (int i = 0; i < gradients[j].length; i++) {
                gradients[j][i] =
                    convertEntireColorLinearRGBtoSRGB(gradients[j][i]);
            }
        }
    }
}
 
Example 21
/**
 * SLOW LOOKUP METHOD
 *
 * This method calculates the gradient color values for each interval and
 * places each into its own 255 size array.  The arrays are stored in
 * gradients[][].  (255 is used because this is the maximum number of
 * unique colors between 2 arbitrary colors in a 24 bit color system.)
 *
 * This method uses the minimum amount of space (only 255 * number of
 * intervals), but it aggravates the lookup procedure, because now we
 * have to find out which interval to select, then calculate the index
 * within that interval.  This causes a significant performance hit,
 * because it requires this calculation be done for every point in
 * the rendering loop.
 *
 * For those of you who are interested, this is a classic example of the
 * time-space tradeoff.
 */
private void calculateMultipleArrayGradient(Color[] colors) {
    // set the flag so we know later it is a non-simple lookup
    isSimpleLookup = false;

    // 2 colors to interpolate
    int rgb1, rgb2;

    // for every interval (transition between 2 colors)
    for (int i = 0; i < gradients.length; i++){
        // create an array of the maximum theoretical size for
        // each interval
        gradients[i] = new int[GRADIENT_SIZE];

        // get the the 2 colors
        rgb1 = colors[i].getRGB();
        rgb2 = colors[i+1].getRGB();

        // fill this array with the colors in between rgb1 and rgb2
        interpolate(rgb1, rgb2, gradients[i]);

        // if the colors are opaque, transparency should still
        // be 0xff000000
        transparencyTest &= rgb1;
        transparencyTest &= rgb2;
    }

    // if interpolation occurred in Linear RGB space, convert the
    // gradients back to SRGB using the lookup table
    if (colorSpace == ColorSpaceType.LINEAR_RGB) {
        for (int j = 0; j < gradients.length; j++) {
            for (int i = 0; i < gradients[j].length; i++) {
                gradients[j][i] =
                    convertEntireColorLinearRGBtoSRGB(gradients[j][i]);
            }
        }
    }
}
 
Example 22
Source Project: openjdk-8   Source File: GradientPaints.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void testOne(BufferedImage refImg, VolatileImage testImg) {
    Graphics2D gref  = refImg.createGraphics();
    Graphics2D gtest = testImg.createGraphics();
    Paint paint =
        makePaint(PaintType.RADIAL, CycleMethod.REPEAT,
                  ColorSpaceType.SRGB, XformType.IDENTITY, 7);
    Object aahint = hints[0];
    renderTest(gref,  paint, aahint);
    renderTest(gtest, paint, aahint);
    Toolkit.getDefaultToolkit().sync();
    compareImages(refImg, testImg.getSnapshot(),
                  TOLERANCE, 0, "");
    gref.dispose();
    gtest.dispose();
}
 
Example 23
Source Project: TencentKona-8   Source File: OGLPaints.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint;

    if (paint.getFractions().length == 2 &&
        paint.getCycleMethod() != CycleMethod.REPEAT &&
        paint.getColorSpace() != ColorSpaceType.LINEAR_RGB)
    {
        // we can delegate to the optimized two-color gradient
        // codepath, which does not require fragment shader support
        return true;
    }

    return super.isPaintValid(sg2d);
}
 
Example 24
/**
 * SLOW LOOKUP METHOD
 *
 * This method calculates the gradient color values for each interval and
 * places each into its own 255 size array.  The arrays are stored in
 * gradients[][].  (255 is used because this is the maximum number of
 * unique colors between 2 arbitrary colors in a 24 bit color system.)
 *
 * This method uses the minimum amount of space (only 255 * number of
 * intervals), but it aggravates the lookup procedure, because now we
 * have to find out which interval to select, then calculate the index
 * within that interval.  This causes a significant performance hit,
 * because it requires this calculation be done for every point in
 * the rendering loop.
 *
 * For those of you who are interested, this is a classic example of the
 * time-space tradeoff.
 */
private void calculateMultipleArrayGradient(Color[] colors) {
    // set the flag so we know later it is a non-simple lookup
    isSimpleLookup = false;

    // 2 colors to interpolate
    int rgb1, rgb2;

    // for every interval (transition between 2 colors)
    for (int i = 0; i < gradients.length; i++){
        // create an array of the maximum theoretical size for
        // each interval
        gradients[i] = new int[GRADIENT_SIZE];

        // get the the 2 colors
        rgb1 = colors[i].getRGB();
        rgb2 = colors[i+1].getRGB();

        // fill this array with the colors in between rgb1 and rgb2
        interpolate(rgb1, rgb2, gradients[i]);

        // if the colors are opaque, transparency should still
        // be 0xff000000
        transparencyTest &= rgb1;
        transparencyTest &= rgb2;
    }

    // if interpolation occurred in Linear RGB space, convert the
    // gradients back to SRGB using the lookup table
    if (colorSpace == ColorSpaceType.LINEAR_RGB) {
        for (int j = 0; j < gradients.length; j++) {
            for (int i = 0; i < gradients[j].length; i++) {
                gradients[j][i] =
                    convertEntireColorLinearRGBtoSRGB(gradients[j][i]);
            }
        }
    }
}
 
Example 25
/**
 * SLOW LOOKUP METHOD
 *
 * This method calculates the gradient color values for each interval and
 * places each into its own 255 size array.  The arrays are stored in
 * gradients[][].  (255 is used because this is the maximum number of
 * unique colors between 2 arbitrary colors in a 24 bit color system.)
 *
 * This method uses the minimum amount of space (only 255 * number of
 * intervals), but it aggravates the lookup procedure, because now we
 * have to find out which interval to select, then calculate the index
 * within that interval.  This causes a significant performance hit,
 * because it requires this calculation be done for every point in
 * the rendering loop.
 *
 * For those of you who are interested, this is a classic example of the
 * time-space tradeoff.
 */
private void calculateMultipleArrayGradient(Color[] colors) {
    // set the flag so we know later it is a non-simple lookup
    isSimpleLookup = false;

    // 2 colors to interpolate
    int rgb1, rgb2;

    // for every interval (transition between 2 colors)
    for (int i = 0; i < gradients.length; i++){
        // create an array of the maximum theoretical size for
        // each interval
        gradients[i] = new int[GRADIENT_SIZE];

        // get the the 2 colors
        rgb1 = colors[i].getRGB();
        rgb2 = colors[i+1].getRGB();

        // fill this array with the colors in between rgb1 and rgb2
        interpolate(rgb1, rgb2, gradients[i]);

        // if the colors are opaque, transparency should still
        // be 0xff000000
        transparencyTest &= rgb1;
        transparencyTest &= rgb2;
    }

    // if interpolation occurred in Linear RGB space, convert the
    // gradients back to SRGB using the lookup table
    if (colorSpace == ColorSpaceType.LINEAR_RGB) {
        for (int j = 0; j < gradients.length; j++) {
            for (int i = 0; i < gradients[j].length; i++) {
                gradients[j][i] =
                    convertEntireColorLinearRGBtoSRGB(gradients[j][i]);
            }
        }
    }
}
 
Example 26
Source Project: jdk8u60   Source File: OGLPaints.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint;

    if (paint.getFractions().length == 2 &&
        paint.getCycleMethod() != CycleMethod.REPEAT &&
        paint.getColorSpace() != ColorSpaceType.LINEAR_RGB)
    {
        // we can delegate to the optimized two-color gradient
        // codepath, which does not require fragment shader support
        return true;
    }

    return super.isPaintValid(sg2d);
}
 
Example 27
Source Project: jdk8u-jdk   Source File: OGLPaints.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint;

    if (paint.getFractions().length == 2 &&
        paint.getCycleMethod() != CycleMethod.REPEAT &&
        paint.getColorSpace() != ColorSpaceType.LINEAR_RGB)
    {
        // we can delegate to the optimized two-color gradient
        // codepath, which does not require fragment shader support
        return true;
    }

    return super.isPaintValid(sg2d);
}
 
Example 28
private void testOne(BufferedImage refImg, VolatileImage testImg) {
    Graphics2D gref  = refImg.createGraphics();
    Graphics2D gtest = testImg.createGraphics();
    Paint paint =
        makePaint(PaintType.RADIAL, CycleMethod.REPEAT,
                  ColorSpaceType.SRGB, XformType.IDENTITY, 7);
    Object aahint = hints[0];
    renderTest(gref,  paint, aahint);
    renderTest(gtest, paint, aahint);
    Toolkit.getDefaultToolkit().sync();
    compareImages(refImg, testImg.getSnapshot(),
                  TOLERANCE, 0, "");
    gref.dispose();
    gtest.dispose();
}
 
Example 29
Source Project: JDKSourceCode1.8   Source File: MultipleGradientPaintContext.java    License: MIT License 5 votes vote down vote up
/**
 * SLOW LOOKUP METHOD
 *
 * This method calculates the gradient color values for each interval and
 * places each into its own 255 size array.  The arrays are stored in
 * gradients[][].  (255 is used because this is the maximum number of
 * unique colors between 2 arbitrary colors in a 24 bit color system.)
 *
 * This method uses the minimum amount of space (only 255 * number of
 * intervals), but it aggravates the lookup procedure, because now we
 * have to find out which interval to select, then calculate the index
 * within that interval.  This causes a significant performance hit,
 * because it requires this calculation be done for every point in
 * the rendering loop.
 *
 * For those of you who are interested, this is a classic example of the
 * time-space tradeoff.
 */
private void calculateMultipleArrayGradient(Color[] colors) {
    // set the flag so we know later it is a non-simple lookup
    isSimpleLookup = false;

    // 2 colors to interpolate
    int rgb1, rgb2;

    // for every interval (transition between 2 colors)
    for (int i = 0; i < gradients.length; i++){
        // create an array of the maximum theoretical size for
        // each interval
        gradients[i] = new int[GRADIENT_SIZE];

        // get the the 2 colors
        rgb1 = colors[i].getRGB();
        rgb2 = colors[i+1].getRGB();

        // fill this array with the colors in between rgb1 and rgb2
        interpolate(rgb1, rgb2, gradients[i]);

        // if the colors are opaque, transparency should still
        // be 0xff000000
        transparencyTest &= rgb1;
        transparencyTest &= rgb2;
    }

    // if interpolation occurred in Linear RGB space, convert the
    // gradients back to SRGB using the lookup table
    if (colorSpace == ColorSpaceType.LINEAR_RGB) {
        for (int j = 0; j < gradients.length; j++) {
            for (int i = 0; i < gradients[j].length; i++) {
                gradients[j][i] =
                    convertEntireColorLinearRGBtoSRGB(gradients[j][i]);
            }
        }
    }
}
 
Example 30
Source Project: openjdk-jdk8u   Source File: OGLPaints.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint;

    if (paint.getFractions().length == 2 &&
        paint.getCycleMethod() != CycleMethod.REPEAT &&
        paint.getColorSpace() != ColorSpaceType.LINEAR_RGB)
    {
        // we can delegate to the optimized two-color gradient
        // codepath, which does not require fragment shader support
        return true;
    }

    return super.isPaintValid(sg2d);
}