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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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;
}
 
Example 41
Project: Spectra   File: OtherUtil.java   Source Code and License 5 votes vote down vote up
public static BufferedImage makeWave(Color c)
{
    BufferedImage bi = new BufferedImage(128,128,BufferedImage.TYPE_INT_ARGB_PRE);
    Graphics2D g2d = bi.createGraphics();
    g2d.setComposite(AlphaComposite.SrcOver);
    g2d.setColor(Color.black);
    g2d.fillRect(0, 0, 128, 128);
    
    float radius = 28+(float)(Math.random()*4);
    float[] dist = {0.0f,.03f, .08f,.3f, 1.0f};
    Color[] colors = {new Color(255,255,255,255),new Color(255,255,255,255), 
        new Color(c.getRed(),c.getGreen(),c.getBlue(),15),new Color(c.getRed(),
                c.getGreen(),c.getBlue(),5), new Color(c.getRed(),c.getGreen(),c.getBlue(),0)};
    int times = 2+(int)(Math.random()*3);
    for(int j=0;j<times;j++)
    {
        double accel=0;
        int height = 64;
        for(int i=-(int)radius;i<128+(int)radius;i++)
        {
            accel+=(Math.random()*2)-1;
            if(accel>2.1)
                accel-=.3;
            if(accel<-2.1)
                accel+=.3;
            if(height<48)
                accel+=.7;
            if(height>80)
                accel-=.7;
            height+=(int)accel;
            Point2D center = new Point2D.Float(i, height);


            RadialGradientPaint p =new RadialGradientPaint(center, radius, dist, colors,MultipleGradientPaint.CycleMethod.NO_CYCLE);
            g2d.setPaint(p);
            g2d.fillRect(0, 0, 128, 128);
        }
    }
    return bi;
}
 
Example 42
Project: umple   File: PaletteButtonBorder.java   Source Code and License 5 votes vote down vote up
public void paintBorder(AbstractButton c, Graphics gr, int x, int y, int width, int height) {
    Graphics2D g = (Graphics2D) gr;
    ButtonModel m = c.getModel();
    int borderColor;
    float[] stops;
    Color[] stopColors;
    if (!m.isEnabled()) {
        borderColor = 0x80a5a5a5;
        stops = enabledStops;
        stopColors = enabledStopColors;
    } else {
        if (m.isSelected() || m.isPressed() && m.isArmed()) {
            borderColor = 0xff333333;
            stops = selectedStops;
            stopColors = selectedStopColors;
        } else {
            borderColor = 0xffa5a5a5;
            stops = enabledStops;
            stopColors = enabledStopColors;
        }
    }
    String segmentPosition = getSegmentPosition(c);
    if (segmentPosition == "first" || segmentPosition == "middle") {
        width += 1;
    }
    g.setColor(new Color(borderColor, true));
    g.drawRect(x, y, width - 1, height - 1);

    LinearGradientPaint lgp = new LinearGradientPaint(
            new Point2D.Float(x, y), new Point2D.Float(x, y + height - 1),
            stops, stopColors,
            MultipleGradientPaint.CycleMethod.REPEAT);
    g.setPaint(lgp);
    g.fillRect(x + 1, y + 1, width - 2, height - 2);
}
 
Example 43
Project: umple   File: PaletteTextComponentBorder.java   Source Code and License 5 votes vote down vote up
@Override
public void paintBorder(Component c, Graphics gr, int x, int y, int width, int height) {
    Graphics2D g = (Graphics2D) gr;
    int borderColor;
    float[] stops;
    Color[] stopColors;
    if (!c.isEnabled()) {
        borderColor = 0x80a5a5a5;
        stops = enabledStops;
        stopColors = enabledStopColors;
    } else {
        borderColor = 0xffa5a5a5;
        stops = enabledStops;
        stopColors = enabledStopColors;
    }

    String segmentPosition = getSegmentPosition(c);
    if (segmentPosition == "first" || segmentPosition == "middle") {
        width += 1;
    }
    g.setColor(new Color(borderColor, true));
    g.drawRect(x, y, width - 1, height - 1);

    LinearGradientPaint lgp = new LinearGradientPaint(
            new Point2D.Float(x, y), new Point2D.Float(x, y + height - 1),
            stops, stopColors,
            MultipleGradientPaint.CycleMethod.REPEAT);
    g.setPaint(lgp);
    g.fillRect(x + 1, y + 1, width - 2, height - 2);
}
 
