Java Code Examples for java.awt.MultipleGradientPaint

The following are top voted examples for showing how to use java.awt.MultipleGradientPaint. 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: OGLPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated OGLPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS) {
        return false;
    }

    OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
    OGLGraphicsConfig gc = dstData.getOGLGraphicsConfig();
    if (!gc.isCapPresent(CAPS_EXT_GRAD_SHADER)) {
        return false;
    }

    return true;
}
 
Example 2
Project: OpenJSharp   File: D3DPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated D3DPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS_D3D) {
        return false;
    }

    D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
    D3DGraphicsDevice gd = (D3DGraphicsDevice)
        dstData.getDeviceConfiguration().getDevice();
    if (!gd.isCapPresent(CAPS_LCD_SHADER)) {
        return false;
    }
    return true;
}
 
Example 3
Project: jdk8u-jdk   File: OGLPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated OGLPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS) {
        return false;
    }

    OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
    OGLGraphicsConfig gc = dstData.getOGLGraphicsConfig();
    if (!gc.isCapPresent(CAPS_EXT_GRAD_SHADER)) {
        return false;
    }

    return true;
}
 
Example 4
Project: jdk8u-jdk   File: D3DPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated D3DPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS_D3D) {
        return false;
    }

    D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
    D3DGraphicsDevice gd = (D3DGraphicsDevice)
        dstData.getDeviceConfiguration().getDevice();
    if (!gd.isCapPresent(CAPS_LCD_SHADER)) {
        return false;
    }
    return true;
}
 
Example 5
Project: openjdk-jdk10   File: OGLPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated OGLPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS) {
        return false;
    }

    OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
    OGLGraphicsConfig gc = dstData.getOGLGraphicsConfig();
    if (!gc.isCapPresent(CAPS_EXT_GRAD_SHADER)) {
        return false;
    }

    return true;
}
 
Example 6
Project: openjdk-jdk10   File: D3DPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated D3DPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS_D3D) {
        return false;
    }

    D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
    D3DGraphicsDevice gd = (D3DGraphicsDevice)
        dstData.getDeviceConfiguration().getDevice();
    if (!gd.isCapPresent(CAPS_LCD_SHADER)) {
        return false;
    }
    return true;
}
 
Example 7
Project: openjdk9   File: OGLPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated OGLPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS) {
        return false;
    }

    OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
    OGLGraphicsConfig gc = dstData.getOGLGraphicsConfig();
    if (!gc.isCapPresent(CAPS_EXT_GRAD_SHADER)) {
        return false;
    }

    return true;
}
 
Example 8
Project: openjdk9   File: D3DPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated D3DPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS_D3D) {
        return false;
    }

    D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
    D3DGraphicsDevice gd = (D3DGraphicsDevice)
        dstData.getDeviceConfiguration().getDevice();
    if (!gd.isCapPresent(CAPS_LCD_SHADER)) {
        return false;
    }
    return true;
}
 
Example 9
Project: jdk8u_jdk   File: OGLPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated OGLPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS) {
        return false;
    }

    OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
    OGLGraphicsConfig gc = dstData.getOGLGraphicsConfig();
    if (!gc.isCapPresent(CAPS_EXT_GRAD_SHADER)) {
        return false;
    }

    return true;
}
 
Example 10
Project: jdk8u_jdk   File: D3DPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated D3DPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS_D3D) {
        return false;
    }

    D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
    D3DGraphicsDevice gd = (D3DGraphicsDevice)
        dstData.getDeviceConfiguration().getDevice();
    if (!gd.isCapPresent(CAPS_LCD_SHADER)) {
        return false;
    }
    return true;
}
 
Example 11
Project: lookaside_java-1.8.0-openjdk   File: OGLPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated OGLPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS) {
        return false;
    }

    OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
    OGLGraphicsConfig gc = dstData.getOGLGraphicsConfig();
    if (!gc.isCapPresent(CAPS_EXT_GRAD_SHADER)) {
        return false;
    }

    return true;
}
 
Example 12
Project: lookaside_java-1.8.0-openjdk   File: D3DPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated D3DPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS_D3D) {
        return false;
    }

    D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
    D3DGraphicsDevice gd = (D3DGraphicsDevice)
        dstData.getDeviceConfiguration().getDevice();
    if (!gd.isCapPresent(CAPS_LCD_SHADER)) {
        return false;
    }
    return true;
}
 
