/[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 2563 - (hide annotations)
Wed Feb 16 23:13:19 2005 UTC (20 years ago) by jan
Original Path: trunk/thuban/Thuban/Model/label.py
File MIME type: text/x-python
File size: 2314 byte(s)
Added import of _.
(Label, Label.__init__): Improved/added doc string.
LabelLayer, LabelLayer.__init__, LabelLayer.Labels,
LabelLayer.RemoveLabel, LabelLayer.ClearLabels):
Improved/added doc string.
(LabelLayer.AddLabel): Use already defined names for
align strings and improved doc string.
(LabelLayer.TreeInfo): New. Return the object data for
the tree view.

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 2563 """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 bh 6 def __init__(self, x, y, text, halign, valign):
31 jan 2563 """Initialize the label with the given parameters."""
32 bh 6 self.x = x
33     self.y = y
34     self.text = text
35     self.halign = halign
36     self.valign = valign
37    
38    
39     class LabelLayer(TitledObject, Modifiable):
40    
41 jan 2563 """This represent a layer holding a number of labels."""
42    
43 bh 6 def __init__(self, title):
44 jan 2563 """Initialize the LabeleLayer with an empty
45     list of labels and set the title to "title".
46     """
47 bh 6 TitledObject.__init__(self, title)
48     Modifiable.__init__(self)
49     self.labels = []
50    
51     def Labels(self):
52 jan 2563 """Return a list of all labels."""
53 bh 6 return self.labels
54    
55 jan 2563 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 bh 6 self.labels.append(Label(x, y, text, halign, valign))
62     self.changed(CHANGED)
63    
64     def RemoveLabel(self, index):
65 jan 2563 """Remove the label specified by index.
66    
67     This will emit a CHANGED signal.
68     """
69 bh 6 del self.labels[index]
70     self.changed(CHANGED)
71 bh 248
72     def ClearLabels(self):
73 jan 2563 """Remove all labels.
74    
75     This will emit a CHANGED signal.
76     """
77 bh 248 del self.labels[:]
78     self.changed(CHANGED)
79 jan 2563
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)

Properties

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26