Java Code Examples for java.awt.MultipleGradientPaint.CycleMethod#REFLECT

The following examples show how to use java.awt.MultipleGradientPaint.CycleMethod#REFLECT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenderTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private LinearGradientPaint makeLinear(int numColors, boolean alpha) {
    float interval = 1.0f / (numColors - 1);
    float[] fractions = new float[numColors];
    for (int i = 0; i < fractions.length; i++) {
        fractions[i] = i * interval;
    }
    Color[] colors = makeGradientColors(numColors, alpha);
    return new LinearGradientPaint(0.0f, 0.0f,
                                   10.0f, 10.0f,
                                   fractions, colors,
                                   CycleMethod.REFLECT);
}
 
Example 2
Source File: RenderTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private LinearGradientPaint makeLinear(int numColors, boolean alpha) {
    float interval = 1.0f / (numColors - 1);
    float[] fractions = new float[numColors];
    for (int i = 0; i < fractions.length; i++) {
        fractions[i] = i * interval;
    }
    Color[] colors = makeGradientColors(numColors, alpha);
    return new LinearGradientPaint(0.0f, 0.0f,
                                   10.0f, 10.0f,
                                   fractions, colors,
                                   CycleMethod.REFLECT);
}
 
Example 3
Source File: RenderTests.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private LinearGradientPaint makeLinear(int numColors, boolean alpha) {
    float interval = 1.0f / (numColors - 1);
    float[] fractions = new float[numColors];
    for (int i = 0; i < fractions.length; i++) {
        fractions[i] = i * interval;
    }
    Color[] colors = makeGradientColors(numColors, alpha);
    return new LinearGradientPaint(0.0f, 0.0f,
                                   10.0f, 10.0f,
                                   fractions, colors,
                                   CycleMethod.REFLECT);
}
 
Example 4
Source File: RenderTests.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private RadialGradientPaint makeRadial(int numColors, boolean alpha) {
    float interval = 1.0f / (numColors - 1);
    float[] fractions = new float[numColors];
    for (int i = 0; i < fractions.length; i++) {
        fractions[i] = i * interval;
    }
    Color[] colors = makeGradientColors(numColors, alpha);
    return new RadialGradientPaint(0.0f, 0.0f, 10.0f,
                                   fractions, colors,
                                   CycleMethod.REFLECT);
}
 
Example 5
Source File: RenderTests.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private LinearGradientPaint makeLinear(int numColors, boolean alpha) {
    float interval = 1.0f / (numColors - 1);
    float[] fractions = new float[numColors];
    for (int i = 0; i < fractions.length; i++) {
        fractions[i] = i * interval;
    }
    Color[] colors = makeGradientColors(numColors, alpha);
    return new LinearGradientPaint(0.0f, 0.0f,
                                   10.0f, 10.0f,
                                   fractions, colors,
                                   CycleMethod.REFLECT);
}
 
Example 6
Source File: RenderTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private RadialGradientPaint makeRadial(int numColors, boolean alpha) {
    float interval = 1.0f / (numColors - 1);
    float[] fractions = new float[numColors];
    for (int i = 0; i < fractions.length; i++) {
        fractions[i] = i * interval;
    }
    Color[] colors = makeGradientColors(numColors, alpha);
    return new RadialGradientPaint(0.0f, 0.0f, 10.0f,
                                   fractions, colors,
                                   CycleMethod.REFLECT);
}
 
Example 7
Source File: RenderTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private LinearGradientPaint makeLinear(int numColors, boolean alpha) {
    float interval = 1.0f / (numColors - 1);
    float[] fractions = new float[numColors];
    for (int i = 0; i < fractions.length; i++) {
        fractions[i] = i * interval;
    }
    Color[] colors = makeGradientColors(numColors, alpha);
    return new LinearGradientPaint(0.0f, 0.0f,
                                   10.0f, 10.0f,
                                   fractions, colors,
                                   CycleMethod.REFLECT);
}
 
Example 8
Source File: RenderTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private RadialGradientPaint makeRadial(int numColors, boolean alpha) {
    float interval = 1.0f / (numColors - 1);
    float[] fractions = new float[numColors];
    for (int i = 0; i < fractions.length; i++) {
        fractions[i] = i * interval;
    }
    Color[] colors = makeGradientColors(numColors, alpha);
    return new RadialGradientPaint(0.0f, 0.0f, 10.0f,
                                   fractions, colors,
                                   CycleMethod.REFLECT);
}
 
Example 9
Source File: RenderTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private RadialGradientPaint makeRadial(int numColors, boolean alpha) {
    float interval = 1.0f / (numColors - 1);
    float[] fractions = new float[numColors];
    for (int i = 0; i < fractions.length; i++) {
        fractions[i] = i * interval;
    }
    Color[] colors = makeGradientColors(numColors, alpha);
    return new RadialGradientPaint(0.0f, 0.0f, 10.0f,
                                   fractions, colors,
                                   CycleMethod.REFLECT);
}
 
Example 10
Source File: RenderTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private RadialGradientPaint makeRadial(int numColors, boolean alpha) {
    float interval = 1.0f / (numColors - 1);
    float[] fractions = new float[numColors];
    for (int i = 0; i < fractions.length; i++) {
        fractions[i] = i * interval;
    }
    Color[] colors = makeGradientColors(numColors, alpha);
    return new RadialGradientPaint(0.0f, 0.0f, 10.0f,
                                   fractions, colors,
                                   CycleMethod.REFLECT);
}
 
