/usr/share/pyshared/pychart/tick_mark.py is in python-pychart 1.39-7build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | #
# Copyright (C) 2000-2005 by Yasushi Saito (yasushi.saito@gmail.com)
#
# Jockey is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any
# later version.
#
# Jockey is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
import color
import line_style
import fill_style
import chart_object
import object_set
import pychart_util
import tick_mark_doc
from pychart_types import *
_keys = {
"line_style": (line_style.T, line_style.default, "The line style of the tick mark."),
"fill_style": (fill_style.T, fill_style.white, "The fill style."),
"size": (UnitType, 5, "Size of the tick mark."),
}
class T(chart_object.T):
__doc__ = tick_mark_doc.doc
keys = _keys
##AUTOMATICALLY GENERATED
##END AUTOMATICALLY GENERATED
class Circle(T):
"""Draws a circle. """
def draw(self, can, x, y):
can.ellipsis(self.line_style, self.fill_style, x, y,
self.size/2.0, 1)
class Square(T):
"""Draws a square."""
def draw(self, can, x, y):
# move to the bottom-left corner
x = x - self.size/2.0
y = y - self.size/2.0
can.rectangle(self.line_style, self.fill_style,
x, y, x+self.size, y+self.size)
class Triangle(T):
"""Draws a triangle pointing up."""
def draw(self, can, x, y):
can.polygon(self.line_style, self.fill_style,
((x-self.size/1.6, y-self.size/2.0),
(x+self.size/1.6, y-self.size/2.0),
(x, y+self.size/2.0)))
class DownTriangle(T):
"""Draws a triangle pointing down."""
def draw(self, can, x, y):
can.polygon(self.line_style, self.fill_style,
((x, y-self.size/2.0),
(x-self.size/1.6, y+self.size/2.0),
(x+self.size/1.6, y+self.size/2.0)))
class X(T):
"""Draw a "X"-shaped tick mark. Attribute "fill-style" is ignored."""
keys = pychart_util.union_dict(T.keys,
{"line_style": (line_style.T,
line_style.T(width=0.7),
"The line style of the tick mark")})
def draw(self, can, x, y):
# move to the bottom-left corner
x = x - self.size/2.0
y = y - self.size/2.0
can.line(self.line_style, x, y, x+self.size, y+self.size)
can.line(self.line_style, x+self.size, y, x, y+self.size)
class Plus(T):
"""Draw a "+"-shaped tick mark. Attribute "fill-style" is ignored."""
keys = pychart_util.union_dict(T.keys,
{"line_style": (line_style.T,
line_style.T(width=1),
"The line style of the tick mark.")})
def draw(self, can, x, y):
# move to the bottom-left corner
can.line(self.line_style, x-self.size/1.4, y, x+self.size/1.4, y)
can.line(self.line_style, x, y-self.size/1.4, x, y+self.size/1.4)
class Diamond(T):
"""Draw a square rotated at 45 degrees."""
def draw(self, can, x, y):
# move to the bottom-left corner
can.polygon(self.line_style, self.fill_style,
((x-self.size/1.4, y), (x, y+self.size/1.4),
(x+self.size/1.4, y), (x, y-self.size/1.4)))
class Star(T):
"""Draw a "*". Attribute "fill-style" is ignored."""
keys = pychart_util.union_dict(T.keys,
{"line_style": (line_style.T,
line_style.T(width=1),
"The line style of the tick mark.")})
def draw(self, can, x, y):
# move to the bottom-left corner
midx = x
midy = y
d_len = self.size / 2.0
r_len = self.size * 1.414 / 2.0
can.line(self.line_style, x-d_len, y-d_len, x+d_len, y+d_len)
can.line(self.line_style, x+d_len, y-d_len, x-d_len, y+d_len)
can.line(self.line_style, midx, y-r_len, midx, y+r_len)
can.line(self.line_style, x-r_len, midy, x+r_len, midy)
class Null(T):
"""This tickmark doesn't draw anything. All the attributes are ignored."""
def __init__ (self):
self.line_style = None
self.fill_style = None
self.size = -1
def draw(self, can, x, y):
pass
standards = object_set.T()
def _intern(style):
standards.add(style)
return style
square = _intern(Square())
square3 = _intern(Square(size=3))
square5 = square
x = _intern(X())
x3 = _intern(X(size=3))
x5 = x
star = _intern(Star())
star3 = _intern(Star(size=3))
star5 = star
plus = _intern(Plus())
plus3 = _intern(Plus(size=3))
plus5 = plus
dia = _intern(Diamond())
dia3 = _intern(Diamond(size=3))
dia5 = dia
tri = _intern(Triangle())
tri3 = _intern(Triangle(size=3))
tri5 = tri
dtri = _intern(DownTriangle())
dtri3 = _intern(DownTriangle(size=3))
dtri5 = dtri
circle1 = _intern(Circle(size=1))
circle2 = _intern(Circle(size=3))
circle3 = _intern(Circle(size=5))
blacksquare = _intern(Square(fill_style=fill_style.black))
blacksquare3 = _intern(Square(size=3, fill_style=fill_style.black))
blackdia = _intern(Diamond(fill_style=fill_style.black))
blackdia3 = _intern(Diamond(size=3, fill_style=fill_style.black))
blacktri = _intern(Triangle(fill_style=fill_style.black))
blacktri3 = _intern(Triangle(size=3, fill_style=fill_style.black))
blackdtri = _intern(DownTriangle(fill_style=fill_style.black))
blackdtri3 = _intern(DownTriangle(size=3, fill_style=fill_style.black))
blackcircle1 = _intern(Circle(size=1, fill_style=fill_style.black))
blackcircle3 = _intern(Circle(size=3, fill_style=fill_style.black))
gray70square = _intern(Square(fill_style=fill_style.gray70))
gray70square3 = _intern(Square(size=3, fill_style=fill_style.gray70))
gray70dia = _intern(Diamond(fill_style=fill_style.gray70))
gray70dia3 = _intern(Diamond(size=3, fill_style=fill_style.gray70))
gray70tri = _intern(Triangle(fill_style=fill_style.gray70))
gray70tri3 = _intern(Triangle(size=3, fill_style=fill_style.gray70))
gray70dtri = _intern(DownTriangle(fill_style=fill_style.gray70))
gray70dtri3 = _intern(DownTriangle(size=3, fill_style=fill_style.gray70))
gray70circle1 = _intern(Circle(size=1, fill_style=fill_style.gray70))
gray70circle3 = _intern(Circle(size=3, fill_style=fill_style.gray70))
default = _intern(Null())
|