[OpenLayers-Commits] r4191 - sandbox/ahocevar/sldRenderer/lib/OpenLayers/Format/SLD

commits at openlayers.org commits at openlayers.org
Wed Sep 5 18:32:29 EDT 2007


Author: ahocevar
Date: 2007-09-05 18:32:28 -0400 (Wed, 05 Sep 2007)
New Revision: 4191

Modified:
   sandbox/ahocevar/sldRenderer/lib/OpenLayers/Format/SLD/Rule.js
Log:
further work on object design

Modified: sandbox/ahocevar/sldRenderer/lib/OpenLayers/Format/SLD/Rule.js
===================================================================
--- sandbox/ahocevar/sldRenderer/lib/OpenLayers/Format/SLD/Rule.js	2007-09-04 21:21:55 UTC (rev 4190)
+++ sandbox/ahocevar/sldRenderer/lib/OpenLayers/Format/SLD/Rule.js	2007-09-05 22:32:28 UTC (rev 4191)
@@ -40,6 +40,12 @@
      */
     elseFilter: null,
     
+    /**
+     * Property: ifClause
+     * {String}
+     */
+    ifClause: null,
+    
 
     /** 
      * Constructor: OpenLayers.Rule
@@ -53,11 +59,12 @@
      * Return:
      * {<OpenLayers.Rule>}
      */
-    initialize: function(layer, lonlat, data) {
-        this.layer = layer;
-        this.lonlat = lonlat;
-        this.data = (data != null) ? data : {};
-        this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); 
+    initialize: function(name, style, constraints) {
+        this.name = name;
+        this.style = style;
+        for (var i in constraints) {
+          this[i] = constraints[i];
+        }
     },
 
     /** 
@@ -65,126 +72,27 @@
      * nullify references to prevent circular references and memory leaks
      */
     destroy: function() {
-
-        //remove the popup from the map
-        if ((this.layer != null) && (this.layer.map != null)) {
-            if (this.popup != null) {
-                this.layer.map.removePopup(this.popup);
-            }
-        }
-
-        if (this.events) {
-            this.events.destroy();
-        }
-        this.events = null;
-        
-        this.layer = null;
-        this.id = null;
-        this.lonlat = null;
-        this.data = null;
-        if (this.marker != null) {
-            this.destroyMarker(this.marker);
-            this.marker = null;
-        }
-        if (this.popup != null) {
-            this.destroyPopup(this.popup);
-            this.popup = null;
-        }
+        this.name = null;
+        this.style = null;
+        this.fid = null;
+        this.minScaleDenominator = null;
+        this.maxScaleDenominator = null;
+        this.ifFilter = null;
+        this.elseFilter = null;
+        this.ifClause = null;
     },
     
     /**
-     * Method: onScreen
-     * 
-     * Returns:
-     * {Boolean} Whether or not the feature is currently visible on screen
-     *           (based on its 'lonlat' property)
-     */
-    onScreen:function() {
-        
-        var onScreen = false;
-        if ((this.layer != null) && (this.layer.map != null)) {
-            var screenBounds = this.layer.map.getExtent();
-            onScreen = screenBounds.containsLonLat(this.lonlat);
-        }    
-        return onScreen;
-    },
-    
-
-    /**
-     * Method: createMarker
-     * Based on the data associated with the Feature, create and return a marker object.
+     * APIMethod: getIfClause
+     * Calculates/caches and returns an eval'able if-clause for
+     * the constraints of this rule
      *
      * Return: 
-     * {<OpenLayers.Marker>} A Marker Object created from the 'lonlat' and 'icon' properties
-     *          set in this.data. If no 'lonlat' is set, returns null. If no
-     *          'icon' is set, OpenLayers.Marker() will load the default image.
-     *          
-     *          Note - this.marker is set to return value
+     * {String} Eval'able Javascript if clause
      * 
      */
-    createMarker: function() {
-
-        if (this.lonlat != null) {
-            this.marker = new OpenLayers.Marker(this.lonlat, this.data.icon);
-        }
-        return this.marker;
+    getIfClause: function() {
     },
 
-    /**
-     * Method: destroyMarker
-     * Destroys marker.
-     * If user overrides the createMarker() function, s/he should be able
-     *   to also specify an alternative function for destroying it
-     */
-    destroyMarker: function() {
-        this.marker.destroy();  
-    },
-
-    /**
-     * Method: createPopup
-     *  Creates a popup object created from the 'lonlat', 'popupSize',
-     *  and 'popupContentHTML' properties set in this.data. It uses
-     *  this.marker.icon as default anchor. 
-     *  
-     *  If no 'lonlat' is set, returns null. 
-     *  If no this.marker has been created, no anchor is sent.
-     * 
-     *  Note - this.popup is set to return value
-     * 
-     * Parameters: 
-     * closeBox - {Boolean} create popup with closebox or not
-     * 
-     * Returns:
-     * {<OpenLayers.Popup.AnchoredBubble>} 
-     * 
-     */
-    createPopup: function(closeBox) {
-
-        if (this.lonlat != null) {
-            
-            var id = this.id + "_popup";
-            var anchor = (this.marker) ? this.marker.icon : null;
-
-            this.popup = new OpenLayers.Popup.AnchoredBubble(id, 
-                                                    this.lonlat,
-                                                    this.data.popupSize,
-                                                    this.data.popupContentHTML,
-                                                    anchor, closeBox); 
-        }        
-        return this.popup;
-    },
-
-    
-    /**
-     * Method: destroyPopup
-     * Destroys the popup created via createPopup.
-     *
-     * As with the marker, if user overrides the createPopup() function, s/he 
-     *   should also be able to override the destruction
-     */
-    destroyPopup: function() {
-        this.popup.destroy() 
-    },
-
     CLASS_NAME: "OpenLayers.Format.SLD.Rule"
 });



More information about the Commits mailing list