[Commits] r1751 - in sandbox/ahocevar/playground: trunk/geoext/lib/GeoExt/widgets ux/Printing/examples ux/Printing/ux/widgets/form

commits at geoext.org commits at geoext.org
Fri Jan 15 02:06:17 CET 2010


Author: ahocevar
Date: 2010-01-15 02:06:16 +0100 (Fri, 15 Jan 2010)
New Revision: 1751

Modified:
   sandbox/ahocevar/playground/trunk/geoext/lib/GeoExt/widgets/PrintExtent.js
   sandbox/ahocevar/playground/ux/Printing/examples/SimplePrint.html
   sandbox/ahocevar/playground/ux/Printing/examples/SimplePrint.js
   sandbox/ahocevar/playground/ux/Printing/ux/widgets/form/SimplePrint.js
Log:
added a stylemap to get nicer handles

Modified: sandbox/ahocevar/playground/trunk/geoext/lib/GeoExt/widgets/PrintExtent.js
===================================================================
--- sandbox/ahocevar/playground/trunk/geoext/lib/GeoExt/widgets/PrintExtent.js	2010-01-14 23:48:18 UTC (rev 1750)
+++ sandbox/ahocevar/playground/trunk/geoext/lib/GeoExt/widgets/PrintExtent.js	2010-01-15 01:06:16 UTC (rev 1751)
@@ -157,11 +157,11 @@
             this.layer = new OpenLayers.Layer.Vector(null, {
                 displayInLayerSwitcher: false
             });
-            for(var i=0, len=this.pages.length; i<len; ++i) {
-                var page = this.pages[i];
-                this.layer.addFeatures([page.feature].concat(page.handles));
-            }
         }
+        for(var i=0, len=this.pages.length; i<len; ++i) {
+            var page = this.pages[i];
+            this.layer.addFeatures([page.feature].concat(page.handles));
+        }
         if(!this.layer.map) {
             this.map.addLayer(this.layer);
         }

Modified: sandbox/ahocevar/playground/ux/Printing/examples/SimplePrint.html
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/examples/SimplePrint.html	2010-01-14 23:48:18 UTC (rev 1750)
+++ sandbox/ahocevar/playground/ux/Printing/examples/SimplePrint.html	2010-01-15 01:06:16 UTC (rev 1751)
@@ -31,7 +31,7 @@
         which is also available as
         <a href="http://geoserver.org/display/GEOS/Printing+2.0+HOWTO">GeoServer print module</a>.</p>
         
-        <p>The rectangle and handle on the map can be used to change center,
+        <p>The rectangle and handles on the map can be used to change center,
         scale and rotation.</p>
         
         <p>Note that this example uses GET requests to communicate with the

Modified: sandbox/ahocevar/playground/ux/Printing/examples/SimplePrint.js
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/examples/SimplePrint.js	2010-01-14 23:48:18 UTC (rev 1750)
+++ sandbox/ahocevar/playground/ux/Printing/examples/SimplePrint.js	2010-01-15 01:06:16 UTC (rev 1751)
@@ -18,7 +18,7 @@
         region: "center",
         layers: [new OpenLayers.Layer.WMS("Global Imagery",
             "http://labs.metacarta.com/wms/vmap0",
-            {layers: "basic"})] ,
+            {layers: "basic"})],
         center: [16,48],
         zoom: 5
     });
@@ -42,9 +42,38 @@
     ]);
     mapPanel.map.addLayer(redline);
     
