2

I am using a Graph Editor made with JGraphX. When there are two vertices connected with an edge, and the user clicks on the first vertex, I want to get the value of the second vertex.

I am getting the current vertex by:

Object cell = mycomponent.getCellAt(e.getX(), e.getY());

Then I am getting the outgoing edge with:

Object outgoing = mygraph.getOutgoingEdges(cell);

Finally, on the debugger, I am able to see that the outgoing object[] has the edge on the object[0]. But I am not able to get the value of the target vertex.

This is the structure

  1. outgoing (type object[])

    1.1 [0] (type mxCell)

    1.1.1 target (type mxCell)

    1.1.1.1 value (type string)

Is there any easier way to do this, or how should I be able to get the value of the second vertex?

Frodo Baggins
  • 8,290
  • 6
  • 45
  • 55
Camilo Guevara
  • 165
  • 1
  • 12

1 Answers1

1
Object[] outgoing = mygraph.getOutgoingEdges(cell);
Object[] values = new Object[outgoing.length];

for (int i = 0; i < outgoing.length; i++)
{
  Object targetCell = mygraph.getModel().getTerminal(outgoing[i], false);
  values[i] = mygraph.getModel().getValue();
}
Frodo Baggins
  • 8,290
  • 6
  • 45
  • 55