/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/Model/classification.py
ViewVC logotype

Annotation of /branches/WIP-pyshapelib-bramz/Thuban/Model/classification.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 491 - (hide annotations)
Mon Mar 10 10:44:42 2003 UTC (22 years ago) by jonathan
Original Path: trunk/thuban/Thuban/Model/classification.py
File MIME type: text/x-python
File size: 22029 byte(s)
(Classification): Don't use
        layer's message function directly, use the ClassChanged() method
        when then classification changes. SetField/SetFieldType/SetLayer
        must keep the information about field name and field type in
        sync when an owning layer is set or removed.

1 bh 453 # Copyright (c) 2001, 2003 by Intevation GmbH
2 jonathan 371 # Authors:
3     # Jonathan Coles <[email protected]>
4     #
5     # This program is free software under the GPL (>=v2)
6     # Read the file COPYING coming with Thuban for details.
7    
8     __version__ = "$Revision$"
9    
10     """
11     A Classification provides a mapping from an input value
12     to data. This mapping can be specified in two ways.
13     First, specific values can be associated with data.
14     Second, ranges can be associated with data such that if
15     an input value falls with a range that data is returned.
16 jonathan 388 If no mapping can be found then default data will
17 jonathan 371 be returned. Input values must be hashable objects
18    
19 jonathan 449 See the description of GetGroup() for more information
20 jonathan 371 on the mapping algorithm.
21     """
22    
23 jonathan 397 # fix for people using python2.1
24     from __future__ import nested_scopes
25    
26 jonathan 484 import copy
27    
28 jonathan 436 from types import *
29    
30 jonathan 388 from messages import LAYER_PROJECTION_CHANGED, LAYER_LEGEND_CHANGED, \
31     LAYER_VISIBILITY_CHANGED
32    
33 jan 374 from Thuban import _
34 jonathan 381 from Thuban.Model.color import Color
35 jan 374
36 jonathan 436 import Thuban.Model.layer
37    
38 jonathan 371 # constants
39     RANGE_MIN = 0
40     RANGE_MAX = 1
41     RANGE_DATA = 2
42    
43     class Classification:
44 jonathan 462 """Encapsulates the classification of layer. The Classification
45     divides some kind of data into Groups which are associated with
46     properties. Later the properties can be retrieved by matching
47     data values to the appropriate group."""
48 jonathan 371
49 jonathan 410 def __init__(self, layer = None, field = None):
50 jonathan 371 """Initialize a classification.
51    
52 jonathan 462 layer -- the Layer object who owns this classification
53 jonathan 388
54 jonathan 371 field -- the name of the data table field that
55     is to be used to classify layer properties
56     """
57    
58 jonathan 462 self.layer = None
59     self.field = None
60     self.fieldType = None
61     self.groups = []
62 jonathan 436
63     self.SetDefaultGroup(ClassGroupDefault())
64 jonathan 491
65 jonathan 462 self.SetLayer(layer)
66 jonathan 436 self.SetField(field)
67    
68 jonathan 428 def __iter__(self):
69 jonathan 462 return ClassIterator(self.groups)
70 jonathan 428
71 jonathan 491 def __SendNotification(self):
72     """Notify the layer that this class has changed."""
73     if self.layer is not None:
74     self.layer.ClassChanged()
75 jonathan 410
76 jonathan 491 def SetField(self, field):
77 jonathan 371 """Set the name of the data table field to use.
78    
79 jonathan 479 If there is no layer then the field type is set to None,
80     otherwise the layer is queried to find the type of the
81     field data
82    
83 jonathan 388 field -- if None then all values map to the default data
84 jonathan 371 """
85    
86 jonathan 436 if field == "":
87     field = None
88    
89 jonathan 462
90 jonathan 491 if field is None:
91     if self.layer is not None:
92     self.fieldType = None
93 jonathan 462 else:
94 jonathan 491 if self.layer is not None:
95     fieldType = self.layer.GetFieldType(field)
96     if fieldType is None:
97     raise ValueError("'%s' was not found in the layer's table."
98     % self.field)
99 jonathan 462
100 jonathan 491 #
101     # unfortunately we cannot call SetFieldType() because it
102     # requires the layer to be None
103     #
104     self.fieldType = fieldType
105     #self.SetFieldType(fieldType)
106 jonathan 462
107 jonathan 491 self.field = field
108 jonathan 462
109 jonathan 491 self.__SendNotification()
110 jonathan 371
111 jonathan 388 def GetField(self):
112 jonathan 462 """Return the name of the field."""
113 jonathan 388 return self.field
114    
115 jonathan 462 def GetFieldType(self):
116     """Return the field type."""
117     return self.fieldType
118    
119     def SetFieldType(self, type):
120 jonathan 491 """Set the type of the field used by this classification.
121 jonathan 462
122 jonathan 491 A ValueError is raised if the owning layer is not None and
123     'type' is different from the current field type.
124     """
125    
126     if type != self.fieldType:
127     if self.layer is not None:
128     raise ValueError()
129     else:
130     self.fieldType = type
131     self.__SendNotification()
132    
133 jonathan 410 def SetLayer(self, layer):
134 jonathan 491 """Set the owning Layer of this classification.
135    
136     A ValueError exception will be thrown either the field or
137     field type mismatch the information in the layer's table.
138     """
139 jonathan 462
140 jonathan 491 if layer is None:
141     if self.layer is not None:
142     l = self.layer
143     self.layer = None
144     l.SetClassification(None)
145     else:
146     assert(isinstance(layer, Thuban.Model.layer.Layer))
147 jonathan 462
148 jonathan 491 # prevent infinite recursion when calling SetClassification()
149     if layer == self.layer:
150     return
151    
152     old_layer = self.layer
153 jonathan 479
154 jonathan 491 self.layer = layer
155 jonathan 462
156 jonathan 491 try:
157     self.SetField(self.GetField()) # this sync's the fieldType
158     except ValueError:
159     self.layer = old_layer
160     raise ValueError
161     else:
162     self.layer.SetClassification(self)
163 jonathan 410
164     def GetLayer(self):
165 jonathan 462 """Return the parent layer."""
166     return self.layer
167 jonathan 410
168 jonathan 436 def SetDefaultGroup(self, group):
169     """Set the group to be used when a value can't be classified.
170 jonathan 371
171 jonathan 462 group -- group that the value maps to.
172 jonathan 371 """
173    
174 jonathan 436 assert(isinstance(group, ClassGroupDefault))
175 jonathan 462 self.AddGroup(group)
176 jonathan 371
177 jonathan 436 def GetDefaultGroup(self):
178 jonathan 462 """Return the default group."""
179     return self.groups[0]
180 jonathan 385
181 jonathan 428 #
182     # these SetDefault* methods are really only provided for
183     # some backward compatibility. they should be considered
184     # for removal once all the classification code is finished.
185     #
186    
187 jonathan 388 def SetDefaultFill(self, fill):
188 jonathan 462 """Set the default fill color.
189    
190     fill -- a Color object.
191     """
192 jonathan 436 assert(isinstance(fill, Color))
193 jonathan 462 self.GetDefaultGroup().GetProperties().SetFill(fill)
194 jonathan 491 self.__SendNotification()
195 jonathan 388
196     def GetDefaultFill(self):
197 jonathan 462 """Return the default fill color."""
198     return self.GetDefaultGroup().GetProperties().GetFill()
199 jonathan 388
200 jonathan 462 def SetDefaultLineColor(self, color):
201     """Set the default line color.
202    
203     color -- a Color object.
204     """
205     assert(isinstance(color, Color))
206     self.GetDefaultGroup().GetProperties().SetLineColor(color)
207 jonathan 491 self.__SendNotification()
208 jonathan 388
209 jonathan 462 def GetDefaultLineColor(self):
210     """Return the default line color."""
211     return self.GetDefaultGroup().GetProperties().GetLineColor()
212 jonathan 388
213 jonathan 462 def SetDefaultLineWidth(self, lineWidth):
214     """Set the default line width.
215    
216     lineWidth -- an integer > 0.
217     """
218     assert(isinstance(lineWidth, IntType))
219     self.GetDefaultGroup().GetProperties().SetLineWidth(lineWidth)
220 jonathan 491 self.__SendNotification()
221 jonathan 388
222 jonathan 462 def GetDefaultLineWidth(self):
223     """Return the default line width."""
224     return self.GetDefaultGroup().GetProperties().GetLineWidth()
225 jonathan 388
226 jonathan 436 def AddGroup(self, item):
227 jonathan 462 """Add a new ClassGroup item to the classification.
228    
229     item -- this must be a valid ClassGroup object
230     """
231    
232 jonathan 436 assert(isinstance(item, ClassGroup))
233 jonathan 371
234 jonathan 462 if len(self.groups) > 0 and isinstance(item, ClassGroupDefault):
235     self.groups[0] = item
236 jonathan 410 else:
237 jonathan 462 self.groups.append(item)
238 jonathan 371
239 jonathan 491 self.__SendNotification()
240 jonathan 371
241 jonathan 436 def GetGroup(self, value):
242 jonathan 462 """Return the associated group, or the default group.
243 jonathan 371
244 jonathan 462 Groups are checked in the order the were added to the
245     Classification.
246 jonathan 371
247 jonathan 388 value -- the value to classify. If there is no mapping,
248 jonathan 479 the field is None or value is None,
249     return the default properties
250 jonathan 371 """
251    
252 jonathan 479 if self.GetField() is not None and value is not None:
253 jonathan 371
254 jonathan 462 for i in range(1, len(self.groups)):
255     group = self.groups[i]
256     if group.Matches(value):
257     return group
258 jonathan 371
259 jonathan 462 return self.GetDefaultGroup()
260 jonathan 371
261 jonathan 462 def GetProperties(self, value):
262     """Return the properties associated with the given value."""
263 jonathan 371
264 jonathan 462 group = self.GetGroup(value)
265     if isinstance(group, ClassGroupMap):
266     return group.GetPropertiesFromValue(value)
267     else:
268     return group.GetProperties()
269 jonathan 436
270 jonathan 381 def TreeInfo(self):
271     items = []
272 jonathan 378
273 jonathan 410 def build_color_item(text, color):
274     if color is Color.None:
275     return ("%s: %s" % (text, _("None")), None)
276 jonathan 381
277 jonathan 410 return ("%s: (%.3f, %.3f, %.3f)" %
278     (text, color.red, color.green, color.blue),
279     color)
280 jonathan 381
281 jonathan 436 def build_item(group, string):
282     label = group.GetLabel()
283 jonathan 410 if label == "":
284     label = string
285     else:
286     label += " (%s)" % string
287    
288 jonathan 436 props = group.GetProperties()
289 jonathan 381 i = []
290 jonathan 462 v = props.GetLineColor()
291     i.append(build_color_item(_("Line Color"), v))
292     v = props.GetLineWidth()
293     i.append(_("Line Width: %s") % v)
294 jonathan 436 v = props.GetFill()
295 jonathan 410 i.append(build_color_item(_("Fill"), v))
296     return (label, i)
297 jonathan 388
298 jonathan 428 for p in self:
299 jonathan 436 if isinstance(p, ClassGroupDefault):
300 jonathan 462 items.append(build_item(self.GetDefaultGroup(), _("'DEFAULT'")))
301 jonathan 436 elif isinstance(p, ClassGroupSingleton):
302 jonathan 428 items.append(build_item(p, str(p.GetValue())))
303 jonathan 436 elif isinstance(p, ClassGroupRange):
304 jonathan 428 items.append(build_item(p, "%s - %s" %
305     (p.GetMin(), p.GetMax())))
306 jonathan 388
307 jonathan 436 return (_("Classification"), items)
308 jonathan 381
309 jonathan 428 class ClassIterator:
310 jonathan 462 """Allows the Groups in a Classifcation to be interated over.
311 jonathan 388
312 jonathan 462 The items are returned in the following order:
313     default data, singletons, ranges, maps
314     """
315 jonathan 428
316 jonathan 462 def __init__(self, data): #default, points, ranges, maps):
317     """Constructor.
318    
319     default -- the default group
320    
321     points -- a list of singleton groups
322    
323     ranges -- a list of range groups
324    
325     maps -- a list of map groups
326     """
327    
328     self.data = data #[default, points, ranges, maps]
329     self.data_index = 0
330     #self.data_iter = iter(self.data)
331     #self.iter = None
332    
333 jonathan 428 def __iter__(self):
334     return self
335    
336     def next(self):
337 jonathan 462 """Return the next item."""
338 jonathan 428
339 jonathan 462 if self.data_index >= len(self.data):
340     raise StopIteration
341     else:
342     d = self.data[self.data_index]
343     self.data_index += 1
344     return d
345    
346     # if self.iter is None:
347     # try:
348     # self.data_item = self.data_iter.next()
349     # self.iter = iter(self.data_item)
350     # except TypeError:
351     # return self.data_item
352    
353     # try:
354     # return self.iter.next()
355     # except StopIteration:
356     # self.iter = None
357     # return self.next()
358 jonathan 428
359 jonathan 436 class ClassGroupProperties:
360 jonathan 462 """Represents the properties of a single Classification Group.
361    
362     These are used when rendering a layer."""
363 jonathan 388
364 jonathan 462 def __init__(self, props = None):
365     """Constructor.
366 jonathan 410
367 jonathan 462 props -- a ClassGroupProperties object. The class is copied if
368     prop is not None. Otherwise, a default set of properties
369 jonathan 479 is created such that: line color = Color.Black, line width = 1,
370     and fill color = Color.None
371 jonathan 462 """
372    
373     self.stroke = None
374     self.strokeWidth = 0
375     self.fill = None
376    
377     if props is not None:
378     self.SetProperties(props)
379 jonathan 410 else:
380 jonathan 484 self.SetLineColor(Color.Black)
381 jonathan 462 self.SetLineWidth(1)
382 jonathan 410 self.SetFill(Color.None)
383    
384 jonathan 462 def SetProperties(self, props):
385     """Set this class's properties to those in class props."""
386    
387     assert(isinstance(props, ClassGroupProperties))
388     self.SetLineColor(props.GetLineColor())
389     self.SetLineWidth(props.GetLineWidth())
390     self.SetFill(props.GetFill())
391    
392     def GetLineColor(self):
393     """Return the line color as a Color object."""
394 jonathan 388 return self.stroke
395    
396 jonathan 462 def SetLineColor(self, color):
397     """Set the line color.
398 jonathan 388
399 jonathan 462 color -- the color of the line. This must be a Color object.
400     """
401 jonathan 388
402 jonathan 462 assert(isinstance(color, Color))
403     self.stroke = color
404 jonathan 410
405 jonathan 462 def GetLineWidth(self):
406     """Return the line width."""
407     return self.strokeWidth
408 jonathan 388
409 jonathan 462 def SetLineWidth(self, lineWidth):
410     """Set the line width.
411    
412     lineWidth -- the new line width. This must be > 0.
413     """
414     assert(isinstance(lineWidth, IntType))
415     if (lineWidth < 1):
416     raise ValueError(_("lineWidth < 1"))
417    
418     self.strokeWidth = lineWidth
419    
420 jonathan 388 def GetFill(self):
421 jonathan 462 """Return the fill color as a Color object."""
422 jonathan 388 return self.fill
423    
424     def SetFill(self, fill):
425 jonathan 462 """Set the fill color.
426    
427     fill -- the color of the fill. This must be a Color object.
428     """
429    
430 jonathan 410 assert(isinstance(fill, Color))
431 jonathan 388 self.fill = fill
432    
433 jonathan 479 def __eq__(self, other):
434     """Return true if 'props' has the same attributes as this class"""
435 jonathan 436
436 jonathan 479 return isinstance(other, ClassGroupProperties) \
437     and self.stroke == other.GetLineColor() \
438     and self.strokeWidth == other.GetLineWidth() \
439     and self.fill == other.GetFill()
440    
441     def __ne__(self, other):
442     return not self.__eq__(other)
443    
444 jonathan 484 def __copy__(self):
445     return ClassGroupProperties(self)
446    
447 jonathan 436 class ClassGroup:
448 jonathan 462 """A base class for all Groups within a Classification"""
449 jonathan 436
450     def __init__(self, label = ""):
451 jonathan 462 """Constructor.
452 jonathan 436
453 jonathan 462 label -- A string representing the Group's label
454     """
455    
456     self.label = None
457    
458     self.SetLabel(label)
459    
460 jonathan 388 def GetLabel(self):
461 jonathan 462 """Return the Group's label."""
462 jonathan 388 return self.label
463    
464     def SetLabel(self, label):
465 jonathan 462 """Set the Group's label.
466    
467     label -- a string representing the Group's label. This must
468     not be None.
469     """
470     assert(isinstance(label, StringType))
471 jonathan 388 self.label = label
472    
473 jonathan 436 def Matches(self, value):
474 jonathan 462 """Determines if this Group is associated with the given value.
475    
476 jonathan 479 Returns False. This needs to be overridden by all subclasses.
477 jonathan 462 """
478 jonathan 479 return False
479 jonathan 436
480 jonathan 462 def GetProperties(self):
481     """Return the properties associated with the given value.
482    
483 jonathan 479 Returns None. This needs to be overridden by all subclasses.
484 jonathan 462 """
485 jonathan 479 return None
486 jonathan 436
487 jonathan 410
488 jonathan 436 class ClassGroupSingleton(ClassGroup):
489 jonathan 462 """A Group that is associated with a single value."""
490 jonathan 410
491 jonathan 436 def __init__(self, value = 0, prop = None, label = ""):
492 jonathan 462 """Constructor.
493    
494     value -- the associated value.
495    
496     prop -- a ClassGroupProperites object. If prop is None a default
497     set of properties is created.
498    
499     label -- a label for this group.
500     """
501 jonathan 436 ClassGroup.__init__(self, label)
502 jonathan 410
503 jonathan 462 self.prop = None
504     self.value = None
505    
506 jonathan 436 self.SetValue(value)
507     self.SetProperties(prop)
508 jonathan 410
509 jonathan 436 def __copy__(self):
510 jonathan 479 return ClassGroupSingleton(self.GetValue(),
511     self.GetProperties(),
512     self.GetLabel())
513 jonathan 436
514 jonathan 484 def __deepcopy__(self, memo):
515     return ClassGroupSingleton(copy.copy(self.GetValue()),
516     copy.copy(self.GetProperties()),
517     copy.copy(self.GetLabel()))
518    
519 jonathan 410 def GetValue(self):
520 jonathan 462 """Return the associated value."""
521 jonathan 410 return self.value
522    
523     def SetValue(self, value):
524 jonathan 462 """Associate this Group with the given value."""
525 jonathan 410 self.value = value
526    
527 jonathan 436 def Matches(self, value):
528 jonathan 462 """Determine if the given value matches the associated Group value."""
529    
530     """Returns True if the value matches, False otherwise."""
531    
532 jonathan 436 return self.value == value
533 jonathan 410
534 jonathan 462 def GetProperties(self):
535     """Return the Properties associated with this Group."""
536 jonathan 410
537 jonathan 462 return self.prop
538 jonathan 410
539 jonathan 436 def SetProperties(self, prop):
540 jonathan 462 """Set the properties associated with this Group.
541    
542     prop -- a ClassGroupProperties object. if prop is None,
543     a default set of properties is created.
544     """
545    
546 jonathan 436 if prop is None: prop = ClassGroupProperties()
547     assert(isinstance(prop, ClassGroupProperties))
548     self.prop = prop
549    
550 jonathan 479 def __eq__(self, other):
551     return isinstance(other, ClassGroupSingleton) \
552     and self.GetProperties() == other.GetProperties() \
553     and self.GetValue() == other.GetValue()
554 jonathan 436
555 jonathan 479 def __ne__(self, other):
556     return not self.__eq__(other)
557    
558     class ClassGroupDefault(ClassGroup):
559 jonathan 462 """The default Group. When values do not match any other
560     Group within a Classification, the properties from this
561     class are used."""
562    
563 jonathan 436 def __init__(self, prop = None, label = ""):
564 jonathan 462 """Constructor.
565    
566     prop -- a ClassGroupProperites object. If prop is None a default
567     set of properties is created.
568    
569     label -- a label for this group.
570     """
571    
572 jonathan 479 ClassGroup.__init__(self, label)
573     self.SetProperties(prop)
574 jonathan 436
575     def __copy__(self):
576 jonathan 479 return ClassGroupDefault(self.GetProperties(), self.GetLabel())
577 jonathan 436
578 jonathan 484 def __deepcopy__(self, memo):
579     return ClassGroupDefault(copy.copy(self.GetProperties()),
580     copy.copy(self.GetLabel()))
581    
582 jonathan 479 def Matches(self, value):
583     return True
584    
585 jonathan 462 def GetProperties(self):
586     """Return the Properties associated with this Group."""
587 jonathan 436 return self.prop
588    
589 jonathan 479 def SetProperties(self, prop):
590     """Set the properties associated with this Group.
591    
592     prop -- a ClassGroupProperties object. if prop is None,
593     a default set of properties is created.
594     """
595    
596     if prop is None: prop = ClassGroupProperties()
597     assert(isinstance(prop, ClassGroupProperties))
598     self.prop = prop
599    
600     def __eq__(self, other):
601     return isinstance(other, ClassGroupDefault) \
602     and self.GetProperties() == other.GetProperties()
603    
604     def __ne__(self, other):
605     return not self.__eq__(other)
606    
607 jonathan 436 class ClassGroupRange(ClassGroup):
608 jonathan 462 """A Group that represents a range of values that map to the same
609     set of properties."""
610 jonathan 436
611     def __init__(self, min = 0, max = 1, prop = None, label = ""):
612 jonathan 462 """Constructor.
613    
614     The minumum value must be strictly less than the maximum.
615    
616     min -- the minimum range value
617    
618     max -- the maximum range value
619    
620     prop -- a ClassGroupProperites object. If prop is None a default
621     set of properties is created.
622    
623     label -- a label for this group.
624     """
625    
626 jonathan 436 ClassGroup.__init__(self, label)
627    
628 jonathan 462 self.min = self.max = 0
629     self.prop = None
630    
631 jonathan 410 self.SetRange(min, max)
632 jonathan 436 self.SetProperties(prop)
633 jonathan 410
634 jonathan 436 def __copy__(self):
635 jonathan 479 return ClassGroupRange(self.GetMin(),
636     self.GetMax(),
637     self.GetProperties(),
638     self.GetLabel())
639 jonathan 436
640 jonathan 484 def __deepcopy__(self, memo):
641     return ClassGroupRange(copy.copy(self.GetMin()),
642     copy.copy(self.GetMax()),
643     copy.copy(self.GetProperties()),
644     copy.copy(self.GetLabel()))
645    
646 jonathan 410 def GetMin(self):
647 jonathan 462 """Return the range's minimum value."""
648 jonathan 410 return self.min
649    
650     def SetMin(self, min):
651 jonathan 462 """Set the range's minimum value.
652    
653     min -- the new minimum. Note that this must be less than the current
654     maximum value. Use SetRange() to change both min and max values.
655     """
656    
657 jonathan 410 self.SetRange(min, self.max)
658    
659     def GetMax(self):
660 jonathan 462 """Return the range's maximum value."""
661 jonathan 410 return self.max
662    
663     def SetMax(self, max):
664 jonathan 462 """Set the range's maximum value.
665    
666     max -- the new maximum. Note that this must be greater than the current
667     minimum value. Use SetRange() to change both min and max values.
668     """
669 jonathan 410 self.SetRange(self.min, max)
670    
671     def SetRange(self, min, max):
672 jonathan 462 """Set a new range.
673    
674     Note that min must be strictly less than max.
675    
676     min -- the new minimum value
677     min -- the new maximum value
678     """
679    
680 jonathan 436 if min >= max:
681     raise ValueError(_("ClassGroupRange: %i(min) >= %i(max)!") %
682     (min, max))
683 jonathan 410 self.min = min
684     self.max = max
685    
686     def GetRange(self):
687 jonathan 462 """Return the range as a tuple (min, max)"""
688 jonathan 410 return (self.min, self.max)
689    
690 jonathan 436 def Matches(self, value):
691 jonathan 462 """Determine if the given value lies with the current range.
692    
693     The following check is used: min <= value < max.
694     """
695    
696 jonathan 410 return self.min <= value < self.max
697    
698 jonathan 462 def GetProperties(self):
699     """Return the Properties associated with this Group."""
700     return self.prop
701 jonathan 410
702 jonathan 462 def SetProperties(self, prop):
703     """Set the properties associated with this Group.
704 jonathan 436
705 jonathan 462 prop -- a ClassGroupProperties object. if prop is None,
706     a default set of properties is created.
707     """
708 jonathan 436 if prop is None: prop = ClassGroupProperties()
709     assert(isinstance(prop, ClassGroupProperties))
710     self.prop = prop
711    
712 jonathan 479 def __eq__(self, other):
713     return isinstance(other, ClassGroupRange) \
714     and self.GetProperties() == other.GetProperties() \
715     and self.GetRange() == other.GetRange()
716    
717     def __ne__(self, other):
718     return not self.__eq__(other)
719    
720 jonathan 436 class ClassGroupMap(ClassGroup):
721 jonathan 462 """Currently, this class is not used."""
722 jonathan 436
723 jonathan 410 FUNC_ID = "id"
724    
725 jonathan 436 def __init__(self, map_type = FUNC_ID, func = None, prop = None, label=""):
726 jonathan 462 ClassGroup.__init__(self, label)
727 jonathan 410
728     self.map_type = map_type
729     self.func = func
730    
731     if self.func is None:
732     self.func = func_id
733    
734     def Map(self, value):
735     return self.func(value)
736    
737 jonathan 462 def GetProperties(self):
738     return None
739    
740     def GetPropertiesFromValue(self, value):
741     pass
742    
743 jonathan 410 #
744     # built-in mappings
745     #
746     def func_id(value):
747     return value
748    

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26