When I manually create an Edge with createEdge, I can provide a style. However, when I draw an edge starting from an existing cell, some handler will create the edge for me. Which handler do I need to override (I suspect that is the way to go) and how to change the preview and style of the edge created? Only found a solution for javascript, but I am using Java. The GraphEditor example does what I want, but no matter where I look, I cannot find the solution to my question in the code.

asked 20 Aug '11, 07:53

vilarion's gravatar image

vilarion
24410
accept rate: 0%

edited 31 Dec '12, 15:39

David's gravatar image

David
4.9k21831


This will set the default style for all new edges.

    private void applyEdgeDefaults() {
    // Settings for edges
    Map<String, Object> edge = new HashMap<String, Object>();
    edge.put(mxConstants.STYLE_ROUNDED, true);
    edge.put(mxConstants.STYLE_ORTHOGONAL, false);
    edge.put(mxConstants.STYLE_EDGE, "elbowEdgeStyle");
    edge.put(mxConstants.STYLE_SHAPE, mxConstants.SHAPE_CONNECTOR);
    edge.put(mxConstants.STYLE_ENDARROW, mxConstants.ARROW_CLASSIC);
    edge.put(mxConstants.STYLE_VERTICAL_ALIGN, mxConstants.ALIGN_MIDDLE);
    edge.put(mxConstants.STYLE_ALIGN, mxConstants.ALIGN_CENTER);
    edge.put(mxConstants.STYLE_STROKECOLOR, "#000000"); // default is #6482B9
    edge.put(mxConstants.STYLE_FONTCOLOR, "#446299");

    mxStylesheet edgeStyle = new mxStylesheet();
    edgeStyle.setDefaultEdgeStyle(edge);
    graph.setStylesheet(edgeStyle);
}
link

answered 20 Aug '11, 08:44

eisbaw's gravatar image

eisbaw
367112
accept rate: 31%

edited 31 Dec '12, 15:39

David's gravatar image

David
4.9k21831

Thank you very much, that is exactly what I needed.

(20 Aug '11, 14:15) vilarion
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
×50

Asked: 20 Aug '11, 07:53

Seen: 5,033 times

Last updated: 31 Dec '12, 15:39