public void drawPolyline(int xPoints[], int yPoints[], int nPoints) { if(nPoints > 0) { GeneralPath generalpath = new GeneralPath(); generalpath.moveTo(xPoints[0], yPoints[0]); for(int j = 1; j < nPoints; j++) generalpath.lineTo(xPoints[j], yPoints[j]); draw(generalpath); } }
public void draw(Graphics2D g2d, double x, double y) { final GeneralPath p = new GeneralPath(); for (CubicCurve2D.Double bez : beziers) { bez = new CubicCurve2D.Double(x + bez.x1, y + bez.y1, x + bez.ctrlx1, y + bez.ctrly1, x + bez.ctrlx2, y + bez.ctrly2, x + bez.x2, y + bez.y2); p.append(bez, true); } g2d.draw(p); }
public GeneralPath makeIntoPath() { int size = getPoints().size(); if(size < 2) return null; GeneralPath path = new GeneralPath(); ShapePoint point = (ShapePoint) getPoints().get(0); path.moveTo((int) point.x, (int) point.y); for(int i = 1; i < size; i++){ point = (ShapePoint) getPoints().get(i); path.lineTo((int) point.x, (int) point.y); } if(isClosed() && size > 2){ path.closePath(); } return path; }
&& shape.dropsShadow() && shape.getType() != DiagramShape.TYPE_CUSTOM){ GeneralPath shadow = new GeneralPath(path); AffineTransform translate = new AffineTransform(); translate.setToTranslation(offset, offset); shadow.transform(translate); g2.setColor(new Color(150,150,150)); g2.fill(shadow); else g2.setColor(Color.white); g2.fill(path); g2.setStroke(normalStroke); g2.setColor(shape.getStrokeColor()); g2.draw(path); else g2.setColor(Color.white); g2.fill(path); else g2.setStroke(normalStroke); g2.draw(path); g2.fill(path); g2.setColor(shape.getStrokeColor()); g2.draw(path);
GeneralPath gp = new GeneralPath(); gp.moveTo(r.x + NODE_WIDTH - 2, r.y + NODE_HEIGHT - 20); gp.lineTo(r.x + NODE_WIDTH - 2, r.y + NODE_HEIGHT - 2); gp.lineTo(r.x + NODE_WIDTH - 20, r.y + NODE_HEIGHT - 2); g.fill(gp);
int endX = x2; GeneralPath path = new GeneralPath(); path.moveTo(startX, y); path.lineTo(endX, y); path.lineTo(endX - ARROW_WIDTH, y - ARROW_WIDTH); path.moveTo(endX, y); path.lineTo(endX - ARROW_WIDTH, y + ARROW_WIDTH); g.draw(path); g.fillArc(startX, y - CIRCLE_WIDTH / 2, CIRCLE_WIDTH, CIRCLE_WIDTH, 0, 360); g.drawString(label, startX + LABEL_OFFSET, y - LABEL_OFFSET); int endX = x2 + endingLine.getWidth(); GeneralPath path = new GeneralPath(); path.moveTo(startX, y); path.lineTo(endX, y); path.lineTo(endX + ARROW_WIDTH, y - ARROW_WIDTH); path.moveTo(endX, y); path.lineTo(endX + ARROW_WIDTH, y + ARROW_WIDTH); g.draw(path); int labelWidth = g.getFontMetrics().stringWidth(label); g.fillArc(startX - CIRCLE_WIDTH / 2, y - CIRCLE_WIDTH / 2, CIRCLE_WIDTH, CIRCLE_WIDTH, 0,
private static void paintConnectionLine(Graphics2D g, int x0, int y0, int x1, int y1) { double dy = Math.abs(y1 - y0); if (dy < GRID_CELL_SIZE) { g.drawLine(x0, y0, x1, y1); } else { double halfDx = Math.abs(x1 - x0) / 2.0; GeneralPath p = new GeneralPath(); p.moveTo(x0, y0); p.curveTo(x0, y0 + halfDx, x1, y1 - halfDx, x1, y1); g.draw(p); } }
public static void drawPoints(Graphics2D g, Iterable<Point> points) { GeneralPath onCurves = new GeneralPath(); GeneralPath offCurves = new GeneralPath(); for (Point point : points) { Shape s = new Ellipse2D.Double(point.x - HALF_POINT_SIZE, point.y - HALF_POINT_SIZE, POINT_SIZE, POINT_SIZE); if (point.isOnCurve()) { onCurves.append(s, false); } else { offCurves.append(s, false); } } g.setColor(Color.BLUE); g.fill(onCurves); g.setColor(Color.RED); g.fill(offCurves); }
private static GeneralPath createPathAcross() { GeneralPath p = new GeneralPath(); p.moveTo(99.936f, 21.019f); p.curveTo(99.936f, 51.019f, 78.316f, 86.931f, 51.019f, 89.745f); p.curveTo(23.721f, 92.559f, -2.012f, 75.843f, 0, 61.21f); return p; }
public Shape createStrokedShape(Shape shape) { GeneralPath result = new GeneralPath(); PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS); float points[] = new float[6]; moveX = lastX = points[0]; moveY = lastY = points[1]; result.moveTo(moveX, moveY); next = 0; break;
public Shape createStrokedShape (Shape shape) { GeneralPath result = new GeneralPath(); PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS); float points[] = new float[6]; moveX = lastX = points[0]; moveY = lastY = points[1]; result.moveTo(moveX, moveY); next = wavelength / 2; break; float y = lastY + next * dy * r; if ((phase & 1) == 0) result.lineTo(x + amplitude * dy * r, y - amplitude * dx * r); else result.lineTo(x - amplitude * dy * r, y + amplitude * dx * r); next += wavelength; phase++; lastX = thisX; lastY = thisY; if (type == PathIterator.SEG_CLOSE) result.closePath(); break;
/** * 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 JDK1.1 */ public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints){ if(nPoints > 0){ GeneralPath path = new GeneralPath(); path.moveTo(xPoints[0], yPoints[0]); for(int i=1; i<nPoints; i++) path.lineTo(xPoints[i], yPoints[i]); draw(path); } }
GeneralPath gp = new GeneralPath(); while (!pi.isDone()) { double[] coords = new double[6]; gp.setWindingRule(windingRule); if (pathSegmentType == PathIterator.SEG_MOVETO) { gp = new GeneralPath(); gp.setWindingRule(windingRule); gp.moveTo(coords[0], coords[1]); } else { g.setColor(bgColor); g.fill(region); g.fill(shapeArea); g.dispose();
GeneralPath shape = new GeneralPath(); shape.moveTo(cubicCurve1.x1, cubicCurve1.y1); shape.curveTo(cubicCurve1.ctrlx1, cubicCurve1.ctrly1, cubicCurve1.ctrlx2, cubicCurve1.ctrly2, cubicCurve1.x2, cubicCurve1.y2); shape.curveTo(cubicCurve2.ctrlx1, cubicCurve2.ctrly1, cubicCurve2.ctrlx2, cubicCurve2.ctrly2, cubicCurve2.x2, cubicCurve2.y2); shape.curveTo(cubicCurve3.ctrlx1, cubicCurve3.ctrly1, cubicCurve3.ctrlx2, cubicCurve3.ctrly2, cubicCurve1.x1, cubicCurve1.y1); g2D.draw(shape); g2D.setClip(shape); // Draw an image g2D.drawImage(image, 0, 0, this);
public void draw(Graphics2D g) { if (getPointCount() < 2) return; // Since a contour has no fill or stroke information, draw it in black. // We save the current color so as not to disrupt the context. java.awt.Color savedColor = g.getColor(); Stroke savedStroke = g.getStroke(); GeneralPath gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, getPointCount()); _extendPath(gp); g.setColor(java.awt.Color.BLACK); g.setStroke(DEFAULT_STROKE); g.draw(gp); g.setColor(savedColor); g.setStroke(savedStroke); }
GlyphVector glyphVector = font.createGlyphVector(frc, text); GeneralPath result = new GeneralPath(); PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS); float points[] = new float[6]; moveX = lastX = points[0]; moveY = lastY = points[1]; result.moveTo(moveX, moveY); nextAdvance = glyphVector.getGlyphMetrics(currentChar).getAdvance() * 0.5f; next = nextAdvance;
public Shape createStrokedShape (Shape shape) { GeneralPath result = new GeneralPath(); PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS); float points[] = new float[6]; moveX = lastX = points[0]; moveY = lastY = points[1]; result.moveTo(moveX, moveY); next = wavelength / 2; break; float y = lastY + next * dy * r; if ((phase & 1) == 0) result.lineTo(x + amplitude * dy * r, y - amplitude * dx * r); else result.lineTo(x - amplitude * dy * r, y + amplitude * dx * r); next += wavelength; phase++; lastX = thisX; lastY = thisY; if (type == PathIterator.SEG_CLOSE) result.closePath(); break;
public Shape createStrokedShape (Shape shape) { GeneralPath result = new GeneralPath(); shape = new BasicStroke(getWidth(), BasicStroke.CAP_SQUARE, getJoin()).createStrokedShape(shape); PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS); moveX = lastX = randomize(points[0]); moveY = lastY = randomize(points[1]); result.moveTo(moveX, moveY); next = 0; break; float x = lastX + next * dx * r; float y = lastY + next * dy * r; result.lineTo(randomize(x), randomize(y)); next += detail;
GeneralPath gp = new GeneralPath(); while (!pi.isDone()) { double[] coords = new double[6]; gp.setWindingRule(windingRule); if (pathSegmentType == PathIterator.SEG_MOVETO) { gp = new GeneralPath(); gp.setWindingRule(windingRule); gp.moveTo(coords[0], coords[1]); if (r1.getX() < 0.001 && r1.getY() < 0.001) { } else { g.fill(region); g.fill(shapeArea); g.dispose();
private static GeneralPath createPathCyclic() { GeneralPath p = new GeneralPath(); p.moveTo(99.936f, 51.019f); p.curveTo(99.936f, 51.019f, 78.316f, 86.931f, 51.019f, 89.745f); p.curveTo(23.721f, 92.559f, -2.012f, 75.843f, 11.082f, 61.21f); p.curveTo(4.178f, 46.576f, 34.931f, 39.565f, 62.229f, 36.751f); p.curveTo(89.526f, 33.937f, 99.936f, 51.019f, 99.936f, 51.019f); return p; } private static GeneralPath createPathAcross() {