26 |
The resulting classification will consist of one group for each |
The resulting classification will consist of one group for each |
27 |
item in _list whose properties ramp between 'prop1' and 'prop2'. |
item in _list whose properties ramp between 'prop1' and 'prop2'. |
28 |
|
|
29 |
_list -- any object that implements the iterator interface |
_list -- a list of values for each singleton |
30 |
|
|
31 |
ramp -- an object which implements the CustomRamp interface |
ramp -- an object which implements the CustomRamp interface |
32 |
""" |
""" |
34 |
clazz = Classification() |
clazz = Classification() |
35 |
|
|
36 |
i = 0 |
i = 0 |
37 |
|
maxValue = float(len(_list) - 1) |
38 |
|
if maxValue < 1: maxValue = 1 |
39 |
|
|
40 |
for value in _list: |
for value in _list: |
41 |
prop = ramp.GetProperties(float(i) / len(_list)) |
prop = ramp.GetProperties(i / maxValue) |
42 |
clazz.AppendGroup(ClassGroupSingleton(value, prop)) |
clazz.AppendGroup(ClassGroupSingleton(value, prop)) |
43 |
i += 1 |
i += 1 |
44 |
|
|
59 |
cur_min = min |
cur_min = min |
60 |
|
|
61 |
end = "[" |
end = "[" |
62 |
|
maxValue = float(numGroups - 1) |
63 |
|
if maxValue < 1: maxValue = 1 |
64 |
|
|
65 |
for i in range(1, numGroups + 1): |
for i in range(1, numGroups + 1): |
66 |
|
|
67 |
prop = ramp.GetProperties(float(i-1) / numGroups) |
prop = ramp.GetProperties(float(i-1) / maxValue) |
68 |
|
|
69 |
if intStep: |
if intStep: |
70 |
cur_max = min + int(round((i * (max - min + 1)) / float(numGroups))) |
cur_max = min + int(round((i * (max - min + 1)) / float(numGroups))) |
80 |
else: |
else: |
81 |
_range = Range(("[", cur_min, cur_max, end)) |
_range = Range(("[", cur_min, cur_max, end)) |
82 |
|
|
83 |
clazz.AppendGroup(ClassGroupRange(_range, None, prop)) |
clazz.AppendGroup(ClassGroupRange(_range, prop)) |
84 |
|
|
85 |
cur_min = cur_max |
cur_min = cur_max |
86 |
|
|
128 |
i = 1 |
i = 1 |
129 |
end = "]" |
end = "]" |
130 |
|
|
131 |
|
maxValue = float(numGroups - 1) |
132 |
|
if maxValue < 1: maxValue = 1 |
133 |
for (q, p) in quantiles[3]: |
for (q, p) in quantiles[3]: |
134 |
|
|
135 |
prop = ramp.GetProperties(float(i-1) / numGroups) |
prop = ramp.GetProperties(float(i-1) / maxValue) |
136 |
|
|
137 |
if i == numGroups: |
if i == numGroups: |
138 |
max = endMax |
max = endMax |
140 |
else: |
else: |
141 |
max = _list[q] |
max = _list[q] |
142 |
|
|
143 |
group = ClassGroupRange(Range((start, min, max, end)), |
group = ClassGroupRange(Range((start, min, max, end)), prop) |
|
None, prop) |
|
144 |
|
|
145 |
group.SetLabel("%s%% - %s%%" % (round(oldp*100, 2), |
group.SetLabel("%s%% - %s%%" % (round(oldp*100, 2), |
146 |
round(p*100, 2))) |
round(p*100, 2))) |
193 |
i = 1 |
i = 1 |
194 |
end = "]" |
end = "]" |
195 |
|
|
196 |
|
maxValue = float(numGroups - 1) |
197 |
|
if maxValue < 1: maxValue = 1 |
198 |
for (q, p) in quantiles[3][1:]: |
for (q, p) in quantiles[3][1:]: |
199 |
prop = ramp.GetProperties(float(i) / numGroups) |
prop = ramp.GetProperties(float(i-1) / maxValue) |
200 |
|
|
201 |
if i == numGroups: |
if i == numGroups: |
202 |
max = endMax |
max = endMax |
204 |
else: |
else: |
205 |
max = _list[q] |
max = _list[q] |
206 |
|
|
207 |
group = ClassGroupRange(Range((start, min, max, end)), |
group = ClassGroupRange(Range((start, min, max, end)), prop) |
|
None, prop) |
|
208 |
|
|
209 |
group.SetLabel("%s%% - %s%%" % (round(oldp*100, 2), |
group.SetLabel("%s%% - %s%%" % (round(oldp*100, 2), |
210 |
round(p*100, 2))) |
round(p*100, 2))) |
396 |
|
|
397 |
newProps = ClassGroupProperties() |
newProps = ClassGroupProperties() |
398 |
|
|
399 |
color1 = self.prop1.GetLineColor() |
self.__SetProperty(self.prop1.GetLineColor(), |
400 |
color2 = self.prop2.GetLineColor() |
self.prop2.GetLineColor(), |
401 |
|
index, newProps.SetLineColor) |
402 |
self.__SetProperty(color1, color2, index, newProps.SetLineColor) |
self.__SetProperty(self.prop1.GetFill(), self.prop2.GetFill(), |
403 |
self.__SetProperty(color1, color2, index, newProps.SetFill) |
index, newProps.SetFill) |
404 |
|
|
405 |
w = (self.prop2.GetLineWidth() - self.prop1.GetLineWidth()) \ |
w = (self.prop2.GetLineWidth() - self.prop1.GetLineWidth()) \ |
406 |
* index \ |
* index \ |
407 |
+ self.prop1.GetLineWidth() |
+ self.prop1.GetLineWidth() |
|
|
|
408 |
newProps.SetLineWidth(int(round(w))) |
newProps.SetLineWidth(int(round(w))) |
409 |
|
|
410 |
return newProps |
return newProps |
445 |
RedRamp = MonochromaticRamp(Color(1, 1, 1), Color(.8, 0, 0)) |
RedRamp = MonochromaticRamp(Color(1, 1, 1), Color(.8, 0, 0)) |
446 |
GreenRamp = MonochromaticRamp(Color(1, 1, 1), Color(0, .8, 0)) |
GreenRamp = MonochromaticRamp(Color(1, 1, 1), Color(0, .8, 0)) |
447 |
BlueRamp = MonochromaticRamp(Color(1, 1, 1), Color(0, 0, .8)) |
BlueRamp = MonochromaticRamp(Color(1, 1, 1), Color(0, 0, .8)) |
448 |
GreenToRedRamp = MonochromaticRamp(Color(1, .8, 1), Color(1, 0, 0)) |
GreenToRedRamp = MonochromaticRamp(Color(0, .8, 0), Color(1, 0, 0)) |
449 |
|
|
450 |
class HotToColdRamp: |
class HotToColdRamp: |
451 |
|
|
480 |
|
|
481 |
return prop |
return prop |
482 |
|
|
483 |
|
class FixedRamp: |
484 |
|
"""FixedRamp allows particular properties of a ramp to be |
485 |
|
held constant over the ramp. |
486 |
|
""" |
487 |
|
|
488 |
|
def __init__(self, ramp, fixes): |
489 |
|
""" |
490 |
|
ramp -- a source ramp to get the default properties |
491 |
|
|
492 |
|
fixes -- a tuple (lineColor, lineWidth, fillColor) such that |
493 |
|
if any item is not None, the appropriate property will |
494 |
|
be fixed to that item value. |
495 |
|
""" |
496 |
|
|
497 |
|
self.fixes = fixes |
498 |
|
self.ramp = ramp |
499 |
|
|
500 |
|
def GetRamp(self): |
501 |
|
return self |
502 |
|
|
503 |
|
def GetProperties(self, index): |
504 |
|
props = self.ramp.GetProperties(index) |
505 |
|
if self.fixes[0] is not None: props.SetLineColor(self.fixes[0]) |
506 |
|
if self.fixes[1] is not None: props.SetLineWidth(self.fixes[1]) |
507 |
|
if self.fixes[2] is not None: props.SetFill(self.fixes[2]) |
508 |
|
|
509 |
|
return props |