﻿////////////////////////////////////////////////////////////
//
//ファイル名:   view.js
//機能		:	ビュー管理
//依存		:	main.js
//				spatial.js
//バージョン:　 2.0.0.1
//更新日時	:　 2006.08.01
//更新者	:	kawame
//
//////////////////////////////////////////////////////////////


function ViewManager(gis)
{
	var gisMain			= gis;
	var currentView		= null;
	
	this.viewTypeDefinition	= new ViewType();
	
	// ズーム管理	
	this.zoomManager = new ZoomManager(this);
	
	// 移動管理	
	this.moveManager = new MoveManager(this);
	
	// 履歴管理	
	this.historyManager = new HistoryManager(this);
	
	//画面サイズ管理*****************************************************************
	this.sizeManager = new SizeManager(this);	
	
	//画像サイズを変える場合必要になる？*********************************************
	this.scaleManager = new ScaleManager(this);		
		
	//地図のスケール管理/*kwm追加*/	
	this.scaleManager = new ScaleManager(this);	
		
	// ビューの取得	
	this.getCurrentView = function()
	{
		return currentView;
	}
	
	// ビューの設定	
	this.setCurrentView = function(view)
	{ 
		var f=check_flg_viewLock();
		if(f)
		{
			currentView = view;
		}
		else
		{
			var i = gis.viewManager.historyManager.history.length;
			if(i>0)
			{
				currentView = gis.viewManager.historyManager.history[i-1];
			}
			else
			{
				currentView = gis.viewManager.historyManager.history[0];
			}
		}
		
		setIndexTarget(currentView.center);
		setIndexRect(currentView.boundingBox);
		
		map_minX=currentView.boundingBox.minX;
		map_minY=currentView.boundingBox.minY;
		map_maxX=currentView.boundingBox.maxX;
		map_maxY=currentView.boundingBox.maxY;
		map_centerX = currentView.center.x;
		map_centerY = currentView.center.y;
		map_width =currentView.width;
		map_height=currentView.height;
		map_scale = currentView.scale;
		
	//	setMapClip();
//		if(mapScale_ImageMode == 0)
//		{
			changeScaleBtnView(map_scale);
//		}
	}
	
	// 更新
	this.refresh = function()
	{
		gisMain.eventManager.viewChange();
	}
}

//
//	ズーム管理//
function ZoomManager(viewMng)
{
	var viewManager		= viewMng;

	// 拡大の割合（表示範囲の比）

	this.zoomInRatio	= zoomInRatio;
	
	// 縮小の割合（表示範囲の比）

	this.zoomOutRatio	= zoomOutRatio;
	
	// 拡大
	this.zoomIn = function()
	{
		return this.zoomCommon(this.zoomInRatio);
	}
	
	// 縮小

	this.zoomOut = function()
	{
		return this.zoomCommon(this.zoomOutRatio);
	}
	
	
	// 追加メソッド***************************************************************************
	// 拡大縮小共通処理

	this.zoomCommon = function(ratio)
	{
		var view = gis.viewManager.getCurrentView();
		if (view)
		{
			var v = viewCopy();
			
			var s	= v.scale*ratio;
			var c	= v.center;
			var bbox =  v.boundingBox;
			var v = getViewScale(c,s);
			view.type   = v.type;
			view.scale  = v.scale;
			view.center = v.center;
			view.boundingBox   = v.boundingBox;
			
			viewManager.setCurrentView(view);
			viewManager.refresh();
		}
	}
	//ここまで************************************************************************	
	
}

