incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtu...@apache.org
Subject svn commit: r534174 - in /incubator/xap/trunk/codebase/src/xap/bridges/google: GoogleLineBridge.js GoogleLinesBridge.js
Date Tue, 01 May 2007 18:01:26 GMT
Author: mturyn
Date: Tue May  1 11:01:25 2007
New Revision: 534174

URL: http://svn.apache.org/viewvc?view=rev&rev=534174
Log:
Implementations for Google lines.

Added:
    incubator/xap/trunk/codebase/src/xap/bridges/google/GoogleLineBridge.js
    incubator/xap/trunk/codebase/src/xap/bridges/google/GoogleLinesBridge.js

Added: incubator/xap/trunk/codebase/src/xap/bridges/google/GoogleLineBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/google/GoogleLineBridge.js?view=auto&rev=534174
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/google/GoogleLineBridge.js (added)
+++ incubator/xap/trunk/codebase/src/xap/bridges/google/GoogleLineBridge.js Tue May  1 11:01:25
2007
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+Xap.provide("xap.bridges.google.GoogleLineBridge"); 
+// Auto-added---o.k.?
+Xap.require("xap.session.ClientEvent");
+
+// Auto-added---o.k.?
+// TO_DO--make sure this is superfluous: Xap.require("xap.bridges.google.GoogleInfoWindowBridge");
+
+Xap.require("xap.bridges.google.GoogleBridge"); 
+
+ /**
+ * @fileoverview
+ * 
+ * A bridge class that controls a GMarker peer.
+ */
+
+/**
+ * Creates a xap.bridges.google.GoogleInfoWindowBridge.
+ * 
+ * 
+ * @class xap.bridges.google.GoogleInfoWindowBridge is the bridge between an XML element
+ * representing a google maps marker.
+ * 
+ * @constructor
+ * 
+ * @author bbuffone
+ */
+xap.bridges.google.GoogleLineBridge = function() {
+	xap.bridges.google.GoogleBridge.call( this );
+}
+
+xap.bridges.google.GoogleLineBridge.prototype = new xap.bridges.google.GoogleBridge;
+
+xap.bridges.google.GoogleLineBridge.s_log = xap.log.Logger.getLogger( "xap.bridges.google.GoogleLineBridge"
);
+
+xap.bridges.google.GoogleLineBridge.prototype.toString = function() {
+	return "xap.bridges.google.GoogleLineBridge";
+}
+
+/**
+ * Creates the peer component that this bridge controls.
+ */
+xap.bridges.google.GoogleLineBridge.prototype.createPeer = function() {
+	var parent = this.getElement().getParent();
+	var handler = this.getUiContentHandler().getHandlerForElement( parent );
+	var parentPeer = handler.getPeer();
+	
+	if ( parentPeer instanceof GMap2 ) {
+    	try {
+    	    //Parse the value into the lat and long that will be used to 
+    	    //set the center position.   
+    	    var pointsString = this.getElement().getAttribute("points");
+    	    var weight = this.getElement().getAttribute("weight") * 1.0;
+    	    var color = this.getElement().getAttribute("color");
+    	    var opacity = this.getElement().getAttribute("opacity");
+    	    if (opacity == null || opacity == ""){
+    	    	opacity = 1.0;
+    	    }
+    	    var thisPeer = this;   	    
+    	    var points = new Array();
+    	        	      	    
+    	    //lat, lng, lat, lng, lat, lng
+    	    var indexPos = pointsString.indexOf(",");
+    	    while (indexPos != -1){
+    	    	var lat = pointsString.substring(0, indexPos) * 1.0;
+    	    	pointsString = pointsString.substring(indexPos + 1);
+    	    	
+    	    	indexPos = pointsString.indexOf(",");
+    	    	var lng = "";
+    	    	if (indexPos != -1){
+    	    		lng = pointsString.substring(0, indexPos) * 1.0;
+    	    		pointsString = pointsString.substring(indexPos + 1);
+				}else{
+					lng = pointsString * 1.0;
+				}
+				var point = new GLatLng(lat, lng); 
+				points.push(point);
+				
+    	    	indexPos = pointsString.indexOf(",");
+    	    }
+
+    	    var polyLine = new GPolyline(points, color, weight, opacity); 
+     	    
+     	     	    
+    		parentPeer.addOverlay(polyLine);                       
+    		this.setPeer(polyLine);
+        } catch ( e ) {
+        	alert(e);
+    	}
+	} else {
+		xap.bridges.google.GoogleLineBridge.s_log.error("Bogus parent peer:" + parentPeer );
+	}
+}
+
+/**
+ * This method is called whenever an attribut
+ * on the XML element that maps to this bridge class
+ * is changed. DwtControlBridge handles the following attributes:
+ * Attributes not handled here are are passed to the 
+ * superclass attributeSet method.
+ */
+xap.bridges.google.GoogleLineBridge.prototype.attributeSet = function( event ) {
+	var name = event.getName();
+	var value = event.getNewValue();
+    
+	if (name=="latitude"){	 
+	}else if (name=="longitude"){
+	}else if (name=="weight"){
+	}else if (name=="color"){
+	}else if (name=="opacity"){
+	}else{
+		xap.bridges.google.GoogleBridge.prototype.attributeSet.call( this, event );
+	}
+	
+}
+
+/**
+ * Called by the parent to handle the removal of the Xml Element from the parent.
+ * In the case of the marker bridge we will need to remove the maker.
+ */
+xap.bridges.google.GoogleLineBridge.prototype.handleRemoval = function(parent, parentPeer)
{
+    //remove the marker.
+    parentPeer.removeOverlay(this.getPeer());
+}

