







































Module('ca.carleton.gcrc.atlas.graphoMap.graphoMap','$Revision: 2907 $',function(mod){

var modObservable=imprt('ca.carleton.gcrc.mvc.observable');
var modDisplayWidget=imprt('ca.carleton.gcrc.atlas.displayWidget');


var g_idCounter=0;








mod.Factory=Class(modDisplayWidget.WidgetFactory,function(publ,priv,supr){



publ.__init__=function(){

supr.__init__.call(this);






this.svgNS='http://www.w3.org/2000/svg';





this.xlinkNS='http://www.w3.org/1999/xlink';




this.mapCentre=0;
this.minX=-180;
this.maxX=180;




this.titleText=null;


this.backgroundImage=null;




this.mapLayers=new Array();




this.mapLabels=new Array();
}




publ.IsSVG=function()
{
return true;
}





publ.Width=function()
{
return 2;
}





publ.Height=function()
{
return 1;
}







publ.InstallBackgroundImage=function(source_,width_,height_)
{
this.backgroundImage={};
this.backgroundImage.href=source_;
this.backgroundImage.width=width_;
this.backgroundImage.height=height_;
}












publ.Create=function(
svgParent_,
dataModel_,
x_,
y_,
width_,
height_
)
{
var map=new mod.GraphoMap(
this,
svgParent_,
dataModel_,
x_,
y_,
width_,
height_
);

return map;
}













publ.AddLayer=function(
layerName_,
symbol_,
valueAttribute_,
colourAttribute_,fillColour_,
visibleAttribute_,
symbolSize_,sizeAttribute_,
opacity_,opacityAttribute_
,geometryAttribute
){
this.mapLayers.push(
[
layerName_,
symbol_,
valueAttribute_,
colourAttribute_,fillColour_,
visibleAttribute_,
symbolSize_,sizeAttribute_,
opacity_,opacityAttribute_
,geometryAttribute
]);
}






publ.AddLabel=function(
longitude_,
label_)
{
this.mapLabels.push(
[
longitude_,
label_
]);
}
});









mod.GraphoMap=Class(modObservable.Observer,function(publ,priv,supr){










publ.__init__=function(
factory_,
svgParent_,
dataModel_,
x_,
y_,
width_,
height_
){

supr.__init__.call(this);




this.mapInfo={};


this.mapInfo.dataModel=dataModel_;


this.mapInfo.mapCentre=factory_.mapCentre;
this.mapInfo.minX=factory_.minX;
this.mapInfo.maxX=factory_.maxX;


this.mapInfo.document=svgParent_.ownerDocument;
this.mapInfo.svgNS=factory_.svgNS;
this.mapInfo.xlinkNS=factory_.xlinkNS;
this.mapInfo.extraNS='http://www.gcrc.carleton.ca/SVGMap/1.0';


try
{
this.mapInfo.svgdefs=this.mapInfo.document.getElementsByTagNameNS(this.mapInfo.svgNS,'defs').item(0);
}
catch(ex)
{
alert('Error '+ex+', Could not find <defs /> section in your svg-file!\nPlease add at least an empty <defs /> element!');
}





this.x=x_*1;



this.y=y_*1;



this.mapInfo.width=width_*1;



this.mapInfo.height=height_*1;



this._parentGroup=svgParent_;


this.mapInfo.title=factory_.titleText;


this.mapInfo.backgroundImage=factory_.backgroundImage;






this._topElement=null;





this._backgroundElement=null;






this._clipPathElement=null;




this.mapInfo.strokeWidth=0.1;




this.mapInfo.colourInFocus='#4d4d4d';




this.mapInfo.colourSelected='#0092ff';




this.mapInfo.colourSelectedInFocus='#0062df';




this._backgroundColourElement=null;




this._mapId=g_idCounter;
++(g_idCounter);


this._labels=new Array();
var labelIndex;
for(labelIndex=0;labelIndex<factory_.mapLabels.length;++labelIndex)
{
var info={};
info.longitude=factory_.mapLabels[labelIndex][0];
info.label=factory_.mapLabels[labelIndex][1];
this._labels.push(info);
}


this._layerInfoObjects=new Array();


var layerIndex;
for(layerIndex=0;layerIndex<factory_.mapLayers.length;++layerIndex)
{
var layerName=factory_.mapLayers[layerIndex][0];
var symbol=factory_.mapLayers[layerIndex][1];
var valueAttribute=factory_.mapLayers[layerIndex][2];
var colourAttribute=factory_.mapLayers[layerIndex][3];
var fillColour=factory_.mapLayers[layerIndex][4];
var visibleAttribute=factory_.mapLayers[layerIndex][5];
var symbolSize=factory_.mapLayers[layerIndex][6];
var sizeAttribute=factory_.mapLayers[layerIndex][7];
var opacity=factory_.mapLayers[layerIndex][8];
var opacityAttribute=factory_.mapLayers[layerIndex][9];
var geometryAttribute=factory_.mapLayers[layerIndex][10];

var layerInfoObject=new mod.LayerInfo(
this.mapInfo,
layerName,
symbol,
valueAttribute,
colourAttribute,
fillColour,
visibleAttribute,
symbolSize,
sizeAttribute,
opacity,
opacityAttribute
,geometryAttribute
);
this._layerInfoObjects.push(layerInfoObject);

}


this.CreateMap();
}




publ.CreateMap=function()
{



















var clipPathId='caGcrcGraphoMap1ClipPath_'+this._mapId;
this._clipPathElement=this.mapInfo.document.createElementNS(this.mapInfo.svgNS,'clipPath');
this._clipPathElement.setAttributeNS(null,'id',clipPathId);
var pathElement=this.mapInfo.document.createElementNS(this.mapInfo.svgNS,'path');
pathElement.setAttributeNS(null,'d',
'M 0 0 L '+this.mapInfo.width+' 0 L '+this.mapInfo.width+' '+this.mapInfo.height
+' L 0 '+this.mapInfo.height+' Z');
this._clipPathElement.appendChild(pathElement);
this.mapInfo.svgdefs.appendChild(this._clipPathElement);


this._topElement=this.mapInfo.document.createElementNS(this.mapInfo.svgNS,'g');
this._topElement.setAttributeNS(null,'id','graphoMap_'+this._mapId);
this._topElement.setAttributeNS(null,'clip-path','url(#'+clipPathId+')');
this._topElement.setAttributeNS(null,'transform','translate('+(this.x)+','+(this.y)+')');
this._parentGroup.appendChild(this._topElement);



















var scale;
var offsetX;
var offsetY;
var backgroundOffsetX;
var backgroundOffsetY;
var backgroundWidth;
var backgroundHeight;
var outsideBoxRatio=this.mapInfo.width/this.mapInfo.height;
if(2==outsideBoxRatio)
{

scale=240/this.mapInfo.width;
offsetX=120;
offsetY=5;
backgroundOffsetX=0;
backgroundOffsetY=0;
backgroundWidth=this.mapInfo.width;
backgroundHeight=this.mapInfo.height;
}
else if(outsideBoxRatio<2)
{

scale=240/this.mapInfo.width;
offsetX=120;
offsetY=5+((this.mapInfo.height*scale)/2)-60;
backgroundOffsetX=0;
backgroundOffsetY=(((this.mapInfo.height*scale)-120)/scale)/2;
backgroundWidth=this.mapInfo.width;
backgroundHeight=this.mapInfo.height-(backgroundOffsetY*2);
}
else
{

scale=120/this.mapInfo.height;
offsetX=120+((this.mapInfo.width*scale)/2)-120;
offsetY=5;
backgroundOffsetX=(((this.mapInfo.width*scale)-240)/scale)/2;
backgroundOffsetY=0;
backgroundWidth=this.mapInfo.width-(backgroundOffsetX*2);
backgroundHeight=this.mapInfo.height;
}



var backgroundGroup=this.mapInfo.document.createElementNS(this.mapInfo.svgNS,'g');
backgroundGroup.setAttributeNS(null,'id','graphoMap_background_'+this._mapId);
backgroundGroup.setAttributeNS(null,'transform','translate('+backgroundOffsetX+','+backgroundOffsetY+')');
this._topElement.appendChild(backgroundGroup);

if(null!=this.mapInfo.backgroundImage){
var imageScaleGroup=this.mapInfo.document.createElementNS(this.mapInfo.svgNS,'g');
imageScaleGroup.setAttributeNS(null,'transform','scale('+(backgroundWidth/this.mapInfo.backgroundImage.width)+','+(backgroundHeight/this.mapInfo.backgroundImage.height)+')');
backgroundGroup.appendChild(imageScaleGroup);

var imageElement=this.mapInfo.document.createElementNS(this.mapInfo.svgNS,'image');
imageElement.setAttributeNS(null,'x',0);
imageElement.setAttributeNS(null,'y',0);
imageElement.setAttributeNS(null,'width',this.mapInfo.backgroundImage.width);
imageElement.setAttributeNS(null,'height',this.mapInfo.backgroundImage.height);
imageElement.setAttributeNS(this.mapInfo.xlinkNS,'href',this.mapInfo.backgroundImage.href);
imageScaleGroup.appendChild(imageElement);
}



var positionGroup=this.mapInfo.document.createElementNS(this.mapInfo.svgNS,'g');
positionGroup.setAttributeNS(null,'transform','matrix('+(1/scale)+' 0 0 '+(1/scale)+' '+(offsetX/scale)+' '+(offsetY/scale)+')');
this._topElement.appendChild(positionGroup);














this._backgroundElement=this.mapInfo.document.createElementNS(this.mapInfo.svgNS,'path');
this._backgroundElement.setAttributeNS(null,'d','M 10,0 a 10,10 0 1,1 -20,0 h -100 a 110,110 0 1,0 220,0 Z');
this._backgroundElement.setAttributeNS(null,'fill','#0000ff');
this._backgroundElement.setAttributeNS(null,'opacity',0.05);
this._backgroundElement.addEventListener('click',this,false);
positionGroup.appendChild(this._backgroundElement);


var labelIndex;
for(labelIndex=0;labelIndex<this._labels.length;++labelIndex)
{
var labelInfo=this._labels[labelIndex];

if(labelInfo.longitude>=this.mapInfo.minX&&labelInfo.longitude<=this.mapInfo.maxX){
var amplitude=this.mapInfo.maxX-this.mapInfo.minX;
var position=(labelInfo.longitude+this.mapInfo.mapCentre-(0.5*this.mapInfo.maxX)-(1.5*this.mapInfo.minX))/amplitude;

if(position<0.0){
position=position+1.0;
}

var rotation=(0.5-position)*180;

var textElement=this.mapInfo.document.createElementNS(this.mapInfo.svgNS,'text');
textElement.setAttributeNS(null,'x',0);
textElement.setAttributeNS(null,'y',116);
textElement.setAttributeNS(null,'text-anchor','middle');
textElement.setAttributeNS(null,'fill','#888888');
textElement.setAttributeNS(null,'font-family','Arial');
textElement.setAttributeNS(null,'font-size','8');
textElement.setAttributeNS(null,'transform','rotate('+rotation+')');
textElement.appendChild(this.mapInfo.document.createTextNode(labelInfo.label));
positionGroup.appendChild(textElement);
}
}


this._layers=this.mapInfo.document.createElementNS(this.mapInfo.svgNS,'g');
this._layers.addEventListener('click',this,false);
this._layers.addEventListener('mouseover',this,false);
this._layers.addEventListener('mouseout',this,false);
positionGroup.appendChild(this._layers);



var loop;
for(loop=0;loop<this._layerInfoObjects.length;++loop)
{
var layerInfo=this._layerInfoObjects[loop];


var gElem=this.mapInfo.document.createElementNS(this.mapInfo.svgNS,'g');
this._layers.appendChild(gElem);


layerInfo.DrawOn(gElem);
}


var titleLayer=this.mapInfo.document.createElementNS(this.mapInfo.svgNS,'g');
this._topElement.appendChild(titleLayer);


if(null!=this.mapInfo.title)
{
var titleElement=this.mapInfo.document.createElementNS(this.mapInfo.svgNS,'text');
titleElement.setAttributeNS(null,'x',3);
titleElement.setAttributeNS(null,'y',this.mapInfo.height-3);
titleElement.setAttributeNS(null,'text-anchor','start');
titleElement.setAttributeNS(null,'font-family','Arial');
titleElement.setAttributeNS(null,'font-size','12');
titleElement.setAttributeNS(null,'font-weight','bold');
titleElement.appendChild(this.mapInfo.document.createTextNode(''+this.mapInfo.title));
titleLayer.appendChild(titleElement);
}
}




publ.Remove=function()
{

var loop;
for(loop=0;loop<this._layerInfoObjects.length;++loop)
{
var layerInfo=this._layerInfoObjects[loop];
layerInfo.Terminate();
}
this._layerInfoObjects=new Array();


if(null!=this._backgroundElement)
{
this._backgroundElement.removeEventListener('click',this,false);
this._backgroundElement=null;
}
if(null!=this._layers)
{
this._layers.removeEventListener('click',this,false);
this._layers.removeEventListener('mouseover',this,false);
this._layers.removeEventListener('mouseout',this,false);
}


if(null!=this._topElement)
{
this._parentGroup.removeChild(this._topElement);
this._topElement=null;
}
if(null!=this._clipPathElement)
{
this.mapInfo.svgdefs.removeChild(this._clipPathElement);
this._clipPathElement=null;
}
}





publ.handleEvent=function(event_)
{

var type=event_.type


var element=event_.target;


if(null!=element.correspondingUseElement){
element=element.correspondingUseElement;
}


var layerId=element.getAttributeNS(this.mapInfo.extraNS,'layerId');
var featureId=element.getAttributeNS(this.mapInfo.extraNS,'featureId');


if(null!=featureId&&''!=featureId&&null!=layerId&&''!=layerId)
{
var layer=this.mapInfo.dataModel.LayerFromName(layerId);
var feature=layer.FeatureFromId(featureId);


if('click'==type)
{
feature.SelectionOnInit();
}
else if('mouseover'==type)
{
feature.FocusOnInit(event_);
}
else if('mouseout'==type)
{
feature.FocusOffInit();
}
}
else
{

this.mapInfo.dataModel.SelectionOffInit();
}
}





publ.BackgroundColourChanged=function(mvcEvent_)
{

this._backgroundColour=mvcEvent_.data;


if(null!=this._backgroundColourElement)
{
this._backgroundColourElement.setAttributeNS(null,'fill',this._backgroundColour);
}
}
});






mod.LayerInfo=Class(modObservable.Observer,function(publ,priv,supr){















publ.__init__=function(
mapInfo_,
layerName_,
symbol_,
valueAttribute_,
colourAttribute_,
fillColour_,
visibleAttribute_,
symbolSize_,
sizeAttribute_,
opacity_,
opacityAttribute_
,geometryAttribute_
){

supr.__init__.call(this);




this.mapInfo=mapInfo_;




this.layerName=layerName_;




this.valueAttribute=valueAttribute_;




this.fillColour=fillColour_;




this.colourAttribute=colourAttribute_;




this.visibleAttribute=visibleAttribute_;




if('square'==symbol_)
{
this.symbol='RectDef';
}
else if('triangle'==symbol_)
{
this.symbol='TriangleDef';
}
else if('picture'==symbol_)
{
this.symbol='CameraDef';
}
else if('video'==symbol_)
{
this.symbol='VideoDef';
}
else
{
this.symbol='CircleDef';
}




this.symbolSize=symbolSize_;




this.sizeAttribute=sizeAttribute_;
if(null==sizeAttribute_&&null==symbolSize_)
{
this.symbolSize=10;
}




this.opacity=opacity_;




this.opacityAttribute=opacityAttribute_;


this.geometryAttribute=geometryAttribute_;




this.layer=this.mapInfo.dataModel.LayerFromName(this.layerName);




this.useStrokeForInteraction=true;
if(null==this.colourAttribute&&null==this.fillColour)
{
this.useStrokeForInteraction=false;
}




this.features={};


this.Observe(this.layer,'add_atom',this.AddAtom,null);
this.Observe(this.layer,'remove_atom',this.RemoveAtom,null);
this.Observe(this.layer,'display_state',this.FeatureStateChanged,null);
this.Observe(this.layer,this.valueAttribute,this.FeatureValueChanged,null);
if(null!=this.colourAttribute)
{
this.Observe(this.layer,this.colourAttribute,this.FeatureColourChanged,null);
}
if(null!=this.visibleAttribute)
{
this.Observe(this.layer,this.visibleAttribute,this.FeatureVisibilityChanged,null);
}
if(null!=this.sizeAttribute)
{
this.Observe(this.layer,this.sizeAttribute,this.FeatureSizeChanged,null);
}
if(null!=this.opacityAttribute)
{
this.Observe(this.layer,this.opacityAttribute,this.FeatureOpacityChanged,null);
}

}





publ.DrawOn=function(group_)
{
this.group=group_;


var featureLoop;
var features=this.layer.Features();
for(featureLoop=0;featureLoop<features.length;++featureLoop)
{
this.AddAllAtomsOnFeature(features[featureLoop]);
}
}





publ.AddAllAtomsOnFeature=function(feature_)
{
var featureInfo=this.FeatureInfo(feature_);


if(1==featureInfo.effectiveVisibility)
{

var atomLoop;
var atoms=feature_.Atoms();
for(atomLoop=0;atomLoop<atoms.length;++atomLoop)
{
this._AddAtomGeometry(feature_,atoms[atomLoop]);
}
}
}






publ.AddAtom=function(event_)
{
var feature=event_.originator;
var atom=event_.data;
var featureInfo=this.FeatureInfo(feature);

var receiver=this;
this.mapInfo.dataModel.RegisterForEndProcessing(function(){

if(1==featureInfo.effectiveVisibility){
receiver._AddAtomGeometry(feature,atom);
}
});
}







publ._AddAtomGeometry=function(feature_,atom_)
{
var layerId=feature_.layerModel.name;
var featureId=feature_.id;

var featureInfo=this.FeatureInfo(feature_);


var coordString=atom_.PropertyValueFromName(this.geometryAttribute);
if(null!=coordString)
{
var coords=coordString.split(',');
var theX=coords[0]*1;

if(theX>=this.mapInfo.minX&&theX<=this.mapInfo.maxX){
var amplitude=this.mapInfo.maxX-this.mapInfo.minX;
var position=(theX+this.mapInfo.mapCentre-(0.5*this.mapInfo.maxX)-(1.5*this.mapInfo.minX))/amplitude;

if(position<0.0){
position=position+1.0;
}

var rotation=(0.5-position)*180;



var rotateGroup=this.mapInfo.document.createElementNS(this.mapInfo.svgNS,'g');
rotateGroup.setAttributeNS(null,'transform','rotate('+rotation+')');
featureInfo.group.appendChild(rotateGroup);


var translateGroup=this.mapInfo.document.createElementNS(this.mapInfo.svgNS,'g');
translateGroup.setAttributeNS(null,'transform',this.GetTranslateString(featureInfo));
rotateGroup.appendChild(translateGroup);


var scaleGroup=this.mapInfo.document.createElementNS(this.mapInfo.svgNS,'g');
scaleGroup.setAttributeNS(null,'transform',this.GetScaleString(featureInfo));
translateGroup.appendChild(scaleGroup);


var useElem=this.mapInfo.document.createElementNS(this.mapInfo.svgNS,'use');
useElem.setAttributeNS(this.mapInfo.xlinkNS,'href','#'+this.symbol);
useElem.setAttributeNS(this.mapInfo.extraNS,'layerId',layerId);
useElem.setAttributeNS(this.mapInfo.extraNS,'featureId',featureId);
this.SetElementOpacity(featureInfo,useElem);
scaleGroup.appendChild(useElem);


featureInfo.translateGroups.push(translateGroup);
featureInfo.scaleGroups.push(scaleGroup);
featureInfo.symbols.push(useElem);
}
}
}






publ.RemoveAtom=function(event_){
var feature=event_.originator;
var atom=event_.data;
var atomId=atom.id;


var featureInfo=this.FeatureInfo(feature);
featureInfo.redrawRequested=true;
var receiver=this;
this.mapInfo.dataModel.RegisterForEndProcessing(function(){

if(true==featureInfo.redrawRequested){
var truVisibility=featureInfo.isVisible;
featureInfo.isVisible=0;
receiver.ApplyEffectiveVisibility(feature);
featureInfo.isVisible=truVisibility;
receiver.ApplyEffectiveVisibility(feature);

featureInfo.redrawRequested=false;
}


});
}






publ.FeatureStateChanged=function(event_)
{
var feature=event_.originator;

this.ApplyColour(feature);
}





publ.FeatureValueChanged=function(event_)
{
var feature=event_.originator;
var effectiveValue=event_.data;
if(effectiveValue>100)
{
effectiveValue=100;
}
else if(effectiveValue<0)
{
effectiveValue=0;
}


var featureInfo=this.FeatureInfo(feature);

if(featureInfo.value!=effectiveValue)
{
featureInfo.value=effectiveValue;

this.ApplyEffectiveVisibility(feature);
}
}





publ.FeatureColourChanged=function(event_)
{
var feature=event_.originator;
var colourValue=event_.data;


var featureInfo=this.FeatureInfo(feature);


featureInfo.colourValue=colourValue;

this.ApplyColour(feature);
}





publ.ApplyColour=function(feature_)
{
var featureInfo=this.FeatureInfo(feature_);

var inFocus=feature_.IsInFocus();
var selected=feature_.IsSelected();

var fillColour;
var strokeColour;
var strokeWidth=this.mapInfo.strokeWidth;
var opacity=1;


if(this.useStrokeForInteraction)
{

if(null==featureInfo.colourValue)
{
fillColour='none';
}
else
{
fillColour=featureInfo.colourValue;
}


if(true==inFocus&&true==selected)
{
strokeColour=this.mapInfo.colourSelectedInFocus;
}
else if(true==selected)
{
strokeColour=this.mapInfo.colourSelected;
}
else if(true==inFocus)
{
strokeColour=this.mapInfo.colourInFocus;
}
else
{
strokeColour='none';
}
}
else
{

strokeColour='#000000';


if(true==inFocus&&true==selected)
{
fillColour=this.mapInfo.colourSelectedInFocus;
}
else if(true==selected)
{
fillColour=this.mapInfo.colourSelected;
}
else if(true==inFocus)
{
fillColour=this.mapInfo.colourInFocus;
}
else
{
fillColour='red';
strokeColour='none';
opacity=0;
}

}


featureInfo.group.setAttributeNS(null,'cursor','pointer');
featureInfo.group.setAttributeNS(null,'fill',fillColour);
featureInfo.group.setAttributeNS(null,'stroke',strokeColour);
featureInfo.group.setAttributeNS(null,'stroke-width',strokeWidth);
featureInfo.group.setAttributeNS(null,'opacity',opacity);
}





publ.FeatureVisibilityChanged=function(event_)
{
var feature=event_.originator;
var isVisible;
if(null==event_.data||0==event_.data)
{
isVisible=0;
}
else
{
isVisible=1;
}


var featureInfo=this.FeatureInfo(feature);


if(featureInfo.isVisible!=isVisible)
{
featureInfo.isVisible=isVisible;

this.ApplyEffectiveVisibility(feature);
}
}





publ.FeatureSizeChanged=function(event_)
{
var feature=event_.originator;
var size=event_.data;


if(size<0)
{
size=0;
}
else if(size>100)
{
size=100;
}
else if(null==size)
{
size=0;
}


var featureInfo=this.FeatureInfo(feature);


if(size!=featureInfo.sizeValue)
{
featureInfo.sizeValue=size;

this.ApplyEffectiveVisibility(feature);
}
}





publ.ApplyEffectiveVisibility=function(feature_)
{
var featureInfo=this.FeatureInfo(feature_);

var size=featureInfo.sizeValue;
var isVisible=featureInfo.isVisible;
var value=featureInfo.value;

var effectiveVisibility=1;
if(0==isVisible)
{
effectiveVisibility=0;
}
else if(0==size)
{
effectiveVisibility=0;
}
else if(0==value)
{
effectiveVisibility=0;
}

if(effectiveVisibility!=featureInfo.effectiveVisibility)
{
featureInfo.effectiveVisibility=effectiveVisibility;

if(1==effectiveVisibility)
{

this.AddAllAtomsOnFeature(feature_);
}
else
{
var domUtil=imprt('ca.carleton.gcrc.dom.util');


domUtil.RemoveChildren(featureInfo.group);
featureInfo.scaleGroups=new Array();
featureInfo.translateGroups=new Array();
featureInfo.symbols=new Array();
}
}
else if(1==effectiveVisibility)
{



var scaleString=this.GetScaleString(featureInfo);
var loop;
for(loop=0;loop<featureInfo.scaleGroups.length;++loop)
{
var scaleGroup=featureInfo.scaleGroups[loop];
scaleGroup.setAttributeNS(null,'transform',scaleString);
}


var translateString=this.GetTranslateString(featureInfo);
var loop;
for(loop=0;loop<featureInfo.translateGroups.length;++loop)
{
var translateGroup=featureInfo.translateGroups[loop];
translateGroup.setAttributeNS(null,'transform',translateString);
}
}
}





publ.GetScaleString=function(featureInfo_)
{
var size=featureInfo_.sizeValue;



var scale=(Math.sqrt(size)*2.5);


var scaleString='scale('+scale+','+scale+')';

return scaleString;
}





publ.GetTranslateString=function(featureInfo_)
{
var value=featureInfo_.value;

var translateString='translate(0,'+(110-value)+')'

return translateString;
}






publ.FeatureOpacityChanged=function(event_)
{
var feature=event_.originator;

var featureInfo=this.FeatureInfo(feature);
this.SetOpacity(featureInfo,event_.data);
}





publ.SetOpacity=function(featureInfo_,opacity_)
{
var opacity=1*opacity_;

var effectiveOpacity=opacity/100;
if(effectiveOpacity<0)
{
effectiveOpacity=0;
}
else if(effectiveOpacity>1)
{
effectiveOpacity=1;
}

if(featureInfo_.opacity!=effectiveOpacity)
{
featureInfo_.opacity=effectiveOpacity;


var symbols=featureInfo_.symbols;
var loop;
for(loop=0;loop<symbols.length;++loop)
{
this.SetElementOpacity(featureInfo_,symbols[loop]);
}
}
}





publ.SetElementOpacity=function(featureInfo_,symbol_)
{
symbol_.setAttributeNS(null,'fill-opacity',featureInfo_.opacity);
}







publ.FeatureInfo=function(feature_)
{
var featureInfo=this.features[feature_.id];
if(null==featureInfo)
{

featureInfo={};
this.features[feature_.id]=featureInfo;
featureInfo.model=feature_;


featureInfo.redrawRequested=false;


featureInfo.group=this.mapInfo.document.createElementNS(this.mapInfo.svgNS,'g');
this.group.appendChild(featureInfo.group);


featureInfo.scaleGroups=new Array();


featureInfo.translateGroups=new Array();


featureInfo.symbols=new Array();




featureInfo.value=feature_.GetVariableValue(this.valueAttribute);


if(null!=this.colourAttribute)
{
featureInfo.colourValue=feature_.GetVariableValue(this.colourAttribute);
}
else if(null!=this.fillColour)
{
featureInfo.colourValue=this.fillColour;
}
else
{
featureInfo.colourValue=null;
}


if(null!=this.visibleAttribute)
{
var isVisible=feature_.GetVariableValue(this.visibleAttribute);
if(null==isVisible||0==isVisible)
{
featureInfo.isVisible=0;
}
else
{
featureInfo.isVisible=1;
}
}
else
{
featureInfo.isVisible=1;
}


var size;
if(null!=this.sizeAttribute)
{
size=feature_.GetVariableValue(this.sizeAttribute);
}
else
{
size=this.symbolSize;
}
if(null==size||size<0)
{
featureInfo.sizeValue=0;
}
else if(size>100)
{
featureInfo.sizeValue=100;
}
else
{
featureInfo.sizeValue=size;
}


if(null!=this.opacityAttribute)
{
var opacity=feature_.GetVariableValue(this.opacityAttribute);
this.SetOpacity(featureInfo,opacity);
}
else
{
this.SetOpacity(featureInfo,this.opacity);
}


featureInfo.effectiveVisibility=1;
if(0==featureInfo.isVisible)
{
featureInfo.effectiveVisibility=0;
}
else if(0==featureInfo.sizeValue)
{
featureInfo.effectiveVisibility=0;
}
else if(0==featureInfo.value)
{
featureInfo.effectiveVisibility=0;
}


this.ApplyEffectiveVisibility(feature_);
this.ApplyColour(feature_);
}

return featureInfo;
}
});

});