﻿
//=================================点要素类[START]=================================
	/**
	 * 定义圆要素类
	 */		
	function KPolyOval(points,bfilled, fillcolor,strokecolor,strokeweight,radius, opacity)
    {
        this.points = points?points:new Array(0);				//经过点数组
        this.fillcolor = fillcolor ? fillcolor : "blue";		//填充颜色
        this.radius = radius ? radius : 10;						//圆半径
        this.coordsize="21600,21600";							//圆标识
        this.strokecolor = strokecolor ? strokecolor : "blue";	//圆边圆颜色
        this.strokeweight = strokeweight ? strokeweight : 2;	//圆边圆宽度
        this.opacity = opacity ? opacity : 0.5;						//透明度      
        this.bfilled=true;										//是否填充颜色

        this.added=false;
       
        if (KBase.getBrowserType()=="IE")
        {
            //创建圆形状
            this.polyoval = KBase.createElement("v:oval");
            KBase.getStyle(this.polyoval)["position"] = "absolute";
            KBase.getStyle(this.polyoval)["left"] = this.points[0]-this.radius/2;
            KBase.getStyle(this.polyoval)["top"] = this.points[1]-this.radius/2;
            KBase.getStyle(this.polyoval)["width"] =this.radius;
            KBase.getStyle(this.polyoval)["height"] = this.radius;
            this.polyoval.unselectable = "on";  
            
            this.polyoval.filled = this.bfilled;
            this.polyoval.coordsize =  this.coordsize;
            this.polyoval.strokecolor =  this.strokecolor;
            this.polyoval.strokeweight =  this.strokeweight;
            
            //创建圆边圆样式
            this.stroke = KBase.createElement("v:stroke");
            this.stroke.dashstyle = "solid";
            this.stroke.opacity = this.opacity;
            this.polyoval.appendChild(this.stroke);
            
            //创建圆填充样式
            this.fill = KBase.createElement("v:fill");
            this.fill.color = this.fillcolor;
            this.fill.opacity = this.opacity;
            this.polyoval.appendChild(this.fill);   
        }
        else
        {
            this.polyoval = KBase.createDiv(0);
            this.polyoval.ID = "KPolyOvalDiv";
            this.graphics = new jsGraphics(this.polyoval);
			KBase.getStyle(this.polyoval)["MozOpacity"] = this.opacity;
        }
        KBase.getStyle(this.polyoval)["position"] = "absolute";
        KBase.setZIndex(this.polyoval, 10);
        
    }
    
	/**
	 * 初始化
	 */		
    var KPolyOval_initialize = function(mapObject)
    {
        var ovalObject = this;
        ovalObject.Map = mapObject; 
        
        //获取地图容器大小
        var mapSize=ovalObject.Map.getContainerSize();
        
        ovalObject.added = true;
    }
    
    /**
	 * 获取VML点的位置
	 */		
    var KPolyOval_getPointsString = function()
    {
        var ovalObject = this;
        return ovalObject.points;
    }
    
    /**
	 * 画圆--用于FireFox
	 */		
    var KPolyOval_drawGraphics = function()
    {
        var ovalObject = this;
  
        ovalObject.graphics.setStroke(ovalObject.strokeweight);	//设置圆宽度

        ovalObject.graphics.setColor(ovalObject.fillcolor);		//设置颜色
       
        var x=ovalObject.points[0]-ovalObject.radius/2;
       
        var y=ovalObject.points[1]-ovalObject.radius/2
        var w=ovalObject.radius;
        var h=ovalObject.radius;
        ovalObject.graphics.fillOval(x,y,w,h); 
        ovalObject.graphics.drawOval(x,y,w,h);        
		ovalObject.graphics.paint();        
    }
    
    /**
	 * 重新绘制
	 */	
    var KPolyOval_reDraw = function()
    {
        var ovalObject = this;        
        if (KBase.getBrowserType()=="IE")
        {                    
            ;
        }
        else
        {
            ovalObject.graphics.clear();
            ovalObject.drawGraphics();
        }        
    }   
    
    /**
	 * 获取HTML控件
	 */	
    var KPolyOval_getObject = function()
    {
        var ovalObject = this;
        return ovalObject.polyoval;
    }
    
    /**
	 * 释放圆要素

	 */	
    var KPolyOval_depose = function()
    {
        var ovalObject = this;
        if (!KBase.getBrowserType()=="IE")
        {
            ovalObject.graphics.clear();
            ovalObject.graphics = null;
        }
        ovalObject.added = false;
    }
    
    /**
	 * 获取圆的填充颜色
	 */	
    var KPolyOval_getOvalColor = function()
    {
        var ovalObject = this;
        return ovalObject.fillcolor;
    }
    
    /**
	 * 获取圆边圆宽度
	 */	
    var KPolyOval_getStrokeWidth = function()
    {
        var ovalObject = this;
        return ovalObject.strokeweight ;
    }

    /**
	 * 获取圆边圆颜色
	 */	
    var KPolyOval_getStrokeColor = function()
    {
        var ovalObject = this;
        return ovalObject.strokecolor ;
    }   
    /**
	 * 设置经过点的集合
	 */	
    var KPolyOval_setPoints = function(points)
    {
        var ovalObject = this;
        ovalObject.points = points;        
        if (ovalObject.Map)
        {
            ovalObject.reDraw(true);
        }
    }
    
    /**
	 * 设置圆的填充颜色
	 */	
    var KPolyOval_setOvalColor = function(fillcolor)
    {
        var ovalObject = this;
        ovalObject.fillcolor = fillcolor;
        if (KBase.getBrowserType()=="IE")
        {
            ovalObject.polyoval.fillcolor = ovalObject.fillcolor;
        }
        else
        {
            if (ovalObject.added)
            {
                ovalObject.reDraw(true);
            }

        }
    }
  
    /**
	 * 设置圆的填充颜色
	 */	
    var KPolyOval_setStrokeWidth = function(strokeweight)
    {
        var ovalObject = this;
        ovalObject.strokeweight = strokeweight;
        if (KBase.getBrowserType()=="IE")
        {
            ovalObject.polyoval.strokeweight = ovalObject.strokeweight;
        }
        else
        {
            if (ovalObject.added)
            {
                ovalObject.reDraw(true);
            }

        }
    }
    /**
	 * 设置圆半径
	 */	
    var KPolyOval_setRadius = function(radius)
    {
        var ovalObject = this;
        ovalObject.radius = radius;
        if (KBase.getBrowserType()=="IE")
        {
            ovalObject.polyoval.radius = ovalObject.radius;
        }
        else
        {
            if (ovalObject.added)
            {
                ovalObject.reDraw(true);
            }

        }
    }
    
    /**
	 * 设置圆的边圆颜色
	 */	
    var KPolyOval_setStrokeColor = function(strokecolor)
    {
        var ovalObject = this;
        ovalObject.strokecolor = strokecolor;
        if (KBase.getBrowserType()=="IE")
        {
            ovalObject.polyoval.strokecolor = ovalObject.strokecolor;
        }
        else
        {
            if (ovalObject.added)
            {
                ovalObject.reDraw(true);
            }
        }
    }
    
    /**
	 * 设置圆的透明度

	 */	
    var KPolyOval_setOpacity = function(scale)
    {
        var ovalObject = this;
        ovalObject.opacity = scale;
        if (KBase.getBrowserType()=="IE")
        {
            ovalObject.stroke.opacity = ovalObject.opacity;
        }
        else
        {
            KBase.getStyle(ovalObject.polyoval)["MozOpacity"] = ovalObject.opacity;
        }
    }
    
   
    
    KConfig.defineClass("KPolyOval", KPolyOval);
    

    KConfig.defineFunction(KPolyOval, "initialize", KPolyOval_initialize);
    KConfig.defineFunction(KPolyOval, "getPointsString", KPolyOval_getPointsString);
	KConfig.defineFunction(KPolyOval, "drawGraphics", KPolyOval_drawGraphics);
    KConfig.defineFunction(KPolyOval, "reDraw", KPolyOval_reDraw);
    
    KConfig.defineFunction(KPolyOval, "getObject", KPolyOval_getObject);
    KConfig.defineFunction(KPolyOval, "depose", KPolyOval_depose);
    
    KConfig.defineFunction(KPolyOval, "getOvalColor", KPolyOval_getOvalColor);
    KConfig.defineFunction(KPolyOval, "getStrokeWidth", KPolyOval_getStrokeWidth);
    KConfig.defineFunction(KPolyOval, "getStrokeColor", KPolyOval_getStrokeColor);
    KConfig.defineFunction(KPolyOval, "setPoints", KPolyOval_setPoints);
    KConfig.defineFunction(KPolyOval, "setOvalColor", KPolyOval_setOvalColor);
    KConfig.defineFunction(KPolyOval, "setOpacity", KPolyOval_setOpacity);
    KConfig.defineFunction(KPolyOval, "setStrokeWidth", KPolyOval_setStrokeWidth);
    KConfig.defineFunction(KPolyOval, "setRadius", KPolyOval_setRadius);
    KConfig.defineFunction(KPolyOval, "setStrokeColor", KPolyOval_setStrokeColor);
    
//=================================地图VML绘图类[END]=================================
