-
Notifications
You must be signed in to change notification settings - Fork 4
/
LineStyle.py
36 lines (28 loc) · 867 Bytes
/
LineStyle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class LineStyle(object):
"""
This property controls the way that a line looks.
"""
_STYLE_TRANSLATOR = {
"-" : ["solid", None],
"--" : ["dashed"],
"-." : ["dash-dot", "dot-dash"],
":" : ["dotted"],
}
VALID_STYLES = {}
for (glyph, equivalents) in _STYLE_TRANSLATOR.items():
VALID_STYLES[glyph] = glyph
for equiv in equivalents:
VALID_STYLES[equiv] = glyph
def __init__(self):
self._style = "-"
@property
def style(self):
"""
The style in which the line will be drawn.
"""
return self._style
@style.setter
def style(self, value):
assert value in LineStyle.VALID_STYLES, "'%s' is not a valid "\
"line style" % (value)
self._style = LineStyle.VALID_STYLES[value]