[Commits] r1558 - in sandbox/ahocevar/playground/ux/Printing: examples ux/data ux/plugins ux/widgets/form

commits at geoext.org commits at geoext.org
Sat Dec 5 00:12:41 CET 2009


Author: ahocevar
Date: 2009-12-05 00:12:41 +0100 (Sat, 05 Dec 2009)
New Revision: 1558

Modified:
   sandbox/ahocevar/playground/ux/Printing/examples/Printing.html
   sandbox/ahocevar/playground/ux/Printing/examples/Printing.js
   sandbox/ahocevar/playground/ux/Printing/ux/data/PrintPage.js
   sandbox/ahocevar/playground/ux/Printing/ux/data/PrintProvider.js
   sandbox/ahocevar/playground/ux/Printing/ux/plugins/PrintPageField.js
   sandbox/ahocevar/playground/ux/Printing/ux/plugins/PrintProviderField.js
   sandbox/ahocevar/playground/ux/Printing/ux/widgets/form/PrintForm.js
   sandbox/ahocevar/playground/ux/Printing/ux/widgets/form/SimplePrint.js
Log:
added api docs and copyright.

Modified: sandbox/ahocevar/playground/ux/Printing/examples/Printing.html
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/examples/Printing.html	2009-12-04 21:54:31 UTC (rev 1557)
+++ sandbox/ahocevar/playground/ux/Printing/examples/Printing.html	2009-12-04 23:12:41 UTC (rev 1558)
@@ -8,10 +8,14 @@
         <link rel="stylesheet" type="text/css" href="../../../trunk/ext/examples/shared/examples.css" />
         <script src="../../../trunk/openlayers/lib/OpenLayers.js"></script>
         <script type="text/javascript" src="../../../trunk/geoext/lib/GeoExt.js"></script>
+        
+        <script type="text/javascript" src="../ux/data/PrintPage.js"></script>
         <script type="text/javascript" src="../ux/data/PrintProvider.js"></script>
-        <script type="text/javascript" src="../ux/plugins/PrintLayoutField.js"></script>
-        <script type="text/javascript" src="../ux/plugins/PrintPageAttributeField.js"></script>
-        <script type="text/javascript" src="../ux/widgets/SimplePrint.js"></script>
+        <script type="text/javascript" src="../ux/plugins/PrintProviderField.js"></script>
+        <script type="text/javascript" src="../ux/plugins/PrintPageField.js"></script>
+        <script type="text/javascript" src="../ux/widgets/form/PrintForm.js"></script>
+        <script type="text/javascript" src="../ux/widgets/form/SimplePrint.js"></script>
+        
         <script type="text/javascript" src="Printing.js"></script>
 
         <script type="text/javascript" src="http://demo.mapfish.org/mapfishsample/1.2/print/info.json?var=printCapabilities"></script>

Modified: sandbox/ahocevar/playground/ux/Printing/examples/Printing.js
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/examples/Printing.js	2009-12-04 21:54:31 UTC (rev 1557)
+++ sandbox/ahocevar/playground/ux/Printing/examples/Printing.js	2009-12-04 23:12:41 UTC (rev 1558)
@@ -43,13 +43,12 @@
         "zoomend": function() {
             if(!fit && mapPanel.map.getZoom() == mapPanel.initialConfig.zoom) {
                 fit = true;
-                printProvider.fitPage(pageFeature);
-                printProvider.updateHandle(printForm.handleFeature, pageFeature);
+                printForm.pages[0].fitPage(mapPanel.map);
             }
         }
     });
     
