1
|
/*
|
2
|
Author: Cameron Shorter cameronATshorter.net, Mike Adair, Nedjo Rogers
|
3
|
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
|
4
|
|
5
|
$Id:
|
6
|
*/
|
7
|
|
8
|
// Ensure this object's dependancies are loaded.
|
9
|
mapbuilder.loadScript(baseDir+"/model/Proj.js");
|
10
|
mapbuilder.loadScript(baseDir+"/widget/MapContainerBase.js");
|
11
|
|
12
|
/**
|
13
|
* Render GML into SVG.
|
14
|
* Calls GmlCoordinates2Coord.xsl to convert GML to a simpler form.
|
15
|
* Calls GmlRendererSVG.xsl to convert GML to SVG.
|
16
|
* this.targetModel references the context model with
|
17
|
* width/height attributes.
|
18
|
* @constructor
|
19
|
* @base MapContainerBase
|
20
|
* @param widgetNode The widget's XML object node from the configuration document.
|
21
|
* @param model The model object that this widget belongs to.
|
22
|
*/
|
23
|
function GmlRendererSVG(widgetNode, model) {
|
24
|
var base = new MapContainerBase(this,widgetNode,model);
|
25
|
|
26
|
/** Output of XSL will be xhtml which will be appended to document.*/
|
27
|
this.paintMethod="xsl2html";
|
28
|
|
29
|
/** Xsl to convert GML Coordinates to Coords. */
|
30
|
this.coordXsl=new XslProcessor(baseDir+"/widget/GmlCooordinates2Coord.xsl");
|
31
|
|
32
|
/**
|
33
|
* Set up XSL params and convert Gml Coordinate nodes to Gml Coords so
|
34
|
* that they are easier to process by XSL.
|
35
|
* @param objRef Pointer to this object.
|
36
|
*/
|
37
|
this.prePaint = function(objRef) {
|
38
|
objRef.model.setParam("modelStatus","preparing coordinates");
|
39
|
objRef.stylesheet.setParameter("width", objRef.containerModel.getWindowWidth() );
|
40
|
objRef.stylesheet.setParameter("height", objRef.containerModel.getWindowHeight() );
|
41
|
bBox=objRef.containerModel.getBoundingBox();
|
42
|
objRef.stylesheet.setParameter("bBoxMinX", bBox[0] );
|
43
|
objRef.stylesheet.setParameter("bBoxMinY", bBox[1] );
|
44
|
objRef.stylesheet.setParameter("bBoxMaxX", bBox[2] );
|
45
|
objRef.stylesheet.setParameter("bBoxMaxY", bBox[3] );
|
46
|
objRef.stylesheet.setParameter("color", "#FF0000" );
|
47
|
|
48
|
objRef.resultDoc = objRef.coordXsl.transformNodeToObject(objRef.resultDoc);
|
49
|
|
50
|
}
|
51
|
|
52
|
/**
|
53
|
* Called when the context's hidden attribute changes.
|
54
|
* @param objRef This object.
|
55
|
* @param layerName The name of the layer that was toggled.
|
56
|
*/
|
57
|
this.hiddenListener=function(objRef, layerName){
|
58
|
var vis="visible";
|
59
|
if(objRef.model.getHidden(layerName)) {
|
60
|
vis="hidden";
|
61
|
}
|
62
|
var outputNode = document.getElementById(objRef.outputNodeId)
|
63
|
for (var i=0; i< outputNode.childNodes.length; ++i) {
|
64
|
outputNode.childNodes[i].style.visibility=vis;
|
65
|
}
|
66
|
}
|
67
|
this.model.addListener("hidden",this.hiddenListener,this);
|
68
|
|
69
|
}
|