LuciadCPillar 2023.1.04
luciad::ComplexStrokePatternFactory Class Reference

Factory to create all patterns that are used to create complex strokes. More...

#include <luciad/layers/styles/complexstrokes/ComplexStrokePatternFactory.h>

Public Member Functions

 ComplexStrokePatternFactory ()=delete
 
 ~ComplexStrokePatternFactory ()=delete
 

Static Public Member Functions

static ComplexStrokePattern allowOverlap (const ComplexStrokePattern &pattern, double overlapLeft, double overlapRight)
 Creates a pattern that allows for overlap of patterns on the left and right side of the given pattern. More...
 
static ComplexStrokePattern appendPatterns (const std::vector< ComplexStrokePattern > &patterns)
 Creates a pattern consisting of multiple sub-patterns appended together, painting them next to each other. More...
 
static ArcPatternBuilder arcBuilder ()
 Creates a builder used to make patterns with an arc, ellipse or circle shape. More...
 
static ArrowPatternBuilder arrowBuilder ()
 Creates a builder used to make patterns with an arrow shape. More...
 
static ComplexStrokePattern atomic (const ComplexStrokePattern &pattern)
 Creates a pattern that ensures that sub-patterns are always painted together. More...
 
static ComplexStrokePattern combineWithFallback (const ComplexStrokePattern &pattern)
 Creates a pattern that allows the fallback pattern to be painted on top of the given pattern. More...
 
static ComplexStrokePattern combineWithRegular (const ComplexStrokePattern &pattern)
 Creates a pattern that allows the regular pattern to be painted on top of the given pattern. More...
 
static ComplexStrokePattern composePatterns (const std::vector< ComplexStrokePattern > &patterns)
 Creates a pattern consisting of multiple sub-patterns that are painted on top of each other. More...
 
static ComplexStrokePattern gapFixed (double fixedLength)
 Creates a gap pattern, which does not paint anything. More...
 
static ComplexStrokePattern gapRelative (double relativeLength)
 Creates a gap pattern, which does not paint anything. More...
 
static IconPatternBuilder iconBuilder ()
 Creates a builder used to make patterns containing an icon. More...
 
static LinePatternBuilder lineBuilder ()
 Creates a builder used to make patterns with a line segment shape. More...
 
static ParallelLinePatternBuilder parallelLineBuilder ()
 Creates a builder used to make patterns with a line segment shape that is parallel to the base line. More...
 
static PolylinePatternBuilder polylineBuilder ()
 Creates a builder used to make patterns with a polyline shape. More...
 
static RectanglePatternBuilder rectangleBuilder ()
 Creates a builder used to make patterns with a rectangle shape. More...
 
static ComplexStrokePattern repeat (const ComplexStrokePattern &pattern, uint32_t count)
 Creates a pattern that repeats a pattern a fixed number of times. More...
 
static ComplexStrokePattern repeatOverLengthFixed (const ComplexStrokePattern &pattern, double fixedLength)
 Creates a pattern that repeats a pattern over a given length. More...
 
static ComplexStrokePattern repeatOverLengthRelative (const ComplexStrokePattern &pattern, double relativeLength)
 Creates a pattern that repeats the given pattern over a given length. More...
 
static TextPatternBuilder textBuilder ()
 Creates a builder used to make patterns containing text. More...
 
static TrianglePatternBuilder triangleBuilder ()
 Creates a builder used to make patterns with a triangle shape. More...
 
static WavePatternBuilder waveBuilder ()
 Creates a builder used to make patterns with a wave shape. More...
 

Detailed Description

Factory to create all patterns that are used to create complex strokes.

Since
2023.1

Constructor & Destructor Documentation

◆ ComplexStrokePatternFactory()

luciad::ComplexStrokePatternFactory::ComplexStrokePatternFactory ( )
delete

◆ ~ComplexStrokePatternFactory()

luciad::ComplexStrokePatternFactory::~ComplexStrokePatternFactory ( )
delete

Member Function Documentation

◆ allowOverlap()

