mxStyleRegistry.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * Copyright (c) 2006-2015, JGraph Ltd
  3. * Copyright (c) 2006-2015, Gaudenz Alder
  4. */
  5. var mxStyleRegistry =
  6. {
  7. /**
  8. * Class: mxStyleRegistry
  9. *
  10. * Singleton class that acts as a global converter from string to object values
  11. * in a style. This is currently only used to perimeters and edge styles.
  12. *
  13. * Variable: values
  14. *
  15. * Maps from strings to objects.
  16. */
  17. values: [],
  18. /**
  19. * Function: putValue
  20. *
  21. * Puts the given object into the registry under the given name.
  22. */
  23. putValue: function(name, obj)
  24. {
  25. mxStyleRegistry.values[name] = obj;
  26. },
  27. /**
  28. * Function: getValue
  29. *
  30. * Returns the value associated with the given name.
  31. */
  32. getValue: function(name)
  33. {
  34. return mxStyleRegistry.values[name];
  35. },
  36. /**
  37. * Function: getName
  38. *
  39. * Returns the name for the given value.
  40. */
  41. getName: function(value)
  42. {
  43. for (var key in mxStyleRegistry.values)
  44. {
  45. if (mxStyleRegistry.values[key] == value)
  46. {
  47. return key;
  48. }
  49. }
  50. return null;
  51. }
  52. };
  53. mxStyleRegistry.putValue(mxConstants.EDGESTYLE_ELBOW, mxEdgeStyle.ElbowConnector);
  54. mxStyleRegistry.putValue(mxConstants.EDGESTYLE_ENTITY_RELATION, mxEdgeStyle.EntityRelation);
  55. mxStyleRegistry.putValue(mxConstants.EDGESTYLE_LOOP, mxEdgeStyle.Loop);
  56. mxStyleRegistry.putValue(mxConstants.EDGESTYLE_SIDETOSIDE, mxEdgeStyle.SideToSide);
  57. mxStyleRegistry.putValue(mxConstants.EDGESTYLE_TOPTOBOTTOM, mxEdgeStyle.TopToBottom);
  58. mxStyleRegistry.putValue(mxConstants.EDGESTYLE_ORTHOGONAL, mxEdgeStyle.OrthConnector);
  59. mxStyleRegistry.putValue(mxConstants.EDGESTYLE_SEGMENT, mxEdgeStyle.SegmentConnector);
  60. mxStyleRegistry.putValue(mxConstants.PERIMETER_ELLIPSE, mxPerimeter.EllipsePerimeter);
  61. mxStyleRegistry.putValue(mxConstants.PERIMETER_RECTANGLE, mxPerimeter.RectanglePerimeter);
  62. mxStyleRegistry.putValue(mxConstants.PERIMETER_RHOMBUS, mxPerimeter.RhombusPerimeter);
  63. mxStyleRegistry.putValue(mxConstants.PERIMETER_TRIANGLE, mxPerimeter.TrianglePerimeter);
  64. mxStyleRegistry.putValue(mxConstants.PERIMETER_HEXAGON, mxPerimeter.HexagonPerimeter);
  65. __mxOutput.mxStyleRegistry = typeof mxStyleRegistry !== 'undefined' ? mxStyleRegistry : undefined;