vml-shape-element.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. jvm.VMLShapeElement = function(name, config){
  2. jvm.VMLShapeElement.parentClass.call(this, name, config);
  3. this.fillElement = new jvm.VMLElement('fill');
  4. this.strokeElement = new jvm.VMLElement('stroke');
  5. this.node.appendChild(this.fillElement.node);
  6. this.node.appendChild(this.strokeElement.node);
  7. this.node.stroked = false;
  8. jvm.AbstractShapeElement.apply(this, arguments);
  9. };
  10. jvm.inherits(jvm.VMLShapeElement, jvm.VMLElement);
  11. jvm.mixin(jvm.VMLShapeElement, jvm.AbstractShapeElement);
  12. jvm.VMLShapeElement.prototype.applyAttr = function(attr, value){
  13. switch (attr) {
  14. case 'fill':
  15. this.node.fillcolor = value;
  16. break;
  17. case 'fill-opacity':
  18. this.fillElement.node.opacity = Math.round(value*100)+'%';
  19. break;
  20. case 'stroke':
  21. if (value === 'none') {
  22. this.node.stroked = false;
  23. } else {
  24. this.node.stroked = true;
  25. }
  26. this.node.strokecolor = value;
  27. break;
  28. case 'stroke-opacity':
  29. this.strokeElement.node.opacity = Math.round(value*100)+'%';
  30. break;
  31. case 'stroke-width':
  32. if (parseInt(value, 10) === 0) {
  33. this.node.stroked = false;
  34. } else {
  35. this.node.stroked = true;
  36. }
  37. this.node.strokeweight = value;
  38. break;
  39. case 'd':
  40. this.node.path = jvm.VMLPathElement.pathSvgToVml(value);
  41. break;
  42. default:
  43. jvm.VMLShapeElement.parentClass.prototype.applyAttr.apply(this, arguments);
  44. }
  45. };