Added: incubator/xap/trunk/codebase/src/xap/bridges/google/GoogleLinesBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/google/GoogleLinesBridge.js?view=auto&rev=534174
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/google/GoogleLinesBridge.js (added)
+++ incubator/xap/trunk/codebase/src/xap/bridges/google/GoogleLinesBridge.js Tue May  1 11:01:25
2007
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+ 
+Xap.provide("xap.bridges.google.GoogleLinesBridge"); 
+// Auto-added---o.k.?
+Xap.require("xap.xml.dom.events.StructureChangeEvent");
+
+// Auto-added---o.k.?
+Xap.require("xap.taghandling.AbstractTagImpl");
+
+Xap.require("xap.bridges.google.GoogleBridge"); 
+
+ /**
+ * @fileoverview
+ * 
+ * A bridge class that controls a Google object peer.
+ */
+
+/**
+ * Creates a xap.bridges.google.GoogleLinesBridge.
+ * 
+ * 
+ * @class xap.bridges.google.GoogleLinesBridge is the bridge between an XML element
+ * representing a google object.
+ * 
+ * @constructor
+ * 
+ * @author bbuffone
+ */
+xap.bridges.google.GoogleLinesBridge = function() {
+	xap.taghandling.AbstractTagImpl.call( this );
+}
+
+xap.bridges.google.GoogleLinesBridge.prototype = new xap.bridges.google.GoogleBridge;
+
+xap.bridges.google.GoogleLinesBridge.s_log = xap.log.Logger.getLogger( "xap.bridges.google.GoogleLinesBridge"
);
+
+xap.bridges.google.GoogleLinesBridge.prototype.toString = function() {
+	return "xap.bridges.google.GoogleLinesBridge";
+}
+
+xap.bridges.google.GoogleLinesBridge.prototype.createPeer = function() {
+	var parent = this.getElement().getParent();
+	var handler = this.getUiContentHandler().getHandlerForElement( parent );
+	var parentPeer = handler.getPeer();
+	
+	//just set the peer to be the google map.
+	if ( parentPeer instanceof GMap2 ) {         
+    	this.setPeer(parentPeer);
+ 	} else {
+		xap.bridges.google.GoogleLinesBridge.s_log.error("Bogus parent peer:" + parentPeer );
+	}
+}
+
+/**
+ * Subclasses should override this method to handle dynamic removal of children.
+ * Subclasses must either call super.onChildRemoved() or invoke
+ * afterChildRemoved() directly.
+ * @param e The xap.xml.dom.events.StructureChangeEvent
+ */
+xap.bridges.google.GoogleLinesBridge.prototype.onChildRemoved = function( event ) {
+	
+	if ( event.getType() == xap.xml.dom.events.StructureChangeEvent.ELEMENT_NODE ) {    
+	    //get the peer for the client and ask it to handle this.
+        var handler = this.getUiContentHandler().getHandlerForElement(event.getChange());
+        handler.handleRemoval(this.getElement().getParent(), this.getPeer());
+	}
+	
+	xap.bridges.google.GoogleBridge.prototype.onChildRemoved.call( this, event );
+}



Mime
View raw message