[Commits] r1642 - in sandbox/cmoullet/ux: . Printer Printer/examples Printer/ux Printer/ux/layout Printer/ux/widgets
commits at geoext.org
commits at geoext.org
Fri Jan 1 14:25:45 CET 2010
Author: cmoullet
Date: 2010-01-01 14:25:44 +0100 (Fri, 01 Jan 2010)
New Revision: 1642
Added:
sandbox/cmoullet/ux/Printer/
sandbox/cmoullet/ux/Printer/examples/
sandbox/cmoullet/ux/Printer/examples/PageSize.xls
sandbox/cmoullet/ux/Printer/examples/PrinterExample.html
sandbox/cmoullet/ux/Printer/examples/PrinterExample.js
sandbox/cmoullet/ux/Printer/examples/README.txt
sandbox/cmoullet/ux/Printer/ux/
sandbox/cmoullet/ux/Printer/ux/layout/
sandbox/cmoullet/ux/Printer/ux/layout/LayoutPrinter.js
sandbox/cmoullet/ux/Printer/ux/layout/LayoutStore.js
sandbox/cmoullet/ux/Printer/ux/layout/a4_landscape.html
sandbox/cmoullet/ux/Printer/ux/layout/a4_portrait.html
sandbox/cmoullet/ux/Printer/ux/widgets/
sandbox/cmoullet/ux/Printer/ux/widgets/PrinterPanel.js
sandbox/cmoullet/ux/Printer/ux/widgets/PrinterWindow.js
Log:
Initial version of client printer
Added: sandbox/cmoullet/ux/Printer/examples/PageSize.xls
===================================================================
(Binary files differ)
Property changes on: sandbox/cmoullet/ux/Printer/examples/PageSize.xls
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: sandbox/cmoullet/ux/Printer/examples/PrinterExample.html
===================================================================
--- sandbox/cmoullet/ux/Printer/examples/PrinterExample.html (rev 0)
+++ sandbox/cmoullet/ux/Printer/examples/PrinterExample.html 2010-01-01 13:25:44 UTC (rev 1642)
@@ -0,0 +1,17 @@
+<html>
+<head>
+ <title>Printer Panel Example</title>
+ <script type="text/javascript" src="http://extjs.cachefly.net/builds/ext-cdn-771.js"></script>
+ <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/resources/css/ext-all.css"/>
+ <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/examples/shared/examples.css"/>
+ <script type="text/javascript" src="../../../trunk/openlayers/lib/OpenLayers.js"></script>
+ <script type="text/javascript" src="../../../trunk/geoext/lib/GeoExt.js"></script>
+ <script type="text/javascript" src="../ux/layout/LayoutStore.js"></script>
+ <script type="text/javascript" src="../ux/layout/LayoutPrinter.js"></script>
+ <script type="text/javascript" src="../ux/widgets/PrinterPanel.js"></script>
+ <script type="text/javascript" src="../ux/widgets/PrinterWindow.js"></script>
+ <script type="text/javascript" src="PrinterExample.js"></script>
+</head>
+<body>
+</body>
+</html>
\ No newline at end of file
Added: sandbox/cmoullet/ux/Printer/examples/PrinterExample.js
===================================================================
--- sandbox/cmoullet/ux/Printer/examples/PrinterExample.js (rev 0)
+++ sandbox/cmoullet/ux/Printer/examples/PrinterExample.js 2010-01-01 13:25:44 UTC (rev 1642)
@@ -0,0 +1,94 @@
+var mapPanel;
+
+var treePanel;
+
+var viewport;
+
+var layer;
+
+Ext.onReady(function() {
+
+ var layer = new OpenLayers.Layer.OSM("OSM");
+
+ var map = new OpenLayers.Map();
+
+ var center = new OpenLayers.LonLat(738481, 5863900);
+
+ var mouse = new OpenLayers.Control.MousePosition();
+
+ map.addControl(mouse);
+ mouse.activate();
+
+ map.addLayers([layer]);
+
+ var mapStore = new GeoExt.data.LayerStore({
+ map: map,
+ layers: [layer]
+ });
+
+ var toolbar = [];
+
+ toolbar.push({
+ text: 'Print',
+ enableToggle: false,
+ handler: function() {
+ var printerWindow = new GeoExt.ux.PrinterWindow({
+ map: map
+ });
+ printerWindow.show();
+ }
+ });
+
+ viewport = new Ext.Viewport({
+ layout: "border",
+ id: 'mainViewport',
+ items: [
+ {
+ region: "center",
+ id: "mappanel",
+ title: "2D Map",
+ xtype: "gx_mappanel",
+ map: map,
+ layers: mapStore,
+ center: center,
+ zoom: 14,
+ split: true,
+ tbar: toolbar
+ },
+ {
+ layout:'accordion',
+ region: "west",
+ width: 350,
+ items: [
+ {
+ id: "treepanel",
+ title: "Layer Tree"
+ }
+ ]
+
+ },
+ {
+ region: "south",
+ layout: 'fit',
+ id: "readme",
+ title: 'README',
+ margins: {left: 5,top: 5, bottom: 5, right: 5},
+ html: '<p style="font-size:12pt;color:#15428B;font-weight:bold;margin:5">GeoExt Printer example.</p>'
+ }
+ ]
+ });
+
+ var treePanelItem = new Ext.tree.TreePanel({
+ root: new GeoExt.tree.LayerContainer({
+ text: 'Map Layers',
+ layerStore: mapStore,
+ leaf: false,
+ expanded: true
+ }),
+ enableDD: true,
+ border: false
+ });
+ treePanel = Ext.getCmp("treepanel");
+ treePanel.add(treePanelItem);
+ treePanel.doLayout();
+});
\ No newline at end of file
Added: sandbox/cmoullet/ux/Printer/examples/README.txt
===================================================================
--- sandbox/cmoullet/ux/Printer/examples/README.txt (rev 0)
+++ sandbox/cmoullet/ux/Printer/examples/README.txt 2010-01-01 13:25:44 UTC (rev 1642)
@@ -0,0 +1,6 @@
+http://github.com/edspencer/Ext.ux.Printer
+
+http://geoas.net/ms/MapFish/client/examples/AGIS/Geodatenportal.html
+http://www.rakowice.eu/
+
+http://data.cameroun-foret.com/geobiep/atlas.php
\ No newline at end of file
Added: sandbox/cmoullet/ux/Printer/ux/layout/LayoutPrinter.js
===================================================================
--- sandbox/cmoullet/ux/Printer/ux/layout/LayoutPrinter.js (rev 0)
+++ sandbox/cmoullet/ux/Printer/ux/layout/LayoutPrinter.js 2010-01-01 13:25:44 UTC (rev 1642)
@@ -0,0 +1,70 @@
+/**
+ * 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.layout");
+
+GeoExt.ux.layout.LayoutPrinter = function(map, layout) {
+ GeoExt.ux.layout.LayoutPrinter.layout = layout;
+ GeoExt.ux.layout.LayoutPrinter.map = map;
+};
+
+GeoExt.ux.layout.LayoutPrinter.OpenPrint = function() {
+ var page = GeoExt.ux.layout.getHtmlPage(GeoExt.ux.layout.LayoutPrinter.layout);
+ var pageUrl = null;
+ if (page.indexOf('http://') === 0) {
+ pageUrl = page;
+ } else {
+ pageUrl = "../ux/layout/" + page;
+ }
+ GeoExt.ux.layout.LayoutPrinter.printWindow = window.open(pageUrl, "_blank", "menubar=0,scrollbars=0,location=0,status=1,width=" + GeoExt.ux.layout.getPageWidth(GeoExt.ux.layout.LayoutPrinter.layout) + ",height=" + GeoExt.ux.layout.getPageHeight(GeoExt.ux.layout.LayoutPrinter.layout) + "");
+};
+
+GeoExt.ux.layout.LayoutPrinter.Apply = function(childWindow) {
+ if (childWindow.map) {
+ GeoExt.ux.layout.LayoutPrinter.setMap(childWindow);
+ }
+};
+
+GeoExt.ux.layout.LayoutPrinter.setMap = function(childWindow) {
+ var options = {
+ tileSize: GeoExt.ux.layout.LayoutPrinter.map.tileSize,
+ projection: GeoExt.ux.layout.LayoutPrinter.map.projection,
+ units: GeoExt.ux.layout.LayoutPrinter.map.units,
+ resolutions: GeoExt.ux.layout.LayoutPrinter.map.resolutions,
+ maxResolution: GeoExt.ux.layout.LayoutPrinter.map.maxResolution,
+ minResolution: GeoExt.ux.layout.LayoutPrinter.map.minResolution,
+ maxScale: GeoExt.ux.layout.LayoutPrinter.map.maxScale,
+ minScale: GeoExt.ux.layout.LayoutPrinter.map.minScale,
+ maxExtent: GeoExt.ux.layout.LayoutPrinter.map.maxExtent,
+ minExtent: GeoExt.ux.layout.LayoutPrinter.map.minExtent,
+ restrictedExtent: GeoExt.ux.layout.LayoutPrinter.map.restrictedExtent,
+ numZoomLevels: GeoExt.ux.layout.LayoutPrinter.map.numZoomLevels,
+ theme: GeoExt.ux.layout.LayoutPrinter.map.theme,
+ displayProjection: GeoExt.ux.layout.LayoutPrinter.map.displayProjection,
+ fallThrough: GeoExt.ux.layout.LayoutPrinter.map.fallThrough,
+ panTween: GeoExt.ux.layout.LayoutPrinter.map.panTween,
+ eventListeners: GeoExt.ux.layout.LayoutPrinter.map.eventListeners,
+ panMethod: GeoExt.ux.layout.LayoutPrinter.map.panMethod,
+ panDuration: GeoExt.ux.layout.LayoutPrinter.map.panDuration,
+ paddingForPopups: GeoExt.ux.layout.LayoutPrinter.map.paddingForPopups
+ };
+
+ childWindow.map.setOptions(options);
+ for (var i = 0; i < GeoExt.ux.layout.LayoutPrinter.map.layers.length; i++) {
+ var layer = GeoExt.ux.layout.LayoutPrinter.map.layers[i].clone();
+ childWindow.map.addLayer(layer);
+ }
+ childWindow.map.setCenter(GeoExt.ux.layout.LayoutPrinter.map.getCenter(), GeoExt.ux.layout.LayoutPrinter.map.getZoom());
+ childWindow.print();
+};
+
+GeoExt.ux.layout.LayoutPrinter.layout = null;
+
+GeoExt.ux.layout.LayoutPrinter.printWindow = null;
+
+GeoExt.ux.layout.LayoutPrinter.map = null;
\ No newline at end of file
Added: sandbox/cmoullet/ux/Printer/ux/layout/LayoutStore.js
===================================================================
--- sandbox/cmoullet/ux/Printer/ux/layout/LayoutStore.js (rev 0)
+++ sandbox/cmoullet/ux/Printer/ux/layout/LayoutStore.js 2010-01-01 13:25:44 UTC (rev 1642)
@@ -0,0 +1,46 @@
+/**
+ * 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.layout");
+
+GeoExt.ux.layout.layouts = [
+ [OpenLayers.i18n('A4 portrait'), 'a4_portrait.html',790,1120],
+ [OpenLayers.i18n('A4 landscape'), 'a4_landscape.html',1120,790]
+];
+
+GeoExt.ux.layout.getHtmlPage = function(layout) {
+ for (var i = 0; i< GeoExt.ux.layout.layouts.length;i++) {
+ if (GeoExt.ux.layout.layouts[i][0] == layout) {
+ return GeoExt.ux.layout.layouts[i][1];
+ }
+ }
+};
+
+GeoExt.ux.layout.getPageWidth = function(layout) {
+ for (var i = 0; i< GeoExt.ux.layout.layouts.length;i++) {
+ if (GeoExt.ux.layout.layouts[i][0] == layout) {
+ return GeoExt.ux.layout.layouts[i][2];
+ }
+ }
+};
+
+GeoExt.ux.layout.getPageHeight = function(layout) {
+ for (var i = 0; i< GeoExt.ux.layout.layouts.length;i++) {
+ if (GeoExt.ux.layout.layouts[i][0] == layout) {
+ return GeoExt.ux.layout.layouts[i][3];
+ }
+ }
+};
+
+GeoExt.ux.layout.LayoutStore = new Ext.data.SimpleStore({
+ fields: ['layout', 'htmlpage', 'pageWidth', 'pageHeight'],
+ data: GeoExt.ux.layout.layouts
+});
+
+
+
Added: sandbox/cmoullet/ux/Printer/ux/layout/a4_landscape.html
===================================================================
--- sandbox/cmoullet/ux/Printer/ux/layout/a4_landscape.html (rev 0)
+++ sandbox/cmoullet/ux/Printer/ux/layout/a4_landscape.html 2010-01-01 13:25:44 UTC (rev 1642)
@@ -0,0 +1,48 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>Print Map</title>
+ <style type="text/css">
+ body {
+ margin: 0;
+ }
+
+ #title {
+ position: absolute;
+ top: 5px;
+ left: 10px;
+ }
+
+ #map {
+ position: absolute;
+ top: 80px;
+ left: 10px;
+ width: 1080px;
+ height: 660px;
+ }
+
+ #copyright {
+ position: absolute;
+ bottom: 5px;
+ left: 10px;
+ }
+
+ .olControlPanZoom {
+ display: none;
+ }
+ </style>
+ <script type="text/javascript" src="http://openlayers.org/api/2.8/OpenLayers.js"></script>
+ <script type="text/javascript">
+ var map;
+ function init() {
+ map = new OpenLayers.Map('map');
+ window.opener.GeoExt.ux.layout.LayoutPrinter.Apply(window);
+ }
+ </script>
+
+</head>
+<body onload="init();">
+<div id="title"><h1>Map printed with GeoExt UX printer</h1></div>
+<div id="map"></div>
+<div id="copyright">All rights reserved</div>
+</body>
+</html>
Added: sandbox/cmoullet/ux/Printer/ux/layout/a4_portrait.html
===================================================================
--- sandbox/cmoullet/ux/Printer/ux/layout/a4_portrait.html (rev 0)
+++ sandbox/cmoullet/ux/Printer/ux/layout/a4_portrait.html 2010-01-01 13:25:44 UTC (rev 1642)
@@ -0,0 +1,48 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>Print Map</title>
+ <style type="text/css">
+ body {
+ margin: 0;
+ }
+
+ #title {
+ position: absolute;
+ top: 5px;
+ left: 10px;
+ }
+
+ #map {
+ position: absolute;
+ top: 80px;
+ left: 10px;
+ width: 770px;
+ height: 970px;
+ }
+
+ #copyright {
+ position: absolute;
+ bottom: 5px;
+ left: 10px;
+ }
+
+ .olControlPanZoom {
+ display: none;
+ }
+ </style>
+ <script type="text/javascript" src="../../../../trunk/openlayers/lib/OpenLayers.js"></script>
+ <script type="text/javascript">
+ var map;
+ function init() {
+ map = new OpenLayers.Map('map');
+ window.opener.GeoExt.ux.layout.LayoutPrinter.Apply(window);
+ }
+ </script>
+
+</head>
+<body onload="init();">
+<div id="title"><h1>Map printed with GeoExt UX printer</h1></div>
+<div id="map"></div>
+<div id="copyright">All rights reserved</div>
+</body>
+</html>
Added: sandbox/cmoullet/ux/Printer/ux/widgets/PrinterPanel.js
===================================================================
--- sandbox/cmoullet/ux/Printer/ux/widgets/PrinterPanel.js (rev 0)
+++ sandbox/cmoullet/ux/Printer/ux/widgets/PrinterPanel.js 2010-01-01 13:25:44 UTC (rev 1642)
@@ -0,0 +1,146 @@
+/**
+ * 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.
+ */
+
+/** api: (define)
+ * module = GeoExt.ux
+ * class = PrinterPanel
+ * base_link = `Ext.Panel <http://extjs.com/deploy/dev/docs/?class=Ext.Panel>`_
+ */
+
+Ext.namespace('GeoExt.ux');
+
+GeoExt.ux.PrinterPanel = Ext.extend(Ext.Panel, {
+
+ /** api: config[map]
+ * ``OpenLayers.Map`` A configured map
+ */
+ /** private: property[map]
+ * ``OpenLayers.Map`` The map object
+ */
+ map: null,
+
+ layoutCombo: null,
+
+ defaultLayout: OpenLayers.i18n('A4 portrait'),
+
+ /** private: method[initComponent]
+ * Private initComponent override.
+ */
+ initComponent : function() {
+ var defConfig = {
+ plain: true,
+ border: false
+ };
+
+ Ext.applyIf(this, defConfig);
+
+ this.layoutCombo = new Ext.form.ComboBox({
+ id: 'layoutcombo',
+ fieldLabel: OpenLayers.i18n('Layout'),
+ store: GeoExt.ux.layout.LayoutStore,
+ displayField:'layout',
+ typeAhead: true,
+ mode: 'local',
+ triggerAction: 'all',
+ emptyText:'Select a layout...',
+ selectOnFocus:true,
+ resizable:true
+ });
+
+ this.layoutCombo.setValue(this.defaultLayout);
+
+ // Create items of printer panel
+ this.items = [
+ {
+ layout: 'form',
+ border:false,
+ items: [
+ {
+ layout: 'column',
+ border: false,
+ defaults:{
+ layout:'form',
+ border:false,
+ bodyStyle:'padding:5px 5px 5px 5px'
+ },
+ items:[
+ {
+ columnWidth:1,
+ defaults:{
+ anchor:'100%'
+ },
+ items: [
+ this.layoutCombo
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ {
+ layout: 'column',
+ border: false,
+ items: [
+ {
+ columnWidth: 1,
+ border: false,
+ bodyCfg: {tag:'center'},
+ items: [
+ {
+ xtype:'button',
+ text: OpenLayers.i18n('Print'),
+ handler: function() {
+ this.print();
+ },
+ scope: this
+ }
+ ]
+ }
+ ]
+
+ }
+ ];
+
+ this.addEvents(
+ /** api: event[printed]
+ * Fires when a routing has been computed
+ *
+ * Listener arguments:
+ * * comp - :class:`GeoExt.ux.RoutingPanel`` This component.
+ * * layout - :class:`GeoExt.ux.RoutingPanel`` This component.
+ */
+ 'printed',
+
+ /** api: event[beforeprinted]
+ * Fires when before a routing is computed
+ *
+ * Listener arguments:
+ * * comp - :class:`GeoExt.ux.RoutingPanel`` This component.
+ * * layout
+ */
+ 'beforeprinted');
+
+ GeoExt.ux.PrinterPanel.superclass.initComponent.call(this);
+ },
+
+ /** private: method[print]
+ * Print the map
+ */
+ print: function() {
+ this.fireEvent('beforeprinted', this, this.layoutCombo.getValue());
+ GeoExt.ux.layout.LayoutPrinter(this.map, this.layoutCombo.getValue());
+ GeoExt.ux.layout.LayoutPrinter.OpenPrint();
+ if (Ext.getCmp('printerwindow')) {
+ Ext.getCmp('printerwindow').close();
+ }
+ this.fireEvent('printed', this, this.layoutCombo.getValue());
+
+ }
+});
+
+Ext.reg('gxux_printerpanel', GeoExt.ux.PrinterPanel);
\ No newline at end of file
Added: sandbox/cmoullet/ux/Printer/ux/widgets/PrinterWindow.js
===================================================================
--- sandbox/cmoullet/ux/Printer/ux/widgets/PrinterWindow.js (rev 0)
+++ sandbox/cmoullet/ux/Printer/ux/widgets/PrinterWindow.js 2010-01-01 13:25:44 UTC (rev 1642)
@@ -0,0 +1,30 @@
+/**
+ * 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');
+
+GeoExt.ux.PrinterWindow = Ext.extend(Ext.Window, {
+ id: 'printerwindow',
+ modal: true,
+ title: OpenLayers.i18n('Printer'),
+ height: 100,
+ width: 275,
+
+ initComponent: function() {
+
+ this.printerPanel = new GeoExt.ux.PrinterPanel({
+ map: this.map,
+ height: 100
+ });
+
+ this.items = [
+ this.printerPanel
+ ];
+ GeoExt.ux.PrinterWindow.superclass.initComponent.call(this);
+ }
+});
\ No newline at end of file
More information about the Commits
mailing list