本文整理汇总了Java中java.awt.MultipleGradientPaint.CycleMethod.REFLECT属性的典型用法代码示例。如果您正苦于以下问题:Java CycleMethod.REFLECT属性的具体用法?Java CycleMethod.REFLECT怎么用?Java CycleMethod.REFLECT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.MultipleGradientPaint.CycleMethod
的用法示例。
在下文中一共展示了CycleMethod.REFLECT属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateGradientPreview
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();
}
}
示例2: makeLinear
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);
}
示例3: makeRadial
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);
}
示例4: calculateGradientPreview
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 = (float) 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();
}
}