1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2000-2005 by Yasushi Saito (yasushi.saito@gmail.com)
5 # Jockey is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2, or (at your option) any
10 # Jockey is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 from pychart_types import *
25 "line_style": (line_style.T, line_style.default, "The line style of the tick mark."),
26 "fill_style": (fill_style.T, fill_style.white, "The fill style."),
27 "size": (UnitType, 5, "Size of the tick mark."),
30 class T(chart_object.T):
31 __doc__ = tick_mark_doc.doc
33 ##AUTOMATICALLY GENERATED
35 ##END AUTOMATICALLY GENERATED
37 def predraw_check(self):
38 if not hasattr(self, "type_checked"):
43 """Draws a circle. """
44 def draw(self, can, x, y):
46 can.ellipsis(self.line_style, self.fill_style, x, y,
51 def draw(self, can, x, y):
53 # move to the bottom-left corner
56 can.rectangle(self.line_style, self.fill_style,
57 x, y, x+self.size, y+self.size)
60 """Draws a triangle pointing up."""
61 def draw(self, can, x, y):
63 can.polygon(self.line_style, self.fill_style,
64 ((x-self.size/1.6, y-self.size/2.0),
65 (x+self.size/1.6, y-self.size/2.0),
66 (x, y+self.size/2.0)))
67 class DownTriangle(T):
68 """Draws a triangle pointing down."""
69 def draw(self, can, x, y):
71 can.polygon(self.line_style, self.fill_style,
72 ((x, y-self.size/2.0),
73 (x-self.size/1.6, y+self.size/2.0),
74 (x+self.size/1.6, y+self.size/2.0)))
78 """Draw a "X"-shaped tick mark. Attribute "fill-style" is ignored."""
79 keys = pychart_util.union_dict(T.keys,
80 {"line_style": (line_style.T,
81 line_style.T(width=0.7),
82 "The line style of the tick mark")})
83 def draw(self, can, x, y):
85 # move to the bottom-left corner
88 can.line(self.line_style, x, y, x+self.size, y+self.size)
89 can.line(self.line_style, x+self.size, y, x, y+self.size)
92 """Draw a "+"-shaped tick mark. Attribute "fill-style" is ignored."""
93 keys = pychart_util.union_dict(T.keys,
94 {"line_style": (line_style.T,
95 line_style.T(width=1),
96 "The line style of the tick mark.")})
97 def draw(self, can, x, y):
99 # move to the bottom-left corner
100 can.line(self.line_style, x-self.size/1.4, y, x+self.size/1.4, y)
101 can.line(self.line_style, x, y-self.size/1.4, x, y+self.size/1.4)
104 """Draw a square rotated at 45 degrees."""
105 def draw(self, can, x, y):
107 # move to the bottom-left corner
108 can.polygon(self.line_style, self.fill_style,
109 ((x-self.size/1.4, y), (x, y+self.size/1.4),
110 (x+self.size/1.4, y), (x, y-self.size/1.4)))
113 """Draw a "*". Attribute "fill-style" is ignored."""
114 keys = pychart_util.union_dict(T.keys,
115 {"line_style": (line_style.T,
116 line_style.T(width=1),
117 "The line style of the tick mark.")})
118 def draw(self, can, x, y):
120 # move to the bottom-left corner
123 d_len = self.size / 2.0
124 r_len = self.size * 1.414 / 2.0
125 can.line(self.line_style, x-d_len, y-d_len, x+d_len, y+d_len)
126 can.line(self.line_style, x+d_len, y-d_len, x-d_len, y+d_len)
127 can.line(self.line_style, midx, y-r_len, midx, y+r_len)
128 can.line(self.line_style, x-r_len, midy, x+r_len, midy)
131 """This tickmark doesn't draw anything. All the attributes are ignored."""
133 self.line_style = None
134 self.fill_style = None
136 def draw(self, can, x, y):
139 standards = object_set.T()
144 square = _intern(Square())
145 square3 = _intern(Square(size=3))
148 x3 = _intern(X(size=3))
150 star = _intern(Star())
151 star3 = _intern(Star(size=3))
153 plus = _intern(Plus())
154 plus3 = _intern(Plus(size=3))
156 dia = _intern(Diamond())
157 dia3 = _intern(Diamond(size=3))
159 tri = _intern(Triangle())
160 tri3 = _intern(Triangle(size=3))
162 dtri = _intern(DownTriangle())
163 dtri3 = _intern(DownTriangle(size=3))
165 circle1 = _intern(Circle(size=1))
166 circle2 = _intern(Circle(size=3))
167 circle3 = _intern(Circle(size=5))
168 blacksquare = _intern(Square(fill_style=fill_style.black))
169 blacksquare3 = _intern(Square(size=3, fill_style=fill_style.black))
170 blackdia = _intern(Diamond(fill_style=fill_style.black))
171 blackdia3 = _intern(Diamond(size=3, fill_style=fill_style.black))
172 blacktri = _intern(Triangle(fill_style=fill_style.black))
173 blacktri3 = _intern(Triangle(size=3, fill_style=fill_style.black))
174 blackdtri = _intern(DownTriangle(fill_style=fill_style.black))
175 blackdtri3 = _intern(DownTriangle(size=3, fill_style=fill_style.black))
176 blackcircle1 = _intern(Circle(size=1, fill_style=fill_style.black))
177 blackcircle3 = _intern(Circle(size=3, fill_style=fill_style.black))
178 gray70square = _intern(Square(fill_style=fill_style.gray70))
179 gray70square3 = _intern(Square(size=3, fill_style=fill_style.gray70))
180 gray70dia = _intern(Diamond(fill_style=fill_style.gray70))
181 gray70dia3 = _intern(Diamond(size=3, fill_style=fill_style.gray70))
182 gray70tri = _intern(Triangle(fill_style=fill_style.gray70))
183 gray70tri3 = _intern(Triangle(size=3, fill_style=fill_style.gray70))
184 gray70dtri = _intern(DownTriangle(fill_style=fill_style.gray70))
185 gray70dtri3 = _intern(DownTriangle(size=3, fill_style=fill_style.gray70))
186 gray70circle1 = _intern(Circle(size=1, fill_style=fill_style.gray70))
187 gray70circle3 = _intern(Circle(size=3, fill_style=fill_style.gray70))
188 default = _intern(Null())