Index: test/test_classification.py =================================================================== --- test/test_classification.py (revision 2688) +++ test/test_classification.py (working copy) @@ -75,11 +75,11 @@ self.assertEqual(group.GetLabel(), "") # test constructor with label - group = ClassGroup("hallo") + group = ClassGroup(label="hallo") self.assertEqual(group.GetLabel(), "hallo") # test SetLabel()/GetLabel() - group = ClassGroup("welt") + group = ClassGroup(label="welt") group.SetLabel("hallo") self.assertEqual(group.GetLabel(), "hallo") Index: Thuban/Model/classification.py =================================================================== --- Thuban/Model/classification.py (revision 2688) +++ Thuban/Model/classification.py (working copy) @@ -384,22 +384,27 @@ # TODO: Actually, size is only relevant for point objects. # Eventually it should be spearated, e.g. when introducing symbols. - def __init__(self, props = None): + def __init__(self, lineColor = Black, lineWidth = 1, + size = 5, fill = Transparent): """Constructor. - props -- a ClassGroupProperties object. The class is copied if - prop is not None. Otherwise, a default set of properties - is created such that: line color = Black, line width = 1, - size = 5 and fill color = Transparent + lineColor -- Color object representing the line (outline) color. + Default: Black + + lineWidth -- Width of line in pixels. + Default: 1 + + size -- Size of a point in pixels, not relevant for other objects. + Default: 5 + + fill -- Color object representing the fill color + (point and polygon), default: Transparent """ - if props is not None: - self.SetProperties(props) - else: - self.SetLineColor(Black) - self.SetLineWidth(1) - self.SetSize(5) - self.SetFill(Transparent) + self.SetLineColor(lineColor) + self.SetLineWidth(lineWidth) + self.SetSize(size) + self.SetFill(fill) def SetProperties(self, props): """Set this class's properties to those in class props.""" @@ -483,19 +488,20 @@ return not self.__eq__(other) def __copy__(self): - return ClassGroupProperties(self) + return ClassGroupProperties().SetProperties(self) def __deepcopy__(self): - return ClassGroupProperties(self) + return ClassGroupProperties().SetProperties(self) def __repr__(self): - return repr((self.__stroke, self.__strokeWidth, self.__size, - self.__fill)) + return "ClassGroupProperties("+\ + repr(self.__stroke)+", "+repr(self.__strokeWidth)+", "+\ + repr(self.__size)+", "+repr(self.__fill)+")" class ClassGroup: """A base class for all Groups within a Classification""" - def __init__(self, label = "", props = None, group = None): + def __init__(self, props = None, label= "", group = None): """Constructor. label -- A string representing the Group's label @@ -566,7 +572,7 @@ return not self.__eq__(other) def __repr__(self): - return repr(self.label) + ", " + repr(self.GetProperties()) + return repr(self.GetProperties()) + ", " + repr(self.label) class ClassGroupSingleton(ClassGroup): """A Group that is associated with a single value.""" @@ -581,7 +587,7 @@ label -- a label for this group. """ - ClassGroup.__init__(self, label, props, group) + ClassGroup.__init__(self, props, label, group) self.SetValue(value) @@ -621,7 +627,8 @@ and self.__value == other.__value def __repr__(self): - return "(" + repr(self.__value) + ", " + ClassGroup.__repr__(self) + ")" + return "ClassGroupSingleton(" + \ + repr(self.__value) + ", " + ClassGroup.__repr__(self) + ")" class ClassGroupDefault(ClassGroup): """The default Group. When values do not match any other @@ -637,7 +644,7 @@ label -- a label for this group. """ - ClassGroup.__init__(self, label, props, group) + ClassGroup.__init__(self, props, label, group) def __copy__(self): return ClassGroupDefault(self.GetProperties(), self.GetLabel()) @@ -661,7 +668,7 @@ and self.GetProperties() == other.GetProperties() def __repr__(self): - return "(" + ClassGroup.__repr__(self) + ")" + return "ClassGroupDefault(" + ClassGroup.__repr__(self) + ")" class ClassGroupRange(ClassGroup): """A Group that represents a range of values that map to the same @@ -673,6 +680,8 @@ The minumum value must be strictly less than the maximum. _range -- either a tuple (min, max) where min < max or + a tuple (left, min, max, right) where left and rigtht + are brackets ('[' or ']') or a Range object prop -- a ClassGroupProperites object. If prop is None a default @@ -681,7 +690,7 @@ label -- a label for this group. """ - ClassGroup.__init__(self, label, props, group) + ClassGroup.__init__(self, props, label, group) self.SetRange(_range) def __copy__(self): @@ -722,6 +731,8 @@ """Set a new range. _range -- Either a tuple (min, max) where min < max or + a tuple (left, min, max, right) where left and rigtht + are brackets ('[' or ']') or a Range object. Raises ValueError on error. @@ -731,6 +742,8 @@ self.__range = _range elif isinstance(_range, types.TupleType) and len(_range) == 2: self.__range = Range(("[", _range[0], _range[1], "[")) + elif isinstance(_range, types.TupleType) and len(_range) == 4: + self.__range = Range((_range[0], _range[1], _range[2], _range[3])) else: raise ValueError() @@ -762,8 +775,9 @@ and self.__range == other.__range def __repr__(self): - return "(" + str(self.__range) + ClassGroup.__repr__(self) + ")" + return "ClassGroupRange(" + repr(self.__range.GetRange()) + ", " + ClassGroup.__repr__(self) + ")" + class ClassGroupPattern(ClassGroup): """A Group that is associated with a reg exp pattern.""" @@ -777,7 +791,7 @@ label -- a label for this group. """ - ClassGroup.__init__(self, label, props, group) + ClassGroup.__init__(self, props, label, group) self.SetPattern(pattern) @@ -820,7 +834,7 @@ and self.__pattern == other.__pattern def __repr__(self): - return "(" + repr(self.__pattern) + ", " + ClassGroup.__repr__(self) + ")" + return "ClassGroupPattern(" + repr(self.__pattern) + " , " + ClassGroup.__repr__(self) + ")" class ClassGroupMap(ClassGroup): """Currently, this class is not used.""" @@ -828,7 +842,7 @@ FUNC_ID = "id" def __init__(self, map_type = FUNC_ID, func = None, prop = None, label=""): - ClassGroup.__init__(self, label) + ClassGroup.__init__(self, prop, label) self.map_type = map_type self.func = func Index: Thuban/UI/classifier.py =================================================================== --- Thuban/UI/classifier.py (revision 2688) +++ Thuban/UI/classifier.py (working copy) @@ -1167,7 +1167,7 @@ wxDialog.__init__(self, parent, -1, _("Select Properties"), style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) - self.prop = ClassGroupProperties(prop) + self.prop = ClassGroupProperties().SetProperties(prop) topBox = wxBoxSizer(wxVERTICAL)