public Shape createStrokedShape (Shape shape) { GeneralPath result = new GeneralPath(); PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS); float points[] = new float[6]; float moveX = 0, moveY = 0; float next = 0; int phase = 0; while (!it.isDone()) { type = it.currentSegment(points); switch (type) { case PathIterator.SEG_MOVETO: 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(); PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS); float points[] = new float[6]; float moveX = 0, moveY = 0; float next = phase; while (!it.isDone()) { type = it.currentSegment(points); switch (type) { case PathIterator.SEG_MOVETO: moveX = lastX = points[0]; moveY = lastY = points[1]; result.moveTo(moveX, moveY); next = 0; break; float x = lastX + next * dx * r; float y = lastY + next * dy * r; t.setToTranslation(x, y); t.rotate(angle); result.append(t.createTransformedShape(theShape), false); next += advance; break; it.next();
private GeneralPath makeStoragePath(Diagram diagram) { if(points.size() != 4) return null; Rectangle bounds = makeIntoPath().getBounds(); ShapePoint point1 = new ShapePoint((float)bounds.getMinX(), (float)bounds.getMinY()); ShapePoint point2 = new ShapePoint((float)bounds.getMaxX(), (float)bounds.getMinY()); GeneralPath path = new GeneralPath(); path.moveTo(point1.x, point1.y); path.curveTo( point1.x + cpOffsetX, point1.y + cpOffsetYTop, point2.x - cpOffsetX, point2.y + cpOffsetYTop, point2.x, point2.y ); path.curveTo( point2.x - cpOffsetX, point2.y - cpOffsetYTop, point1.x + cpOffsetX, point1.y - cpOffsetYTop, path.moveTo(point1.x, point1.y); path.lineTo(point4.x, point4.y); path.curveTo( point4.x + cpOffsetX, point4.y + cpOffsetYBottom, point3.x - cpOffsetX, point3.y + cpOffsetYBottom, ); path.lineTo(point2.x, point2.y);
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); } }
final public GeneralPath asGeneralPath() { final GeneralPath generalPath = new GeneralPath(); for (LineSegmentInt seg : segments()) { generalPath.append(seg, false); } return 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); }
private void paintShapeNode_0_0_0_1(Graphics2D g) { GeneralPath shape1 = new GeneralPath(); shape1.moveTo(-2.8669329, -6.202803); shape1.lineTo(-8.820576, -6.142075); shape1.lineTo(-5.8963456, -11.328445); shape1.closePath(); g.setPaint(new LinearGradientPaint(new Point2D.Double(-10.63449764251709, -21.764833450317383), new Point2D.Double(-10.617325782775879, -23.629880905151367), new float[] {0.0f,1.0f}, new Color[] {new Color(33, 153, 255, 255),new Color(171, 236, 255, 255)}, MultipleGradientPaint.CycleMethod.NO_CYCLE, MultipleGradientPaint.ColorSpaceType.SRGB, new AffineTransform(1.8868346214294434f, 0.0f, 0.0f, 1.4989235401153564f, 14.2290678024292f, 26.43236541748047f))); g.fill(shape1); g.setPaint(new Color(0, 143, 244, 255)); g.setStroke(new BasicStroke(0.57000023f,0,0,4.0f,null,0.0f)); g.draw(shape1); }
antialiasSetting = RenderingHints.VALUE_ANTIALIAS_ON; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antialiasSetting); g2.setColor(Color.white); g2.fillRect(0, 0, image.getWidth()+10, image.getHeight()+10); g2.setStroke(new BasicStroke(1, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND)); && 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); new BasicStroke( strokeWeight, new BasicStroke( strokeWeight, BasicStroke.CAP_BUTT,
ArrayList<Shape> regions = new ArrayList<Shape>(); PathIterator pi = shape.getPathIterator(null); int ii = 0; GeneralPath gp = new GeneralPath(); while (!pi.isDone()) { double[] coords = new double[6]; int pathSegmentType = pi.currentSegment(coords); int windingRule = pi.getWindingRule(); gp.setWindingRule(windingRule); if (pathSegmentType == PathIterator.SEG_MOVETO) { gp = new GeneralPath(); gp.setWindingRule(windingRule); gp.moveTo(coords[0], coords[1]); Shape shapeCentered = trans.createTransformedShape(shape1); addColoredUnicodeCharToContainer( piece, gui, new Color(203,203,197), Color.DARK_GRAY, blackSquare); addColoredUnicodeCharToContainer( piece, gui, new Color(192,142,60), Color.DARK_GRAY, blackSquare);
private void paintShapeNode_0_0_0_5(Graphics2D g) { GeneralPath shape5 = new GeneralPath(); shape5.moveTo(488.57144, -181.92354); shape5.curveTo(488.57144, -129.85098, 427.8101, -87.637825, 352.85718, -87.637825); shape5.curveTo(277.90424, -87.637825, 217.14288, -129.85098, 217.14288, -181.92354); shape5.curveTo(217.14288, -233.9961, 277.90424, -276.20926, 352.85718, -276.20926); shape5.curveTo(427.8101, -276.20926, 488.57144, -233.9961, 488.57144, -181.92354); shape5.closePath(); g.setPaint(new RadialGradientPaint(new Point2D.Double(352.8571472167969, -181.9235382080078), 135.71428f, new Point2D.Double(352.8571472167969, -181.9235382080078), new float[] {0.0f,1.0f}, new Color[] {new Color(118, 255, 255, 50),new Color(118, 255, 255, 0)}, MultipleGradientPaint.CycleMethod.NO_CYCLE, MultipleGradientPaint.ColorSpaceType.SRGB, new AffineTransform(1.0f, 0.0f, 0.0f, 0.694736897945404f, 0.0f, -55.534549713134766f))); g.fill(shape5); }
clip.intersect(new Area(transformedBox)); Rectangle2D clipRect = clip.getBounds2D(); if (clipRect.isEmpty()) return; this.bbox = new PDRectangle((float)clipRect.getX(), (float)clipRect.getY(), (float)clipRect.getWidth(), (float)clipRect.getHeight()); AffineTransform dpiTransform = AffineTransform.getScaleInstance(Math.abs(m.getScalingFactorX()), Math.abs(m.getScalingFactorY())); Rectangle2D bounds = dpiTransform.createTransformedShape(clip.getBounds2D()).getBounds2D(); minX = (int) Math.floor(bounds.getMinX()); g.drawImage(backdropImage, 0, 0, width, height, backdropX, backdropY, backdropX + width, backdropY + height, null); g = new GroupGraphics(image, g); g.setBackground(new Color(backdropColor.toRGB())); g.clearRect(0, 0, width, height); xform = AffineTransform.getScaleInstance(Math.abs(m.getScalingFactorX()), Math.abs(m.getScalingFactorY())); PDRectangle pageSizeOriginal = pageSize; pageSize = new PDRectangle(minX / Math.abs(m.getScalingFactorX()), clipWindingRule = -1; GeneralPath linePathOriginal = linePath; linePath = new GeneralPath();
public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) { final UPolygon shape = (UPolygon) ushape; g2d.setStroke(new BasicStroke((float) param.getStroke().getThickness())); final GeneralPath path = new GeneralPath(); final double xp = pt.getX() + x; final double yp = pt.getY() + y; visible.ensureVisible(xp, yp); if (first) { path.moveTo((float) xp, (float) yp); } else { path.lineTo((float) xp, (float) yp); path.closePath(); .getColor2())); g2d.setPaint(paint); g2d.fill(path); } else if (back!=null) { g2d.setColor(mapper.getMappedColor(back));
int endY = (wp.getY() + CULL_CHUNK_BORDERS_RANGE) / MAP_SQUARE_SIZE * MAP_SQUARE_SIZE; graphics.setStroke(new BasicStroke(STROKE_WIDTH)); graphics.setColor(MAP_SQUARE_COLOR); GeneralPath path = new GeneralPath(); for (int x = startX; x <= endX; x += MAP_SQUARE_SIZE) path.moveTo(p.getX(), p.getY()); first = false; path.lineTo(p.getX(), p.getY()); path.moveTo(p.getX(), p.getY()); first = false; path.lineTo(p.getX(), p.getY()); graphics.draw(path);
GlyphVector glyphVector = font.createGlyphVector(frc, text); GeneralPath result = new GeneralPath(); PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS); float points[] = new float[6]; float moveX = 0, moveY = 0; while (currentChar < length && !it.isDone()) { type = it.currentSegment(points); switch (type) { case PathIterator.SEG_MOVETO: moveX = lastX = points[0]; moveY = lastY = points[1]; result.moveTo(moveX, moveY); nextAdvance = glyphVector.getGlyphMetrics(currentChar).getAdvance() * 0.5f; next = nextAdvance; nextAdvance = currentChar < length - 1 ? glyphVector.getGlyphMetrics( currentChar + 1).getAdvance() * 0.5f : 0; t.setToTranslation(x, y); t.rotate(angle); t.translate(-px - advance, -py + height * factor / 2.0f); result.append(t.createTransformedShape(glyph), false); next += (advance + nextAdvance) * factor; currentChar++; break;
@Override public void paintComponent(Graphics g){ Graphics2D g2d = (Graphics2D) g; Stroke pen = new BasicStroke(stroke); g2d.setStroke(pen); g2d.setColor(colorFront); GeneralPath polyline = new GeneralPath(); polyline.moveTo(0,0); polyline.lineTo(5,5); polyline.lineTo(5,length/2-6); polyline.lineTo(8,length/2); polyline.lineTo(5,length/2+6); polyline.lineTo(5,length-5); polyline.lineTo(0,length); AffineTransform rat = new AffineTransform(); if (direction == DIRECTION_EAST){ rat.translate(thickness,length); rat.rotate(Math.PI); } else if (direction == DIRECTION_SOUTH){ rat.translate(0,thickness); rat.rotate(-Math.PI/2); } else if (direction == DIRECTION_NORTH){ rat.translate(length,0); rat.rotate(Math.PI/2); } g2d.transform(rat); g2d.draw(polyline); super.paintComponent(g); } }
/** * Draws a polygon with the given (x[i], y[i]) coordinates. * * @param x an array of all the x-coordindates of the polygon * @param y an array of all the y-coordindates of the polygon */ public void polygon(double[] x, double[] y) { int n = x.length; GeneralPath path = new GeneralPath(); path.moveTo((float) scaleX(x[0]), (float) scaleY(y[0])); for (int i = 0; i < n; i++) path.lineTo((float) scaleX(x[i]), (float) scaleY(y[i])); path.closePath(); offscreen.draw(path); draw(); }
public Shape getShape() { Rectangle2D bounds = getBounds(); GeneralPath path = new GeneralPath(); path.moveTo((float) bounds.getX(), (float) bounds.getY()); path.lineTo((float) bounds.getMaxX(), (float) bounds.getY()); path.lineTo((float) bounds.getMaxX(), (float) bounds.getY()); path.lineTo((float) bounds.getMaxX(), (float) bounds.getMaxY()); path.lineTo((float) bounds.getX(), (float) bounds.getMaxY()); path.closePath(); return path; }
DriverLineG2d.manageStroke(param, g2d); final GeneralPath p = new GeneralPath(); boolean hasBezier = false; final MinMaxDouble minMax = new MinMaxDouble(); p.moveTo((float) (x + coord[0]), (float) (y + coord[1])); minMax.manage(x + coord[0], y + coord[1]); } else if (type == USegmentType.SEG_LINETO) { p.lineTo((float) (x + coord[0]), (float) (y + coord[1])); minMax.manage(x + coord[0], y + coord[1]); } else if (type == USegmentType.SEG_CUBICTO) { p.curveTo((float) (x + coord[0]), (float) (y + coord[1]), (float) (x + coord[2]), (float) (y + coord[3]), (float) (x + coord[4]), (float) (y + coord[5])); minMax.manage(x + coord[4], y + coord[5]); (float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr.getColor2())); g2d.setPaint(paint); g2d.fill(p); } else if (back != null) { g2d.setColor(mapper.getMappedColor(back)); g2d.fill(p);
public static Shape getDonutSliceShape( Rectangle2D pieBounds, double thickness, double start, double extent) { thickness = thickness / 2; GeneralPath generalPath = new GeneralPath(); GeneralPath dummy = new GeneralPath(); // used to find arc endpoints double x = pieBounds.getX(); double y = pieBounds.getY(); double width = pieBounds.getWidth(); double height = pieBounds.getHeight(); Shape outer = new Arc2D.Double(x, y, width, height, start, extent, Arc2D.OPEN); double wt = width * thickness; double ht = height * thickness; Shape inner = new Arc2D.Double( x + wt, y + ht, width - 2 * wt, height - 2 * ht, start + extent, -extent, Arc2D.OPEN); generalPath.append(outer, false); dummy.append( new Arc2D.Double( x + wt, y + ht, width - 2 * wt, height - 2 * ht, start, extent, Arc2D.OPEN), false); Point2D point = dummy.getCurrentPoint(); if (point != null) { generalPath.lineTo(point.getX(), point.getY()); } generalPath.append(inner, false); dummy.append(new Arc2D.Double(x, y, width, height, start + extent, -extent, Arc2D.OPEN), false); point = dummy.getCurrentPoint(); generalPath.lineTo(point.getX(), point.getY()); return generalPath; }