本文整理汇总了Java中java.awt.geom.Path2D.WIND_EVEN_ODD属性的典型用法代码示例。如果您正苦于以下问题:Java Path2D.WIND_EVEN_ODD属性的具体用法?Java Path2D.WIND_EVEN_ODD怎么用?Java Path2D.WIND_EVEN_ODD使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.geom.Path2D
的用法示例。
在下文中一共展示了Path2D.WIND_EVEN_ODD属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawPolyline
/**
* Draws a sequence of connected lines defined by
* arrays of <i>x</i> and <i>y</i> coordinates.
* Each pair of (<i>x</i>, <i>y</i>) coordinates defines a point.
* The figure is not closed if the first point
* differs from the last point.
* @param xPoints an array of <i>x</i> points
* @param yPoints an array of <i>y</i> points
* @param nPoints the total number of points
* @see java.awt.Graphics#drawPolygon(int[], int[], int)
* @since 1.1
*/
public void drawPolyline(int xPoints[], int yPoints[],
int nPoints) {
if (nPoints == 2) {
draw(new Line2D.Float(xPoints[0], yPoints[0],
xPoints[1], yPoints[1]));
} else if (nPoints > 2) {
Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD, nPoints);
path.moveTo(xPoints[0], yPoints[0]);
for(int i = 1; i < nPoints; i++) {
path.lineTo(xPoints[i], yPoints[i]);
}
draw(path);
}
}
示例2: paintYPin
private void paintYPin(Graphics2D g, int number) {
double y = top;
for (int i = 0; i < number; i++) {
y += yBounds[i].getSize().getHeight();
}
g.setColor(Color.black);
double max = 6;
g.setPaint(new GradientPaint(new Point2D.Double(LEFT - max, y - max),
Color.green, new Point2D.Double(LEFT + max, y + max),
Color.black));
GeneralPath path1 = new GeneralPath(Path2D.WIND_EVEN_ODD, 4);
GeneralPath path2 = new GeneralPath(Path2D.WIND_EVEN_ODD, 4);
path1.moveTo(LEFT - 5, y);
path1.lineTo(LEFT - 5 - max, y + max / 2);
path1.lineTo(LEFT - 5 - max, y - max / 2);
path1.lineTo(LEFT - 5, y);
path2.moveTo(5 + LEFT + width, y);
path2.lineTo(5 + LEFT + width + max, y + max / 2);
path2.lineTo(5 + LEFT + width + max, y - max / 2);
path2.lineTo(5 + LEFT + width, y);
g.fill(path1);
g.setPaint(new GradientPaint(new Point2D.Double(LEFT + width - max, y
- max), Color.black, new Point2D.Double(LEFT + max + width, y
+ max), Color.green));
g.fill(path2);
g.setColor(Color.gray);
g.draw(path1);
g.draw(path2);
}
示例3: paintArrowEnd
/**
* Малює кінець стрілки.
*
* @param g Область для виводу стрілки.
* @param x Координата x кінця стрілки.
* @param y Координата y кінця стрілки.
* @param type Напрямок направленості стрілки, MovingPanel.RIGHT,...
*/
public void paintArrowEnd(final Graphics2D g, double x1, double y1,
final double xD, final double yD, int type) {
final float x = (float) xD;
final float y = (float) yD;
final GeneralPath t = new GeneralPath(Path2D.WIND_EVEN_ODD, 3);
t.moveTo(x, y);
final float arrowWidth = (float) movingArea
.getIDoubleOrdinate(ARROW_WIDTH);
final float arrowHeight = (float) movingArea
.getIDoubleOrdinate(ARROW_HEIGHT);
type = MovingPanel.getOpposite(type);
switch (type) {
case MovingPanel.BOTTOM: {
t.lineTo(x - arrowWidth, y - arrowHeight);
t.lineTo(x + arrowWidth, y - arrowHeight);
}
break;
case MovingPanel.RIGHT: {
t.lineTo(x - arrowHeight, y - arrowWidth);
t.lineTo(x - arrowHeight, y + arrowWidth);
}
break;
case MovingPanel.TOP: {
t.lineTo(x - arrowWidth, y + arrowHeight);
t.lineTo(x + arrowWidth, y + arrowHeight);
}
break;
case MovingPanel.LEFT: {
t.lineTo(x + arrowHeight, y - arrowWidth);
t.lineTo(x + arrowHeight, y + arrowWidth);
}
break;
}
t.closePath();
g.fill(t);
}
示例4: main
public static void main(final String[] args) {
final Path2D path1 = new Path2D.Double(Path2D.WIND_EVEN_ODD, 0);
path1.moveTo(10, 10);
path1.lineTo(20, 20);
final Path2D path2 = new Path2D.Float(Path2D.WIND_EVEN_ODD, 0);
path2.moveTo(10, 10);
path2.lineTo(20, 20);
}
示例5: paintXPin
private void paintXPin(Graphics2D g, int index, XMLDiagram diagram) {
double y = diagram.getBounds(this).getTop() + 15;
double width = getMinWidth();
double w = width / columns.length;
g.setColor(Color.black);
double x = w * index + XMLDiagram.LEFT;
double max = 6;
g
.setPaint(new GradientPaint(
new Point2D.Double(x - max, y - max), Color.green,
new Point2D.Double(x + max, y + max), Color.black));
GeneralPath path1 = new GeneralPath(Path2D.WIND_EVEN_ODD, 4);
GeneralPath path2 = new GeneralPath(Path2D.WIND_EVEN_ODD, 4);
path1.moveTo(x, y);
path1.lineTo(x + max / 2, y - max);
path1.lineTo(x - max / 2, y - max);
path1.lineTo(x, y);
y += 75;
path2.moveTo(x, y);
path2.lineTo(x + max / 2, y + max);
path2.lineTo(x - max / 2, y + max);
path2.lineTo(x, y);
g.fill(path1);
g
.setPaint(new GradientPaint(
new Point2D.Double(x - max, y - max), Color.black,
new Point2D.Double(x + max, y + max), Color.green));
g.fill(path2);
g.setColor(Color.gray);
g.draw(path1);
g.draw(path2);
}
示例6: paintBorder
/**
* Paints the border for the specified component with the
* specified position and size.
* @param c the component for which this border is being painted
* @param g the paint graphics
* @param x the x position of the painted border
* @param y the y position of the painted border
* @param width the width of the painted border
* @param height the height of the painted border
*/
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
if ((this.thickness > 0) && (g instanceof Graphics2D)) {
Graphics2D g2d = (Graphics2D) g;
Color oldColor = g2d.getColor();
g2d.setColor(this.lineColor);
Shape outer;
Shape inner;
int offs = this.thickness;
int size = offs + offs;
if (this.roundedCorners) {
float arc = .2f * offs;
outer = new RoundRectangle2D.Float(x, y, width, height, offs, offs);
inner = new RoundRectangle2D.Float(x + offs, y + offs, width - size, height - size, arc, arc);
}
else {
outer = new Rectangle2D.Float(x, y, width, height);
inner = new Rectangle2D.Float(x + offs, y + offs, width - size, height - size);
}
Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD);
path.append(outer, false);
path.append(inner, false);
g2d.fill(path);
g2d.setColor(oldColor);
}
}
示例7: paintBorder
/**
* Paints the border for the specified component with the
* specified position and size.
*
* @param c the component for which this border is being painted
* @param g the paint graphics
* @param x the x position of the painted border
* @param y the y position of the painted border
* @param width the width of the painted border
* @param height the height of the painted border
*/
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
if ((this.thickness > 0) && (g instanceof Graphics2D)) {
Graphics2D g2d = (Graphics2D) g;
Color oldColor = g2d.getColor();
g2d.setColor(this.lineColor);
Shape outer;
Shape inner;
int offs = this.thickness;
int size = offs + offs;
if (this.roundedCorners) {
float arc = .2f * offs;
outer = new RoundRectangle2D.Float(x, y, width, height, offs, offs);
inner = new RoundRectangle2D.Float(x + offs, y + offs, width - size, height - size, arc, arc);
}
else {
outer = new Rectangle2D.Float(x, y, width, height);
inner = new Rectangle2D.Float(x + offs, y + offs, width - size, height - size);
}
Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD);
path.append(outer, false);
path.append(inner, false);
g2d.fill(path);
g2d.setColor(oldColor);
}
}
示例8: drawPolylineGOOD
private void drawPolylineGOOD(Graphics2D g2d,
int[] x2Points, int[] y2Points) {
Path2D polyline =
new Path2D.Float(Path2D.WIND_EVEN_ODD, x2Points.length);
polyline.moveTo(x2Points[0], y2Points[0]);
for (int index = 1; index < x2Points.length; index++) {
polyline.lineTo(x2Points[index], y2Points[index]);
}
g2d.draw(polyline);
}
示例9: parsePolygon
private Path2D.Double parsePolygon(final List<?> points) {
Path2D.Double polygon = new Path2D.Double(Path2D.WIND_EVEN_ODD, points.size());
Iterator<?> iterPoint = points.iterator();
List<?> firstPoint = (List<?>) iterPoint.next();
polygon.moveTo(((Number) firstPoint.get(0)).doubleValue(), ((Number) firstPoint.get(1)).doubleValue());
while (iterPoint.hasNext()) {
List<?> point = (List<?>) iterPoint.next();
polygon.lineTo(((Number) point.get(0)).doubleValue(), ((Number) point.get(1)).doubleValue());
}
polygon.closePath();
return polygon;
}