1

I'm using JGraphX to draw a graph,using mxCircleLayout as basic representation, but I want to change some behavior. For example I want the EDGESTYLE_TOPTOBOTTOM, so before build mxGraphComponent I define a new edge style:

' JGraphXAdapter graphAdapter = new JGraphXAdapter(this.stradario.getStradario());

graphAdapter.getModel().beginUpdate();
try {
    Map<String, Object> edgeStyle = new HashMap<String, Object>();
    edgeStyle = graphAdapter.getStylesheet().getDefaultEdgeStyle();
    edgeStyle.put(mxConstants.STYLE_EDGE, mxConstants.EDGESTYLE_TOPTOBOTTOM);
    mxStylesheet stylesheet = new mxStylesheet();
    stylesheet.setDefaultEdgeStyle(edgeStyle);
    graphAdapter.setStylesheet(stylesheet);

} finally {
    graphAdapter.getModel().endUpdate();
}

mxCircleLayout layout = new mxCircleLayout(graphAdapter);

layout.execute(graphAdapter.getDefaultParent());

mxGraphComponent graphComponent = new mxGraphComponent(graphAdapter);  
graphComponent.getViewport().setBackground(Color.white);

' The graph was drawn as a circle layout, but edges are not in TOPTOBOTTOM style. First draw Then, if I draw a new edge, or I change an existing one, the edge is drawn with TOPTOBOTTON style.

Modified edge take the TOPTOBOTTOMSTYLE

I don't understand why the initial drawn is without TOPTOBOTTOM style and the modified edge was done with the new style.

Fabrizio R.
  • 117
  • 1
  • 14

1 Answers1

0

The layout disables edge styles by default. Set the disableEdgeStyle member to false.

mxCircleLayout layout = new mxCircleLayout(graphAdapter);
layout.setDisableEdgeStyle(false);
layout.execute(graphAdapter.getDefaultParent());
Dan
  • 76
  • 1