static ComplexStrokePattern luciad::ComplexStrokePatternFactory::allowOverlap ( const ComplexStrokePattern pattern,
double  overlapLeft,
double  overlapRight 
)
static

Creates a pattern that allows for overlap of patterns on the left and right side of the given pattern.

Note that the given pattern must be a pattern with a fixed (non-relative) length for the overlap to work.

In the following examples, two half circles are painted next to each other. This is done twice. The first time, no overlap is allowed. The second time, overlap is allowed:

Sample code:

.angle(180)
.startAngle(180)
.build();
auto arcs = ComplexStrokePatternFactory::appendPatterns({leftArc, rightArc});
.addDecoration(arcs, 0.5)
.build();
auto leftArcAllowOverlap = ComplexStrokePatternFactory::allowOverlap(leftArc, 0, 8);
auto rightArcAllowOverlap = ComplexStrokePatternFactory::allowOverlap(rightArc, 8, 0);
auto arcsOverlap = ComplexStrokePatternFactory::appendPatterns({leftArcAllowOverlap, rightArcAllowOverlap});
ComplexStrokeLineStyle strokeStyleOverlap = ComplexStrokeLineStyle::newBuilder()
.addDecoration(arcsOverlap, 0.5)
.build();
ArcPatternBuilder & startAngle(Angle startAngle)
This determines at which point on the ellipse the arc begins.
ArcPatternBuilder & lineColor(Color color)
Sets the line color.
ArcPatternBuilder & angle(double angle)
Specifies that only a part of the ellipse should be used, creating an arc.
ComplexStrokePattern build()
Build the arc pattern as configured.
ArcPatternBuilder & fixedLength(double fixedLength)
Set the length of the pattern in pixels.
ArcPatternBuilder & lineWidth(double lineWidth)
Sets the line width.
ArcPatternBuilder & minorRadius(double radius)
The minor radius is the distance from the baseline to the top/bottom of the arc.
static constexpr Color red()
The color red.
Definition: Color.h:44
static constexpr Color blue()
The color blue.
Definition: Color.h:36
Builder & fallback(const ComplexStrokePattern &pattern)
The pattern that is painted if no decoration or regular pattern can be painted.
ComplexStrokeLineStyle build()
Build the ComplexStrokeLineStyle as configured.
Builder & addDecoration(const ComplexStrokePattern &pattern, double relativePosition, HorizontalAlignment alignment)
Add a decoration to be painted along the line.
A style that can be used to stroke the outline of a shape with complex patterns.
Definition: ComplexStrokeLineStyle.h:54
static Builder newBuilder()
Creates a new ComplexStrokeLineStyle Builder.
static ParallelLinePatternBuilder parallelLineBuilder()
Creates a builder used to make patterns with a line segment shape that is parallel to the base line.
static ComplexStrokePattern appendPatterns(const std::vector< ComplexStrokePattern > &patterns)
Creates a pattern consisting of multiple sub-patterns appended together, painting them next to each o...
static ArcPatternBuilder arcBuilder()
Creates a builder used to make patterns with an arc, ellipse or circle shape.
static ComplexStrokePattern allowOverlap(const ComplexStrokePattern &pattern, double overlapLeft, double overlapRight)
Creates a pattern that allows for overlap of patterns on the left and right side of the given pattern...

Results in:

allowOverlap example
Parameters
patternthe pattern to allow overlaps.
overlapLeftThe allowed overlap on the left, in pixels.
overlapRightThe allowed overlap on the right, in pixels.
Returns
A pattern that allows overlap with other patterns.
Exceptions
luciad::InvalidArgumentExceptionoverlapLeft and overlapRight must be >=0.

◆ appendPatterns()

static ComplexStrokePattern luciad::ComplexStrokePatternFactory::appendPatterns ( const std::vector< ComplexStrokePattern > &  patterns)
static

Creates a pattern consisting of multiple sub-patterns appended together, painting them next to each other.

Sample code:

Results in:

appendPatterns example
Parameters
patternspatterns to append, may not be empty.
Returns
a new pattern consisting of the appended patterns.
Exceptions
luciad::InvalidArgumentExceptionpatterns may not be empty.

◆ arcBuilder()

static ArcPatternBuilder luciad::ComplexStrokePatternFactory::arcBuilder ( )
static

Creates a builder used to make patterns with an arc, ellipse or circle shape.

You can define the length and minor radius to create an ellipse (or a circle by setting the minor radius to be half of the length), and use the angle and startAngle to paint only a part of the ellipse.

angle and startAngle work counter clockwise and a startAngle of 0 means the arc starts on the baseline on the point the furthest from the start of the baselise. On a horizontal line going from left to right, this would be the right-most point of the arc. A startAngle of 90 in this case means the arc starts above the baseline.

Sample code:

.startAngle(225)
.angle(270)
.build();
.addDecoration(arc1, 0.2)
.addDecoration(arc2, 0.5)
.addDecoration(arc3, 0.8)
.build();
ArcPatternBuilder & fillColor(Color color)
Sets the fill color.
This class represents a complex stroke pattern, for example a dash or an arrow.
Definition: ComplexStrokePattern.h:25

Results in:

arc pattern example
Returns
the pattern builder.

◆ arrowBuilder()

static ArrowPatternBuilder luciad::ComplexStrokePatternFactory::arrowBuilder ( )
static

Creates a builder used to make patterns with an arrow shape.

Sample code:

.addDecoration(arrow, 0.5)
.build();
ArrowPatternBuilder & size(double size)
The size (~length) of the arrow, in pixels.
ArrowPatternBuilder & type(ComplexStrokePatternArrowType type)
Sets the arrow's type.
ComplexStrokePattern build()
Build the arrow pattern as configured.
static ArrowPatternBuilder arrowBuilder()
Creates a builder used to make patterns with an arrow shape.
@ PlainOutlined
plain outlined arrow.

Results in:

arrow pattern example
Returns
the pattern builder.

◆ atomic()

static ComplexStrokePattern luciad::ComplexStrokePatternFactory::atomic ( const ComplexStrokePattern pattern)
static

Creates a pattern that ensures that sub-patterns are always painted together.

By making a composed pattern (compose, append, repeat,...) atomic, you ensure that the composed pattern is never broken apart during painting. The sub-patterns will always be painted together, or not at all.

In the example image, the circle patterns are appended. When they are not atomic, the sub-patterns of the appendPattern can be dropped individually. This is what happens in the first pattern. If there is not enough room for a circle to be placed, it is dropped.

However, in an atomic pattern, all sub-patterns of the appendPattern are dropped together if one of them does not have enough space. This is useful when you are appending multiple patterns, where it is important that all sub-patterns are always visible at the same time.

Sample code:

auto appendedPattern = ComplexStrokePatternFactory::appendPatterns({line, circle1, circle2, line});
.regular(appendedPattern)
.build();
auto atomicPattern = ComplexStrokePatternFactory::atomic(appendedPattern);
.regular(atomicPattern)
.build();
Builder & regular(const ComplexStrokePattern &pattern)
The pattern that is repeated along the line.
static ComplexStrokePattern atomic(const ComplexStrokePattern &pattern)
Creates a pattern that ensures that sub-patterns are always painted together.
static LinePatternBuilder lineBuilder()
Creates a builder used to make patterns with a line segment shape.
ComplexStrokePattern build()
Build the line pattern as configured.
LinePatternBuilder & fixedLength(double fixedLength)
Set the length of the pattern in pixels.

Results in:

atomic pattern example
Parameters
patternThe pattern to make atomic.
Returns
An atomic version of the pattern.

◆ combineWithFallback()

static ComplexStrokePattern luciad::ComplexStrokePatternFactory::combineWithFallback ( const ComplexStrokePattern pattern)
static

Creates a pattern that allows the fallback pattern to be painted on top of the given pattern.

