vml-canvas-element.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. jvm.VMLCanvasElement = function(container, width, height){
  2. this.classPrefix = 'VML';
  3. jvm.VMLCanvasElement.parentClass.call(this, 'group');
  4. jvm.AbstractCanvasElement.apply(this, arguments);
  5. this.node.style.position = 'absolute';
  6. };
  7. jvm.inherits(jvm.VMLCanvasElement, jvm.VMLElement);
  8. jvm.mixin(jvm.VMLCanvasElement, jvm.AbstractCanvasElement);
  9. jvm.VMLCanvasElement.prototype.setSize = function(width, height){
  10. var paths,
  11. groups,
  12. i,
  13. l;
  14. this.width = width;
  15. this.height = height;
  16. this.node.style.width = width + "px";
  17. this.node.style.height = height + "px";
  18. this.node.coordsize = width+' '+height;
  19. this.node.coordorigin = "0 0";
  20. if (this.rootElement) {
  21. paths = this.rootElement.node.getElementsByTagName('shape');
  22. for(i = 0, l = paths.length; i < l; i++) {
  23. paths[i].coordsize = width+' '+height;
  24. paths[i].style.width = width+'px';
  25. paths[i].style.height = height+'px';
  26. }
  27. groups = this.node.getElementsByTagName('group');
  28. for(i = 0, l = groups.length; i < l; i++) {
  29. groups[i].coordsize = width+' '+height;
  30. groups[i].style.width = width+'px';
  31. groups[i].style.height = height+'px';
  32. }
  33. }
  34. };
  35. jvm.VMLCanvasElement.prototype.applyTransformParams = function(scale, transX, transY) {
  36. this.scale = scale;
  37. this.transX = transX;
  38. this.transY = transY;
  39. this.rootElement.node.coordorigin = (this.width-transX-this.width/100)+','+(this.height-transY-this.height/100);
  40. this.rootElement.node.coordsize = this.width/scale+','+this.height/scale;
  41. };