You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Guilherme Viteri <gv...@ebi.ac.uk> on 2016/08/22 09:51:35 UTC
Apache POI - XSLF ooxml library
Dear Developers,
Is there anyone monitoring the stack overflow forum for #apache-poi ?
I have created a couple of post but I haven't gotten any replies recently
http://stackoverflow.com/questions/38971376/apache-poi-xslfconnectorshape <http://stackoverflow.com/questions/38971376/apache-poi-xslfconnectorshape>
http://stackoverflow.com/questions/39001499/apache-poi-xslfautoshape-shape-offset-property <http://stackoverflow.com/questions/39001499/apache-poi-xslfautoshape-shape-offset-property>
Besides that, I have one more issue when drawing XSLFFreeFormShape. I am trying to draw a kind of bone shape, however I am getting an exception in the low-level xml classes. I am adding the class.
public class TestBoneShape {
public static void main(String[] args) {
try {
XMLSlideShow pptx = new XMLSlideShow();
XSLFSheet slide = pptx.createSlide();
XSLFFreeformShape freeformShape = slide.createFreeform();
freeformShape.setPath(boneShape(300, 300, 200, 100, 20));
freeformShape.setLineColor(Color.RED);
freeformShape.setAnchor(new Rectangle2D.Double(300, 300, 500, 200));
FileOutputStream out = new FileOutputStream("custom-shape.pptx");
pptx.write(out);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
static Path2D.Double boneShape(double x,
double y,
double width,
double height,
double loopWidth) {
Path2D.Double bone = new Path2D.Double();
double right = x + width;
double bottom = y + height;
double xAux = x + loopWidth;
double yAux = y + loopWidth / 2;
bone.moveTo(xAux, yAux);
xAux = right - loopWidth;
bone.lineTo(xAux, yAux);
yAux = y + height / 2;
bone.quadTo(right, y, right, yAux);
xAux = right - loopWidth;
yAux = bottom - loopWidth / 2;
bone.quadTo(right, bottom, xAux, yAux);
xAux = x + loopWidth;
bone.lineTo(xAux, yAux);
yAux = y + height / 2;
bone.quadTo(x, bottom, x, yAux);
xAux = x + loopWidth;
yAux = y + loopWidth / 2;
bone.quadTo(x, y, xAux, yAux);
bone.closePath();
return bone;
}
}
Thank you
Guilherme.
Re: Apache POI - XSLF ooxml library
Posted by Dominik Stadler <do...@gmx.at>.
Hi,
Your sample code works with current POI trunk, maybe you can try with the
latest version or at least a recent nightly build to see if your problem is
actually fixed there already.
Dominik.
On Mon, Aug 22, 2016 at 11:51 AM, Guilherme Viteri <gv...@ebi.ac.uk>
wrote:
> Dear Developers,
>
> Is there anyone monitoring the stack overflow forum for #apache-poi ?
>
> I have created a couple of post but I haven't gotten any replies recently
>
> http://stackoverflow.com/questions/38971376/apache-poi-xslfconnectorshape
> <http://stackoverflow.com/questions/38971376/apache-poi-xslfconnectorshape
> >
> http://stackoverflow.com/questions/39001499/apache-poi-
> xslfautoshape-shape-offset-property <http://stackoverflow.com/
> questions/39001499/apache-poi-xslfautoshape-shape-offset-property>
>
>
> Besides that, I have one more issue when drawing XSLFFreeFormShape. I am
> trying to draw a kind of bone shape, however I am getting an exception in
> the low-level xml classes. I am adding the class.
>
> public class TestBoneShape {
>
> public static void main(String[] args) {
> try {
> XMLSlideShow pptx = new XMLSlideShow();
> XSLFSheet slide = pptx.createSlide();
>
> XSLFFreeformShape freeformShape = slide.createFreeform();
>
> freeformShape.setPath(boneShape(300, 300, 200, 100, 20));
> freeformShape.setLineColor(Color.RED);
> freeformShape.setAnchor(new Rectangle2D.Double(300, 300, 500,
> 200));
>
> FileOutputStream out = new FileOutputStream("custom-
> shape.pptx");
> pptx.write(out);
> out.close();
>
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
>
> static Path2D.Double boneShape(double x,
> double y,
> double width,
> double height,
> double loopWidth) {
>
> Path2D.Double bone = new Path2D.Double();
> double right = x + width;
> double bottom = y + height;
>
> double xAux = x + loopWidth;
> double yAux = y + loopWidth / 2;
> bone.moveTo(xAux, yAux);
> xAux = right - loopWidth;
> bone.lineTo(xAux, yAux);
> yAux = y + height / 2;
> bone.quadTo(right, y, right, yAux);
>
> xAux = right - loopWidth;
> yAux = bottom - loopWidth / 2;
> bone.quadTo(right, bottom, xAux, yAux);
>
> xAux = x + loopWidth;
> bone.lineTo(xAux, yAux);
> yAux = y + height / 2;
> bone.quadTo(x, bottom, x, yAux);
>
> xAux = x + loopWidth;
> yAux = y + loopWidth / 2;
> bone.quadTo(x, y, xAux, yAux);
>
> bone.closePath();
>
> return bone;
> }
> }
>
>
> Thank you
> Guilherme.
>
>
>
>
>