source:
trunk/workshop-routing-foss4g/web/OpenLayers/lib/OpenLayers/Strategy.js
@
81
Revision 76, 3.0 KB checked in by djay, 13 years ago (diff) | |
---|---|
|
Line | |
---|---|
1 | /* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for |
2 | * full list of contributors). Published under the Clear BSD license. |
3 | * See http://svn.openlayers.org/trunk/openlayers/license.txt for the |
4 | * full text of the license. */ |
5 | |
6 | /** |
7 | * Class: OpenLayers.Strategy |
8 | * Abstract vector layer strategy class. Not to be instantiated directly. Use |
9 | * one of the strategy subclasses instead. |
10 | */ |
11 | OpenLayers.Strategy = OpenLayers.Class({ |
12 | |
13 | /** |
14 | * Property: layer |
15 | * {<OpenLayers.Layer.Vector>} The layer this strategy belongs to. |
16 | */ |
17 | layer: null, |
18 | |
19 | /** |
20 | * Property: options |
21 | * {Object} Any options sent to the constructor. |
22 | */ |
23 | options: null, |
24 | |
25 | /** |
26 | * Property: active |
27 | * {Boolean} The control is active. |
28 | */ |
29 | active: null, |
30 | |
31 | /** |
32 | * Property: autoActivate |
33 | * {Boolean} The creator of the strategy can set autoActivate to false |
34 | * to fully control when the protocol is activated and deactivated. |
35 | * Defaults to true. |
36 | */ |
37 | autoActivate: true, |
38 | |
39 | /** |
40 | * Property: autoDestroy |
41 | * {Boolean} The creator of the strategy can set autoDestroy to false |
42 | * to fully control when the strategy is destroyed. Defaults to |
43 | * true. |
44 | */ |
45 | autoDestroy: true, |
46 | |
47 | /** |
48 | * Constructor: OpenLayers.Strategy |
49 | * Abstract class for vector strategies. Create instances of a subclass. |
50 | * |
51 | * Parameters: |
52 | * options - {Object} Optional object whose properties will be set on the |
53 | * instance. |
54 | */ |
55 | initialize: function(options) { |
56 | OpenLayers.Util.extend(this, options); |
57 | this.options = options; |
58 | // set the active property here, so that user cannot override it |
59 | this.active = false; |
60 | }, |
61 | |
62 | /** |
63 | * APIMethod: destroy |
64 | * Clean up the strategy. |
65 | */ |
66 | destroy: function() { |
67 | this.deactivate(); |
68 | this.layer = null; |
69 | this.options = null; |
70 | }, |
71 | |
72 | /** |
73 | * Method: setLayer |
74 | * Called to set the <layer> property. |
75 | * |
76 | * Parameters: |
77 | * {<OpenLayers.Layer.Vector>} |
78 | */ |
79 | setLayer: function(layer) { |
80 | this.layer = layer; |
81 | }, |
82 | |
83 | /** |
84 | * Method: activate |
85 | * Activate the strategy. Register any listeners, do appropriate setup. |
86 | * |
87 | * Returns: |
88 | * {Boolean} True if the strategy was successfully activated or false if |
89 | * the strategy was already active. |
90 | */ |
91 | activate: function() { |
92 | if (!this.active) { |
93 | this.active = true; |
94 | return true; |
95 | } |
96 | return false; |
97 | }, |
98 | |
99 | /** |
100 | * Method: deactivate |
101 | * Deactivate the strategy. Unregister any listeners, do appropriate |
102 | * tear-down. |
103 | * |
104 | * Returns: |
105 | * {Boolean} True if the strategy was successfully deactivated or false if |
106 | * the strategy was already inactive. |
107 | */ |
108 | deactivate: function() { |
109 | if (this.active) { |
110 | this.active = false; |
111 | return true; |
112 | } |
113 | return false; |
114 | }, |
115 | |
116 | CLASS_NAME: "OpenLayers.Strategy" |
117 | }); |
Note: See TracBrowser
for help on using the repository browser.