Example 44
Project: umple   File: PaletteTabbedPaneUI.java   Source Code and License 5 votes vote down vote up
@Override
protected void paintTabBackground(Graphics gr, int tabPlacement,
        int tabIndex,
        int x, int y, int w, int h,
        boolean isSelected) {
    Graphics2D g = (Graphics2D) gr;
    g.setColor(!isSelected || selectedColor == null
            ? tabPane.getBackgroundAt(tabIndex) : selectedColor);
    switch (tabPlacement) {
        case LEFT:
            g.fillRect(x + 1, y + 1, w - 1, h - 3);
            break;
        case RIGHT:
            g.fillRect(x, y + 1, w - 2, h - 3);
            break;
        case BOTTOM:
            if (!isSelected) {
                LinearGradientPaint lgp = new LinearGradientPaint(
                        new Point2D.Float(x, y), new Point2D.Float(x, y + h - 1),
                        enabledStops, enabledStopColors,
                        MultipleGradientPaint.CycleMethod.REPEAT);
                g.setPaint(lgp);
            }
            g.fillRect(x + 1, y, w - 3, h - 1);
            break;
        case TOP:
        default:
            g.fillRect(x + 1, y + 1, w - 3, h - 1);
    }
}
 
Example 45
Project: jeddict   File: DBColorScheme.java   Source Code and License 5 votes vote down vote up
public Paint getBackgroundPaint() {
    final float[] FRACTIONS = {0.0f, 0.25f, 0.5f, 0.75f, 1.0f};
    final Color[] DARK_COLORS = {new Color(76, 30, 57), new Color(78, 29, 47), new Color(76, 24, 40), new Color(115, 68, 56), new Color(163, 83, 76)};

    LinearGradientPaint DARK_GRADIENT = new LinearGradientPaint(
            new Point2D.Double(0, 0), new Point2D.Double(1000, 0),
            FRACTIONS, DARK_COLORS, MultipleGradientPaint.CycleMethod.REFLECT);
    return DARK_GRADIENT;
}
 
Example 46
Project: THINK-VPL   File: Executable.java   Source Code and License 5 votes vote down vote up
private void paintFocus(Graphics2D g2, Color color){
	Point2D start = new Point2D.Float(0, 0);
	Point2D end = new Point2D.Float(this.getWidth()/2, 0);
	float[] dist = {0.0f, 0.7f};
	Color[] colors = {new Color(0,0,0,0), color};
	LinearGradientPaint p =
			new LinearGradientPaint(start, end, dist, colors, MultipleGradientPaint.CycleMethod.REFLECT);
	
	g2.setPaint(p);
	g2.setStroke(new BasicStroke(5));
	g2.draw(new RoundRectangle2D.Double(-3, inputNodeHolder.getHeight()-8, this.getSize().width+4, this.body.getSize().height+14, 20, 20));
}
 
Example 47
Project: THINK-VPL   File: FunctionEditor.java   Source Code and License 5 votes vote down vote up
@Override
public void paintComponent(Graphics g){
	Graphics2D g2 = (Graphics2D) g;
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
	if(selected){
		 Point2D start = new Point2D.Float(0, 0);
	     Point2D end = new Point2D.Float(this.getWidth()/2, 0);
	     float[] dist = {0.0f, 0.7f};
	     Color[] colors = {new Color(0,0,0,0), Color.YELLOW};
	     LinearGradientPaint p =
	         new LinearGradientPaint(start, end, dist, colors, MultipleGradientPaint.CycleMethod.REFLECT);
	    
		g2.setPaint(p);
		g2.setStroke(new BasicStroke(5));
		if(this.mode == Mode.OUTPUT){
			g2.draw(new Line2D.Double(5,5,this.getWidth(),5));
		}else{
			g2.draw(new Line2D.Double(0,30,this.getWidth(),30));
		}
	}
	GradientPaint gradient = new GradientPaint(
			fillSize.x, 
			fillSize.y, 
			((mode == Mode.INPUT) ? new Color(0,0,0,0) : Color.BLACK),
			fillSize.x,
			fillSize.height,
			((mode == Mode.INPUT) ? Color.BLACK : new Color(0,0,0,0)));
	
	g2.setPaint(gradient);
    g2.fill(new Rectangle2D.Double(fillSize.x,fillSize.y,fillSize.width,fillSize.height));
    g2.setPaint(Color.black);
}
 
