LineStyle

Description

The LineStyle element defines a style for a line.

Context

Table 1 lists the elements that can contain, or be contained by, a LineStyle element.

Table 1. Context
Contained by Element Contains

NamedStyle or CompositeStyle or AreaStyle

LineStyle

Pen

Attributes

Table 2 lists the attributes of a LineStyle element.

Table 2. Attributes
Attribute Description

id

A unique identifier for the element.

name

A descriptive name for the element.

stroke

A string value specifying the color of the line.

The value can be any valid CSS color. (See http://www.w3.org/TR/REC-CSS1#color-units.)

The stroke attribute is optional. The default value is black.

stroke-opacity

A floating-point value from 0 to 1 specifying the opacity of the line.

A value of 0 means that the line is totally transparent. A value of 1 means that the line is totally opaque. A value of 0.5 means that the line is 50% translucent.

The stroke-opacity attribute is optional. The default value is 1.

width

An integer value specifying the width of the line.

The width attribute is optional. The default value is 1.

width-unit

A reference to an imagesize in the mapinfo codespace, which specifies a width unit.

The width-unit attribute is optional. The default value is mapinfo:imagesize pixel.

miterlimit

A limit on the ratio of the miter length to the line width for linejoins of type miter. When two line segments meet at a sharp angle and miter joins have been specified for linejoin, it is possible for the miter to extend far beyond the thickness of the line stroking the path.

The miterlimit attribute is optional. The default value is 10.

linecap

An enumeration value specifying the decorative shape to be used at the end of open subpaths when they are stroked. The possible values are:

  • butt
  • round
  • square

The value butt means no decoration is used. The value round means the line ends with a semicircle whose radius is half the line width. The value square means the line ends with a rectangle whose length is half the line width.

The linecap attribute is optional. The default value is round.

linejoin

An enumeration value specifying the shape to be used at the corners of paths or basic shapes when they are stroked. The possible values are:

  • miter
  • bevel
  • round

The value miter means the outer edges of lines extend until they intersect. If the miter is longer than the miterlimit, the type bevel is substituted. The value bevel means lines are joined by connecting the outer edges of their ends. The value round means each line segment is ended with a semicircle whose radius is half the line width.

The linejoin attribute is optional. The default value is round.

marker-placement

An enumeration value specifying the placement style for markers. The possible values are:

  • LEFT
  • CENTER
  • RIGHT
  • HORIZONTAL
  • MATCH_SEGMENT
  • none
Note: Currently only none is supported for marker placement.

Markers can be placed at the start, end, or middle nodes of line segments and can be drawn along line segments continuously. The values LEFT, CENTER, and RIGHT specify the horizontal justification for a multi-line text marker. The values HORIZONTAL and MATCH_SEGMENT specify the rotational orientation of a symbol marker relative to the line segment.

The marker-placement attribute is optional. The default value is none.

dasharray

An array of comma or whitespace delimited integer values that specify the lengths (in pixels) of alternating dashes and spaces for a dashed line. For example, 10 20 30 10 or 10,20,30,10.

The array must contain an even number of positive integers, or the special value none. The first integer in the array specifies the length of the first dash, the second integer specifies the length of the first space, and so on through the array.

For example, the following value
    10,20,30,10
specifies a dashed line in which the first dash is 10 pixels long, followed by a space 20 pixels long, followed by a dash 30 pixels long, followed by a space 10 pixels long. The pattern then repeats for the length of the dashed line.

The dasharray attribute is optional. The default value is none, which is equivalent to the array 1,1.

dashoffset

A positive integer value specifying the number of units (in pixels) from the start of the line segment at which the first dash of a dashed line will be drawn.

The dashoffset attribute is optional. The default value is 0.

Example

This example specifies a dashed black line that is one pixel wide.



<?xml version="1.0" encoding="UTF-8"?>
<NamedStyle
    version="MXP_WorkSpace_1_5"
    xmlns="http://www.mapinfo.com/mxp">
    <LineStyle
        stroke="black"
        stroke-opacity="1"
        width="1"
        width-unit="mapinfo:imagesize pixel">
        <Pen>mapinfo:pen 9</Pen>
    </LineStyle>
</NamedStyle>