When I use insertEdge, I can supply some Object as value. How can I achieve the same for edges drawn from one vertex to another inside the editor?\n(apparently there is no userobject tag, btw.)

asked 23 Aug '11, 13:53

vilarion's gravatar image

vilarion
24410
accept rate: 0%

edited 24 Aug '11, 02:35


Solved it myself by overriding mxGraphModel.cellAdded

link

answered 23 Aug '11, 15:32

vilarion's gravatar image

vilarion
24410
accept rate: 0%

I tried the same thing, but the source and target properties are not set yet. I need to set a label based on the source type. Is there a way to do this?

(13 Feb '12, 15:07) Clark Rasmussen

Deriving mxGraphModel creates a bunch of problems, e.g. you lose your codec. Another solution would be adding a listener to your mxGraph as follows:

\n
addListener(mxEvent.ADD_CELLS, new mxIEventListener()\n{\n    public void invoke(Object sender, mxEventObject evt)\n    {\n        Object[] cells = (Object[])evt.getProperty("cells");\n\n        for (Object cell : cells)\n        {\n            if (getModel().isEdge(cell))\n            {\n                ((mxCell)cell).setValue(new UserObject());\n            }\n        }\n    }\n});\n
link

answered 24 Aug '11, 06:19

vilarion's gravatar image

vilarion
24410
accept rate: 0%

graph.addEdge = function(edge, parent, source, target, index){                      \n    value = mxUtils.createXmlDocument().createElement('transicion');        \n    value.setAttribute('type', 'transicion');   \n    value.setAttribute('label', 'Tarea');   \n    edge.value = value;\n\n    return mxGraph.prototype.addEdge.apply(this, arguments); // "supercall"\n};\n
link

answered 19 Mar '12, 10:27

cristisan's gravatar image

cristisan
135
accept rate: 0%

edited 19 Mar '12, 11:32

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×194
×100
×45
×16

Asked: 23 Aug '11, 13:53

Seen: 2,913 times

Last updated: 19 Mar '12, 11:32