Example 48
Project: griffon2   File: LinearGradientPaintPropertyEditor.java   Source Code and License 5 votes vote down vote up
private void handleAsString(String str) {
    if (isBlank(str)) {
        super.setValueInternal(null);
        return;
    }

    float x1 = 0;
    float y1 = 0;
    float x2 = 0;
    float y2 = 0;
    float[] fractions = null;
    Color[] colors = null;
    MultipleGradientPaint.CycleMethod cyclicMethod = MultipleGradientPaint.CycleMethod.NO_CYCLE;
    String[] parts = str.split(",");
    switch (parts.length) {
        case 7:
            cyclicMethod = parseCyclicMethod(str, parts[6]);
        case 6:
            x1 = parseValue(parts[0]);
            y1 = parseValue(parts[1]);
            x2 = parseValue(parts[2]);
            y2 = parseValue(parts[3]);
            fractions = parseFractions(str, parts[4].trim());
            colors = parseColors(str, parts[5].trim());
            if (fractions.length != colors.length) {
                throw illegalValue(str, LinearGradientPaint.class);
            }
            super.setValueInternal(new LinearGradientPaint(x1, y1, x2, y2, fractions, colors, cyclicMethod));
            break;
        default:
            throw illegalValue(str, LinearGradientPaint.class);
    }
}
 
Example 49
Project: griffon2   File: LinearGradientPaintPropertyEditor.java   Source Code and License 5 votes vote down vote up
private void handleAsList(List<?> list) {
    if(list.isEmpty()) {
        super.setValueInternal(null);
        return;
    }

    float x1 = 0;
    float y1 = 0;
    float x2 = 0;
    float y2 = 0;
    float[] fractions = null;
    Color[] colors = null;
    MultipleGradientPaint.CycleMethod cyclicMethod = MultipleGradientPaint.CycleMethod.NO_CYCLE;
    switch (list.size()) {
        case 7:
            cyclicMethod = parseCyclicMethod(list, String.valueOf(list.get(6)).trim());
        case 6:
            x1 = parseValue(list.get(0));
            y1 = parseValue(list.get(1));
            x2 = parseValue(list.get(2));
            y2 = parseValue(list.get(3));
            fractions = parseFractions(list, list.get(4));
            colors = parseColors(list, list.get(5));
            if (fractions.length != colors.length) {
                throw illegalValue(list, LinearGradientPaint.class);
            }
            super.setValueInternal(new LinearGradientPaint(x1, y1, x2, y2, fractions, colors, cyclicMethod));
            break;
        default:
            throw illegalValue(list, LinearGradientPaint.class);
    }
}
 
Example 50
Project: griffon2   File: LinearGradientPaintPropertyEditor.java   Source Code and License 5 votes vote down vote up
private MultipleGradientPaint.CycleMethod parseCyclicMethod(Object source, String str) {
    try {
        Field cyclicMethodField = MultipleGradientPaint.CycleMethod.class.getDeclaredField(str.toUpperCase().trim());
        return (MultipleGradientPaint.CycleMethod) cyclicMethodField.get(null);
    } catch (NoSuchFieldException | IllegalAccessException e) {
        throw illegalValue(source, LinearGradientPaint.class, e);
    }
}
 
Example 51
Project: griffon2   File: RadialGradientPaintPropertyEditor.java   Source Code and License 5 votes vote down vote up
private void handleAsString(String str) {
    if (isBlank(str)) {
        super.setValueInternal(null);
        return;
    }

    float cx = 0;
    float cy = 0;
    float radius = 0;
    float fx = 0;
    float fy = 0;
    float[] fractions = null;
    Color[] colors = null;
    MultipleGradientPaint.CycleMethod cyclicMethod = MultipleGradientPaint.CycleMethod.NO_CYCLE;
    String[] parts = str.split(",");
    switch (parts.length) {
        case 8:
            cyclicMethod = parseCyclicMethod(str, parts[7]);
        case 7:
            cx = parseValue(parts[0]);
            cy = parseValue(parts[1]);
            radius = parseValue(parts[2]);
            fx = parseValue(parts[3]);
            fy = parseValue(parts[4]);
            fractions = parseFractions(str, parts[5].trim());
            colors = parseColors(str, parts[6].trim());
            if (fractions.length != colors.length) {
                throw illegalValue(str, RadialGradientPaint.class);
            }
            super.setValueInternal(new RadialGradientPaint(cx, cy, radius, fx, fy, fractions, colors, cyclicMethod));
            break;
        default:
            throw illegalValue(str, RadialGradientPaint.class);
    }
}
 
