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

Diff of /branches/WIP-pyshapelib-bramz/Thuban/Model/label.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2562 by bh, Tue Jul 30 14:15:39 2002 UTC revision 2563 by jan, Wed Feb 16 23:13:19 2005 UTC
# Line 1  Line 1 
1  # Copyright (c) 2001, 2002 by Intevation GmbH  # Copyright (c) 2001, 2002, 2005 by Intevation GmbH
2  # Authors:  # Authors:
3  # Bernhard Herzog <[email protected]>  # Bernhard Herzog <[email protected]>
4  #  #
# Line 7  Line 7 
7    
8  __version__ = "$Revision$"  __version__ = "$Revision$"
9    
10    from Thuban import _
11    
12  from messages import CHANGED  from messages import CHANGED
13    
14  from base import TitledObject, Modifiable  from base import TitledObject, Modifiable
# Line 20  ALIGN_BASELINE = "baseline" Line 22  ALIGN_BASELINE = "baseline"
22    
23  class Label:  class Label:
24    
25        """This class repesents a single label that is
26        defined by its coordinate, the text as well
27        as vertical and horizontal alignment concerning
28        the coordinate."""
29    
30      def __init__(self, x, y, text, halign, valign):      def __init__(self, x, y, text, halign, valign):
31            """Initialize the label with the given parameters."""
32          self.x = x          self.x = x
33          self.y = y          self.y = y
34          self.text = text          self.text = text
# Line 30  class Label: Line 38  class Label:
38    
39  class LabelLayer(TitledObject, Modifiable):  class LabelLayer(TitledObject, Modifiable):
40    
41        """This represent a layer holding a number of labels."""
42    
43      def __init__(self, title):      def __init__(self, title):
44            """Initialize the LabeleLayer with an empty
45            list of labels and set the title to "title".
46            """
47          TitledObject.__init__(self, title)          TitledObject.__init__(self, title)
48          Modifiable.__init__(self)          Modifiable.__init__(self)
49          self.labels = []          self.labels = []
50    
51      def Labels(self):      def Labels(self):
52            """Return a list of all labels."""
53          return self.labels          return self.labels
54    
55      def AddLabel(self, x, y, text, halign = "left", valign="center"):      def AddLabel(self, x, y, text, halign = ALIGN_LEFT,
56                     valign = ALIGN_CENTER):
57            """Add a label at position (x,y) with contents "text".
58    
59            This will emit a CHANGED signal.
60            """
61          self.labels.append(Label(x, y, text, halign, valign))          self.labels.append(Label(x, y, text, halign, valign))
62          self.changed(CHANGED)          self.changed(CHANGED)
63    
64      def RemoveLabel(self, index):      def RemoveLabel(self, index):
65            """Remove the label specified by index.
66    
67            This will emit a CHANGED signal.
68            """
69          del self.labels[index]          del self.labels[index]
70          self.changed(CHANGED)          self.changed(CHANGED)
71    
72      def ClearLabels(self):      def ClearLabels(self):
73          """Remove all labels"""          """Remove all labels.
74    
75            This will emit a CHANGED signal.
76            """
77          del self.labels[:]          del self.labels[:]
78          self.changed(CHANGED)          self.changed(CHANGED)
79    
80        def TreeInfo(self):
81            """Return a tuple of (title, tupel) describing the contents
82            of the object in a tree-structure.
83            """
84            items = []
85            items.append(_("Number of labels: %d") % len(self.labels))
86            return (_("Label Layer: %s") % self.title, items)

Legend:
Removed from v.2562  
changed lines
  Added in v.2563

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26