本文整理匯總了Java中org.apache.batik.ext.awt.MultipleGradientPaint.CycleMethodEnum方法的典型用法代碼示例。如果您正苦於以下問題:Java MultipleGradientPaint.CycleMethodEnum方法的具體用法?Java MultipleGradientPaint.CycleMethodEnum怎麽用?Java MultipleGradientPaint.CycleMethodEnum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.batik.ext.awt.MultipleGradientPaint
的用法示例。
在下文中一共展示了MultipleGradientPaint.CycleMethodEnum方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: if
import org.apache.batik.ext.awt.MultipleGradientPaint; //導入方法依賴的package包/類
/**
* Converts the spreadMethod attribute.
*
* @param paintElement the paint Element with a spreadMethod
* @param s the spread method
* @param ctx the BridgeContext to use for error information
*/
protected static MultipleGradientPaint.CycleMethodEnum convertSpreadMethod
(Element paintElement, String s, BridgeContext ctx) {
if (SVG_REPEAT_VALUE.equals(s)) {
return MultipleGradientPaint.REPEAT;
}
if (SVG_REFLECT_VALUE.equals(s)) {
return MultipleGradientPaint.REFLECT;
}
if (SVG_PAD_VALUE.equals(s)) {
return MultipleGradientPaint.NO_CYCLE;
}
throw new BridgeException
(ctx, paintElement, ERR_ATTRIBUTE_VALUE_MALFORMED,
new Object[] {SVG_SPREAD_METHOD_ATTRIBUTE, s});
}
示例2: calculateGradient
import org.apache.batik.ext.awt.MultipleGradientPaint; //導入方法依賴的package包/類
private MultipleGradientPaint calculateGradient(final float[] fractions, final Color[] colors) {
// set up the end points
Point2D start = this.start;
Point2D end = this.end;
if(isReversed()) {
//if(picker.reversedCheck.isSelected()) {
start = this.end;
end = this.start;
}
// set up the cycle type
MultipleGradientPaint.CycleMethodEnum cycle = MultipleGradientPaint.NO_CYCLE;
if(isRepeated()) {
//if(picker.repeatedRadio.isSelected()) {
cycle = MultipleGradientPaint.REPEAT;
}
if(isReflected()) {
//if(picker.reflectedRadio.isSelected()) {
cycle = MultipleGradientPaint.REFLECT;
}
// create the underlying gradient paint
MultipleGradientPaint paint = null;
if(isRadial()) { //picker.styleCombo.getSelectedItem().toString().equals("Radial")) {
paint = new org.apache.batik.ext.awt.RadialGradientPaint(
start, (float)start.distance(end),start,
fractions, colors, cycle, MultipleGradientPaint.SRGB
);
} else {
paint = new org.apache.batik.ext.awt.LinearGradientPaint(
(float)start.getX(),
(float)start.getY(),
(float)end.getX(),
(float)end.getY(),
fractions,colors,cycle);
}
return paint;
}
示例3: createPaint
import org.apache.batik.ext.awt.MultipleGradientPaint; //導入方法依賴的package包/類
/**
* Creates a <code>Paint</code> according to the specified parameters.
*
* @param ctx the bridge context to use
* @param paintElement the element that defines a Paint
* @param paintedElement the element referencing the paint
* @param paintedNode the graphics node on which the Paint will be applied
* @param opacity the opacity of the Paint to create
*/
public Paint createPaint(BridgeContext ctx,
Element paintElement,
Element paintedElement,
GraphicsNode paintedNode,
float opacity) {
String s;
// stop elements
List stops = extractStop(paintElement, opacity, ctx);
// if no stops are defined, painting is the same as 'none'
if (stops == null) {
return null;
}
int stopLength = stops.size();
// if one stops is defined, painting is the same as a single color
if (stopLength == 1) {
return ((Stop)stops.get(0)).color;
}
float [] offsets = new float[stopLength];
Color [] colors = new Color[stopLength];
Iterator iter = stops.iterator();
for (int i=0; iter.hasNext(); ++i) {
Stop stop = (Stop)iter.next();
offsets[i] = stop.offset;
colors[i] = stop.color;
}
// 'spreadMethod' attribute - default is pad
MultipleGradientPaint.CycleMethodEnum spreadMethod
= MultipleGradientPaint.NO_CYCLE;
s = SVGUtilities.getChainableAttributeNS
(paintElement, null, SVG_SPREAD_METHOD_ATTRIBUTE, ctx);
if (s.length() != 0) {
spreadMethod = convertSpreadMethod(paintElement, s, ctx);
}
// 'color-interpolation' CSS property
MultipleGradientPaint.ColorSpaceEnum colorSpace
= CSSUtilities.convertColorInterpolation(paintElement);
// 'gradientTransform' attribute - default is an Identity matrix
AffineTransform transform;
s = SVGUtilities.getChainableAttributeNS
(paintElement, null, SVG_GRADIENT_TRANSFORM_ATTRIBUTE, ctx);
if (s.length() != 0) {
transform = SVGUtilities.convertTransform
(paintElement, SVG_GRADIENT_TRANSFORM_ATTRIBUTE, s, ctx);
} else {
transform = new AffineTransform();
}
Paint paint = buildGradient(paintElement,
paintedElement,
paintedNode,
spreadMethod,
colorSpace,
transform,
colors,
offsets,
ctx);
return paint;
}
示例4: buildGradient
import org.apache.batik.ext.awt.MultipleGradientPaint; //導入方法依賴的package包/類
/**
* Builds a concrete gradient according to the specified parameters.
*
* @param paintElement the element that defines a Paint
* @param paintedElement the element referencing the paint
* @param paintedNode the graphics node on which the Paint will be applied
* @param spreadMethod the spread method
* @param colorSpace the color space (sRGB | LinearRGB)
* @param transform the gradient transform
* @param colors the colors of the gradient
* @param offsets the offsets
* @param ctx the bridge context to use
*/
protected abstract
Paint buildGradient(Element paintElement,
Element paintedElement,
GraphicsNode paintedNode,
MultipleGradientPaint.CycleMethodEnum spreadMethod,
MultipleGradientPaint.ColorSpaceEnum colorSpace,
AffineTransform transform,
Color [] colors,
float [] offsets,
BridgeContext ctx);