Difference between revisions of "Documentation/DevGuide/Drawings/Bezier Shapes"
From Apache OpenOffice Wiki
< Documentation | DevGuide
(Initial author Sun Microsystems, Inc.) |
m |
||
| (5 intermediate revisions by 4 users not shown) | |||
| Line 6: | Line 6: | ||
|NextPage=Documentation/DevGuide/Drawings/Shape Operations | |NextPage=Documentation/DevGuide/Drawings/Shape Operations | ||
}} | }} | ||
| − | {{DISPLAYTITLE:Bezier Shapes}} | + | {{Documentation/DevGuideLanguages|Documentation/DevGuide/Drawings/{{SUBPAGENAME}}}} |
| + | {{DISPLAYTITLE:Bezier Shapes}} | ||
<!--<idltopic>com.sun.star.drawing.PolyPolygonBezierDescriptor</idltopic>--> | <!--<idltopic>com.sun.star.drawing.PolyPolygonBezierDescriptor</idltopic>--> | ||
Draw supports three different kinds of Bezier curves: <code>OpenBezierShape</code>, <code>ClosedBezierShape</code> and <code>PolyPolygonBezierShape</code>. They are all controlled by <idl>com.sun.star.drawing.PolyPolygonBezierDescriptor</idl> which is made up of the following properties: | Draw supports three different kinds of Bezier curves: <code>OpenBezierShape</code>, <code>ClosedBezierShape</code> and <code>PolyPolygonBezierShape</code>. They are all controlled by <idl>com.sun.star.drawing.PolyPolygonBezierDescriptor</idl> which is made up of the following properties: | ||
| Line 28: | Line 29: | ||
|- | |- | ||
|<idlm>com.sun.star.drawing.PolyPolygonBezierDescriptor:PolyPolygonBezier</idlm> | |<idlm>com.sun.star.drawing.PolyPolygonBezierDescriptor:PolyPolygonBezier</idlm> | ||
| − | |<code>struct</code> | + | |<code>struct</code> <idl>com.sun.star.drawing.PolyPolygonBezierCoords</idl>. These are the bezier points of the polygon. The struct members are <code>Coordinates</code> and <code>Flags</code>, which are both sequences of sequences. The <code>Coordinates</code> sequence contains <idl>com.sun.star.awt.Point</idl> structs and the <code>Flags</code> sequence contains <idl>com.sun.star.drawing.PolygonFlags</idl> enums. Point members are X and Y. Possible <code>PolygonFlags</code> values are: |
* <code>NORMAL</code> the point is normal, from the curve discussion view. | * <code>NORMAL</code> the point is normal, from the curve discussion view. | ||
* <code>SMOOTH</code> the point is smooth, the first derivation from the curve discussion view. | * <code>SMOOTH</code> the point is smooth, the first derivation from the curve discussion view. | ||
| Line 39: | Line 40: | ||
The next Java example will demonstrate how to create a <code>ClosedBezierShape</code> that looks like the following picture. | The next Java example will demonstrate how to create a <code>ClosedBezierShape</code> that looks like the following picture. | ||
| − | |||
| − | |||
[[Image:ClosedBezierShapeArt.png|none|thumb|300px|Closed bezier shape]] | [[Image:ClosedBezierShapeArt.png|none|thumb|300px|Closed bezier shape]] | ||
| + | <!--[SOURCE:Drawing/DrawingDemo.java]--> | ||
| + | <syntaxhighlight lang="java"> | ||
XShape xPolyPolygonBezier = createShape( xComponent, 0, 0, 0, 0, | XShape xPolyPolygonBezier = createShape( xComponent, 0, 0, 0, 0, | ||
"com.sun.star.drawing.ClosedBezierShape"); | "com.sun.star.drawing.ClosedBezierShape"); | ||
| Line 96: | Line 97: | ||
} catch (Exception ex) | } catch (Exception ex) | ||
{ | { | ||
| − | } | + | }</syntaxhighlight> |
{{PDL1}} | {{PDL1}} | ||
| − | [[Category: Drawing Documents and Presentation Documents]] | + | |
| + | [[Category:Documentation/Developer's Guide/Drawing Documents and Presentation Documents]] | ||
Latest revision as of 14:24, 20 December 2020
Draw supports three different kinds of Bezier curves: OpenBezierShape, ClosedBezierShape and PolyPolygonBezierShape. They are all controlled by com.sun.star.drawing.PolyPolygonBezierDescriptor which is made up of the following properties:
| Properties of com.sun.star.drawing.PolyPolygonBezierDescriptor | |
|---|---|
| PolygonKind | [readonly] com.sun.star.drawing.PolygonKind. Type of the polygon. Possible values are:
|
| PolyPolygonBezier | struct com.sun.star.drawing.PolyPolygonBezierCoords. These are the bezier points of the polygon. The struct members are Coordinates and Flags, which are both sequences of sequences. The Coordinates sequence contains com.sun.star.awt.Point structs and the Flags sequence contains com.sun.star.drawing.PolygonFlags enums. Point members are X and Y. Possible PolygonFlags values are:
|
| Geometry | com.sun.star.drawing.PolyPolygonBezierCoords. These are the untransformed bezier coordinates of the polygon. The property has the same type as PolyPolygonBezier.
|
The next Java example will demonstrate how to create a ClosedBezierShape that looks like the following picture.
XShape xPolyPolygonBezier = createShape( xComponent, 0, 0, 0, 0,
"com.sun.star.drawing.ClosedBezierShape");
// take care of the fact that the shape must have been added
// to the page before it is possible to apply changes
XShapes xShapes = (XShapes)UnoRuntime.queryInterface( XShapes.class, xDrawPage);
xShapes.add(xPolyPolygonBezier);
// now it is possible to edit the PropertySet
XPropertySet xShapeProperties = (XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, xPolyPolygonBezier);
// The following values are exemplary and provokes that a PolyPolygon of
// sixteen single polygons containing four points each is created. The
// PolyPolygon total point count will be 64.
// If control points are used they are allowed to appear as pair only,
// before and after such pair has to be a normal point.
// A bezier point sequence may look like
// this (n=normal, c=control) : n c c n c c n n c c n
int nPolygonCount = 16;
int nPointCount = 4;
int nWidth = 10000;
int nHeight = 10000;
PolyPolygonBezierCoords aCoords = new PolyPolygonBezierCoords();
// allocating the outer sequence
aCoords.Coordinates = new Point[nPolygonCount][];
aCoords.Flags = new PolygonFlags[nPolygonCount][];
int i, n, nY;
// fill the inner point sequence now
for (nY = 0, i = 0; i < nPolygonCount; i++, nY += nHeight / nPolygonCount) {
// create a polygon using two normal and two control points
// allocating the inner sequence
Point[] pPolyPoints = new Point[nPointCount];
PolygonFlags[]pPolyFlags = new PolygonFlags[nPointCount];
for (n = 0; n < nPointCount; n++)
pPolyPoints[n] = new Point();
pPolyPoints[0].X = 0;
pPolyPoints[0].Y = nY;
pPolyFlags [0] = PolygonFlags.NORMAL;
pPolyPoints[1].X = nWidth / 2;
pPolyPoints[1].Y = nHeight;
pPolyFlags[1] = PolygonFlags.CONTROL;
pPolyPoints[2].X = nWidth / 2;
pPolyPoints[2].Y = nHeight;
pPolyFlags [2] = PolygonFlags.CONTROL;
pPolyPoints[3].X = nWidth;
pPolyPoints[3].Y = nY;
pPolyFlags [3] = PolygonFlags.NORMAL;
aCoords.Coordinates[i] = pPolyPoints;
aCoords.Flags[i] = pPolyFlags;
}
try {
xShapeProperties.setPropertyValue("PolyPolygonBezier", aCoords);
} catch (Exception ex)
{
}
| Content on this page is licensed under the Public Documentation License (PDL). |