315 |
items.append(build_item(p, p.GetDisplayText())) |
items.append(build_item(p, p.GetDisplayText())) |
316 |
|
|
317 |
return (_("Classification"), items) |
return (_("Classification"), items) |
318 |
|
|
319 |
class ClassIterator: |
class ClassIterator: |
320 |
"""Allows the Groups in a Classifcation to be interated over. |
"""Allows the Groups in a Classifcation to be interated over. |
321 |
|
|
327 |
"""Constructor. |
"""Constructor. |
328 |
|
|
329 |
default -- the default group |
default -- the default group |
330 |
|
|
331 |
points -- a list of singleton groups |
points -- a list of singleton groups |
332 |
|
|
333 |
ranges -- a list of range groups |
ranges -- a list of range groups |
334 |
|
|
335 |
maps -- a list of map groups |
maps -- a list of map groups |
336 |
""" |
""" |
337 |
|
|
350 |
d = self.data[self.data_index] |
d = self.data[self.data_index] |
351 |
self.data_index += 1 |
self.data_index += 1 |
352 |
return d |
return d |
353 |
|
|
354 |
class ClassGroupProperties: |
class ClassGroupProperties: |
355 |
"""Represents the properties of a single Classification Group. |
"""Represents the properties of a single Classification Group. |
356 |
|
|
357 |
These are used when rendering a layer.""" |
These are used when rendering a layer.""" |
358 |
|
|
359 |
|
# TODO: Actually, size is only relevant for point objects. |
360 |
|
# Eventually it should be spearated, e.g. when introducing symbols. |
361 |
|
|
362 |
def __init__(self, props = None): |
def __init__(self, props = None): |
363 |
"""Constructor. |
"""Constructor. |
364 |
|
|
365 |
props -- a ClassGroupProperties object. The class is copied if |
props -- a ClassGroupProperties object. The class is copied if |
366 |
prop is not None. Otherwise, a default set of properties |
prop is not None. Otherwise, a default set of properties |
367 |
is created such that: line color = Black, line width = 1, |
is created such that: line color = Black, line width = 1, |
368 |
and fill color = Transparent |
size = 5 and fill color = Transparent |
369 |
""" |
""" |
370 |
|
|
371 |
if props is not None: |
if props is not None: |
373 |
else: |
else: |
374 |
self.SetLineColor(Black) |
self.SetLineColor(Black) |
375 |
self.SetLineWidth(1) |
self.SetLineWidth(1) |
376 |
|
self.SetSize(5) |
377 |
self.SetFill(Transparent) |
self.SetFill(Transparent) |
378 |
|
|
379 |
def SetProperties(self, props): |
def SetProperties(self, props): |
382 |
assert isinstance(props, ClassGroupProperties) |
assert isinstance(props, ClassGroupProperties) |
383 |
self.SetLineColor(props.GetLineColor()) |
self.SetLineColor(props.GetLineColor()) |
384 |
self.SetLineWidth(props.GetLineWidth()) |
self.SetLineWidth(props.GetLineWidth()) |
385 |
|
self.SetSize(props.GetSize()) |
386 |
self.SetFill(props.GetFill()) |
self.SetFill(props.GetFill()) |
387 |
|
|
388 |
def GetLineColor(self): |
def GetLineColor(self): |
389 |
"""Return the line color as a Color object.""" |
"""Return the line color as a Color object.""" |
390 |
return self.__stroke |
return self.__stroke |
412 |
|
|
413 |
self.__strokeWidth = lineWidth |
self.__strokeWidth = lineWidth |
414 |
|
|
415 |
|
def GetSize(self): |
416 |
|
"""Return the size.""" |
417 |
|
return self.__size |
418 |
|
|
419 |
|
def SetSize(self, size): |
420 |
|
"""Set the size. |
421 |
|
|
422 |
|
size -- the new size. This must be > 0. |
423 |
|
""" |
424 |
|
assert isinstance(size, types.IntType) |
425 |
|
if (size < 1): |
426 |
|
raise ValueError(_("size < 1")) |
427 |
|
|
428 |
|
self.__size = size |
429 |
|
|
430 |
def GetFill(self): |
def GetFill(self): |
431 |
"""Return the fill color as a Color object.""" |
"""Return the fill color as a Color object.""" |
432 |
return self.__fill |
return self.__fill |
433 |
|
|
434 |
def SetFill(self, fill): |
def SetFill(self, fill): |
435 |
"""Set the fill color. |
"""Set the fill color. |
436 |
|
|
451 |
self.__stroke == other.__stroke) \ |
self.__stroke == other.__stroke) \ |
452 |
and (self.__fill is other.__fill or \ |
and (self.__fill is other.__fill or \ |
453 |
self.__fill == other.__fill) \ |
self.__fill == other.__fill) \ |
454 |
and self.__strokeWidth == other.__strokeWidth |
and self.__strokeWidth == other.__strokeWidth\ |
455 |
|
and self.__size == other.__size |
456 |
|
|
457 |
def __ne__(self, other): |
def __ne__(self, other): |
458 |
return not self.__eq__(other) |
return not self.__eq__(other) |
464 |
return ClassGroupProperties(self) |
return ClassGroupProperties(self) |
465 |
|
|
466 |
def __repr__(self): |
def __repr__(self): |
467 |
return repr((self.__stroke, self.__strokeWidth, self.__fill)) |
return repr((self.__stroke, self.__strokeWidth, self.__size, |
468 |
|
self.__fill)) |
469 |
|
|
470 |
class ClassGroup: |
class ClassGroup: |
471 |
"""A base class for all Groups within a Classification""" |
"""A base class for all Groups within a Classification""" |
488 |
def GetLabel(self): |
def GetLabel(self): |
489 |
"""Return the Group's label.""" |
"""Return the Group's label.""" |
490 |
return self.label |
return self.label |
491 |
|
|
492 |
def SetLabel(self, label): |
def SetLabel(self, label): |
493 |
"""Set the Group's label. |
"""Set the Group's label. |
494 |
|
|