Enum Class ContourLineType
- All Implemented Interfaces:
Serializable
,Comparable<ContourLineType>
,Constable
Contour line style for 2-dimensional object boundaries, traced by Boundary2DScanner
.
Used by some classes that measure parameters of 2-dimensional objects on the base of their boundaries,
like the length of the perimeter, the area, the projections, etc.
For example, it is used while creating Boundary2DSimpleMeasurer
and
Boundary2DProjectionMeasurer
.
Please note: this enum may be extended in future versions with new contour styles (for example, rounded or curve). So, if your application chooses behaviour depending on a switch of this type, please always provide a special branch for a case of new future contour types, unknown yet. (It can be default case for Java switch operator.) It is a good idea to throw UnsupportedOperationException in such a branch.
This class is immutable and thread-safe: there are no ways to modify settings of the created instance.
- Author:
- Daniel Alievsky
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionStyle, for which it is considered that the contour is a polyline, connecting centers of all pixels, visited byscanBoundary
method (boundary pixels of an object).Style, for which it is considered that the contour is a polyline, connecting centers of all boundary segments, visited byscanBoundary
method.Style, for which it is considered that the contour is identical to the boundary. -
Method Summary
Modifier and TypeMethodDescriptionstatic ContourLineType
Returns the enum constant of this class with the specified name.static ContourLineType[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.abstract double
x
(Boundary2DScanner scanner) Returns x-coordinate of some point at the contour line, corresponding to the current position at the boundary in the given scanner.abstract double
y
(Boundary2DScanner scanner) Returns y-coordinate of some point at the contour line, corresponding to the current position at the boundary in the given scanner.
-
Enum Constant Details
-
STRICT_BOUNDARY
Style, for which it is considered that the contour is identical to the boundary. Such contour consists of 1-pixel segments, separating object pixels (unit matrix elements) from the free space (zero matrix elements). In this case, for example, if an object consists of only 1 pixel (a square with the side 1.0), the contour line consists of 4 segments of the length 1.0 — sides of this square, and the length of contour is 4.0. -
PIXEL_CENTERS_POLYLINE
Style, for which it is considered that the contour is a polyline, connecting centers of all pixels, visited byscanBoundary
method (boundary pixels of an object). Such contour consists of segments with the length 1.0 and √2, lying inside an object at the little distance from its boundary (not farther than 0.5). In this case, for example, if an object consists of only 1 pixel (a square with the side 1.0), the contour line is empty (degenerated to a point). -
SEGMENT_CENTERS_POLYLINE
Style, for which it is considered that the contour is a polyline, connecting centers of all boundary segments, visited byscanBoundary
method. Such contour consists of segments with the length 1.0 and 0.5*√2, lying almost at the boundary of an object (sometimes little inside, sometimes little outside). In this case, for example, if an object consists of only 1 pixel (a square with the side 1.0), the contour line consists of 4 segments of the length 0.5*√2, connecting centers of the sides of this square, and the length of contour is 2*√2.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
x
Returns x-coordinate of some point at the contour line, corresponding to the current position at the boundary in the given scanner.More precisely, this method is equivalent to:
scanner. x()
+scanner.lastStep()
.pixelVertexX()
for STRICT_BOUNDARY
;scanner. x()
for PIXEL_CENTERS_POLYLINE
;scanner. x()
+scanner.side()
.centerX()
for SEGMENT_CENTERS_POLYLINE
;- Parameters:
scanner
- some boundary scanner.- Returns:
- x-coordinate of the point at the contour line, corresponding to the current position at the boundary in the given scanner.
- Throws:
NullPointerException
- if the argument is null.IllegalStateException
- if the scanner was notpositioned yet
, or, maybe, ifBoundary2DScanner.next()
(orBoundary2DScanner.scanBoundary()
) method was never called for it.
-
y
Returns y-coordinate of some point at the contour line, corresponding to the current position at the boundary in the given scanner.More precisely, this method is equivalent to:
scanner. y()
+scanner.lastStep()
.pixelVertexY()
for STRICT_BOUNDARY
;scanner. y()
for PIXEL_CENTERS_POLYLINE
;scanner. y()
+scanner.side()
.centerY()
for SEGMENT_CENTERS_POLYLINE
;- Parameters:
scanner
- some boundary scanner.- Returns:
- y-coordinate of the point at the contour line, corresponding to the current position at the boundary in the given scanner.
- Throws:
NullPointerException
- if the argument is null.IllegalStateException
- if the scanner was notpositioned yet
, or, maybe, ifBoundary2DScanner.next()
(orBoundary2DScanner.scanBoundary()
) method was never called for it.
-