Normally, a fallback pattern is only painted where no other pattern could be painted. This pattern wrapper adds an exception to this. When a pattern is wrapped with a combineWithFallback, this pattern can be painted in addition to a fallback pattern. This is useful when adding a non-filled arrowhead, as in the image example.

Sample code:

auto combineWithFallbackPattern = ComplexStrokePatternFactory::combineWithFallback(arrowPattern);
ComplexStrokeLineStyle strokeStyleBottom = ComplexStrokeLineStyle::newBuilder().fallback(line).addDecoration(combineWithFallbackPattern, 1.0).build();
ArrowPatternBuilder & lineWidth(double lineWidth)
Sets the line width.
static ComplexStrokePattern combineWithFallback(const ComplexStrokePattern &pattern)
Creates a pattern that allows the fallback pattern to be painted on top of the given pattern.
ParallelLinePatternBuilder & lineWidth(double lineWidth)
Sets the line width.
ComplexStrokePattern build()
Build the parallel line pattern as configured.

Results in:

combineWithFallback pattern example
Parameters
patternThe pattern to combine with the fallback pattern.
Returns
a pattern that allows the fallback pattern to be combined with this pattern.

◆ combineWithRegular()

static ComplexStrokePattern luciad::ComplexStrokePatternFactory::combineWithRegular ( const ComplexStrokePattern pattern)
static

Creates a pattern that allows the regular pattern to be painted on top of the given pattern.

A regular pattern is a pattern that is repeated along the whole line. Normally, a regular pattern is only painted where no decorations could be painted. This pattern wrapper adds an exception to this. When a pattern is wrapped with a combineWithRegular pattern, the pattern can be painted in addition to the regular pattern. This is useful for adding a non-filled arrowhead,as in the example.

In the example there is still a small gap. This is because regular patterns don't get cut off but get dropped instead, while fallback patterns do get cut off.

Note that using this pattern wrapper implies that a fallback pattern can be painted as well (if part of the regular pattern cannot be painted).

Also note that if no regular pattern is specified, then this pattern is combined with the fallback pattern instead, as if you are using combineWithFallback.

Sample code:

auto combineWithRegularPattern = ComplexStrokePatternFactory::combineWithRegular(arrowPattern);
ComplexStrokeLineStyle strokeStyleBottom = ComplexStrokeLineStyle::newBuilder().regular(line).addDecoration(combineWithRegularPattern, 1.0).build();
static ComplexStrokePattern combineWithRegular(const ComplexStrokePattern &pattern)
Creates a pattern that allows the regular pattern to be painted on top of the given pattern.

Results in:

combineWithRegular pattern example
Parameters
patternThe pattern to combine with the regular pattern.
Returns
a pattern that allows the regular pattern to be combined with this pattern.

◆ composePatterns()

static ComplexStrokePattern luciad::ComplexStrokePatternFactory::composePatterns ( const std::vector< ComplexStrokePattern > &  patterns)
static

Creates a pattern consisting of multiple sub-patterns that are painted on top of each other.

If one of the strokes has a different length than the other strokes, it is aligned to the center of the largest stroke.

In the following example, a horizontal red line and half a red circle are composed.

Sample code:

auto composedPattern = ComplexStrokePatternFactory::composePatterns({pattern1, pattern2});
.addDecoration(composedPattern, 0.5)
.build();
static ComplexStrokePattern composePatterns(const std::vector< ComplexStrokePattern > &patterns)
Creates a pattern consisting of multiple sub-patterns that are painted on top of each other.
LinePatternBuilder & lineWidth(double lineWidth)
Sets the line width.
LinePatternBuilder & lineColor(Color color)
Sets the line color.

Results in:

composePatterns example
Parameters
patternspatterns to compose, may not be empty.
Returns
A new pattern that composes a number of sub-patterns.
Exceptions
luciad::InvalidArgumentExceptionpatterns may not be empty.

◆ gapFixed()

static ComplexStrokePattern luciad::ComplexStrokePatternFactory::gapFixed ( double  fixedLength)
static

Creates a gap pattern, which does not paint anything.

A gap pattern occupies space only. It can be used to add space in between other strokes.

