类java.awt.MultipleGradientPaint.ColorSpaceType源码实例Demo

下面列出了怎么用java.awt.MultipleGradientPaint.ColorSpaceType的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: hottub   文件: MultiGradientTest.java
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();
}
 
源代码2 项目: openjdk-jdk9   文件: MultiGradientTest.java
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();
}
 
源代码3 项目: openjdk-jdk9   文件: D3DPaints.java
@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);
}
 
源代码4 项目: dragonwell8_jdk   文件: D3DPaints.java
@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);
}
 
源代码5 项目: dragonwell8_jdk   文件: MultiGradientTest.java
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();
}
 
源代码6 项目: openjdk-8   文件: MultiGradientTest.java
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();
}
 
源代码7 项目: openjdk-8-source   文件: MultiGradientTest.java
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();
}
 
源代码8 项目: TencentKona-8   文件: D3DPaints.java
@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);
}
 
源代码9 项目: jdk8u60   文件: D3DPaints.java
@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);
}
 
源代码10 项目: jdk8u-jdk   文件: D3DPaints.java
@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);
}
 
源代码11 项目: openjdk-jdk8u   文件: D3DPaints.java
@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);
}
 
源代码12 项目: jdk8u_jdk   文件: MultiGradientTest.java
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();
}
 
源代码13 项目: jdk8u-jdk   文件: D3DPaints.java
@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);
}
 
源代码14 项目: openjdk-jdk8u-backup   文件: MultiGradientTest.java
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();
}
 
源代码15 项目: openjdk-8-source   文件: D3DPaints.java
@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);
}
 
源代码16 项目: Bytecoder   文件: OGLPaints.java
@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);
}
 
/**
 * 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]);
            }
        }
    }
}
 
源代码18 项目: CSSBox   文件: BackgroundBitmap.java
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());
}
 
源代码19 项目: jdk8u-dev-jdk   文件: GradientPaints.java
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();
}
 
源代码20 项目: Java8CN   文件: MultipleGradientPaintContext.java
/**
 * 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]);
            }
        }
    }
}
 
/**
 * 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]);
            }
        }
    }
}
 
源代码22 项目: openjdk-8   文件: GradientPaints.java
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();
}
 
源代码23 项目: TencentKona-8   文件: OGLPaints.java
@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);
}
 
源代码24 项目: jdk8u-jdk   文件: MultipleGradientPaintContext.java
/**
 * 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]);
            }
        }
    }
}
 
源代码25 项目: jdk8u60   文件: MultipleGradientPaintContext.java
/**
 * 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]);
            }
        }
    }
}
 
源代码26 项目: jdk8u60   文件: OGLPaints.java
@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);
}
 
源代码27 项目: jdk8u-jdk   文件: OGLPaints.java
@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);
}
 
源代码28 项目: openjdk-8-source   文件: GradientPaints.java
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();
}
 
/**
 * 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]);
            }
        }
    }
}
 
源代码30 项目: openjdk-jdk8u   文件: OGLPaints.java
@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);
}
 
 类所在包
 同包方法