gvsig-scripting / org.gvsig.scripting.app / trunk / org.gvsig.scripting.app / org.gvsig.scripting.app.extension / src / main / resources-plugin / scripting / lib / gvsig21 / view.py @ 442
History | View | Annotate | Download (3.66 KB)
1 |
|
---|---|
2 |
|
3 |
__docformat__ = "restructuredtext en"
|
4 |
|
5 |
|
6 |
from org.gvsig.app.project.documents.view import DefaultViewDocument as JViewDocument |
7 |
|
8 |
class ViewDocument(JViewDocument): |
9 |
"""
|
10 |
|
11 |
Represents gvSIG view document
|
12 |
|
13 |
Extends the java class DefaultViewDocument_
|
14 |
|
15 |
.. _DefaultViewDocument : FIXME_URL
|
16 |
"""
|
17 |
|
18 |
def getLayer(self, name=None): |
19 |
"""
|
20 |
Return a layer of the view document.
|
21 |
|
22 |
If don't pecified a layer name, return the current layer of
|
23 |
the view. If has more than one active layer return None.
|
24 |
If spacified a layer name and exists a layer with this name,
|
25 |
return this, otherwise return None.
|
26 |
|
27 |
:parameters:
|
28 |
name : string
|
29 |
optional name of the layer to retrieve, if not pased return active layer.
|
30 |
:returns:
|
31 |
the layer or None
|
32 |
:returntype:
|
33 |
Layer_
|
34 |
.. _layer : FIXME_URL
|
35 |
"""
|
36 |
mapContext = self.getMapContext();
|
37 |
if name == None: |
38 |
activeLayers = mapContext.getLayers().getActives() |
39 |
if len(activeLayers) != 1 : |
40 |
return None |
41 |
for layer in activeLayers: |
42 |
if not isinstance(layer, FLayers): |
43 |
return layer
|
44 |
return None |
45 |
layers = self.getLayers()
|
46 |
for i in xrange(layers.getLayersCount()): |
47 |
layer = layers.getLayer(i) |
48 |
if layer.name == name:
|
49 |
return layer
|
50 |
return None |
51 |
|
52 |
def getMap(self): |
53 |
"""
|
54 |
Return the map definition asociated to the view.
|
55 |
|
56 |
This contains the layers, projection and definition
|
57 |
of the area to view.
|
58 |
|
59 |
:returns:
|
60 |
the map definition
|
61 |
:returntype:
|
62 |
MapContext_
|
63 |
|
64 |
.. _MapContext : FIXME_URL
|
65 |
"""
|
66 |
return self.getMapContext(); |
67 |
|
68 |
def addLayer(self, layer): |
69 |
"""
|
70 |
Add a new layer to the view.
|
71 |
|
72 |
Don't return any thing.
|
73 |
|
74 |
:parameters:
|
75 |
layer : Layer_
|
76 |
the layer to add to the view
|
77 |
|
78 |
.. _Layer : FIXME_URL
|
79 |
"""
|
80 |
self.getMapContext().getLayers().addLayer(layer)
|
81 |
|
82 |
def getLayers(self): |
83 |
"""
|
84 |
Return a iterable set of \p Layers from the view.
|
85 |
|
86 |
:returns:
|
87 |
a Layers object
|
88 |
:returntype:
|
89 |
Layers_
|
90 |
|
91 |
.. _Layers : FIXME_URL
|
92 |
"""
|
93 |
mapContext = self.getMapContext()
|
94 |
return mapContext.getLayers()
|
95 |
|
96 |
def getGraphicsLayer(self): |
97 |
"""
|
98 |
Return the graphics layer of the view.
|
99 |
|
100 |
:returns:
|
101 |
a the graphics layer
|
102 |
:returntype:
|
103 |
DefaultGraphicLayer_
|
104 |
|
105 |
.. _DefaultGraphicLayer : FIXME_URL
|
106 |
"""
|
107 |
return self.getMapContext().getGraphicsLayer() |
108 |
|
109 |
def getProjectionCode(self): |
110 |
"""
|
111 |
Returns Project projection code name of the view as a string.
|
112 |
|
113 |
:return:
|
114 |
the projection code as a string.
|
115 |
:returntype:
|
116 |
String
|
117 |
"""
|
118 |
return self.getProjection().getFullCode() |
119 |
|
120 |
def isProjected(self): |
121 |
"""
|
122 |
Returns if the coordinate system of the view is projected.
|
123 |
|
124 |
:return:
|
125 |
true if the coordinate system of the view is projected, otherwise return false.
|
126 |
:returntype:
|
127 |
boolean
|
128 |
"""
|
129 |
self.getProjection().isProjected()
|
130 |
|
131 |
def __call__(self): |
132 |
"""
|
133 |
Return the java object represented by this object.
|
134 |
|
135 |
This method is for compatibility with scripting API of gvSIG 2.0
|
136 |
|
137 |
:ReturnType:
|
138 |
ViewDocument
|
139 |
:deprecated:
|
140 |
With gvSIG 2.1 the call this method isn't necesary
|
141 |
|
142 |
"""
|
143 |
return self |
144 |
|
145 |
|
146 |
|
147 |
#
|
148 |
# Inject new methods in the class JViewDocument
|
149 |
#
|
150 |
JViewDocument.getLayer = ViewDocument.getLayer |
151 |
JViewDocument.getMap = ViewDocument.getMap |
152 |
JViewDocument.addLayer = ViewDocument.addLayer |
153 |
JViewDocument.getGraphicsLayer = ViewDocument.getGraphicsLayer |
154 |
JViewDocument.getProjectionCode = ViewDocument.getProjectionCode |
155 |
JViewDocument.isProjected = ViewDocument.isProjected |
156 |
JViewDocument.__call__ = ViewDocument.__call__ |
157 |
|
158 |
|