Example 11
Source File: JHMaskedHalftone.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
private void setupHelperVariables() {
    int repetition = repetitionType.getValue();
    if (repetition == REPETITION_REFLECT) {
        cycleMethod = CycleMethod.REFLECT;
        distanceCorrection = 2.0f;
    } else if (repetition == REPETITION_REPEAT) {
        cycleMethod = CycleMethod.REPEAT;
        distanceCorrection = 1.0f;
    } else {
        throw new IllegalStateException("repetition = " + repetition);
    }
}
 
Example 12
Source File: RenderTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private RadialGradientPaint makeRadial(int numColors, boolean alpha) {
    float interval = 1.0f / (numColors - 1);
    float[] fractions = new float[numColors];
    for (int i = 0; i < fractions.length; i++) {
        fractions[i] = i * interval;
    }
    Color[] colors = makeGradientColors(numColors, alpha);
    return new RadialGradientPaint(0.0f, 0.0f, 10.0f,
                                   fractions, colors,
                                   CycleMethod.REFLECT);
}
 
Example 13
Source File: RenderTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private LinearGradientPaint makeLinear(int numColors, boolean alpha) {
    float interval = 1.0f / (numColors - 1);
    float[] fractions = new float[numColors];
    for (int i = 0; i < fractions.length; i++) {
        fractions[i] = i * interval;
    }
    Color[] colors = makeGradientColors(numColors, alpha);
    return new LinearGradientPaint(0.0f, 0.0f,
                                   10.0f, 10.0f,
                                   fractions, colors,
                                   CycleMethod.REFLECT);
}
 
Example 14
Source File: RenderTests.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private RadialGradientPaint makeRadial(int numColors, boolean alpha) {
    float interval = 1.0f / (numColors - 1);
    float[] fractions = new float[numColors];
    for (int i = 0; i < fractions.length; i++) {
        fractions[i] = i * interval;
    }
    Color[] colors = makeGradientColors(numColors, alpha);
    return new RadialGradientPaint(0.0f, 0.0f, 10.0f,
                                   fractions, colors,
                                   CycleMethod.REFLECT);
}
 
Example 15
Source File: RenderTests.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private LinearGradientPaint makeLinear(int numColors, boolean alpha) {
    float interval = 1.0f / (numColors - 1);
    float[] fractions = new float[numColors];
    for (int i = 0; i < fractions.length; i++) {
        fractions[i] = i * interval;
    }
    Color[] colors = makeGradientColors(numColors, alpha);
    return new LinearGradientPaint(0.0f, 0.0f,
                                   10.0f, 10.0f,
                                   fractions, colors,
                                   CycleMethod.REFLECT);
}
 
Example 16
Source File: RenderTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private LinearGradientPaint makeLinear(int numColors, boolean alpha) {
    float interval = 1.0f / (numColors - 1);
    float[] fractions = new float[numColors];
    for (int i = 0; i < fractions.length; i++) {
        fractions[i] = i * interval;
    }
    Color[] colors = makeGradientColors(numColors, alpha);
    return new LinearGradientPaint(0.0f, 0.0f,
                                   10.0f, 10.0f,
                                   fractions, colors,
                                   CycleMethod.REFLECT);
}
 
Example 17
Source File: RenderTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private LinearGradientPaint makeLinear(int numColors, boolean alpha) {
    float interval = 1.0f / (numColors - 1);
    float[] fractions = new float[numColors];
    for (int i = 0; i < fractions.length; i++) {
        fractions[i] = i * interval;
    }
    Color[] colors = makeGradientColors(numColors, alpha);
    return new LinearGradientPaint(0.0f, 0.0f,
                                   10.0f, 10.0f,
                                   fractions, colors,
                                   CycleMethod.REFLECT);
}
 
Example 18
Source File: ColorSchemeDialog.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
private void calculateGradientPreview() {

		Color startColor = (Color) gradientStartColorComboBox.getSelectedItem();
		Color endColor = (Color) gradientEndColorComboBox.getSelectedItem();

		if (startColor != null && endColor != null) {

			int width = preview.getWidth() - 1;

			ContinuousColorProvider colorProvider = new ContinuousColorProvider(1, width, startColor, endColor, 255, false);

			// create paint
			float fractions[] = new float[width];
			Color colors[] = new Color[width];

			for (int i = 0; i < width; ++i) {

				float fraction = i / (width - 1.0f);
				double fractionValue = 1 + fraction * (width - 1);
				colors[i] = colorProvider.getColorForValue(fractionValue);
				fractions[i] = fraction;
			}

			Point leftPoint = new Point(0, 0);
			Point rightPoint = new Point(width, 0);

			LinearGradientPaint gradient = new LinearGradientPaint(leftPoint, rightPoint, fractions, colors,
					CycleMethod.REFLECT);
			preview.setGradientPaint(gradient);
			preview.repaint();
		}
	}
 
Example 19
Source File: RenderTests.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private LinearGradientPaint makeLinear(int numColors, boolean alpha) {
    float interval = 1.0f / (numColors - 1);
    float[] fractions = new float[numColors];
    for (int i = 0; i < fractions.length; i++) {
        fractions[i] = i * interval;
    }
    Color[] colors = makeGradientColors(numColors, alpha);
    return new LinearGradientPaint(0.0f, 0.0f,
                                   10.0f, 10.0f,
                                   fractions, colors,
                                   CycleMethod.REFLECT);
}
 
Example 20
Source File: RenderTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private RadialGradientPaint makeRadial(int numColors, boolean alpha) {
    float interval = 1.0f / (numColors - 1);
    float[] fractions = new float[numColors];
    for (int i = 0; i < fractions.length; i++) {
        fractions[i] = i * interval;
    }
    Color[] colors = makeGradientColors(numColors, alpha);
    return new RadialGradientPaint(0.0f, 0.0f, 10.0f,
                                   fractions, colors,
                                   CycleMethod.REFLECT);
}