Example 52
Project: griffon2   File: RadialGradientPaintPropertyEditor.java   Source Code and License 5 votes vote down vote up
private void handleAsList(List<?> list) {
    if(list.isEmpty()) {
        super.setValueInternal(null);
        return;
    }

    float cx = 0;
    float cy = 0;
    float radius = 0;
    float fx = 0;
    float fy = 0;
    float[] fractions = null;
    Color[] colors = null;
    MultipleGradientPaint.CycleMethod cyclicMethod = MultipleGradientPaint.CycleMethod.NO_CYCLE;
    switch (list.size()) {
        case 8:
            cyclicMethod = parseCyclicMethod(list, String.valueOf(list.get(7)).trim());
        case 7:
            cx = parseValue(list.get(0));
            cy = parseValue(list.get(1));
            radius = parseValue(list.get(2));
            fx = parseValue(list.get(3));
            fy = parseValue(list.get(4));
            fractions = parseFractions(list, list.get(5));
            colors = parseColors(list, list.get(6));
            if (fractions.length != colors.length) {
                throw illegalValue(list, RadialGradientPaint.class);
            }
            super.setValueInternal(new RadialGradientPaint(cx, cy, radius, fx, fy, fractions, colors, cyclicMethod));
            break;
        default:
            throw illegalValue(list, RadialGradientPaint.class);
    }
}
 
Example 53
Project: griffon2   File: RadialGradientPaintPropertyEditor.java   Source Code and License 5 votes vote down vote up
private MultipleGradientPaint.CycleMethod parseCyclicMethod(Object source, String str) {
    try {
        Field cyclicMethodField = MultipleGradientPaint.CycleMethod.class.getDeclaredField(str.toUpperCase().trim());
        return (MultipleGradientPaint.CycleMethod) cyclicMethodField.get(null);
    } catch (NoSuchFieldException | IllegalAccessException e) {
        throw illegalValue(source, RadialGradientPaint.class, e);
    }
}
 
Example 54
Project: MASPlanes   File: TaskGraphic.java   Source Code and License 5 votes vote down vote up
private void paintShapeNode_0_0_1(Graphics2D g) {
    GeneralPath shape1 = new GeneralPath();
    shape1.moveTo(8.551, 390.497);
    shape1.lineTo(193.403, 21.695);
    shape1.curveTo(193.403, 21.695, 219.812, -9.809, 246.218, 21.695);
    shape1.curveTo(272.626, 53.201, 426.41, 392.349, 426.41, 392.349);
    shape1.curveTo(426.41, 392.349, 429.515, 410.883, 398.449, 410.883);
    shape1.curveTo(367.383, 410.883, 36.511, 410.883, 36.511, 410.883);
    shape1.curveTo(36.511, 410.883, 13.211, 410.881, 8.551, 390.497);
    shape1.closePath();
    g.setPaint(new RadialGradientPaint(new Point2D.Double(216.7041015625, 393.7948913574219), 296.6968f, new Point2D.Double(216.7041015625, 393.7948913574219), new float[]{0.0f, 1.0f}, new Color[]{new Color(244, 215, 8, 255), new Color(252, 180, 0, 255)}, MultipleGradientPaint.CycleMethod.NO_CYCLE, MultipleGradientPaint.ColorSpaceType.SRGB, new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f)));
    g.fill(shape1);
}
 
