hive/html/js-graph/vjSVG_primitive.js
//TODO: Create default property objects for required properties of primitives (eg box: vjPropSVG_box = new Object({x:0,y:0,z:0,height:1,width:1});)and ensure properties.
Create default property objects for required properties of primitives ;)and ensure properties.
Create default property objects for required properties of primitives ; ) and ensure properties .
function vjSVG_primitive(source)
{
    this.objID="svg"+Math.random();
    vjObj.register(this.objID,this);
    this.children=new Array();
    this.clone=function (source)
    {
         var i=0;  
         for (i in source) {
            this[i] = source[i];
         }
    };
    this.clone(source);
    this.renderChildren=function(svg)
    {
        if(!this.children )return ;
        for(var i=0; i<this.children.length;++i ) {
            if(this.children[i].render)
                this.children[i].render(svg);
        }
    };
    this.render=function(svg)
    {
        this.pushMyAttributes(svg);
        if(this.draw){
            var obj=this.draw(svg);
            if (this.svgID) {
                obj.id = this.svgID;
            }
            if(this.graphCallbacks){
                for(i in this.graphCallbacks){
                    obj.setAttribute(i,this.graphCallbacks[i]);
                }
            }
            if(this.title)
                svg.setTitle(this.title);
            if(this.desc)
                svg.setDesc(this.desc);
            if(this.attribute) 
                svg.setNewAttribute(this.attribute);
        }
        this.renderChildren(svg);
        this.popMyAttributes(svg);
    };
    this.pushMyAttributes=function(svg)
    {
        if (this.pen)  svg.setPen(this.pen);
        if (this.brush) svg.setBrush(this.brush);
        if (this.font) svg.setFont(this.font);
        if (this.link) svg.setLink(this.font);
        if (this.handler) {
            svg.setHandler(this.handler);
        }
        if (this.matrix) {
            var currentMatrix = svg.getCurrentFromArray(svg.matrixArray);
            svg.setMatrix( matrixMultiplication(currentMatrix, this.matrix) );
        }
        if (this.translation) {
            svg.translateMatrix( this.translation );
        }
        if (this.rotation) {
            svg.rotateMatrix(this.rotation.crd,this.rotation.vec,this.rotation.angle);
        }
        if (this.scale) {
            svg.scaleMatrix(this.scale);
        }
    };
    this.popMyAttributes=function(svg){
        if (this.pen)   svg.popPen();
        if (this.brush) svg.popBrush();
        if (this.font)  svg.popFont();
        if (this.link)  svg.popLink();
        if (this.handler) svg.popHandler();
        if (this.matrix) svg.popMatrix();
        if (this.rotation)svg.popMatrix();
        if (this.scale)svg.popMatrix();
        if (this.translation)svg.popMatrix();
    };
    this.unlink=function() {
        for (var i=0; i<this.children.length; i++)
            this.children[i].unlink();
        this.children = [];
        vjObj.unregister(this.objID);
    };
}
function vjSVG_primitive ( source ) { this . objID = "svg" + Math . random ( ) ; vjObj . register ( this . objID , this ) ; this . children = new Array ( ) ; this . clone = function ( source ) { var i = 0 ; for ( i in source ) { this [ i ] = source [ i ] ; } } ; this . clone ( source ) ; this . renderChildren = function ( svg ) { if ( ! this . children ) return ; for ( var i = 0 ; i < this . children . length ; ++ i ) { if ( this . children [ i ] . render ) this . children [ i ] . render ( svg ) ; } } ; this . render = function ( svg ) { this . pushMyAttributes ( svg ) ; if ( this . draw ) { var obj = this . draw ( svg ) ; if ( this . svgID ) { obj . id = this . svgID ; } if ( this . graphCallbacks ) { for ( i in this . graphCallbacks ) { obj . setAttribute ( i , this . graphCallbacks [ i ] ) ; } } if ( this . title ) svg . setTitle ( this . title ) ; if ( this . desc ) svg . setDesc ( this . desc ) ; if ( this . attribute ) svg . setNewAttribute ( this . attribute ) ; } this . renderChildren ( svg ) ; this . popMyAttributes ( svg ) ; } ; this . pushMyAttributes = function ( svg ) { if ( this . pen ) svg . setPen ( this . pen ) ; if ( this . brush ) svg . setBrush ( this . brush ) ; if ( this . font ) svg . setFont ( this . font ) ; if ( this . link ) svg . setLink ( this . font ) ; if ( this . handler ) { svg . setHandler ( this . handler ) ; } if ( this . matrix ) { var currentMatrix = svg . getCurrentFromArray ( svg . matrixArray ) ; svg . setMatrix ( matrixMultiplication ( currentMatrix , this . matrix ) ) ; } if ( this . translation ) { svg . translateMatrix ( this . translation ) ; } if ( this . rotation ) { svg . rotateMatrix ( this . rotation . crd , this . rotation . vec , this . rotation . angle ) ; } if ( this . scale ) { svg . scaleMatrix ( this . scale ) ; } } ; this . popMyAttributes = function ( svg ) { if ( this . pen ) svg . popPen ( ) ; if ( this . brush ) svg . popBrush ( ) ; if ( this . font ) svg . popFont ( ) ; if ( this . link ) svg . popLink ( ) ; if ( this . handler ) svg . popHandler ( ) ; if ( this . matrix ) svg . popMatrix ( ) ; if ( this . rotation ) svg . popMatrix ( ) ; if ( this . scale ) svg . popMatrix ( ) ; if ( this . translation ) svg . popMatrix ( ) ; } ; this . unlink = function ( ) { for ( var i = 0 ; i < this . children . length ; i ++ ) this . children [ i ] . unlink ( ) ; this . children = [ ] ; vjObj . unregister ( this . objID ) ; } ; }
TODO: Create default property objects for required properties of primitives (eg box: vjPropSVG_box = new Object({x:0,y:0,z:0,height:1,width:1});)and ensure properties.
TODO : Create default property objects for required properties of primitives ( eg box : vjPropSVG_box = new Object ( { x : 0 y : 0 z : 0 height : 1 width : 1 } ) ; ) and ensure properties .
//if (!this.objID || !this.objID.length ) // copy all the features from base object // object Attribute ==> attribute={"tagName":value} //alerJ("new attribute ", this.attribute) //        if (this.svgID) svg.setSVGID(this.svgID); //            for (ii in this.handler){ //                this.handler[ii]='vjSVG_GIhandler(\"'+this.handler[ii]+'\",\"'+this.objID+'\",\"'+this.coordinates[0].irow+'\");'; //call whatever function from the wrapper //            } //        if (this.svgID) svg.popSVGID();