Example 13
Project: iSeleda   File: GradientTool.java   View source code 6 votes vote down vote up
public static void drawGradient(ImageLayer layer, GradientType gradientType, GradientColorType colorType, MultipleGradientPaint.CycleMethod cycleMethod, Composite composite, UserDrag userDrag, boolean invert) {
    if (userDrag.isClick()) {
        return;
    }

    TmpDrawingLayer tmpDrawingLayer = layer.createTmpDrawingLayer(composite, true);
    Graphics2D g = tmpDrawingLayer.getGraphics();
    // repeated gradients are still jaggy
    g.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);

    Color[] colors = {colorType.getStartColor(invert), colorType.getEndColor(invert)};
    Paint gradient = gradientType.getGradient(userDrag, colors, cycleMethod);

    g.setPaint(gradient);

    int width = tmpDrawingLayer.getWidth();
    int height = tmpDrawingLayer.getHeight();
    g.fillRect(0, 0, width, height);
    g.dispose();
    layer.mergeTmpDrawingImageDown();
}
 
Example 14
Project: iSeleda   File: DiamondGradientPaint.java   View source code 6 votes vote down vote up
private DiamondGradientPaintContext(UserDrag userDrag, Color startColor, Color endColor, ColorModel cm, MultipleGradientPaint.CycleMethod cycleMethod) {
    this.userDrag = userDrag;
    this.cycleMethod = cycleMethod;

    startAlpha = startColor.getAlpha();
    startRed = startColor.getRed();
    startGreen = startColor.getGreen();
    startBlue = startColor.getBlue();

    endAlpha = endColor.getAlpha();
    endRed = endColor.getRed();
    endGreen = endColor.getGreen();
    endBlue = endColor.getBlue();

    this.cm = cm;

    dragDist = userDrag.getDistance();
    double dragDistSqr = dragDist * dragDist;
    dragRelDX = (float) (userDrag.getDX() / dragDistSqr);
    dragRelDY = (float) (userDrag.getDY() / dragDistSqr);
}
 
Example 15
Project: iSeleda   File: AngleGradientPaint.java   View source code 6 votes vote down vote up
private AngleGradientPaintContext(UserDrag userDrag, Color startColor, Color endColor, ColorModel cm, MultipleGradientPaint.CycleMethod cycleMethod) {
    this.userDrag = userDrag;
    this.cycleMethod = cycleMethod;

    startAlpha = startColor.getAlpha();
    startRed = startColor.getRed();
    startGreen = startColor.getGreen();
    startBlue = startColor.getBlue();

    endAlpha = endColor.getAlpha();
    endRed = endColor.getRed();
    endGreen = endColor.getGreen();
    endBlue = endColor.getBlue();

    this.cm = cm;
    drawAngle = userDrag.getDrawAngle();
}
 
Example 16
Project: iSeleda   File: SpiralGradientPaint.java   View source code 6 votes vote down vote up
private SpiralGradientPaintContext(boolean clockwise, UserDrag userDrag, Color startColor, Color endColor, ColorModel cm, MultipleGradientPaint.CycleMethod cycleMethod) {
    this.clockwise = clockwise;
    this.userDrag = userDrag;
    this.cycleMethod = cycleMethod;

    startAlpha = startColor.getAlpha();
    startRed = startColor.getRed();
    startGreen = startColor.getGreen();
    startBlue = startColor.getBlue();

    endAlpha = endColor.getAlpha();
    endRed = endColor.getRed();
    endGreen = endColor.getGreen();
    endBlue = endColor.getBlue();

    this.cm = cm;
    drawAngle = userDrag.getDrawAngle() + Math.PI;  // between 0 and 2*PI

    dragDistance = userDrag.getDistance();
}
 
Example 17
Project: swingx   File: PaintPicker.java   View source code 6 votes vote down vote up
public void setPaint(Paint paint) {
    if(paint == selectedPaint) {
        return;
    }
    Paint old = selectedPaint;
    selectedPaint = paint;
    if(paint instanceof Color) {
        tabbedPane.setSelectedComponent(colorPickerParent);
        colorPicker.setColor((Color)paint);
        alphaSlider.setValue(((Color)paint).getAlpha());
    }
    if(paint instanceof MultipleGradientPaint) {
        tabbedPane.setSelectedComponent(gradientPicker);
        gradientPicker.setGradient((MultipleGradientPaint)paint);
    }
    firePropertyChange("paint", old, selectedPaint);
}
 
