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/line.js | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'js/lib/geom/line.js') diff --git a/js/lib/geom/line.js b/js/lib/geom/line.js index c0322f46..eec4f6d9 100755 --- a/js/lib/geom/line.js +++ b/js/lib/geom/line.js @@ -89,17 +89,9 @@ exports.Line = 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); - } - } + this.initColors(); } }, @@ -245,7 +237,7 @@ exports.Line = Object.create(GeomObj, { 'strokeWidth' : this._strokeWidth, 'strokeColor' : this._strokeColor, 'strokeStyle' : this._strokeStyle, - 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : MaterialsModel.getDefaultMaterialName(), + 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : null, 'materials' : this.exportMaterialsJSON() }; @@ -265,15 +257,17 @@ exports.Line = Object.create(GeomObj, { this._slope = jObj.slope; this._strokeStyle = jObj.strokeStyle; this._strokeColor = jObj.strokeColor; - var strokeMaterialName = jObj.strokeMat; - var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); - if (!strokeMat) { - console.log( "object material not found in library: " + strokeMaterialName ); - strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); + 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; + this.initColors(); this.importMaterialsJSON( jObj.materials ); } }, -- cgit v1.2.3