[Commits] r1758 - in sandbox/redlining/ux/FeatureEditing: examples ux/widgets/form

commits at geoext.org commits at geoext.org
Fri Jan 15 21:03:26 CET 2010


Author: adube
Date: 2010-01-15 21:03:26 +0100 (Fri, 15 Jan 2010)
New Revision: 1758

Modified:
   sandbox/redlining/ux/FeatureEditing/examples/RedLiningPanelExample.js
   sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeatureEditingPanel.js
   sandbox/redlining/ux/FeatureEditing/ux/widgets/form/RedLiningPanel.js
Log:
style can now be defined, opacity support impl. (need more work)

Modified: sandbox/redlining/ux/FeatureEditing/examples/RedLiningPanelExample.js
===================================================================
--- sandbox/redlining/ux/FeatureEditing/examples/RedLiningPanelExample.js	2010-01-15 14:51:15 UTC (rev 1757)
+++ sandbox/redlining/ux/FeatureEditing/examples/RedLiningPanelExample.js	2010-01-15 20:03:26 UTC (rev 1758)
@@ -11,10 +11,14 @@
         zoom: 5
     });
 
+    var style = OpenLayers.Util.applyDefaults(
+        {fillColor: "red"}, OpenLayers.Feature.Vector.style["default"]);
+
     redLiningPanel = new GeoExt.ux.form.RedLiningPanel({
         title: "RedLining Panel",
         region: "east",
         width: 300,
+        style: style,
         plugins: [new GeoExt.ux.ImportFeatures(), 
                   new GeoExt.ux.ExportFeatures()]
     });

Modified: sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeatureEditingPanel.js
===================================================================
--- sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeatureEditingPanel.js	2010-01-15 14:51:15 UTC (rev 1757)
+++ sandbox/redlining/ux/FeatureEditing/ux/widgets/form/FeatureEditingPanel.js	2010-01-15 20:03:26 UTC (rev 1758)
@@ -78,6 +78,18 @@
      *  ``Boolean`` Enable the auto-save of any changes made to any feature
      */
     autoSave: true,
+
+    /** private: property[style]
+     *  ``Object`` Feature style hash to use.  If none is defined,
+     *   OpenLayers.Feature.Vector.style['default'] is used instead.
+     */
+    style: null,
+
+    /** private: property[styleMap]
+     *  ``OpenLayers.StyleMap`` StyleMap object to use when automatically 
+     *  creating new OpenLayers.Layer.Vector objects.
+     */
+    styleMap: null,
     
     /** private: method[initComponent]
      */

Modified: sandbox/redlining/ux/FeatureEditing/ux/widgets/form/RedLiningPanel.js
===================================================================
--- sandbox/redlining/ux/FeatureEditing/ux/widgets/form/RedLiningPanel.js	2010-01-15 14:51:15 UTC (rev 1757)
+++ sandbox/redlining/ux/FeatureEditing/ux/widgets/form/RedLiningPanel.js	2010-01-15 20:03:26 UTC (rev 1758)
@@ -41,6 +41,27 @@
      */
     layer: null,
 
+    /** api: config[fadeRatio]
+     *  ``Numeric``
+     *  The fade ratio to apply when features are not selected.
+     */
+    fadeRatio: '0.4',
+
+    /** api: config[opacityProperties]
+     *  ``Array(String)``
+     *  The style properties refering to opacity.
+     */
+    opacityProperties: [
+        "fillOpacity", "hoverFillOpacity",
+        "strokeOpacity", "hoverStrokeOpacity"
+    ],
+
+    /** api: config[defaultOpacity]
+     *  ``Numeric``
+     *  Default opacity maximum value
+     */
+    defaultOpacity: 1,
+
     /** private: method[initComponent]
      */
     initComponent: function() {
@@ -77,18 +98,41 @@
               }
             };
 
+            // get the style hash to work with
+            var styleHash = this.style || OpenLayers.Feature.Vector.style["default"];
+
+            // normal style
             var style = new OpenLayers.Style(
                 OpenLayers.Util.applyDefaults(
-                    labelStyle,OpenLayers.Feature.Vector.style["default"]),
+                    labelStyle, styleHash),
                 styleOptions
             );
 
-            var styleMap = new OpenLayers.StyleMap({
-                "default": style
+            // faded style auto-generation
+            var fadedHash = {};
+            for(var i=0; i<this.opacityProperties.length; i++) {
+                var prop = this.opacityProperties[i];
+                if(styleHash[prop]) {
+                    fadedHash[prop] = styleHash[prop] * this.fadeRatio;
+                } else {
+                    fadedHash[prop] = this.defaultOpacity * this.fadeRatio;
+                }
+            }
+
+            var fadedStyle = new OpenLayers.Style(
+                OpenLayers.Util.applyDefaults(fadedHash,
+                OpenLayers.Util.applyDefaults(
+                    labelStyle, styleHash)),
+                styleOptions
+            );
+
+            this.styleMap = new OpenLayers.StyleMap({
+                 "default": fadedStyle,
+                 "select": style
             }); 
        
             layer = new OpenLayers.Layer.Vector(
-                "Cosmetic", {'styleMap': styleMap});
+                "Cosmetic", {'styleMap': this.styleMap});
         }
 
         this.layers = [layer];



More information about the Commits mailing list