Sample code:

auto pattern = ComplexStrokePatternFactory::appendPatterns({gapPattern, circle, gapPattern});
.addDecoration(pattern, 0.5)
.build();
static ComplexStrokePattern gapFixed(double fixedLength)
Creates a gap pattern, which does not paint anything.

Results in:

fixed length gap pattern example
Parameters
fixedLengththe length of the gap in pixels.
Returns
a gap pattern.
Exceptions
luciad::InvalidArgumentExceptionfixedLength must be >=0.

◆ gapRelative()

static ComplexStrokePattern luciad::ComplexStrokePatternFactory::gapRelative ( double  relativeLength)
static

Creates a gap pattern, which does not paint anything.

A gap pattern occupies space only. It can be used to add space in between other strokes.

Sample code:

auto pattern = ComplexStrokePatternFactory::appendPatterns({gapPattern, circle, gapPattern});
.addDecoration(pattern, 0.5)
.build();
static ComplexStrokePattern gapRelative(double relativeLength)
Creates a gap pattern, which does not paint anything.

Results in:

relative length gap pattern example
Parameters
relativeLengththe length (relative to the length of the entire line, [0,1]) of the gap.
Returns
a gap pattern.
Exceptions
luciad::InvalidArgumentExceptionrelativeLength must be in range [0,1].

◆ iconBuilder()

static IconPatternBuilder luciad::ComplexStrokePatternFactory::iconBuilder ( )
static

Creates a builder used to make patterns containing an icon.

The icon must be set by calling the icon method before calling build. All other methods are optional.

Sample code:

std::shared_ptr<IIcon> icon = ImageIcon::create("test/resources/icons/closecross.png");
auto iconPattern = ComplexStrokePatternFactory::iconBuilder().icon(icon).build();
.addDecoration(iconPattern, 0.5)
.build();
static IconPatternBuilder iconBuilder()
Creates a builder used to make patterns containing an icon.
IconPatternBuilder & icon(std::shared_ptr< IIcon > icon)
Sets the icon to be displayed.
ComplexStrokePattern build()
Build the icon pattern as configured.
static std::shared_ptr< IIcon > create(const std::string &filePath)
Create an IIcon from a PNG or JPEG file.

Results in:

icon pattern example
Returns
the pattern builder.

◆ lineBuilder()

static LinePatternBuilder luciad::ComplexStrokePatternFactory::lineBuilder ( )
static

Creates a builder used to make patterns with a line segment shape.

A line segment is defined by:

  • a length, meaning the distance between its start and end points
  • the offsets of the start and end points with respect to the base line.
  • styling properties: the width and color

Note that the difference with a parallel line is that a line has rounded corners, whereas a parallel line does not have rounded corners.

Sample code:

auto pattern = ComplexStrokePatternFactory::appendPatterns({lineLeft, lineRight});
auto patternFilled = ComplexStrokePatternFactory::appendPatterns({lineLeftFilled, lineRightFilled});
ComplexStrokeLineStyle strokeStyle = ComplexStrokeLineStyle::newBuilder()
.addDecoration(pattern, 0.33)
.addDecoration(patternFilled, 0.66)
.build();
LinePatternBuilder & offset1(double offset1)
Sets the offset of the end point of the segment, relative to the base line, in pixels.
LinePatternBuilder & offset0(double offset0)
Sets the offset of the start point of the segment, relative to the base line, in pixels.
LinePatternBuilder & fillColor(Color color)
Sets the fill color.

Results in:

lineBuilder example
Returns
the pattern builder.

◆ parallelLineBuilder()

static ParallelLinePatternBuilder luciad::ComplexStrokePatternFactory::parallelLineBuilder ( )
static

Creates a builder used to make patterns with a line segment shape that is parallel to the base line.

Note that the difference with a line is that a line has rounded corners, whereas a parallel line does not have rounded corners.

Sample code:

