mxStencilRegistry.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /**
  2. * Copyright (c) 2006-2015, JGraph Ltd
  3. * Copyright (c) 2006-2015, Gaudenz Alder
  4. *
  5. * Code to add stencils.
  6. *
  7. * (code)
  8. * var req = mxUtils.load('test/stencils.xml');
  9. * var root = req.getDocumentElement();
  10. * var shape = root.firstChild;
  11. *
  12. * while (shape != null)
  13. * {
  14. * if (shape.nodeType == mxConstants.NODETYPE_ELEMENT)
  15. * {
  16. * mxStencilRegistry.addStencil(shape.getAttribute('name'), new mxStencil(shape));
  17. * }
  18. *
  19. * shape = shape.nextSibling;
  20. * }
  21. * (end)
  22. */
  23. var mxStencilRegistry =
  24. {
  25. /**
  26. * Class: mxStencilRegistry
  27. *
  28. * A singleton class that provides a registry for stencils and the methods
  29. * for painting those stencils onto a canvas or into a DOM.
  30. */
  31. stencils: {},
  32. /**
  33. * Function: addStencil
  34. *
  35. * Adds the given <mxStencil>.
  36. */
  37. addStencil: function(name, stencil)
  38. {
  39. mxStencilRegistry.stencils[name] = stencil;
  40. },
  41. /**
  42. * Function: getStencil
  43. *
  44. * Returns the <mxStencil> for the given name.
  45. */
  46. getStencil: function(name)
  47. {
  48. return mxStencilRegistry.stencils[name];
  49. }
  50. };
  51. __mxOutput.mxStencilRegistry = typeof mxStencilRegistry !== 'undefined' ? mxStencilRegistry : undefined;