1

I've been using JGraphX for displaying a static graph on a JPanel. So far I've had no problems with it. I drew the graph, customized the style, even added vertex listeners for a custom graph colorization.

Nontheless I need some of my graph edges to use a dotted line instead of the standard one the JGraphX uses. Something like this: ------------------------>

I've read different posts on SO on JGraphX edge customization but all they pointed out was the changing of the edge style by using mxEdgeStyle Class' constants.

Is there an easy way that JGraphX provides with the dotted line option that I have missed?

TylerH
  • 20,799
  • 66
  • 75
  • 101
fanulis
  • 175
  • 1
  • 1
  • 9
  • Can you provide a link to the solution(s) you found but did not work for you? I searched SO but despite your assurance, I found none. – Jongware Jun 27 '15 at 10:43
  • Sure. Here are some questions I found on SO that they look for the change of style on JGraphX edges. http://stackoverflow.com/questions/18575959/jgraphx-change-edge-rooting-style http://stackoverflow.com/questions/22746439/jgraphx-custom-layoult-curved-edges http://stackoverflow.com/questions/29926768/how-to-make-the-edges-of-needed-form-in-jgraphxs-graph – fanulis Jun 28 '15 at 10:39

1 Answers1

1

After searching for a while on mxConstants of JGraphX I've come across with this: public static String STYLE_DASHED = "dashed";

I've tried it on my graph and I can finally draw dotted edges

If you want dotted/dashed edges use the dashed=true key value pair or just add it on your stylesheet as a custom option: style.put(mxConstants.STYLE_DASHED, true);

fanulis
  • 175
  • 1
  • 1
  • 9
  • Just to add (to those that follow) jgraphx also supports SVG style dash-pattern (as per https://developer.mozilla.org/en/docs/Web/SVG/Attribute/stroke-dasharray) . Use style.put(STYLE_DASH_PATTERN, "7 3"); Note: pattern is seperated by space rather than comma. – Dazed May 25 '17 at 16:01