LuciadCPillar 2023.1.04
|
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... | |
Factory to create all patterns
that are used to create complex strokes
.
|
delete |
|
delete |
|
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:
Results in:
pattern | the pattern to allow overlaps. |
overlapLeft | The allowed overlap on the left, in pixels. |
overlapRight | The allowed overlap on the right, in pixels. |
luciad::InvalidArgumentException | overlapLeft and overlapRight must be >=0 . |
|
static |
Creates a pattern consisting of multiple sub-patterns appended together, painting them next to each other.
Sample code:
Results in:
patterns | patterns to append, may not be empty. |
luciad::InvalidArgumentException | patterns may not be empty. |
|
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:
Results in:
|
static |
Creates a builder used to make patterns with an arrow shape.
Sample code:
Results in:
|
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:
Results in:
pattern | The pattern to make atomic. |
|
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:
Results in:
pattern | The pattern to combine with the fallback pattern . |
fallback pattern
to be combined with this 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:
Results in:
pattern | The pattern to combine with the regular pattern . |
regular pattern
to be combined with this pattern.
|
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:
Results in:
patterns | patterns to compose, may not be empty. |
luciad::InvalidArgumentException | patterns may not be empty. |
|
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:
Results in:
fixedLength | the length of the gap in pixels. |
luciad::InvalidArgumentException | fixedLength must be >=0 . |
|
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:
Results in:
relativeLength | the length (relative to the length of the entire line, [0,1] ) of the gap. |
luciad::InvalidArgumentException | relativeLength must be in range [0,1] . |
|
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:
Results in:
|
static |
Creates a builder used to make patterns with a line segment shape.
A line segment is defined by:
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:
Results in:
|
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:
Results in:
|
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:
Results in:
|
static |
Creates a builder used to make patterns with a rectangle shape.
Sample code:
Results in:
|
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:
Results in:
pattern | the pattern to repeat. |
count | the number of times to repeat the pattern. Must be greater than or equal to 1. |
|
static |
Creates a pattern that repeats a pattern over a given length.
This length is a fixed length (in pixels).
Sample code:
Results in:
pattern | the pattern to repeat. |
fixedLength | the length (in pixels) over which the pattern should be repeated. |
luciad::InvalidArgumentException | fixedLength must be >0 . |
|
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:
Results in:
pattern | the pattern to repeat. |
relativeLength | the length (relative to the length of the entire line, [0,1] ) over which the pattern should be repeated. |
luciad::InvalidArgumentException | relativeLength must be in range [0,1] . |
|
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:
Results in:
|
static |
Creates a builder used to make patterns with a triangle shape.
Sample code:
Results in:
|
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
.
Created by the following code:
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:
Results in: