Java Code Examples for java.awt.MultipleGradientPaint.ColorSpaceType

The following are top voted examples for showing how to use java.awt.MultipleGradientPaint.ColorSpaceType. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OpenJSharp   File: D3DPaints.java   View source code 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 2
Project: jdk8u-jdk   File: D3DPaints.java   View source code 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 3
Project: jdk8u-jdk   File: MultiGradientTest.java   View source code 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 4
Project: openjdk-jdk10   File: D3DPaints.java   View source code 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
Project: openjdk-jdk10   File: MultiGradientTest.java   View source code 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 6
Project: openjdk9   File: D3DPaints.java   View source code 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 7
Project: openjdk9   File: MultiGradientTest.java   View source code 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 8
Project: jdk8u_jdk   File: D3DPaints.java   View source code 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
Project: jdk8u_jdk   File: MultiGradientTest.java   View source code 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 10
Project: lookaside_java-1.8.0-openjdk   File: D3DPaints.java   View source code 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
Project: lookaside_java-1.8.0-openjdk   File: MultiGradientTest.java   View source code 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 12
Project: infobip-open-jdk-8   File: D3DPaints.java   View source code 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 13
Project: infobip-open-jdk-8   File: MultiGradientTest.java   View source code 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 14
Project: jdk8u-dev-jdk   File: D3DPaints.java   View source code 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 15
Project: jdk8u-dev-jdk   File: MultiGradientTest.java   View source code 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 16
Project: jdk7-jdk   File: D3DPaints.java   View source code 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 17
Project: jdk7-jdk   File: MultiGradientTest.java   View source code 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 18
Project: openjdk-source-code-learn   File: D3DPaints.java   View source code 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 19
Project: openjdk-source-code-learn   File: MultiGradientTest.java   View source code 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 20
Project: OLD-OpenJDK8   File: D3DPaints.java   View source code 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 21
Project: OLD-OpenJDK8   File: MultiGradientTest.java   View source code 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 22
Project: JAVA_UNIT   File: MultiGradientTest.java   View source code 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 23
Project: openjdk-jdk7u-jdk   File: D3DPaints.java   View source code 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 24
Project: openjdk-jdk7u-jdk   File: MultiGradientTest.java   View source code 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 25
Project: openjdk-icedtea7   File: D3DPaints.java   View source code 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 26
Project: openjdk-icedtea7   File: MultiGradientTest.java   View source code 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 27
Project: OpenJSharp   File: MultipleGradientPaintContext.java   View source code 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 28
Project: OpenJSharp   File: OGLPaints.java   View source code 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 29
Project: jdk8u-jdk   File: MultipleGradientPaintContext.java   View source code 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
Project: jdk8u-jdk   File: OGLPaints.java   View source code 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 31
Project: jdk8u-jdk   File: GradientPaints.java   View source code 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 32
Project: openjdk-jdk10   File: MultipleGradientPaintContext.java   View source code 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 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 33
Project: openjdk-jdk10   File: OGLPaints.java   View source code 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 34
Project: openjdk-jdk10   File: GradientPaints.java   View source code 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 35
Project: openjdk9   File: MultipleGradientPaintContext.java   View source code 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 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 36
Project: openjdk9   File: OGLPaints.java   View source code 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 37
Project: openjdk9   File: GradientPaints.java   View source code 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 38
Project: Java8CN   File: MultipleGradientPaintContext.java   View source code 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 39
Project: jdk8u_jdk   File: MultipleGradientPaintContext.java   View source code 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 40
Project: jdk8u_jdk   File: OGLPaints.java   View source code 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);
}