/[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 6 by bh, Tue Aug 28 15:41:52 2001 UTC revision 2569 by jan, Thu Feb 17 11:02:28 2005 UTC
# Line 1  Line 1 
1  # Copyright (c) 2001 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 17  ALIGN_BOTTOM = "bottom" Line 19  ALIGN_BOTTOM = "bottom"
19  ALIGN_LEFT = "left"  ALIGN_LEFT = "left"
20  ALIGN_RIGHT = "right"  ALIGN_RIGHT = "right"
21  ALIGN_BASELINE = "baseline"  ALIGN_BASELINE = "baseline"
22            
23  class Label:  class Label:
24    
25        """This class repesents a single label.
26    
27        The label is defined by its coordinate, the text as well
28        as vertical and horizontal alignment concerning
29        the coordinate.
30        """
31    
32      def __init__(self, x, y, text, halign, valign):      def __init__(self, x, y, text, halign, valign):
33            """Initialize the label with the given parameters."""
34          self.x = x          self.x = x
35          self.y = y          self.y = y
36          self.text = text          self.text = text
# Line 30  class Label: Line 40  class Label:
40    
41  class LabelLayer(TitledObject, Modifiable):  class LabelLayer(TitledObject, Modifiable):
42    
43        """This represent a layer holding a number of labels."""
44    
45      def __init__(self, title):      def __init__(self, title):
46            """Initialize the LabeleLayer.
47    
48            Initialization is done with an empty
49            list of labels and set the title to "title".
50            """
51          TitledObject.__init__(self, title)          TitledObject.__init__(self, title)
52          Modifiable.__init__(self)          Modifiable.__init__(self)
53          self.labels = []          self.labels = []
54    
55      def Labels(self):      def Labels(self):
56            """Return a list of all labels."""
57          return self.labels          return self.labels
58    
59      def AddLabel(self, x, y, text, halign = "left", valign="center"):      def AddLabel(self, x, y, text, halign = ALIGN_LEFT,
60                     valign = ALIGN_CENTER):
61            """Add a label at position (x,y) with contents "text".
62    
63            This will emit a CHANGED signal.
64            """
65          self.labels.append(Label(x, y, text, halign, valign))          self.labels.append(Label(x, y, text, halign, valign))
66          self.changed(CHANGED)          self.changed(CHANGED)
67    
68      def RemoveLabel(self, index):      def RemoveLabel(self, index):
69            """Remove the label specified by index.
70    
71            This will emit a CHANGED signal.
72            """
73          del self.labels[index]          del self.labels[index]
74          self.changed(CHANGED)          self.changed(CHANGED)
75    
76        def ClearLabels(self):
77            """Remove all labels.
78    
79            This will emit a CHANGED signal.
80            """
81            del self.labels[:]
82            self.changed(CHANGED)
83    
84        def TreeInfo(self):
85            """Return a description of the object.
86    
87            A tuple of (title, tupel) describing the contents
88            of the object in a tree-structure is returned.
89            """
90            items = []
91            items.append(_("Number of labels: %d") % len(self.labels))
92            return (_("Label Layer: %s") % self.title, items)

Legend:
Removed from v.6  
changed lines
  Added in v.2569

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26