Example 55
Project: MASPlanes   File: TaskGraphic.java   Source Code and License 5 votes vote down vote up
private void paintShapeNode_0_0_3_0(Graphics2D g) {
    GeneralPath shape3 = new GeneralPath();
    shape3.moveTo(-392.0625, 28.9375);
    shape3.curveTo(-392.17993, 29.141064, -392.37985, 29.501896, -392.65625, 30.0);
    shape3.curveTo(-392.1424, 29.330217, -392.11414, 29.073711, -392.0625, 28.9375);
    shape3.closePath();
    shape3.moveTo(-386.40625, 29.6875);
    shape3.curveTo(-386.37363, 29.743301, -385.9259, 30.119497, -385.84375, 30.21875);
    shape3.curveTo(-385.89215, 30.140516, -386.05777, 29.868866, -386.09375, 29.8125);
    shape3.curveTo(-386.23685, 29.58822, -386.56287, 29.419708, -386.40625, 29.6875);
    shape3.closePath();
    shape3.moveTo(-388.15625, 30.625);
    shape3.curveTo(-389.88336, 30.50541, -392.10272, 31.245201, -393.71875, 31.96875);
    shape3.curveTo(-394.51224, 33.430683, -395.32602, 34.914635, -396.53125, 37.1875);
    shape3.curveTo(-399.7489, 43.25551, -404.27594, 51.944267, -409.65625, 62.3125);
    shape3.curveTo(-420.41684, 83.048965, -434.56396, 110.57422, -448.65625, 138.125);
    shape3.curveTo(-458.86295, 158.07935, -467.8102, 175.70268, -476.625, 193.09375);
    shape3.curveTo(-467.6627, 189.74818, -458.52142, 187.00513, -449.25, 185.0);
    shape3.curveTo(-429.2333, 180.67099, -403.0504, 180.62221, -383.21875, 185.0625);
    shape3.curveTo(-367.70816, 188.53531, -354.96066, 193.26141, -335.03125, 202.625);
    shape3.curveTo(-326.28098, 206.7362, -314.87515, 211.6718, -313.0, 212.375);
    shape3.curveTo(-305.386, 215.23038, -297.9891, 216.97464, -292.8125, 217.5625);
    shape3.curveTo(-292.4478, 217.60391, -292.1862, 217.54636, -291.84375, 217.5625);
    shape3.lineTo(-291.84375, 217.53125);
    shape3.lineTo(-337.53125, 125.34375);
    shape3.curveTo(-355.61072, 88.861855, -367.73746, 64.60052, -375.5625, 49.375);
    shape3.curveTo(-379.475, 41.76224, -382.33862, 36.402084, -384.1875, 33.09375);
    shape3.curveTo(-384.5048, 32.52602, -384.5884, 32.410324, -384.84375, 31.96875);
    shape3.curveTo(-385.53793, 31.538422, -386.34225, 31.022312, -386.5625, 30.9375);
    shape3.curveTo(-386.87384, 30.817612, -387.43365, 30.675034, -388.15625, 30.625);
    shape3.closePath();
    g.setPaint(new RadialGradientPaint(new Point2D.Double(-409.7658386230469, 87.34991455078125), 92.390625f, new Point2D.Double(-409.7658386230469, 87.34991455078125), new float[]{0.0f, 0.6785714f, 1.0f}, new Color[]{new Color(255, 234, 149, 255), new Color(255, 234, 149, 127), new Color(255, 234, 149, 0)}, MultipleGradientPaint.CycleMethod.NO_CYCLE, MultipleGradientPaint.ColorSpaceType.SRGB, new AffineTransform(0.7807053923606873f, 1.8151880502700806f, -1.0895527601242065f, 0.4686119854450226f, 5.312927722930908f, 789.4688110351562f)));
    g.fill(shape3);
}
 
Example 56
Project: iSeleda   File: DiamondGradientPaint.java   Source Code and License 4 votes vote down vote up
public DiamondGradientPaint(UserDrag userDrag, Color startColor, Color endColor, MultipleGradientPaint.CycleMethod cycleMethod) {
    this.userDrag = userDrag;
    this.startColor = startColor;
    this.endColor = endColor;
    this.cycleMethod = cycleMethod;
}
 
Example 57
Project: iSeleda   File: AngleGradientPaint.java   Source Code and License 4 votes vote down vote up
public AngleGradientPaint(UserDrag userDrag, Color startColor, Color endColor, MultipleGradientPaint.CycleMethod cycleMethod) {
    this.userDrag = userDrag;
    this.startColor = startColor;
    this.endColor = endColor;
    this.cycleMethod = cycleMethod;
}
 
Example 58
Project: mars-sim   File: GradientWrapper.java   Source Code and License 4 votes vote down vote up
public GradientWrapper(float startX, float startY, float endX, float endY, float[] fractions, Color[] colors) {
    GRADIENT = new LinearGradientPaint(new Point2D.Float(startX, startY), new Point2D.Float(endX, endY), fractions, colors, java.awt.MultipleGradientPaint.CycleMethod.NO_CYCLE);
    copyArrays(fractions, colors);
}
 
Example 59
Project: mars-sim   File: GradientWrapper.java   Source Code and License 4 votes vote down vote up
public GradientWrapper(float startX, float startY, float endX, float endY, float[] fractions, Color[] colors, MultipleGradientPaint.CycleMethod cycleMethod) {
    GRADIENT = new LinearGradientPaint(new Point2D.Float(startX, startY), new Point2D.Float(endX, endY), fractions, colors, cycleMethod);
    copyArrays(fractions, colors);
}
 
Example 60
Project: mars-sim   File: GradientWrapper.java   Source Code and License 4 votes vote down vote up
public GradientWrapper(Point2D start, Point2D end, float[] fractions, Color[] colors) {
    GRADIENT = new LinearGradientPaint(start, end, fractions, colors, java.awt.MultipleGradientPaint.CycleMethod.NO_CYCLE);
    copyArrays(fractions, colors);
}