auto pattern = ComplexStrokePatternFactory::appendPatterns({parallelLineLeft, parallelLineRight});
.addDecoration(pattern, 0.5)
.build();
ParallelLinePatternBuilder & fixedLength(double fixedLength)
Set the length of the pattern in pixels.
ParallelLinePatternBuilder & offset(double offset)
Sets the offset of the line, relative to the base line, in pixels.

Results in:

parallelLine pattern example
Returns
the pattern builder.

◆ polylineBuilder()

static PolylinePatternBuilder luciad::ComplexStrokePatternFactory::polylineBuilder ( )
static

Creates a builder used to make patterns with a polyline shape.

The polyline's points must be set by calling the points method before calling build. All other methods are optional.

Sample code:

auto polylinePattern = ComplexStrokePatternFactory::polylineBuilder().points({{0, 10}, {20, 10}, {30, 0}, {20, -10}, {0, -10}, {0, 10}}).build();
ComplexStrokeLineStyle strokeStyle = ComplexStrokeLineStyle::newBuilder()
.addDecoration(polylinePattern, 0.5)
.build();
static PolylinePatternBuilder polylineBuilder()
Creates a builder used to make patterns with a polyline shape.
PolylinePatternBuilder & points(const std::vector< Coordinate > &points)
Sets the points of the polyline.

Results in:

polyline pattern example
Returns
the pattern builder.

◆ rectangleBuilder()

static RectanglePatternBuilder luciad::ComplexStrokePatternFactory::rectangleBuilder ( )
static

Creates a builder used to make patterns with a rectangle shape.

Sample code:

.lineColor(Color::fromDoubles(1.0, 0.64, 0.0))
.minHeight(-10)
.build();
auto pattern = ComplexStrokePatternFactory::appendPatterns({rectangleSide, gap, rectangleCenter, gap, rectangleSide});
auto rectangleCenterFilled = ComplexStrokePatternFactory::rectangleBuilder()
.fillColor(Color::fromDoubles(1.0, 0.64, 0.0))
.minHeight(-9)
.build();
auto patternFilled = ComplexStrokePatternFactory::appendPatterns({rectangleSideFilled, rectangleCenterFilled, rectangleSideFilled});
ComplexStrokeLineStyle strokeStyle = ComplexStrokeLineStyle::newBuilder()
.addDecoration(pattern, 0.33)
.addDecoration(patternFilled, 0.66)
.build();
static constexpr Color fromDoubles(const double r, const double g, const double b, const double a=1.0)
Creates a new Color from the given double values.
Definition: Color.h:26
static RectanglePatternBuilder rectangleBuilder()
Creates a builder used to make patterns with a rectangle shape.
RectanglePatternBuilder & lineColor(Color color)
Sets the line color.
RectanglePatternBuilder & maxHeight(double maxHeight)
Sets the maximum height of the rectangle, in pixels, relative to the base line.
RectanglePatternBuilder & fixedLength(double fixedLength)
Set the length of the pattern in pixels.
ComplexStrokePattern build()
Build the rectangle pattern as configured.
RectanglePatternBuilder & minHeight(double minHeight)
Sets the minimum height of the rectangle, in pixels, relative to the base line.
RectanglePatternBuilder & fillColor(Color color)
Sets the fill color.

Results in:

rectangle pattern example
Returns
the pattern builder.

◆ repeat()

static ComplexStrokePattern luciad::ComplexStrokePatternFactory::repeat ( const ComplexStrokePattern pattern,
uint32_t  count 
)
static

Creates a pattern that repeats a pattern a fixed number of times.

Note that with this pattern, there is no guarantee that the given number of patterns is actually painted. This also depends on the line on which the complex stroke is painted. For example, if the line is too short, not all of the patterns may fit on it. If one of the repeated patterns crosses a sharp corner, it may be omitted as well. In that case, the regular or fallback patterns may be painted instead.

In the following example, a circular arc pattern is repeated 3 times:

Sample code:

auto repeatedCircle = ComplexStrokePatternFactory::repeat(circle, 3);
.addDecoration(repeatedCircle, 0.5)
.build();
static ComplexStrokePattern repeat(const ComplexStrokePattern &pattern, uint32_t count)
Creates a pattern that repeats a pattern a fixed number of times.

