alt text

I can't understand how edge styling is done in JGraphX.

For style the blue and yellow cells, I used:

    mxStylesheet stylesheet = graphForStyling.getStylesheet();

    style = new Hashtable<String, Object>();
    style.put(mxConstants.STYLE_SHAPE,          mxConstants.SHAPE_ELLIPSE);
    style.put(mxConstants.STYLE_VERTICAL_ALIGN, mxConstants.ALIGN_MIDDLE);
    style.put(mxConstants.STYLE_FONTFAMILY,     editorFont);
    style.put(mxConstants.STYLE_FILLCOLOR,      lightBlueColor);
    style.put(mxConstants.STYLE_FONTCOLOR,      fontColor);

    stylesheet.putCellStyle("PETRINET_PLACE", style);

    style = new Hashtable<String, Object>();
    style.put(mxConstants.STYLE_SHAPE,          mxConstants.SHAPE_RECTANGLE);
    style.put(mxConstants.STYLE_ROUNDED,        true);
    style.put(mxConstants.STYLE_VERTICAL_ALIGN, mxConstants.ALIGN_MIDDLE);
    style.put(mxConstants.STYLE_FONTFAMILY,     editorFont);
    style.put(mxConstants.STYLE_FILLCOLOR,      yellowColor);
    style.put(mxConstants.STYLE_FONTCOLOR,      fontColor);

    stylesheet.putCellStyle("PETRINET_TRANSITION", style);

How can I change default color of all edges? If possible, without setting style NAME to every single edge, and with possibiity to set label text color too.

And after that, how can I position edge labels like this:

alt text

Or alternatively, how to set white background + border + rounded edges to the edge lables to enhance their readability.

asked 05 May '12, 10:28

bab%C4%8Da's gravatar image

babča
2316
accept rate: 0%

edited 06 May '12, 15:23

David's gravatar image

David
4.9k21831


Finally, I figured it out by myself. At least styling edges:

Map<String, Object> edgeStyle = new HashMap<String, Object>();
//edgeStyle.put(mxConstants.STYLE_EDGE, mxConstants.EDGESTYLE_ORTHOGONAL);
edgeStyle.put(mxConstants.STYLE_SHAPE,    mxConstants.SHAPE_CONNECTOR);
edgeStyle.put(mxConstants.STYLE_ENDARROW, mxConstants.ARROW_CLASSIC);
edgeStyle.put(mxConstants.STYLE_STROKECOLOR, "#000000");
edgeStyle.put(mxConstants.STYLE_FONTCOLOR, "#000000");
edgeStyle.put(mxConstants.STYLE_LABEL_BACKGROUNDCOLOR, "#ffffff");

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

answered 06 May '12, 19:15

bab%C4%8Da's gravatar image

babča
2316
accept rate: 0%

edited 06 May '12, 19:17

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
×9
×5

Asked: 05 May '12, 10:28

Seen: 5,569 times

Last updated: 06 May '12, 19:17