+    // Create a vector layer for the print page extent and handles.
+    // We only do this because we want fancy styles for the handles,
+    // otherwise SimplePrint's PrintExtent would auto-create one for us.
+    var extentLayer = new OpenLayers.Layer.Vector("print", {
+        displayInLayerSwitcher: false,
+        styleMap: new OpenLayers.StyleMap(new OpenLayers.Style(Ext.applyIf({
+            pointRadius: 4,
+            graphicName: "square",
+            rotation: "${getRotation}",
+            strokeColor: "${getStrokeColor}",
+            fillOpacity: "${getFillOpacity}"
+        }, OpenLayers.Feature.Vector.style["default"]), {
+            context: {
+                getRotation: function(feature) {
+                    return printForm.page.rotation;
+                },
+                getStrokeColor: function(feature) {
+                    return feature.geometry.CLASS_NAME == "OpenLayers.Geometry.Point" ?
+                        "#000" : "#ee9900";
+                },
+                getFillOpacity: function(feature) {
+                    return feature.geometry.CLASS_NAME == "OpenLayers.Geometry.Point" ?
+                        0 : 0.4;
+                }
+            }
+        })
+    )});
+    
     // a simple print form
     printForm = new GeoExt.ux.form.SimplePrint({
         mapPanel: mapPanel,
+        layer: extentLayer, // optional
         printProvider: printProvider,
         bodyStyle: {padding: "5px"},
         labelWidth: 65,
@@ -61,7 +90,7 @@
         fieldLabel: "Title",
         value: "A custom title",
         plugins: new GeoExt.plugins.PrintPageField({
-            page: printForm.pages[0]
+            page: printForm.page
         })
     });
     printForm.insert(1, {
@@ -70,7 +99,7 @@
         name: "comment",
         value: "A custom comment",
         plugins: new GeoExt.plugins.PrintPageField({
-            page: printForm.pages[0]
+            page: printForm.page
         })
     });
     
@@ -93,7 +122,7 @@
      */
     formCt.add(printForm);
     formCt.doLayout();
-    printForm.pages[0].fit(mapPanel.map);
+    printForm.page.fit(mapPanel.map);
 
     /* use this code block instead of the above one if you configured the
      * printProvider with url instead of capabilities
@@ -103,7 +132,7 @@
         myMask.hide();
         formCt.add(printForm);
         formCt.doLayout();
-        printForm.pages[0].fit(mapPanel.map);
+        printForm.page.fit(mapPanel.map);
     });
      */
     

Modified: sandbox/ahocevar/playground/ux/Printing/ux/widgets/form/SimplePrint.js
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/ux/widgets/form/SimplePrint.js	2010-01-14 23:48:18 UTC (rev 1750)
+++ sandbox/ahocevar/playground/ux/Printing/ux/widgets/form/SimplePrint.js	2010-01-15 01:06:16 UTC (rev 1751)
@@ -50,6 +50,12 @@
      *  :class:`GeoExt.MapPanel` The map panel that this form should be
      *  connected to.
      */
+    
+    /** api: config[layer]
+     *  ``OpenLayers.Layer`` Layer to render page extents and handles
+     *  to. Useful e.g. for setting a StyleMap. Optional, will be auto-created
+     *  if not provided.
+     */
 
     /** api: config[printOptions]
      *  ``Object`` Optional options for the printProvider's print command.
@@ -85,19 +91,26 @@
      *  :class:`GeoExt.PrintExtent`
      */
     printExtent: null,
+    
+    /** api: property[page]
+     *  :class:`GeoExt.data.PrintPage` The print page for this form. Useful
+     *  e.g. for rotating handles when used in a style map context. Read-only.
+     */
+    printPage: null,
    
     /** private: method[initComponent]
      */
     initComponent: function() {
         GeoExt.ux.form.SimplePrint.superclass.initComponent.call(this);
         
-        this.pages = [new GeoExt.data.PrintPage({
+        this.page = new GeoExt.data.PrintPage({
             printProvider: this.initialConfig.printProvider
-        })];
+        });
         
         this.printExtent = new GeoExt.PrintExtent({
             printProvider: this.initialConfig.printProvider,
-            pages: this.pages
+            layer: this.initialConfig.layer,
+            pages: [this.page]
         });
         
         this.mapPanel.add(this.printExtent);
@@ -166,7 +179,7 @@
             triggerAction: "all",
             selectOnFocus: true,
             plugins: new GeoExt.plugins.PrintPageField({
-                page: this.pages[0]
+                page: this.page
             })
         });
         this.initialConfig.hideRotation !== true && this.add({
@@ -178,7 +191,7 @@
                 return !isNaN(v)
             },
             plugins: new GeoExt.plugins.PrintPageField({
-                page: this.pages[0]
+                page: this.page
             })
         });
 



More information about the Commits mailing list