Results in:

repeat pattern example
Parameters
patternthe pattern to repeat.
countthe number of times to repeat the pattern. Must be greater than or equal to 1.
Returns
pattern that repeats another pattern a fixed number of times.

◆ repeatOverLengthFixed()

static ComplexStrokePattern luciad::ComplexStrokePatternFactory::repeatOverLengthFixed ( const ComplexStrokePattern pattern,
double  fixedLength 
)
static

Creates a pattern that repeats a pattern over a given length.

This length is a fixed length (in pixels).

Sample code:

auto repeatedCircle = ComplexStrokePatternFactory::repeatOverLengthFixed(circle, 100);
.addDecoration(repeatedCircle, 0.5)
.build();
static ComplexStrokePattern repeatOverLengthFixed(const ComplexStrokePattern &pattern, double fixedLength)
Creates a pattern that repeats a pattern over a given length.

Results in:

repeatOverLengthFixed pattern example
Parameters
patternthe pattern to repeat.
fixedLengththe length (in pixels) over which the pattern should be repeated.
Returns
A pattern that repeats another pattern over a given length.
Exceptions
luciad::InvalidArgumentExceptionfixedLength must be >0.

◆ repeatOverLengthRelative()

static ComplexStrokePattern luciad::ComplexStrokePatternFactory::repeatOverLengthRelative ( const ComplexStrokePattern pattern,
double  relativeLength 
)
static

Creates a pattern that repeats the given pattern over a given length.

This is a length relative to the length of the line.

Sample code:

auto repeatedCircle = ComplexStrokePatternFactory::repeatOverLengthRelative(circle, 0.5);
.addDecoration(repeatedCircle, 0.5)
.build();
static ComplexStrokePattern repeatOverLengthRelative(const ComplexStrokePattern &pattern, double relativeLength)
Creates a pattern that repeats the given pattern over a given length.

Results in:

repeatOverLengthRelative pattern example
Parameters
patternthe pattern to repeat.
relativeLengththe length (relative to the length of the entire line, [0,1]) over which the pattern should be repeated.
Returns
A pattern that repeats another pattern over a given length.
Exceptions
luciad::InvalidArgumentExceptionrelativeLength must be in range [0,1].

◆ textBuilder()

static TextPatternBuilder luciad::ComplexStrokePatternFactory::textBuilder ( )
static

Creates a builder used to make patterns containing text.

The text must be set by calling a text method before calling build. All other methods are optional.

Sample code:

