From 4648e2eda9aa8c8f9b0aed4d12fef8b1d00f1769 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 19 Jul 2012 16:26:03 -0700 Subject: IKNINJA-1780 - [Shape] Error when opening document that contains a shape with gradient color or no color. Signed-off-by: Nivesh Rajbhandari --- js/lib/geom/circle.js | 57 +++++++++++++++++---------------------------------- 1 file changed, 19 insertions(+), 38 deletions(-) (limited to 'js/lib/geom/circle.js') diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js index ba47603b..4995c2cb 100755 --- a/js/lib/geom/circle.js +++ b/js/lib/geom/circle.js @@ -83,31 +83,13 @@ exports.Circle = Object.create(GeomObj, { if(strokeMaterial) { this._strokeMaterial = strokeMaterial.dup(); - } else { - this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); - } - - if(strokeColor) { - if(this._strokeMaterial.hasProperty("color")) { - this._strokeMaterial.setProperty( "color", this._strokeColor ); - } else if (this._strokeMaterial && (this._strokeMaterial.gradientType === this._strokeColor.gradientMode)) { - this._strokeMaterial.setGradientData(this._strokeColor.color); - } } if(fillMaterial) { this._fillMaterial = fillMaterial.dup(); - } else { - this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); } - if(fillColor) { - if(this._fillMaterial.hasProperty("color")) { - this._fillMaterial.setProperty( "color", this._fillColor ); - } else if (this._fillMaterial && (this._fillMaterial.gradientType === this._fillColor.gradientMode)) { - this._fillMaterial.setGradientData(this._fillColor.color); - } - } + this.initColors(); } }, @@ -770,8 +752,8 @@ exports.Circle = Object.create(GeomObj, { 'fillColor' : this._fillColor, 'innerRadius' : this._innerRadius, 'strokeStyle' : this._strokeStyle, - 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : MaterialsModel.getDefaultMaterialName(), - 'fillMat' : this._fillMaterial ? this._fillMaterial.getName() : MaterialsModel.getDefaultMaterialName(), + 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : null, + 'fillMat' : this._fillMaterial ? this._fillMaterial.getName() : null, 'materials' : this.exportMaterialsJSON() }; @@ -790,27 +772,26 @@ exports.Circle = Object.create(GeomObj, { this._fillColor = jObj.fillColor; this._innerRadius = jObj.innerRadius; this._strokeStyle = jObj.strokeStyle; - var strokeMaterialName = jObj.strokeMat; - var fillMaterialName = jObj.fillMat; - var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ).dup(); - if (!strokeMat) { - console.log( "object material not found in library: " + strokeMaterialName ); - strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); + if(jObj.strokeMat) { + var strokeMat = MaterialsModel.getMaterial(jObj.strokeMat).dup(); + if (!strokeMat) { + console.log("object material not found in library: " + jObj.strokeMat); + } else { + this._strokeMaterial = strokeMat; + } } - this._strokeMaterial = strokeMat; - if (this._strokeMaterial.hasProperty( 'color' )) - this._strokeMaterial.setProperty( 'color', this._strokeColor ); - - var fillMat = MaterialsModel.getMaterial( fillMaterialName ).dup(); - if (!fillMat) { - console.log( "object material not found in library: " + fillMaterialName ); - fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); + + if(jObj.fillMat) { + var fillMat = MaterialsModel.getMaterial(jObj.fillMat).dup(); + if (!fillMat) { + console.log("object material not found in library: " + jObj.fillMat); + } else { + this._fillMaterial = fillMat; + } } - this._fillMaterial = fillMat; - if (this._fillMaterial.hasProperty( 'color' )) - this._fillMaterial.setProperty( 'color', this._fillColor ); + this.initColors(); this.importMaterialsJSON( jObj.materials ); } }, -- cgit v1.2.3