src/reportlab/graphics/charts/markers.py
author robin <robin@reportlab.com>
Tue, 07 Mar 2017 10:00:34 +0000
changeset 4330 617ffa6bbdc8
parent 4252 fe660f227cac
child 4370 823a8c33ce43
permissions -rw-r--r--
changes for release 3.4.0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4330
617ffa6bbdc8 changes for release 3.4.0
robin <robin@reportlab.com>
parents: 4252
diff changeset
     1
#Copyright ReportLab Europe Ltd. 2000-2017
1555
a0c3e76acdb6 Headers+versioning
rgbecker
parents: 1241
diff changeset
     2
#see license.txt for license details
2332
2a7ab4405e18 Remove $Header:, fix CopyRight & history
rgbecker
parents: 1683
diff changeset
     3
#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/graphics/charts/markers.py
3032
22224b1b4d24 New docstrings mainly for module titles
damian
parents: 2964
diff changeset
     4
4252
fe660f227cac changes for release 3.3.0
robin
parents: 3617
diff changeset
     5
__version__='3.3.0'
3032
22224b1b4d24 New docstrings mainly for module titles
damian
parents: 2964
diff changeset
     6
__doc__="""This modules defines a collection of markers used in charts.
845
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
     7
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
     8
The make* functions return a simple shape or a widget as for
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
     9
the smiley.
840
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    10
"""
3032
22224b1b4d24 New docstrings mainly for module titles
damian
parents: 2964
diff changeset
    11
1683
7fa753e4420a Removed all trailing whitespace
andy_robinson
parents: 1557
diff changeset
    12
from reportlab.lib import colors
845
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    13
from reportlab.graphics.shapes import Rect, Line, Circle, Polygon
1223
6f9bee82e5a9 Changes for new Marker Class
rgbecker
parents: 845
diff changeset
    14
from reportlab.graphics.widgets.signsandsymbols import SmileyFace
845
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    15
840
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    16
845
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    17
def makeEmptySquare(x, y, size, color):
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    18
    "Make an empty square marker."
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    19
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    20
    d = size/2.0
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    21
    rect = Rect(x-d, y-d, 2*d, 2*d)
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    22
    rect.strokeColor = color
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    23
    rect.fillColor = None
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    24
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    25
    return rect
840
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    26
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    27
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    28
def makeFilledSquare(x, y, size, color):
845
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    29
    "Make a filled square marker."
840
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    30
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    31
    d = size/2.0
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    32
    rect = Rect(x-d, y-d, 2*d, 2*d)
845
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    33
    rect.strokeColor = color
840
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    34
    rect.fillColor = color
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    35
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    36
    return rect
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    37
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    38
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    39
def makeFilledDiamond(x, y, size, color):
845
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    40
    "Make a filled diamond marker."
840
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    41
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    42
    d = size/2.0
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    43
    poly = Polygon((x-d,y, x,y+d, x+d,y, x,y-d))
845
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    44
    poly.strokeColor = color
840
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    45
    poly.fillColor = color
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    46
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    47
    return poly
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    48
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    49
845
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    50
def makeEmptyCircle(x, y, size, color):
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    51
    "Make a hollow circle marker."
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    52
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    53
    d = size/2.0
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    54
    circle = Circle(x, y, d)
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    55
    circle.strokeColor = color
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    56
    circle.fillColor = colors.white
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    57
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    58
    return circle
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    59
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    60
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    61
def makeFilledCircle(x, y, size, color):
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    62
    "Make a hollow circle marker."
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    63
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    64
    d = size/2.0
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    65
    circle = Circle(x, y, d)
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    66
    circle.strokeColor = color
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    67
    circle.fillColor = color
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    68
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    69
    return circle
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    70
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    71
840
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    72
def makeSmiley(x, y, size, color):
845
0f7777cad29b Added two funcions and tidied-up.
dinu_gherman
parents: 840
diff changeset
    73
    "Make a smiley marker."
840
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    74
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    75
    d = size
1223
6f9bee82e5a9 Changes for new Marker Class
rgbecker
parents: 845
diff changeset
    76
    s = SmileyFace()
1241
c3166ce09ed8 Fixed fillColor
rgbecker
parents: 1223
diff changeset
    77
    s.fillColor = color
840
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    78
    s.x = x-d
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    79
    s.y = y-d
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    80
    s.size = d*2
64e12ca4389a Initial checkin.
dinu_gherman
parents:
diff changeset
    81
3032
22224b1b4d24 New docstrings mainly for module titles
damian
parents: 2964
diff changeset
    82
    return s