Example 18
Project: swingx   File: PaintPicker.java   View source code 6 votes vote down vote up
/**
 * Creates a flat version of the current gradient. This is a linear gradient
 * from 0.0 to length,0. This gradient is suitable for drawing previews of
 * the real gradient.
 *
 * @param length
 * @return a gradient Paint with values between 0.0 and length
 */
private MultipleGradientPaint getFlatGradient(JXGradientChooser chooser, double length) {
    MultipleGradientPaint gp = chooser.getGradient();

    // set up the data for the gradient
    float[] fractions = gp.getFractions();
    Color[] colors = gp.getColors();

    // fill in the gradient
    Point2D start = new Point2D.Float(0, 0);
    Point2D end = new Point2D.Float((float) length, 0);
    MultipleGradientPaint paint = new LinearGradientPaint(
            (float) start.getX(),
            (float) start.getY(),
            (float) end.getX(),
            (float) end.getY(),
            fractions, colors);
    return paint;
}
 
Example 19
Project: swingx   File: JXGradientChooser.java   View source code 6 votes vote down vote up
/**
 * Creates a string representation of a {@code MultipleGradientPaint}. This
 * string is used for debugging purposes. Its contents cannot be guaranteed
 * between releases.
 * 
 * @param paint
 *                the {@code paint} to create a string for
 * @return a string representing the supplied {@code paint}
 */
public static String toString(MultipleGradientPaint paint) {
    StringBuffer buffer = new StringBuffer();
    buffer.append(paint.getClass().getName());
    Color[] colors = paint.getColors();
    float[] values = paint.getFractions();
    buffer.append("[");
    for(int i=0; i<colors.length; i++) {
        buffer.append("#").append(Integer.toHexString(colors[i].getRGB()));
        buffer.append(":");
        buffer.append(values[i]);
        buffer.append(", ");
    }
    buffer.append("]");
    return buffer.toString();
}
 
Example 20
Project: swingx   File: GradientPreviewPanel.java   View source code 6 votes vote down vote up
public MultipleGradientPaint calculateGradient() {
    List<Thumb<Color>> stops = getStops();
    int len = stops.size();
    
    // set up the data for the gradient
    float[] fractions = new float[len];
    Color[] colors = new Color[len];
    int i = 0;
    for (Thumb<Color> thumb : stops) {
        colors[i] = (Color)thumb.getObject();
        fractions[i] = thumb.getPosition();
        i++;
    }
    
    // get the final gradient
    this.setGradient(calculateGradient(fractions, colors));
    return getGradient();
}
 
Example 21
Project: ExportImageSOI   File: ColorMapper.java   View source code 6 votes vote down vote up
private BufferedImage createGradientImage(Color... colors)
{
    final float[] fractions = new float[colors.length];

    final float step = 1.0F / colors.length;

    for (int i = 0; i < colors.length; i++)
    {
        fractions[i] = i * step;
    }

    final LinearGradientPaint gradient = new LinearGradientPaint(0, 0, 256, 1, fractions, colors, MultipleGradientPaint.CycleMethod.REPEAT);
    final BufferedImage bi = new BufferedImage(256, 1, BufferedImage.TYPE_INT_ARGB);
    final Graphics2D g = bi.createGraphics();
    try
    {
        g.setPaint(gradient);
        g.fillRect(0, 0, 256, 1);
    }
    finally
    {
        g.dispose();
    }
    return bi;
}
 
Example 22
Project: infobip-open-jdk-8   File: OGLPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated OGLPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS) {
        return false;
    }

    OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
    OGLGraphicsConfig gc = dstData.getOGLGraphicsConfig();
    if (!gc.isCapPresent(CAPS_EXT_GRAD_SHADER)) {
        return false;
    }

    return true;
}
 
Example 23
Project: infobip-open-jdk-8   File: D3DPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated D3DPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS_D3D) {
        return false;
    }

    D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
    D3DGraphicsDevice gd = (D3DGraphicsDevice)
        dstData.getDeviceConfiguration().getDevice();
    if (!gd.isCapPresent(CAPS_LCD_SHADER)) {
        return false;
    }
    return true;
}
 