//
//	移動管理//
function MoveManager(viewMng)
{
	var viewManager		= viewMng;

	// 移動の割合（１画面分の移動を1.0とする）

	this.moveRatio		= moveRatio;
	
	// 中心移動

	this.moveCenter = function(x, y)
	{
		var view = viewManager.getCurrentView();
		if (view)
		{	
			var v = viewCopy();
		
			var bbox = v.boundingBox;
			var newCenterX = x;
			var newCenterY = y;
			var newCenter=new Point(newCenterX,newCenterY);
			var diffCenterX = newCenterX - v.center.x;
			var diffCenterY = newCenterY - v.center.y;
		
		//画面サイズを更新
			
			var _v = getViewScale(newCenter,v.scale);
			view.type   = _v.type;
			view.scale  = _v.scale;
			view.center = _v.center;
			view.boundingBox   = _v.boundingBox;
			
			viewManager.setCurrentView(view);
			viewManager.refresh();	
		}
	}

	// 左上移動
	this.moveUL = function()
	{
		return this.moveCommon(-this.moveRatio,this.moveRatio);
	}
	
	// 上移動
	this.moveUC = function()
	{
		return this.moveCommon(0,this.moveRatio);
	}
	
	// 右上移動
	this.moveUR = function()
	{
		return this.moveCommon(this.moveRatio,this.moveRatio);
	}
	
	// 左移動
	this.moveML = function()
	{
		return this.moveCommon(-this.moveRatio,0);
	}
	
	// 右移動
	this.moveMR = function()
	{
		return this.moveCommon(this.moveRatio,0);
	}
	
	// 左下移動
	this.moveBL = function()
	{
		return this.moveCommon(-this.moveRatio,-this.moveRatio);
	}
	
	// 下移動
	this.moveBC = function()
	{
		return this.moveCommon(0,-this.moveRatio);
	}
	
	// 右下移動
	this.moveBR = function()
	{
		return this.moveCommon(this.moveRatio,-this.moveRatio);
	}
	
	// 追加メソッド***************************************************************************
	// 移動共通処理
	this.moveCommon = function(ratioX, ratioY)
	{
		var view = viewManager.getCurrentView();
		if (view)
		{
			var v = viewCopy();
			
			var bbox = new BoundingBox(v.boundingBox.minX,v.boundingBox.minY,v.boundingBox.maxX,v.boundingBox.maxY);
			var diffX = bbox.maxX - bbox.minX;
			var diffY = bbox.maxY - bbox.minY;
			
			bbox.minX +=diffX * ratioX;
			bbox.maxX +=diffX * ratioX;
			bbox.minY +=diffY * ratioY;
			bbox.maxY +=diffY * ratioY;
			
			var cx = (bbox.minX + bbox.maxX)/2;
			var cy = (bbox.minY + bbox.maxY)/2;
			var c = new Point(cx,cy);
			var s = v.scale;
			
			var _v = getViewScale(c,s);
			view.type   = _v.type;
			view.scale  = _v.scale;
			view.center = _v.center;
			view.boundingBox   = _v.boundingBox;
			
			viewManager.setCurrentView(view);
			viewManager.refresh();
		}
	}	
	//ここまで************************************************************************************
}

//
//	ビューの履歴管理//
function HistoryManager(viewMng)
{
	var viewManager		= viewMng;
	
	// 履歴に保持するビューの最大数
	this.maxHistorySize	= 10;
	
	// ビューのリスト（インデックスの小さい方が古い履歴）	
	this.history = new Array();
}

//
//	ビュー
//
function View(type, boundingBox, center, scale, angle, time, width, height)
{
	var viewType		= new ViewType();
	var newType			= type;
	var newBoundingBox	= ((boundingBox) ? boundingBox : null);
	var newCenter		= ((center) ? center : null);
	var newScale		= ((scale) ? parseInt(scale) : null);
	
	var newAngle		= ((angle) ? parseInt(angle) : 0);
	var newTime			= ((time) ? time : new Date());	
	var newWidth		= ((width) ? width  : 0 );
	var newHeight		= ((height) ? height: 0 ); 
	
	if (newBoundingBox && ! newType)
	{
		newType = viewType.BOUNDING_BOX;
	}
	else if (newCenter && newScale && ! newType)
	{
		newType = viewType.SCALE;
	}
	
	// ビュー種別
	this.type = newType;
	
	// 境界矩形
	this.boundingBox = newBoundingBox;
	
	// 中心座標	
	this.center = newCenter;
	
	// 縮尺
	this.scale = newScale;
	
	// 回転角度（反時計周り）
	this.angle = newAngle;
	
	// 日時	this.time = newTime;	
	
	//画面サイズ
	this.width = newWidth ;
	this.height =newHeight ; 
}

//
//	ビュー種別
//
function ViewType()
{
	// 境界矩形で表現するビュー
	this.BOUNDING_BOX	= "bounding_box";
	
	// 中心座標と縮尺で表現するビュー
	this.SCALE			= "scale";
}