auto textStyle = TextStyle::newBuilder().fontName("Arial Black").fontSize(16).haloWidth(0).build();
auto textPattern = ComplexStrokePatternFactory::textBuilder().text("Read me").textStyle(textStyle).build();
.addDecoration(textPattern, 0.5)
.build();
static TextPatternBuilder textBuilder()
Creates a builder used to make patterns containing text.
TextPatternBuilder & text(std::string text)
Sets the text as a single line.
TextPatternBuilder & textStyle(TextStyle textStyle)
Sets the style of the text.
ComplexStrokePattern build()
Build the text pattern as configured.
Builder & haloWidth(double haloWidth)
Sets the width of the halo (outline) around the text in pixels.
TextStyle build() const
Creates a newly created text style, based on the properties set on this builder.
Builder & fontName(std::string fontName)
Sets the font name used for text rendering (possible values: Serif, Sans, Arial, Arial Black,...
Builder & fontSize(size_t fontSize)
Sets the font size in pixels , where a pixel is defined as 1/96th of 1 inch (https://www....
static Builder newBuilder()
Creates a new builder for creating a TextStyle.

Results in:

text pattern example
Returns
the pattern builder.

◆ triangleBuilder()

static TrianglePatternBuilder luciad::ComplexStrokePatternFactory::triangleBuilder ( )
static

Creates a builder used to make patterns with a triangle shape.

Sample code:

auto triangle1 = ComplexStrokePatternFactory::triangleBuilder().lineColor(Color::blue()).lineWidth(2).p0({0, 10}).p1({0, -10}).p2({16, -10}).build();
auto triangle2 = ComplexStrokePatternFactory::triangleBuilder().fillColor(Color::red()).p0({0, 10}).p1({16, 10}).p2({16, -10}).build();
auto pattern = ComplexStrokePatternFactory::appendPatterns({triangle1, triangle2});
ComplexStrokeLineStyle strokeStyle = ComplexStrokeLineStyle::newBuilder()
.addDecoration(pattern, 0.5)
.build();
static TrianglePatternBuilder triangleBuilder()
Creates a builder used to make patterns with a triangle shape.
TrianglePatternBuilder & fillColor(Color color)
Sets the fill color.
TrianglePatternBuilder & p0(Coordinate coordinate)
The 2D coordinate of the first point of the triangle.
TrianglePatternBuilder & lineColor(Color color)
Sets the line color.
TrianglePatternBuilder & lineWidth(double lineWidth)
Sets the line width.

Results in:

triangle pattern example
Returns
the pattern builder.

◆ waveBuilder()

static WavePatternBuilder luciad::ComplexStrokePatternFactory::waveBuilder ( )
static

Creates a builder used to make patterns with a wave shape.

More specifically, the wave shape follows a sine wave. Which part of the sine wave gets painted is determined by angle and startAngle. The amplitude (height) is set with amplitude. The wave is stretched over the given length.

In the first image below, we have horizontal lines going from left to right. As you see, a regular wave first goes up (or to the left of the baseline, if looking at it from the baseline's start towards the end), then back to the baseline, repeating the same shape below the baseline (i.e. to the right of the baseline when looking from the baseline's start).

The second wave is broken down in four separate colored segments each with an angle of 90, but with different startAngles.

wave pattern chopped in four segments

Created by the following code:

//Blue from 0->90.
.angle(90)
.amplitude(20)
.build();
//Green from 90->180.
.angle(90)
.amplitude(20)
.build();
//Magenta from 180->270
.angle(90)
.amplitude(20)
.startAngle(180)
.build();
//Yellow from 270->360
.angle(90)
.amplitude(20)
.startAngle(270)
.build();
auto waves = ComplexStrokePatternFactory::appendPatterns({waveSegment1, waveSegment2, waveSegment3, waveSegment4});
.addDecoration(wave, 0.5)
.build();
.addDecoration(waves, 0.5)
.build();
static constexpr Color green()
The color green.
Definition: Color.h:52
static constexpr Color yellow()
The color yellow.
Definition: Color.h:92
static constexpr Color magenta()
The color magenta.
Definition: Color.h:100
static WavePatternBuilder waveBuilder()
Creates a builder used to make patterns with a wave shape.
WavePatternBuilder & angle(double angle)
The angle of the wave pattern in degrees.
WavePatternBuilder & lineColor(Color color)
Sets the line color.
ComplexStrokePattern build()
Build the wave pattern as configured.
WavePatternBuilder & lineWidth(double lineWidth)
Sets the line width.
WavePatternBuilder & startAngle(Angle startAngle)
This determines at which point on the sine function the wave begins.
WavePatternBuilder & fixedLength(double fixedLength)
Set the length of the pattern in pixels.
WavePatternBuilder & amplitude(double amplitude)
The amplitude or height of the wave.

Note that, unlike most patterns, the wave can be partially drawn even as a regular or decoration pattern when there is not enough space and other patterns would be omitted in full. By making the wave atomic only the full wave pattern will be drawn.

Sample code:

.amplitude(30)
.build();
auto waves = ComplexStrokePatternFactory::appendPatterns({wave1, wave2, wave3});
.addDecoration(waves, 0.5)
.build();
WavePatternBuilder & relativeLength(double relativeLength)
Set the length of the pattern relative to the length of the entire line, as a value between 0 and 1.
WavePatternBuilder & fillColor(Color color)
Sets the fill color.

Results in:

wave pattern example
Returns
the pattern builder.