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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2734 - (hide annotations)
Thu Mar 1 12:42:59 2007 UTC (18 years ago) by bramz
File MIME type: text/x-python
File size: 2409 byte(s)
made a copy
1 jan 2563 # Copyright (c) 2001, 2002, 2005 by Intevation GmbH
2 bh 6 # Authors:
3     # Bernhard Herzog <[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 jan 2563 from Thuban import _
11    
12 bh 6 from messages import CHANGED
13    
14     from base import TitledObject, Modifiable
15    
16     ALIGN_CENTER = "center"
17     ALIGN_TOP = "top"
18     ALIGN_BOTTOM = "bottom"
19     ALIGN_LEFT = "left"
20     ALIGN_RIGHT = "right"
21     ALIGN_BASELINE = "baseline"
22 bh 248
23 bh 6 class Label:
24    
25 jan 2569 """This class repesents a single label.
26    
27     The label is defined by its coordinate, the text as well
28 jan 2563 as vertical and horizontal alignment concerning
29 jan 2569 the coordinate.
30     """
31 jan 2563
32 bh 6 def __init__(self, x, y, text, halign, valign):
33 jan 2563 """Initialize the label with the given parameters."""
34 bh 6 self.x = x
35     self.y = y
36     self.text = text
37     self.halign = halign
38     self.valign = valign
39    
40    
41     class LabelLayer(TitledObject, Modifiable):
42    
43 jan 2563 """This represent a layer holding a number of labels."""
44    
45 bh 6 def __init__(self, title):
46 jan 2569 """Initialize the LabeleLayer.
47    
48     Initialization is done with an empty
49 jan 2563 list of labels and set the title to "title".
50     """
51 bh 6 TitledObject.__init__(self, title)
52     Modifiable.__init__(self)
53     self.labels = []
54    
55     def Labels(self):
56 jan 2563 """Return a list of all labels."""
57 bh 6 return self.labels
58    
59 jan 2563 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 bh 6 self.labels.append(Label(x, y, text, halign, valign))
66     self.changed(CHANGED)
67    
68     def RemoveLabel(self, index):
69 jan 2563 """Remove the label specified by index.
70    
71     This will emit a CHANGED signal.
72     """
73 bh 6 del self.labels[index]
74     self.changed(CHANGED)
75 bh 248
76     def ClearLabels(self):
77 jan 2563 """Remove all labels.
78    
79     This will emit a CHANGED signal.
80     """
81 bh 248 del self.labels[:]
82     self.changed(CHANGED)
83 jan 2563
84     def TreeInfo(self):
85 jan 2569 """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 jan 2563 """
90     items = []
91     items.append(_("Number of labels: %d") % len(self.labels))
92     return (_("Label Layer: %s") % self.title, items)

Properties

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26