Class ClipperBridge
For example:
PolyTreetoPathPointtoPoint.LongPointPoint.LongPointtoPoint
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic DoubleSince the clipper library uses integer coordinates, we should convert our floating point numbers into fixed point numbers by multiplying by this coefficient. -
Constructor Summary
ConstructorsConstructorDescriptionCreates newClipperBridgeinstance with default float multiplier value which is 10^14.ClipperBridge(Path... paths) Creates newClipperBridgeinstance with adjusted float multiplier value.ClipperBridge(Point[]... points) Creates newClipperBridgeinstance with adjusted float multiplier value. -
Method Summary
Modifier and TypeMethodDescriptionaddPath(ClipperOffset offset, Path path, IClipper.JoinType joinType, IClipper.EndType endType) Adds all iTextSubpaths of the iTextPathto theClipperOffsetobject with one note: it doesn't add degenerate subpaths.voidaddPath(IClipper clipper, Path path, IClipper.PolyType polyType) booleanaddPolygonToClipper(IClipper clipper, Point[] polyVertices, IClipper.PolyType polyType) Adds polygon path based on array ofPoint(internally converting them byconvertToLongPoints(java.util.List) and adds this path to) IClipperinstance, treating the path as a closed polygon.booleanaddPolylineSubjectToClipper(IClipper clipper, Point[] lineVertices) Adds polyline path based on array ofPoint(internally converting them byconvertToLongPoints(java.util.List) and adds this path to) IClipperinstance, treating the path as a polyline (an open path in terms of clipper library).convertToFloatPoints(List<Point.LongPoint> points) Converts list ofPoint.LongPointobjects into list ofPointobjects.convertToLongPoints(List<Point> points) Converts list ofPointobjects into list ofPoint.LongPointobjects.convertToPath(PolyTree result) static IClipper.EndTypegetEndType(int lineCapStyle) Converts iText line cap style constant into the corresponding constant of the Clipper library.static IClipper.PolyFillTypegetFillType(int fillingRule) Converts iText filling rule constant into the corresponding constant of the Clipper library.doubleGets multiplier coefficient for converting our floating point numbers into fixed point numbers.static IClipper.JoinTypegetJoinType(int lineJoinStyle) Converts iText line join style constant into the corresponding constant of the Clipper library.floatCalculates the height of the rectangle represented by theLongRectobject.floatCalculates the width of the rectangle represented by theLongRectobject.
-
Field Details
-
floatMultiplier
Since the clipper library uses integer coordinates, we should convert our floating point numbers into fixed point numbers by multiplying by this coefficient. Vary it to adjust the preciseness of the calculations.Note that if this value is specified, it will be used for all ClipperBridge instances and dynamic float multiplier calculation will be disabled.
-
-
Constructor Details
-
ClipperBridge
public ClipperBridge()Creates newClipperBridgeinstance with default float multiplier value which is 10^14.Since the clipper library uses integer coordinates, we should convert our floating point numbers into fixed point numbers by multiplying by float multiplier coefficient. It is possible to vary it to adjust the preciseness of the calculations: if static
floatMultiplieris specified, it will be used for all ClipperBridge instances and default value will be ignored. -
ClipperBridge
Creates newClipperBridgeinstance with adjusted float multiplier value. This instance will work correctly with the provided paths only.Since the clipper library uses integer coordinates, we should convert our floating point numbers into fixed point numbers by multiplying by float multiplier coefficient. It is calculated automatically, however it is possible to vary it to adjust the preciseness of the calculations: if static
floatMultiplieris specified, it will be used for all ClipperBridge instances and automatic calculation won't work.- Parameters:
-
paths- paths to calculate multiplier coefficient to convert floating point numbers into fixed point numbers
-
ClipperBridge
Creates newClipperBridgeinstance with adjusted float multiplier value. This instance will work correctly with the provided point only.Since the clipper library uses integer coordinates, we should convert our floating point numbers into fixed point numbers by multiplying by float multiplier coefficient. It is calculated automatically, however it is possible to vary it to adjust the preciseness of the calculations: if static
floatMultiplieris specified, it will be used for all ClipperBridge instances and automatic calculation won't work.- Parameters:
-
points- points to calculate multiplier coefficient to convert floating point numbers into fixed point numbers
-
-
Method Details
-
convertToPath
-
addPath
- Parameters:
-
clipper- TheIClipperobject. -
path- ThePathobject to be added to theIClipper. -
polyType- SeeIClipper.PolyType.
-
addPath
public List<Subpath> addPath(ClipperOffset offset, Path path, IClipper.JoinType joinType, IClipper.EndType endType) Adds all iTextSubpaths of the iTextPathto theClipperOffsetobject with one note: it doesn't add degenerate subpaths.- Parameters:
-
offset- theClipperOffsetobject to add all iTextSubpaths that are not degenerated. -
path-Pathobject, containing the requiredSubpaths -
joinType-IClipperjoin type. The value could beIClipper.JoinType.BEVEL,IClipper.JoinType.ROUND,IClipper.JoinType.MITER -
endType-IClipperend type. The value could beIClipper.EndType.CLOSED_POLYGON,IClipper.EndType.CLOSED_LINE,IClipper.EndType.OPEN_BUTT,IClipper.EndType.OPEN_SQUARE,IClipper.EndType.OPEN_ROUND - Returns:
-
Listconsisting of all degenerate iTextSubpaths of the path.
-
convertToFloatPoints
Converts list ofPoint.LongPointobjects into list ofPointobjects.- Parameters:
-
points- the list ofPoint.LongPointobjects to convert - Returns:
-
the resultant list of
Pointobjects.
-
convertToLongPoints
Converts list ofPointobjects into list ofPoint.LongPointobjects.- Parameters:
-
points- the list ofPointobjects to convert - Returns:
-
the resultant list of
Point.LongPointobjects.
-
getJoinType
Converts iText line join style constant into the corresponding constant of the Clipper library.- Parameters:
-
lineJoinStyle- iText line join style constant. SeePdfCanvasConstants - Returns:
- Clipper line join style constant.
-
getEndType
Converts iText line cap style constant into the corresponding constant of the Clipper library.- Parameters:
-
lineCapStyle- iText line cap style constant. SeePdfCanvasConstants - Returns:
- Clipper line cap (end type) style constant.
-
getFillType
Converts iText filling rule constant into the corresponding constant of the Clipper library.- Parameters:
-
fillingRule- EitherPdfCanvasConstants.FillingRule.NONZERO_WINDINGorPdfCanvasConstants.FillingRule.EVEN_ODD. - Returns:
- Clipper fill type constant.
-
addPolygonToClipper
public boolean addPolygonToClipper(IClipper clipper, Point[] polyVertices, IClipper.PolyType polyType) Adds polygon path based on array ofPoint(internally converting them byconvertToLongPoints(java.util.List) and adds this path to) IClipperinstance, treating the path as a closed polygon.The return value will be false if the path is invalid for clipping. A path is invalid for clipping when:
- it has less than 3 vertices;
- the vertices are all co-linear.
- Parameters:
-
clipper-IClipperinstance to which the created polygon path will be added. -
polyVertices- an array ofPointwhich will be internally converted to clipper path and added to the clipper instance. -
polyType- eitherIClipper.PolyType.SUBJECTorIClipper.PolyType.CLIPdenoting whether added path is a subject of clipping or a part of the clipping polygon. - Returns:
- true if polygon path was successfully added, false otherwise.
-
addPolylineSubjectToClipper
Adds polyline path based on array ofPoint(internally converting them byconvertToLongPoints(java.util.List) and adds this path to) IClipperinstance, treating the path as a polyline (an open path in terms of clipper library). This path is added to the subject of future clipping. Polylines cannot be part of clipping polygon.The return value will be false if the path is invalid for clipping. A path is invalid for clipping when:
- it has less than 2 vertices;
-
longRectCalculateWidth
Calculates the width of the rectangle represented by theLongRectobject.- Parameters:
-
rect- theLongRectobject representing the rectangle. - Returns:
- the width of the rectangle.
-
longRectCalculateHeight
Calculates the height of the rectangle represented by theLongRectobject.- Parameters:
-
rect- theLongRectobject representing the rectangle. - Returns:
- the height of the rectangle.
-
getFloatMultiplier
public double getFloatMultiplier()Gets multiplier coefficient for converting our floating point numbers into fixed point numbers.- Returns:
- multiplier coefficient for converting our floating point numbers into fixed point numbers
-