//
//画面サイズの設定************************************************************************************
//
function SizeManager(viewMng){

	var viewManager = viewMng;
	
	this.setMapSize = function(width,height)
	{
		var newWidth  = width;
		var newHeight = height;
			
		return this.sizeCommon(newWidth,newHeight);		
	}

   // 追加メソッド***************************************************************************			
	this.sizeCommon = function(width,height)
	{					
		var view = viewManager.getCurrentView();
		
		if (view)
		{				
			var v = viewCopy();
			
			var bbox = v.boundingBox;
			var diffX = bbox.maxX - bbox.minX;
			var diffY = bbox.maxY - bbox.minY;
			var w = v.width;
			var h = v.height;
			var s = v.scale;
			
			var newDiffX = diffX*width/w;
			var newDiffY = diffY*height/h;
			
			var centerX = (bbox.minX + bbox.maxX) / 2;//今表示している中心座標X
			var centerY = (bbox.minY + bbox.maxY) / 2;//今表示している中心座標Y
			var center = new Point(centerX,centerY);
			var coordwidth = diffX / w;//現在のm/pisel（X）			
			var coordheight = diffY / h;//現在のm/pisel（Y）			
			//画面サイズを変更したときに表示する範囲の計算						
			var minX = Math.round((centerX - (newDiffX / 2))*1000)/1000;
			var maxX = Math.round((centerX + (newDiffX / 2))*1000)/1000;
			var minY = Math.round((centerY - (newDiffY / 2))*1000)/1000;
			var maxY = Math.round((centerY + (newDiffY / 2))*1000)/1000;
			
			var  _bbox = new BoundingBox(minX,minY,maxX,maxY);
			
			//画面サイズを更新
			var ww = (width-view.width)/2;
			var hh = (height-view.height)/2;
			
			var min_x = 0;
			var min_y = height;
			var max_x = width;
			var max_y = 0;
			
			if(ww<0)
			{
				min_x = min_x - ww;
				max_x = max_x - ww;
			}
			
			if(hh<0)
			{
				min_y = min_y - hh;
				max_y = max_y - hh;
			}
			
			ClipShow(min_x,min_y,max_x,max_y);			      
			
			mapLayer.style.left = eval(mapLayer.style.left.replace("px","").replace("pt",""))+ww;
			mapLayer.style.top  = eval(mapLayer.style.top.replace("px","").replace("pt",""))+hh;
			
			view.width  = width;
			view.height = height;
			map_width	= width;
			map_height	= height;
			setsize();
			dummyLayer.width=map_width;
			dummyLayer.height=map_height;
			eventLayer.width=map_width;
			eventLayer.height=map_height;
			
			var _v = getViewBbox(_bbox);
			view.type		= _v.type;
			view.center		= _v.center;
			view.scale		= _v.scale;
			view.boundingBox= _v.boundingBox;					
						
			viewManager.setCurrentView(view);
			viewManager.refresh();
		}			
	}
}



		/*以下kwm追加*/
		//
		//縮尺の設定************************************************************************************
		//
		function ScaleManager(viewMng){

			var viewManager = viewMng;
			
			this.setMapScale = function(scale)
			{
				var newScale = scale;
					
				return this.scaleCommon(newScale);		
			}


		// 追加メソッド***************************************************************************			
			this.scaleCommon = function(scale)
			{					
				changeScale(scale);
				viewManager.refresh();			
			}
		}
		
		function changeScale(newscale)
		{
			var view = gis.viewManager.getCurrentView();
				
			if (view)
			{		
				view.viewType="SCALE";	
							
				if(newscale == -1)
				{
					var bbox = new BoundingBox();
				
					bbox.minX	= MAPEXTENT_MINX;
					bbox.minY	= MAPEXTENT_MINY;
					bbox.maxX	= MAPEXTENT_MAXX;
					bbox.maxY	= MAPEXTENT_MAXY;
					
					var v = getViewBbox(bbox);
					view.type       = v.type;
					view.center		= v.center;
					view.scale		= v.scale;
					view.boundingBox= v.boundingBox;	
				}	
				else
				{
					var v = viewCopy();
					var _v = getViewScale(v.center,newscale);
					view.type   = _v.type;
					view.scale  = _v.scale;
					view.center = _v.center;
					view.boundingBox   = _v.boundingBox;	
				}
				gis.viewManager.setCurrentView(view);
			}
		}
		
		var sUrl = null;
		//地図表示領域切り替え
		function gisViewChange()
		{				
			var view = gis.viewManager.getCurrentView();
			if (view && !flg_viewLock)				
			{	
				//地図切り替え中メッセージ準備
				setMapLoadingLayer();
				gis.eventManager.beforeRedraw(view);	
				
				//補正計算用変数
				var xx = map_mpp*(map_width*(map_magnification-1))/2;
				var yy = map_mpp*(map_height*(map_magnification-1))/2;
				
				mapExt_minx = Math.round((view.boundingBox.minX-xx)*1000)/1000;
				mapExt_maxx = Math.round((view.boundingBox.maxX+xx)*1000)/1000;
				mapExt_miny = Math.round((view.boundingBox.minY-yy)*1000)/1000;
				mapExt_maxy = Math.round((view.boundingBox.maxY+yy)*1000)/1000;
				
				//地図URL作成
				bbox = mapExt_minx +','+ mapExt_miny +','+ mapExt_maxx +','+ mapExt_maxy;
				sUrl='FrontController/handler/MapImageBuilder.ashx?BBOX='+bbox;
				sUrl = sUrl + '&WIDTH=' + view.width*map_magnification + '&HEIGHT=' + view.height*map_magnification+'&FORMAT='+MAP_FORMAT;
				
				mapLayer.src = sUrl;	
				
				var node = document.getElementsByName("range");
				if(node)
				{
					var i;
					for( i= 0;i<node.length;i++)
					{
						if(node[i].checked)
						{
							con_neighbor_search_dist = node[i].value;
							break;
						}
					}
				} 
				//印刷用URL
				bbox = view.boundingBox.minX +','+ view.boundingBox.minY +','+ view.boundingBox.maxX +','+ view.boundingBox.maxY;
				con_mapurl='_&BBOX='+bbox+'&WIDTH=' + view.width + '&HEIGHT=' + view.height+'&FORMAT='+MAP_FORMAT;
				
				//縮尺を表示
				var scl = document.getElementById("map_scale_lbl");
				if(scl && scl.style.display=="block")
				{
					scl.innerHTML = "縮尺：1/"+view.scale;
				}
				gis.eventManager.afterRedraw(view);			
			}
		}
		
		
		
		//地図読み込み時のメッセージ表示
		function setMapLoadingLayer()
		{
			if(!loadLayer)
			{
				loadLayer=document.getElementById(MAP_LOAD_LAYER);
			}
			mapClip_minx = (map_width*(map_magnification-1))/2;
			mapClip_maxy = (map_height*(map_magnification-1))/2;
			
			if(mapLayer.style.left.replace("px","").replace("pt","")!=(-mapClip_minx) || mapLayer.style.top.replace("px","").replace("pt","")!=(-mapClip_maxy))
			{
				loadLayer.src = style_path +"/images/utility/loadingmsg.gif";
				mapLayer.style.display="none";
			}
			else
			{
				loadLayer.src = style_path +"/images/utility/processing.gif";
				
			}
				loadLayer.style.zIndex="105";
			if(eventLayer)
			{
				eventLayer.style.display="none";
			}
			
			loadLayer.style.left=(map_width-loadLayer.width)/2;
			loadLayer.style.top=(map_height-loadLayer.height)/2;
			
			loadLayer.style.display="block";
			
			var node =document.getElementById('searchneighbor_result');
			if(node)
			{
				node.align = "center";	
				node.innerHTML = "ただ今検索中です。<br>お待ちください。";
			}
			setDisableObj();
			clearTargetImage();
		}


		function setMapClip()
		{
			mapLayer.style.display = "none";
			mapClip_minx = (map_width*(map_magnification-1))/2;
			mapClip_maxy = (map_height*(map_magnification-1))/2;
			
			mapClip_maxx = map_width+mapClip_minx;
			mapClip_miny = map_height+mapClip_maxy;
			mapLayer_left=(-mapClip_minx);
			mapLayer_top=(-mapClip_maxy);
			
			ClipShow(mapClip_minx,mapClip_miny,mapClip_maxx,mapClip_maxy);
			
			mapLayer.style.left=mapLayer_left;
			mapLayer.style.top=mapLayer_top;
			
		}


		//地図読み込み終了時の処理
		function clearLoadingLayer(value)
		{	
			setMapClip();
			mapLayer.style.display="block";
			moveLayer.style.display = "none";
			
			loadLayer.style.display="none";
			loadLayer.style.zIndex="100";
			
			//マウスイベント取得レイヤ初期化			
			setEventLayer();
			//作図したものを入れるDiv
			setCanvasLayer();
			//近隣施設検索
			GetRequestItem('reqSearchNeighbor');
			//URL取得			
			GetRequestItem('reqURL');
			//各種ボタンのdisable解除
			clearDisableObj();
		}
		
		//ヒストリー作成	
		function gisBeforeRedraw(view)
		{
			var max = gis.viewManager.historyManager.maxHistorySize;
			var j;
		
			var v = viewCopy();
			
			//ひとまず現在のViewを履歴に追加
			gis.viewManager.historyManager.history.push(v);
			
			j = gis.viewManager.historyManager.history.length;
			//履歴数が最大保持数を超えていたら古いものを消去
			if (j == max+1)
			{
				var i;
				for(i=0;i<max+1;i++)
				{
					var temp = gis.viewManager.historyManager.history[i];
					gis.viewManager.historyManager.history[i]=gis.viewManager.historyManager.history[i+1];
				}
				gis.viewManager.historyManager.history.pop();
			}
			
			//以下動作確認			
			var url = null;
			var cur = gis.viewManager.historyManager.history;
			var bbox = cur[0].boundingBox.minX +','+ cur[0].boundingBox.minY +','+ cur[0].boundingBox.maxX +','+ cur[0].boundingBox.maxY;
				
				url ='0:'+bbox+'\n';
			var l;
			
			j = gis.viewManager.historyManager.history.length;
			for(l=1;l<j;l++)
			{
				bbox = cur[l].boundingBox.minX +','+ cur[l].boundingBox.minY +','+ cur[l].boundingBox.maxX +','+ cur[l].boundingBox.maxY;
				
				url+= l+':'+bbox+'\n';
			}
		}	
				
		//viewの値を表示			
		function gisAfterRedraw(view){						
			var node = document.getElementById('v_center');	
			if(node)	{	node.value = '('+ view .center.x + ',' + view.center.y + ') ';	}
			
			node = document.getElementById('v_min');
			if(node)	{	node.value = '(' + view.boundingBox.minX +','+ view.boundingBox.minY +')';	}
			
			node = document.getElementById('v_max');	
			if (node)	{	node.value = '(' + view.boundingBox.maxX +','+ view.boundingBox.maxY +')';	}
			
			node=document.getElementById("v_scale");
			if(node)	{	node.value ='('+ view.scale+ ') '; }
		}		
		
		//範囲の補正計算		
		function getViewBbox(boundingbox)
		{
			var bbox;
			var center;
			var scale;
			
			//指定した矩形の座標			
			var min_x = boundingbox.minX;
			var min_y = boundingbox.minY;
			var max_x = boundingbox.maxX;
			var max_y = boundingbox.maxY;
			
			var diff_x = max_x-min_x;
			var diff_y = max_y-min_y;
			
			//指定した矩形の中心座標→表示切替後の中心となる			
			var c_x=Math.round((min_x+diff_x/2)*1000)/1000;
			var c_y=Math.round((min_y+diff_y/2)*1000)/1000;
			
			var ratio;
			
			//表示範囲と画面サイズの調整				
			if ((diff_x/map_width) > (diff_y/map_height))
			{
				diff_y=diff_x / map_width * map_height;
				ratio = (diff_x/map_width)/standard_map_dpi;
			}
			else
			{
				diff_x=diff_y / map_height * map_width;
				ratio = (diff_y/map_height)/standard_map_dpi;
			}
			center = new Point (c_x,c_y);
			
			var s=Math.round(standard_scale*ratio);
			
			if(!checkScaleValue(s).flg)
			{
				scale	= checkScaleValue(s).scale;
				var _v  = getViewScale(center,scale);
				bbox	= _v.boundingBox;	
			}
			else
			{
				min_x=Math.round((c_x-diff_x/2)*1000)/1000;
				max_x=Math.round((c_x+diff_x/2)*1000)/1000;	
				min_y=Math.round((c_y-diff_y/2)*1000)/1000;
				max_y=Math.round((c_y+diff_y/2)*1000)/1000;
				
				bbox = new BoundingBox(min_x,min_y,max_x,max_y);
				scale = s;
			}
				
			var v = new View("bounding_box",bbox,center,scale,"","","","");
			
			return v;	
		}

		//範囲の補正計算		
		function getViewScale(c,s)
		{
			var bbox;
			var center;
			var scale;
			var type;
			
			scale=checkScaleValue(s).scale;

			if(!checkScaleValue(s).flg)
			{
				var _v = getViewScale(c,scale);
				type   = _v.type;
				scale  = _v.scale;
				center = _v.center;
				bbox   = _v.boundingBox;	
			}
			else
			{
				//指定した矩形の中心座標→表示切替後の中心となる
				var c_x=Math.round((c.x*1000))/1000;
				var c_y=Math.round((c.y*1000))/1000;
				var new_mpp = standard_map_dpi * s /standard_scale;
				if(new_mpp != map_mpp)
				{
					map_mpp = new_mpp;
					if(mapScaleShow)
					{
						var ms = Math.round(map_mpp*200);
						if(ms<1000)
						{
							mapScaleShow.innerHTML = ms+"m";
						}
						else
						{
							mapScaleShow.innerHTML = Math.round(ms/10)/100+"km";
						}
					}
				}
				//表示する範囲の計算
				var width=Math.round((map_width)*new_mpp*1000)/1000;
				var height=Math.round((map_height)*new_mpp*1000)/1000;
				
				//bboxの座標
				var min_x =Math.round((c_x-width/2)*1000)/1000;
				var min_y =Math.round((c_y-height/2)*1000)/1000;
				var max_x =Math.round((c_x+width/2)*1000)/1000;
				var max_y =Math.round((c_y+height/2)*1000)/1000;
				
				type = "scale";
				bbox	= new BoundingBox(min_x,min_y,max_x,max_y);
				center	= new Point(c_x,c_y);
				scale	= scale;
			}
			
			var v = new View(type,bbox,center,scale,"","","","");
			return v;
		}

		//スケールのチェック
		function checkScaleValue(s)
		{
			var scale = s;
			var f=true;
			
			var min=MAPSHOWSCALE_MIN?MAPSHOWSCALE_MIN:map_scaleMin;
			var max=MAPSHOWSCALE_MAX?MAPSHOWSCALE_MAX:map_scaleMax;
			
			if(scale<min)
			{
				scale= min;
				f= false;
			}
			else if(scale>max)
			{
				scale= max;
				f= false;
			}
			else 
			{
				scale = s;
				f= true;
			}
			
			return {scale:scale,flg:f};
		}
		
	var MAPSHOWSCALE_MIN = null;	
	var MAPSHOWSCALE_MAX = null;	
		
		//主題ごとの表示縮尺取得
		function setMapShowScale(val)
		{
			var refresh = true;
			
			var min = parseFloat(val.split(',')[0]);
			var max = parseFloat(val.split(',')[1]);	
			
			var view = viewCopy();
			var vscale = parseFloat(view.scale);
			
			if(min && !(min == -1))
			{
				MAPSHOWSCALE_MIN = min
			}	
			else
			{
				MAPSHOWSCALE_MIN = map_scaleMin;
			}
			
			if(max && !(max == -1))
			{
				MAPSHOWSCALE_MAX = max;
			}
			else
			{
				MAPSHOWSCALE_MAX = map_scaleMax;
			}
		
			if(vscale<MAPSHOWSCALE_MIN) 
			{
				changeScale(MAPSHOWSCALE_MIN);
			}
			else if(vscale > MAPSHOWSCALE_MAX)
			{
				changeScale(MAPSHOWSCALE_MAX);
			}
			else
			{
				refresh = false;
			}
			return refresh;
		}
		
		
		//カレントビューをコピー
		//(オブジェクト参照しないため)
		function viewCopy()
		{
			var view = gis.viewManager.getCurrentView();
			
			var t = view.viewType;
			var b_minx = parseFloat(view.boundingBox.minX );
			var b_miny = parseFloat(view.boundingBox.minY );
			var b_maxx = parseFloat(view.boundingBox.maxX );
			var b_maxy = parseFloat(view.boundingBox.maxY );
			var b = new BoundingBox(b_minx,b_miny,b_maxx,b_maxy);
			var c_x = parseFloat(view.center.x );
			var c_y = parseFloat(view.center.y );
			var c = new InputPoint(c_x,c_y);
			var s = parseFloat(view.scale);
			var w = parseFloat(view.width);
			var h = parseFloat(view.height);
			
			var v = new View(t,b,c,s, 0, new Date(),w,h);
			
			return v;
		}
