-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathma_draw_statistic.e
More file actions
192 lines (158 loc) · 4.76 KB
/
ma_draw_statistic.e
File metadata and controls
192 lines (158 loc) · 4.76 KB
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
note
description: "Objects that used for draw graphics whihch are the datas about memory useage."
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date: 2009-09-29 06:26:59 +0200 (tis, 29 sep 2009) $"
revision: "$Revision: 80947 $"
deferred class
MA_DRAW_STATISTIC
feature -- Command
draw_graph (a_used_percent, a_overhead_percent:DOUBLE)
-- Draw the graph of the statistics.
require
used_percent_not_too_large_not_too_small : a_used_percent >= 0 and a_used_percent <= 1
overhead_percent_not_too_large_not_too_small : a_overhead_percent >= 0 and a_overhead_percent <= 1
deferred
end
draw_text (a_info: STRING)
-- Draw some infomation on the graph.
do
end
pixmap: EV_PIXMAP
-- Return the drawed graph.
do
Result := internal_pixmap
ensure
result_not_void: Result /= Void
end
set_height (a_height: INTEGER)
-- Set the height of graph.
require
a_height_valid: a_height >= 0 and a_height <= 800
do
graph_height := a_height
internal_pixmap.set_size (graph_width, a_height)
ensure
a_height_set: graph_height = a_height
end
set_width (a_width: INTEGER)
-- Set the width of graph.
require
a_width_valid: a_width >= 0 and a_width <= 3000
do
graph_width := a_width
internal_pixmap.set_size (a_width, graph_height)
ensure
a_width_set: graph_width = a_width
end
feature -- Query
inner_graph_width: INTEGER
-- The inner graph's width.
do
Result := graph_width - left_top_x - right_interval
ensure
result_greater_than_zero: Result > 0
end
inner_graph_height: INTEGER
-- The inner graph's height.
do
Result := graph_height - left_top_y - bottom_interval
ensure
result_greater_than_zero: Result > 0
end
inner_graph_draw_height (a_percent: DOUBLE): INTEGER
-- The inner graph's used/overhead height.
do
Result := (inner_graph_height * a_percent).ceiling
ensure
result_positive: Result >= 0
end
inner_graph_draw_height_y (a_percent: DOUBLE): INTEGER
-- The inner used graph's y position which can be used by EV_DRAWABLE.draw_sth.(x,y...).
do
Result := inner_graph_height - inner_graph_draw_height (a_percent) + left_top_y
ensure
result_positive: Result >= 0
end
feature {NONE} -- Implemention
internal_pixmap: EV_PIXMAP
-- The drawable diagram for draw histogram diagram.
left_top_x: INTEGER = 30
-- The statistic graph left_top x point.
left_top_y: INTEGER = 10
-- The statistic graph left_top y point.
bottom_interval: INTEGER
-- The interval between the graph and the EV_DRAWABLE bottom which is used for draw texts.
right_interval: INTEGER
-- The interval between the inner graph and the EV_DRAWABLE right side.
graph_height: INTEGER
-- The max height of the graph.
graph_width: INTEGER
--The max width of the graph.
graph_used_color: EV_COLOR
-- The used section's color of the graph.
once
Result := (create {EV_STOCK_COLORS}).red
end
graph_overhead_color: EV_COLOR
-- The overhead section's color of the graph.
once
Result := (create {EV_STOCK_COLORS}).yellow
ensure
reuslt_not_void: Result /= Void
end
graph_grid_color: EV_COLOR
-- The grid color of the graphs.
once
Result := (create {EV_STOCK_COLORS}).white
ensure
result_not_void: Result /= Void
end
graph_inner_background_color: EV_COLOR
-- The background color of the inner graphs.
once
Result := (create {EV_STOCK_COLORS}).white
ensure
result_not_void: Result /= Void
end
graph_background_color: EV_COLOR
-- The background color of the inner graphs.
once
Result := (create {EV_STOCK_COLORS}).black
ensure
result_not_void: Result /= Void
end
graph_pixmap_background_color: EV_COLOR
-- The background color of the whole graph.
once
Result := (create {EV_STOCK_COLORS}).black
ensure
result_not_void: Result /= Void
end
graph_text_color: EV_COLOR
-- The color of the text in the graph.
once
Result := (create {EV_STOCK_COLORS}).white
ensure
result_not_void: Result /= Void
end
grid_size: INTEGER = 20
-- The grid size of the graph.
invariant
pixmap_not_void: internal_pixmap /= Void
bottom_interval_not_zero: bottom_interval /= 0
inner_graph_width_valid: inner_graph_width >= 0 and inner_graph_width <= graph_width
inner_graph_height_valid: inner_graph_height >= 0 and inner_graph_height <= graph_height
graph_width_valid: graph_width >= 0
graph_height_valid: graph_height >= 0 and graph_height <= 200
note
copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
356 Storke Road, Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end