-    printForm = new GeoExt.ux.SimplePrint({
+    printForm = new GeoExt.ux.form.SimplePrint({
         map: mapPanel,
         printProvider: printProvider,
         layer: pageLayer,
@@ -58,26 +57,28 @@
         labelWidth: 65,
         defaults: {width: 115},
         region: "east",
-        width: 200,
-        items: [{
-            xtype: "textfield",
-            fieldLabel: "Title",
-            plugins: new GeoExt.ux.plugins.PrintPageAttributeField({
-                printProvider: this.printProvider,
-                attribute: "title",
-                pageFeature: pageFeature
-            })
-        }, {
-            xtype: "textarea",
-            fieldLabel: "Comment",
-            plugins: new GeoExt.ux.plugins.PrintPageAttributeField({
-                printProvider: this.printProvider,
-                attribute: "comment",
-                pageFeature: pageFeature
-            })
-        }]
+        width: 200
     });
-    
+    printForm.insert(0, {
+        xtype: "textfield",
+        name: "mapTitle",
+        fieldLabel: "Title",
+        value: "A custom title",
+        plugins: new GeoExt.ux.plugins.PrintPageField({
+            page: printForm.pages[0]
+        })
+    });
+    printForm.insert(1, {
+        xtype: "textarea",
+        fieldLabel: "Comment",
+        name: "comment",
+        value: "A custom comment",
+        plugins: new GeoExt.ux.plugins.PrintPageField({
+            page: printForm.pages[0]
+        })
+    });
+    printForm.doLayout();
+
     new Ext.Panel({
         renderTo: document.body,
         layout: "border",

Modified: sandbox/ahocevar/playground/ux/Printing/ux/data/PrintPage.js
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/ux/data/PrintPage.js	2009-12-04 21:54:31 UTC (rev 1557)
+++ sandbox/ahocevar/playground/ux/Printing/ux/data/PrintPage.js	2009-12-04 23:12:41 UTC (rev 1558)
@@ -17,7 +17,10 @@
  *  .. class:: PrintPage
  * 
  *  Provides a representation of a print page for
- *  :class:`GeoExt.ux.data.PrintProvider`.
+ *  :class:`GeoExt.ux.data.PrintProvider`. The extent of the page is stored as
+ *  ``OpenLayers.Feature.Vector``. Widgets can use this to display the print
+ *  extent on the map. In addition, a handle feature is also provided, which
+ *  controls can use to modify the print extent's scale and rotation.
  */
 GeoExt.ux.data.PrintPage = Ext.extend(Ext.util.Observable, {
     
@@ -48,8 +51,14 @@
      */
     handle: null,
     
+    /** api: property[scale]
+     *  ``Float`` The current scale of the page. Read-only.
+     */
     scale: null,
     
+    /** api: property[rotation]
+     *  ``Float`` The current rotation of the page. Read-only.
+     */
     rotation: null,
     
     /** api:config[customParams]
@@ -95,7 +104,7 @@
 
         this.printProvider.on({
             "layoutchange": function() {
-                this.updateByHandle(true);
+                this.updateByHandle();
             },
             scope: this
         });
@@ -117,7 +126,7 @@
      * 
      *  Updates the page geometry to match a given scale. Since this takes the
      *  current layout of the printProvider into account, this can be used to
-     *  update the page geometry when the layout has changed.
+     *  update the page geometry feature when the layout has changed.
      */
     setScale: function(scale) {
         var bounds = this.calculatePageBounds(scale);
@@ -178,7 +187,9 @@
      *      will not be aligned with the feature after updating. Default is
      *      true.
      *  
-     *  Updates scale and rotation by the current handle location.
+     *  Updates scale and rotation based on the current handle location. This
+     *  method is useful for drag handlers on the handle geometry, when
+     *  displayed on a layer.
      */
     updateByHandle: function(updateHandle) {
         var f = this.feature;
@@ -250,7 +261,7 @@
      *  :return: ``OpenLayers.LonLat`` The location of the scale/rotation
      *      handle.
      *  
-     *  Calculates the position of the scale/rotation handle for this
+     *  Calculates the position of the scale/rotation handle to align with the
      *  page feature.
      */
     calculateHandleLocation: function() {

Modified: sandbox/ahocevar/playground/ux/Printing/ux/data/PrintProvider.js
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/ux/data/PrintProvider.js	2009-12-04 21:54:31 UTC (rev 1557)
+++ sandbox/ahocevar/playground/ux/Printing/ux/data/PrintProvider.js	2009-12-04 23:12:41 UTC (rev 1558)
@@ -219,19 +219,40 @@
         GeoExt.ux.data.PrintProvider.superclass.constructor.apply(this, arguments);
     },
     
+    /** api: method[getLayout]
+     *  :return: ``Ext.data.Record`` the layout record of the current layout.
+     *  
+     *  Gets the current layout.
+     */
     getLayout: function() {
         return this.layouts.getAt(this.layouts.find("name", this.layout));
     },
     
+    /** api: method[setLayout]
+     *  :param layout: ``String`` the name of the layout.
+     *  
+     *  Sets the layout for this printProvider.
+     */
     setLayout: function(layout) {
         this.layout = layout;
         this.fireEvent("layoutchange", this, this.getLayout());
     },
     
+    /** api: method[getDpi]
+     *  :return: ``Ext.data.Record`` the layout record of the currently
+     *      configured dpi setting.
+     *  
+     *  Gets the current dpi setting.
+     */
     getDpi: function() {
         return this.dpis.getAt(this.dpis.find("value", this.dpi));
     },
     
+    /** api: method[setDpi]
+     *  :param layout: ``Number`` the dpi setting.
+     *  
+     *  Sets the dpi for this printProvider.
+     */
     setDpi: function(dpi) {
         this.dpi = dpi;
         this.fireEvent("dpichange", this, this.getDpi())
@@ -339,7 +360,7 @@
 });
 
 /** private: property[encode]
- *  Sn object providing encoding functions for different layer types.
+ *  An object providing encoding functions for different layer types.
  */
 GeoExt.ux.data.PrintProvider.encode = {
     "WMS": function(layer){

Modified: sandbox/ahocevar/playground/ux/Printing/ux/plugins/PrintPageField.js
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/ux/plugins/PrintPageField.js	2009-12-04 21:54:31 UTC (rev 1557)
+++ sandbox/ahocevar/playground/ux/Printing/ux/plugins/PrintPageField.js	2009-12-04 23:12:41 UTC (rev 1558)
@@ -1,9 +1,38 @@
+/**
+ * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
+ * 
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
 Ext.namespace("GeoExt.ux.plugins");
 
+/** api: (define)
+ *  module = GeoExt.ux.plugins
+ *  class = PrintPageField
+ *  base_link = `Ext.util.Observable <http://extjs.com/deploy/dev/docs/?class=Ext.util.Observable>`_
+ */
+
+/** api: constructor
+ *  .. class:: PrintPageField
+ * 
+ *  A plugin for ``Ext.form.Field`` components which provides synchronization
+ *  with a :class:`GeoExt.ux.data.PrintPage`.
+ */
 GeoExt.ux.plugins.PrintPageField = Ext.extend(Ext.util.Observable, {
     
+    /** api: config[page]
+     *  ``GeoExt.ux.data.PrintPage`` The print page to synchronize with.
+     */
+
+    /** private: property[page]
+     *  ``GeoExt.ux.data.PrintPage`` The print page to synchronize with.
+     */
     page: null,
     
+    /** private: property[target]
+     *  ``Ext.form.Field`` This plugin's target field.
+     */
     target: null,
     
     /** private: method[constructor]
@@ -15,6 +44,11 @@
         GeoExt.ux.plugins.PrintPageField.superclass.constructor.apply(this, arguments);
     },
     
+    /** private: method[init]
+     *  :param target: ``Ext.form.Field`` The component that this plugin
+     *      extends.
+     * @param {Object} target
+     */
     init: function(target) {
         this.target = target;
         target.on({
@@ -27,6 +61,11 @@
         });
     },
 
+    /** private: method[onFieldChange]
+     *  :param field: ``Ext.form.Field
+     *  
+     *  Handler for the target field's "valid" event.
+     */
     onFieldChange: function(field) {
         var printProvider = this.page.printProvider;
         var value = field.getValue();
@@ -40,6 +79,12 @@
         }
     },
 
+    /** private: method[onPageChange]
+     *  :param page: :class:`GeoExt.ux.data.PrintPage`
+     *  
+     *  Handler for the "change" event for the page this plugin is configured
+     *  with.
+     */
     onPageChange: function(page) {
         var t = this.target;
         t.suspendEvents();
@@ -55,5 +100,5 @@
 
 });
 
-/** api: ptype = gx-printpagefield */
-Ext.preg && Ext.preg("gx-printpagefield", GeoExt.ux.plugins.PrintPageField);
+/** api: ptype = gx_printpagefield */
+Ext.preg && Ext.preg("gx_printpagefield", GeoExt.ux.plugins.PrintPageField);

Modified: sandbox/ahocevar/playground/ux/Printing/ux/plugins/PrintProviderField.js
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/ux/plugins/PrintProviderField.js	2009-12-04 21:54:31 UTC (rev 1557)
+++ sandbox/ahocevar/playground/ux/Printing/ux/plugins/PrintProviderField.js	2009-12-04 23:12:41 UTC (rev 1558)
@@ -1,5 +1,24 @@
+/**
+ * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
+ * 
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
 Ext.namespace("GeoExt.ux.plugins");
 
+/** api: (define)
+ *  module = GeoExt.ux.plugins
+ *  class = PrintProviderField
+ *  base_link = `Ext.util.Observable <http://extjs.com/deploy/dev/docs/?class=Ext.util.Observable>`_
+ */
+
+/** api: constructor
+ *  .. class:: PrintProviderField
+ * 
+ *  A plugin for ``Ext.form.Field`` components which provides synchronization
+ *  with a :class:`GeoExt.ux.data.PrintProvider`.
+ */
 GeoExt.ux.plugins.PrintProviderField = Ext.extend(Ext.util.Observable, {
     
     /** private: method[constructor]
@@ -11,6 +30,10 @@
         GeoExt.ux.plugins.PrintProviderField.superclass.constructor.apply(this, arguments);
     },
     
+    /** private: method[init]
+     *  :param target: ``Ext.form.Field`` The component that this plugin
+     *      extends.
+     */
     init: function(target) {
         target.on({
             "valid": this.onFieldChange,
@@ -19,6 +42,11 @@
         });
     },
     
+    /** private: method[onRender]
+     *  :param field: ``Ext.Form.Field``
+     *  
+     *  Handler for the target field's "render" event.
+     */
     onRender: function(field) {
         var printProvider = field.ownerCt.printProvider;
         if(field.store === printProvider.layouts) {
@@ -44,6 +72,11 @@
         }
     },
     
+    /** private: method[onFieldChange]
+     *  :param field: ``Ext.form.Field``
+     *  
+     *  Handler for the target field's valid event.
+     */
     onFieldChange: function(field) {
         var printProvider = field.ownerCt.printProvider;
         var value = field.getValue();
@@ -58,5 +91,5 @@
     }
 });
 
-/** api: ptype = gx-printproviderfield */
-Ext.preg && Ext.preg("gx-printproviderfield", GeoExt.ux.plugins.PrintProviderField);
+/** api: ptype = gx_printproviderfield */
+Ext.preg && Ext.preg("gx_printproviderfield", GeoExt.ux.plugins.PrintProviderField);

Modified: sandbox/ahocevar/playground/ux/Printing/ux/widgets/form/PrintForm.js
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/ux/widgets/form/PrintForm.js	2009-12-04 21:54:31 UTC (rev 1557)
+++ sandbox/ahocevar/playground/ux/Printing/ux/widgets/form/PrintForm.js	2009-12-04 23:12:41 UTC (rev 1558)
@@ -1,17 +1,77 @@
+/**
+ * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
+ * 
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
 Ext.namespace("GeoExt.ux.form")
 
+/** api: (define)
+ *  module = GeoExt.ux.form
+ *  class = PrintForm
+ *  base_link = `Ext.form.FormPanel <http://extjs.com/deploy/dev/docs/?class=Ext.form.FormPanel>`_
+ */
+
+/** api: constructor
+ *  .. class:: PrintForm
+ * 
+ *  Provides a base class form for working with
+ *  :class:`GeoExt.ux.data.PrintProvider`, :class:`GeoExt.ux.data.PrintPage`
+ *  and the plugins available for fields to synchronize. The form also
+ *  provides a layer for the page extent and handle features of print pages,
+ *  with a control to modify them. Finally, it configures the printProvider
+ *  with the appropriate units of the map.
+ *  
+ *  This form comes with no fields and is meant to be extended (unless it is
+ *  enough to configure print extent, scale and rotation interactively on the
+ *  map). See :ref:`GeoExt.ux.form.SimplePrint` for a simple implementation.
+ */
 GeoExt.ux.form.PrintForm = Ext.extend(Ext.form.FormPanel, {
     
+    /** api: config[printProvider]
+     *  :class:`GeoExt.ux.data.PrintProvider` The print provider this form
+     *  is connected to.
+     */
+    
+    /** api: property[printProvider]
+     *  :class:`GeoExt.ux.data.PrintProvider` The print provider this form
+     *  is connected to. Read-only.
+     */
     printProvider: null,
     
+    /** api: config[map]
+     *  ``GeoExt.MapPanel``|``OpenLayers.Map`` The map this control uses to
+     *  draw and control extent features and handles, and to determine the map
+     *  units for the printProvider. 
+     */
     map: null,
     
+    /** private: property[layer]
+     *  ``OpenLayers.Layer.Vector`` The layer used to render extent and handle
+     *  features to.
+     */
     layer: null,
     
+    /** private: property[control]
+     *  ``OpenLayers.Control.DragFeature`` The control used to change extent
+     *  center, rotation and scale.
+     */
     control: null,
     
+    /** api: config[pages]
+     *  Array of :class:`GeoExt.ux.data.PrintPage` The pages that this form
+     *  controls.
+     */
+    
+    /** api: property[pages]
+     *  Array of :class:`GeoExt.ux.data.PrintPage` The pages that this form
+     *  controls.
+     */
     pages: null,
     
+    /** private: method[initComponent]
+     */
     initComponent: function() {
         GeoExt.ux.form.PrintForm.superclass.initComponent.call(this);
         if(this.map instanceof GeoExt.MapPanel) {
@@ -25,8 +85,6 @@
                         
         this.initLayer();
         this.initControl();
-        this.map.addLayer(this.layer);
-        this.control.activate();
 
         this.on({
             "show": function() {
@@ -40,19 +98,26 @@
         });
     },
     
+    /** private: method[initLayer]
+     */
     initLayer: function() {
         this.layer = new OpenLayers.Layer.Vector(null, {
             displayInLayerSwitcher: false
-        })
+        });
+        this.map.addLayer(this.layer);
     },
     
+    /** private: method[initControl]
+     */
     initControl: function() {
         var pages = this.pages;
+
         var updateHandles = function() {
             for(var i=0, len=pages.length; i<len; ++i) {
                 pages[i].updateHandle();
             };
         }
+
         this.control = new OpenLayers.Control.DragFeature(this.layer, {
             onDrag: function(feature) {
                 if(feature.geometry instanceof OpenLayers.Geometry.Polygon) {
@@ -67,7 +132,22 @@
             },
             onComplete: updateHandles
         });
+
         this.map.addControl(this.control);
+        this.control.activate();
+    },
+    
+    /** private: method[beforeDestroy]
+     */
+    beforeDestroy: function() {
+        Ext.each(this.pages, function(page) {
+            this.layer.removeFeatures(page.feature, page.handle);
+        }, this);
+        this.layer.destroy();
+        this.control.destroy();
     }
     
 });
+
+/** api: xtype = gx_printform */
+Ext.reg("gx_printform", GeoExt.ux.form.PrintForm);

Modified: sandbox/ahocevar/playground/ux/Printing/ux/widgets/form/SimplePrint.js
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/ux/widgets/form/SimplePrint.js	2009-12-04 21:54:31 UTC (rev 1557)
+++ sandbox/ahocevar/playground/ux/Printing/ux/widgets/form/SimplePrint.js	2009-12-04 23:12:41 UTC (rev 1558)
@@ -1,15 +1,45 @@
+/**
+ * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
+ * 
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
+
+/**
+ * @requires ux/widgets/form/PrintForm.js
+ */
 Ext.namespace("GeoExt.ux.form")
 
+/** api: (define)
+ *  module = GeoExt.ux.form
+ *  class = SimplePrint
+ */
+
+/** api: (extends)
+ * ux/widgets/form/PrintForm.js
+ */
+
+/** api: constructor
+ *  .. class:: SimplePrint
+ * 
+ *  A simple implementation of :ref:`GeoExt.ux.form.PrintForm`. The form
+ *  creates a single print page. Layout, DPI, scale and rotation are
+ *  configurable. A Print button is also added to actually let the
+ *  printProvider send the configuration to the print service.
+ */
 GeoExt.ux.form.SimplePrint = Ext.extend(GeoExt.ux.form.PrintForm, {
     
+    /* begin i18n */
     layoutText: "Layout",
     dpiText: "DPI",
     scaleText: "Scale",
     rotationText: "Rotation",
     printText: "Print",
+    /* end i18n */
     
-    showLayoutField: true,
-    
+    /** private: method[initComponent]
+     */
     initComponent: function() {
         GeoExt.ux.form.SimplePrint.superclass.initComponent.call(this);
         
@@ -21,9 +51,12 @@
         this.initForm();
     },
     
+    /** private: method[initForm]
+     *  Creates and adds items to the form.
+     */
     initForm: function() {
         var items = [{
-            xtype: this.showLayoutField ? "combo" : "hidden",
+            xtype: "combo",
             fieldLabel: this.layoutText,
             store: this.printProvider.layouts,
             displayField: "name",
@@ -34,7 +67,7 @@
             selectOnFocus: true,
             plugins: new GeoExt.ux.plugins.PrintProviderField()
         }, {
-            xtype: this.dpi ? "hidden" : "combo",
+            xtype: "combo",
             fieldLabel: this.dpiText,
             store: this.printProvider.dpis,
             displayField: "name",
@@ -85,3 +118,6 @@
     }
     
 });
+
+/** api: xtype = gx_simpleprint */
+Ext.reg("gx_simpleprint", GeoExt.ux.form.SimplePrint);



More information about the Commits mailing list