本文整理汇总了Java中java.awt.geom.PathIterator.getWindingRule方法的典型用法代码示例。如果您正苦于以下问题:Java PathIterator.getWindingRule方法的具体用法?Java PathIterator.getWindingRule怎么用?Java PathIterator.getWindingRule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.PathIterator
的用法示例。
在下文中一共展示了PathIterator.getWindingRule方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertToPSPath
import java.awt.geom.PathIterator; //导入方法依赖的package包/类
/**
* Given a Java2D <code>PathIterator</code> instance,
* this method translates that into a PostScript path..
*/
void convertToPSPath(PathIterator pathIter) {
float[] segment = new float[6];
int segmentType;
/* Map the PathIterator's fill rule into the PostScript
* fill rule.
*/
int fillRule;
if (pathIter.getWindingRule() == PathIterator.WIND_EVEN_ODD) {
fillRule = FILL_EVEN_ODD;
} else {
fillRule = FILL_WINDING;
}
beginPath();
setFillMode(fillRule);
while (pathIter.isDone() == false) {
segmentType = pathIter.currentSegment(segment);
switch (segmentType) {
case PathIterator.SEG_MOVETO:
moveTo(segment[0], segment[1]);
break;
case PathIterator.SEG_LINETO:
lineTo(segment[0], segment[1]);
break;
/* Convert the quad path to a bezier.
*/
case PathIterator.SEG_QUADTO:
float lastX = getPenX();
float lastY = getPenY();
float c1x = lastX + (segment[0] - lastX) * 2 / 3;
float c1y = lastY + (segment[1] - lastY) * 2 / 3;
float c2x = segment[2] - (segment[2] - segment[0]) * 2/ 3;
float c2y = segment[3] - (segment[3] - segment[1]) * 2/ 3;
bezierTo(c1x, c1y,
c2x, c2y,
segment[2], segment[3]);
break;
case PathIterator.SEG_CUBICTO:
bezierTo(segment[0], segment[1],
segment[2], segment[3],
segment[4], segment[5]);
break;
case PathIterator.SEG_CLOSE:
closeSubpath();
break;
}
pathIter.next();
}
}
示例2: convertToWPath
import java.awt.geom.PathIterator; //导入方法依赖的package包/类
/**
* Given a Java2D <code>PathIterator</code> instance,
* this method translates that into a Window's path
* in the printer device context.
*/
private void convertToWPath(PathIterator pathIter) {
float[] segment = new float[6];
int segmentType;
WPrinterJob wPrinterJob = (WPrinterJob) getPrinterJob();
/* Map the PathIterator's fill rule into the Window's
* polygon fill rule.
*/
int polyFillRule;
if (pathIter.getWindingRule() == PathIterator.WIND_EVEN_ODD) {
polyFillRule = WPrinterJob.POLYFILL_ALTERNATE;
} else {
polyFillRule = WPrinterJob.POLYFILL_WINDING;
}
wPrinterJob.setPolyFillMode(polyFillRule);
wPrinterJob.beginPath();
while (pathIter.isDone() == false) {
segmentType = pathIter.currentSegment(segment);
switch (segmentType) {
case PathIterator.SEG_MOVETO:
wPrinterJob.moveTo(segment[0], segment[1]);
break;
case PathIterator.SEG_LINETO:
wPrinterJob.lineTo(segment[0], segment[1]);
break;
/* Convert the quad path to a bezier.
*/
case PathIterator.SEG_QUADTO:
int lastX = wPrinterJob.getPenX();
int lastY = wPrinterJob.getPenY();
float c1x = lastX + (segment[0] - lastX) * 2 / 3;
float c1y = lastY + (segment[1] - lastY) * 2 / 3;
float c2x = segment[2] - (segment[2] - segment[0]) * 2/ 3;
float c2y = segment[3] - (segment[3] - segment[1]) * 2/ 3;
wPrinterJob.polyBezierTo(c1x, c1y,
c2x, c2y,
segment[2], segment[3]);
break;
case PathIterator.SEG_CUBICTO:
wPrinterJob.polyBezierTo(segment[0], segment[1],
segment[2], segment[3],
segment[4], segment[5]);
break;
case PathIterator.SEG_CLOSE:
wPrinterJob.closeFigure();
break;
}
pathIter.next();
}
wPrinterJob.endPath();
}
示例3: convertToPSPath
import java.awt.geom.PathIterator; //导入方法依赖的package包/类
/**
* Given a Java2D {@code PathIterator} instance,
* this method translates that into a PostScript path..
*/
void convertToPSPath(PathIterator pathIter) {
float[] segment = new float[6];
int segmentType;
/* Map the PathIterator's fill rule into the PostScript
* fill rule.
*/
int fillRule;
if (pathIter.getWindingRule() == PathIterator.WIND_EVEN_ODD) {
fillRule = FILL_EVEN_ODD;
} else {
fillRule = FILL_WINDING;
}
beginPath();
setFillMode(fillRule);
while (pathIter.isDone() == false) {
segmentType = pathIter.currentSegment(segment);
switch (segmentType) {
case PathIterator.SEG_MOVETO:
moveTo(segment[0], segment[1]);
break;
case PathIterator.SEG_LINETO:
lineTo(segment[0], segment[1]);
break;
/* Convert the quad path to a bezier.
*/
case PathIterator.SEG_QUADTO:
float lastX = getPenX();
float lastY = getPenY();
float c1x = lastX + (segment[0] - lastX) * 2 / 3;
float c1y = lastY + (segment[1] - lastY) * 2 / 3;
float c2x = segment[2] - (segment[2] - segment[0]) * 2/ 3;
float c2y = segment[3] - (segment[3] - segment[1]) * 2/ 3;
bezierTo(c1x, c1y,
c2x, c2y,
segment[2], segment[3]);
break;
case PathIterator.SEG_CUBICTO:
bezierTo(segment[0], segment[1],
segment[2], segment[3],
segment[4], segment[5]);
break;
case PathIterator.SEG_CLOSE:
closeSubpath();
break;
}
pathIter.next();
}
}
示例4: convertToWPath
import java.awt.geom.PathIterator; //导入方法依赖的package包/类
/**
* Given a Java2D {@code PathIterator} instance,
* this method translates that into a Window's path
* in the printer device context.
*/
private void convertToWPath(PathIterator pathIter) {
float[] segment = new float[6];
int segmentType;
WPrinterJob wPrinterJob = (WPrinterJob) getPrinterJob();
/* Map the PathIterator's fill rule into the Window's
* polygon fill rule.
*/
int polyFillRule;
if (pathIter.getWindingRule() == PathIterator.WIND_EVEN_ODD) {
polyFillRule = WPrinterJob.POLYFILL_ALTERNATE;
} else {
polyFillRule = WPrinterJob.POLYFILL_WINDING;
}
wPrinterJob.setPolyFillMode(polyFillRule);
wPrinterJob.beginPath();
while (pathIter.isDone() == false) {
segmentType = pathIter.currentSegment(segment);
switch (segmentType) {
case PathIterator.SEG_MOVETO:
wPrinterJob.moveTo(segment[0], segment[1]);
break;
case PathIterator.SEG_LINETO:
wPrinterJob.lineTo(segment[0], segment[1]);
break;
/* Convert the quad path to a bezier.
*/
case PathIterator.SEG_QUADTO:
int lastX = wPrinterJob.getPenX();
int lastY = wPrinterJob.getPenY();
float c1x = lastX + (segment[0] - lastX) * 2 / 3;
float c1y = lastY + (segment[1] - lastY) * 2 / 3;
float c2x = segment[2] - (segment[2] - segment[0]) * 2/ 3;
float c2y = segment[3] - (segment[3] - segment[1]) * 2/ 3;
wPrinterJob.polyBezierTo(c1x, c1y,
c2x, c2y,
segment[2], segment[3]);
break;
case PathIterator.SEG_CUBICTO:
wPrinterJob.polyBezierTo(segment[0], segment[1],
segment[2], segment[3],
segment[4], segment[5]);
break;
case PathIterator.SEG_CLOSE:
wPrinterJob.closeFigure();
break;
}
pathIter.next();
}
wPrinterJob.endPath();
}
示例5: getAATileGenerator
import java.awt.geom.PathIterator; //导入方法依赖的package包/类
/**
* Construct an antialiased tile generator for the given shape with
* the given rendering attributes and store the bounds of the tile
* iteration in the bbox parameter.
* The {@code at} parameter specifies a transform that should affect
* both the shape and the {@code BasicStroke} attributes.
* The {@code clip} parameter specifies the current clip in effect
* in device coordinates and can be used to prune the data for the
* operation, but the renderer is not required to perform any
* clipping.
* If the {@code BasicStroke} parameter is null then the shape
* should be filled as is, otherwise the attributes of the
* {@code BasicStroke} should be used to specify a draw operation.
* The {@code thin} parameter indicates whether or not the
* transformed {@code BasicStroke} represents coordinates smaller
* than the minimum resolution of the antialiasing rasterizer as
* specified by the {@code getMinimumAAPenWidth()} method.
* <p>
* Upon returning, this method will fill the {@code bbox} parameter
* with 4 values indicating the bounds of the iteration of the
* tile generator.
* The iteration order of the tiles will be as specified by the
* pseudo-code:
* <pre>
* for (y = bbox[1]; y < bbox[3]; y += tileheight) {
* for (x = bbox[0]; x < bbox[2]; x += tilewidth) {
* }
* }
* </pre>
* If there is no output to be rendered, this method may return
* null.
*
* @param s the shape to be rendered (fill or draw)
* @param at the transform to be applied to the shape and the
* stroke attributes
* @param clip the current clip in effect in device coordinates
* @param bs if non-null, a {@code BasicStroke} whose attributes
* should be applied to this operation
* @param thin true if the transformed stroke attributes are smaller
* than the minimum dropout pen width
* @param normalize true if the {@code VALUE_STROKE_NORMALIZE}
* {@code RenderingHint} is in effect
* @param bbox returns the bounds of the iteration
* @return the {@code AATileGenerator} instance to be consulted
* for tile coverages, or null if there is no output to render
* @since 1.7
*/
public AATileGenerator getAATileGenerator(Shape s,
AffineTransform at,
Region clip,
BasicStroke bs,
boolean thin,
boolean normalize,
int bbox[])
{
Renderer r;
NormMode norm = (normalize) ? NormMode.ON_WITH_AA : NormMode.OFF;
if (bs == null) {
PathIterator pi;
if (normalize) {
pi = new NormalizingPathIterator(s.getPathIterator(at), norm);
} else {
pi = s.getPathIterator(at);
}
r = new Renderer(3, 3,
clip.getLoX(), clip.getLoY(),
clip.getWidth(), clip.getHeight(),
pi.getWindingRule());
pathTo(pi, r);
} else {
r = new Renderer(3, 3,
clip.getLoX(), clip.getLoY(),
clip.getWidth(), clip.getHeight(),
PathIterator.WIND_NON_ZERO);
strokeTo(s, at, bs, thin, norm, true, r);
}
r.endRendering();
PiscesTileGenerator ptg = new PiscesTileGenerator(r, r.MAX_AA_ALPHA);
ptg.getBbox(bbox);
return ptg;
}