Example 24
Project: jdk8u-dev-jdk   File: OGLPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated OGLPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS) {
        return false;
    }

    OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
    OGLGraphicsConfig gc = dstData.getOGLGraphicsConfig();
    if (!gc.isCapPresent(CAPS_EXT_GRAD_SHADER)) {
        return false;
    }

    return true;
}
 
Example 25
Project: jdk8u-dev-jdk   File: D3DPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated D3DPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS_D3D) {
        return false;
    }

    D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
    D3DGraphicsDevice gd = (D3DGraphicsDevice)
        dstData.getDeviceConfiguration().getDevice();
    if (!gd.isCapPresent(CAPS_LCD_SHADER)) {
        return false;
    }
    return true;
}
 
Example 26
Project: jdk7-jdk   File: OGLPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated OGLPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS) {
        return false;
    }

    OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
    OGLGraphicsConfig gc = dstData.getOGLGraphicsConfig();
    if (!gc.isCapPresent(CAPS_EXT_GRAD_SHADER)) {
        return false;
    }

    return true;
}
 
Example 27
Project: jdk7-jdk   File: D3DPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated D3DPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS_D3D) {
        return false;
    }

    D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
    D3DGraphicsDevice gd = (D3DGraphicsDevice)
        dstData.getDeviceConfiguration().getDevice();
    if (!gd.isCapPresent(CAPS_LCD_SHADER)) {
        return false;
    }
    return true;
}
 
Example 28
Project: openjdk-source-code-learn   File: OGLPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated OGLPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS) {
        return false;
    }

    OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
    OGLGraphicsConfig gc = dstData.getOGLGraphicsConfig();
    if (!gc.isCapPresent(CAPS_EXT_GRAD_SHADER)) {
        return false;
    }

    return true;
}
 
Example 29
Project: openjdk-source-code-learn   File: D3DPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated D3DPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS_D3D) {
        return false;
    }

    D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
    D3DGraphicsDevice gd = (D3DGraphicsDevice)
        dstData.getDeviceConfiguration().getDevice();
    if (!gd.isCapPresent(CAPS_LCD_SHADER)) {
        return false;
    }
    return true;
}
 
Example 30
Project: OLD-OpenJDK8   File: OGLPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated OGLPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS) {
        return false;
    }

    OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
    OGLGraphicsConfig gc = dstData.getOGLGraphicsConfig();
    if (!gc.isCapPresent(CAPS_EXT_GRAD_SHADER)) {
        return false;
    }

    return true;
}
 
Example 31
Project: OLD-OpenJDK8   File: D3DPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated D3DPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS_D3D) {
        return false;
    }

    D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
    D3DGraphicsDevice gd = (D3DGraphicsDevice)
        dstData.getDeviceConfiguration().getDevice();
    if (!gd.isCapPresent(CAPS_LCD_SHADER)) {
        return false;
    }
    return true;
}
 
Example 32
Project: openjdk-jdk7u-jdk   File: OGLPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated OGLPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS) {
        return false;
    }

    OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
    OGLGraphicsConfig gc = dstData.getOGLGraphicsConfig();
    if (!gc.isCapPresent(CAPS_EXT_GRAD_SHADER)) {
        return false;
    }

    return true;
}
 
Example 33
Project: openjdk-jdk7u-jdk   File: D3DPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated D3DPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS_D3D) {
        return false;
    }

    D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
    D3DGraphicsDevice gd = (D3DGraphicsDevice)
        dstData.getDeviceConfiguration().getDevice();
    if (!gd.isCapPresent(CAPS_LCD_SHADER)) {
        return false;
    }
    return true;
}
 
Example 34
Project: openjdk-icedtea7   File: OGLPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated OGLPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS) {
        return false;
    }

    OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
    OGLGraphicsConfig gc = dstData.getOGLGraphicsConfig();
    if (!gc.isCapPresent(CAPS_EXT_GRAD_SHADER)) {
        return false;
    }

    return true;
}
 
