Java 如何使用GeneralPath和apache POI创建圆

Java 如何使用GeneralPath和apache POI创建圆,java,awt,apache-poi,powerpoint,Java,Awt,Apache Poi,Powerpoint,如何使用GeneralPath和apache POI创建圆。我想在MS PowerPoint幻灯片中创建任意圆圈。我在Java程序中使用AppachePOI String exportFile = "pptx/export.pptx"; XSLFSlide[] slides = ppt.getSlides(); XSLFSlide slide = slides[0]; int x=300; int y=400; int R=50; java.awt.geom.GeneralPath circle

如何使用GeneralPath和apache POI创建圆。我想在MS PowerPoint幻灯片中创建任意圆圈。我在Java程序中使用AppachePOI

String exportFile = "pptx/export.pptx";
XSLFSlide[] slides = ppt.getSlides();
XSLFSlide slide = slides[0];
int x=300;
int y=400;
int R=50;
java.awt.geom.GeneralPath circle = new java.awt.geom.GeneralPath();
circle.moveTo(x, y-R); // move to A
circle.curveTo(??????);
circle.curveTo(??????);
circle.closePath();
XSLFFreeformShape shape5 = slide.createFreeform();
shape5.setPath(circle);
shape5.setLineWidth(3);
shape5.setLineColor(Color.ORANGE);

// creating a file object
File file = new File(exportFile);
FileOutputStream out = new FileOutputStream(file);
// saving the changes to a file
ppt.write(out);
out.close();

我在Eclipse中找到并测试了答案!!!我的pptx文件中的结果正常

String exportFile = "pptx/export.pptx";
XSLFSlide[] slides = ppt.getSlides();
XSLFSlide slide = slides[0];
int x=300;
int y=400;
int R=50;
double kappa = 0.5522847498;
java.awt.geom.GeneralPath circle = new java.awt.geom.GeneralPath();
circle.moveTo(x, y-R); // move to A
circle.curveTo(x+R*kappa, y-R, x+R, y-R*kappa, x+R, y); // curve to A', B', B
circle.curveTo(x+R, y+R*kappa, x+R*kappa, y+R, x, y+R );
circle.curveTo(x-R*kappa, y+R, x-R, y+R*kappa, x-R, y);
circle.curveTo(x-R, y-R*kappa, x-R*kappa, y-R, x, y-R );
circle.closePath();
XSLFFreeformShape shape5 = slide.createFreeform();
shape5.setPath(circle);
shape5.setLineWidth(3);
shape5.setLineColor(Color.ORANGE);

// creating a file object
File file = new File(exportFile);
FileOutputStream out = new FileOutputStream(file);
// saving the changes to a file
ppt.write(out);
out.close();