Example 35
Project: openjdk-icedtea7   File: D3DPaints.java   View source code 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated D3DPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS_D3D) {
        return false;
    }

    D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
    D3DGraphicsDevice gd = (D3DGraphicsDevice)
        dstData.getDeviceConfiguration().getDevice();
    if (!gd.isCapPresent(CAPS_LCD_SHADER)) {
        return false;
    }
    return true;
}
 
Example 36
Project: griffon2   File: LinearGradientPaintPropertyEditor.java   View source code 6 votes vote down vote up
private void handleAsMap(Map<?, ?> map) {
    if(map.isEmpty()) {
        super.setValueInternal(null);
        return;
    }

    float x1 = (Float) getMapValue(map, "x1", 0f);
    float y1 = (Float) getMapValue(map, "y1", 0f);
    float x2 = (Float) getMapValue(map, "x2", 0f);
    float y2 = (Float) getMapValue(map, "y2", 0f);
    MultipleGradientPaint.CycleMethod cyclicMethod = MultipleGradientPaint.CycleMethod.NO_CYCLE;

    float[] fractions = parseFractions(map, map.get("fractions"));
    Color[] colors = parseColors(map, map.get("colors"));
    if (fractions.length != colors.length) {
        throw illegalValue(map, LinearGradientPaint.class);
    }
    Object cyclicValue = map.get("cycle");
    if (null != cyclicValue) {
        cyclicMethod = parseCyclicMethod(map, String.valueOf(cyclicValue));
    }

    super.setValueInternal(new LinearGradientPaint(x1, y1, x2, y2, fractions, colors, cyclicMethod));
}
 
Example 37
Project: griffon2   File: RadialGradientPaintPropertyEditor.java   View source code 6 votes vote down vote up
private void handleAsMap(Map<?, ?> map) {
    if(map.isEmpty()) {
        super.setValueInternal(null);
        return;
    }

    float cx = (Float) getMapValue(map, "cx", 0f);
    float cy = (Float) getMapValue(map, "cy", 0f);
    float radius = (Float) getMapValue(map, "radius", 0f);
    float fx = (Float) getMapValue(map, "fx", 0f);
    float fy = (Float) getMapValue(map, "fy", 0f);
    MultipleGradientPaint.CycleMethod cyclicMethod = MultipleGradientPaint.CycleMethod.NO_CYCLE;

    float[] fractions = parseFractions(map, map.get("fractions"));
    Color[] colors = parseColors(map, map.get("colors"));
    if (fractions.length != colors.length) {
        throw illegalValue(map, RadialGradientPaint.class);
    }
    Object cyclicValue = map.get("cycle");
    if (null != cyclicValue) {
        cyclicMethod = parseCyclicMethod(map, String.valueOf(cyclicValue));
    }

    super.setValueInternal(new RadialGradientPaint(cx, cy, radius, fx, fy, fractions, colors, cyclicMethod));
}
 
Example 38
Project: KATscans   File: TransferFunction.java   View source code 5 votes vote down vote up
public LinearGradientPaint getPaint(float startX, float endX, boolean quadratic) {
    if (dirtyPaint || colorPoints == null || colorsQuadratic == null || colorsLinear == null) {
        rebuildPaint();
    }

    return new LinearGradientPaint(startX, 0f, endX, 0f, colorPoints, quadratic ? colorsQuadratic : colorsLinear, MultipleGradientPaint.CycleMethod.NO_CYCLE);
}
 
Example 39
Project: iSeleda   File: GradientTool.java   View source code 5 votes vote down vote up
private static MultipleGradientPaint.CycleMethod getCycleMethodFromString(String s) {
    switch (s) {
        case NO_CYCLE_AS_STRING:
            return NO_CYCLE;
        case REFLECT_AS_STRING:
            return REFLECT;
        case REPEAT_AS_STRING:
            return REPEAT;
    }
    throw new IllegalStateException("should not get here");
}
 
Example 40
Project: iSeleda   File: SpiralGradientPaint.java   View source code 5 votes vote down vote up
public SpiralGradientPaint(boolean clockwise, UserDrag userDrag, Color startColor, Color endColor, MultipleGradientPaint.CycleMethod cycleMethod) {
    this.clockwise = clockwise;
    this.userDrag = userDrag;
    this.startColor = startColor;
    this.endColor = endColor;
    this.cycleMethod = cycleMethod;
}