Question about availability of com.intellij.openapi.graph module in recent IntelliJ Ultimate 2021.3

Answered

Is there in recent IntelliJ Ultimate 2021.3 (213.5744.223) a library that replaced com.intellij.openapi.graph (based on yWorks one)?

I know of com.intellij.diagram library, but I would like to do some custom layout and rendering of Graph nodes/ports and Edges (by adding some JComponents).

 

8 comments
Comment actions Permalink
Official comment

Hello!
I am the main (as I am a single) developer of the diagram subsystem in the IntelliJ platform.

Let me clarify a few points relating to the functionality we provide:

  1. The history of diagrams in IntelliJ platform is pretty complicated and uneasy. There are three ways of implementing diagram functionality in platform now, each with its own problems. You may read high-level overview about them here. To put it shortly, none of the existing diagram API is developer-friendly.
  2. We are developing a completely-new extra-concise API for diagrams in a builder pattern (inside `com.intellij.diagram.v2`). Just give it a graph and it will do everything on its own. We hope it to become available in 2022.1. It will be limited in its functionality a but at least it is enough for all our own diagrams. This API will become the main to develop new diagrams and the only for which we provide our support. So I would kindly suggest you wait for it a bit and use it then. Some unprecise API usage example:
    final var chartHandler = JBGraphChartFactory.getInstance().createBuilder()
      .setGraph(myGraph)
      .setToolbarActions(toolbarActions)
      .setNodePopupActions(nodePopupActions)
      .setOnNodeDoubleClickCallback(...)
      .setOnEdgeDoubleClickCallback(...)
    .setNodePainter(...)
    .setEdgePainter(...)
    ... .create(); final var chartComponent = chartHandler.getComponent();
  3. We do not provide any diagrams with editing support. I.e. you won't be able change any node/label content or add some node/edge manually, only maybe delete some excess nodes/edges. There are dozens of reasons behind it, but to put it shortly, if you would like do develop such functionality we won't be able to help you, except kindly suggesting avoiding it at all costs. To eliminate some problems with it we plan to introduce the functionality of exporting our diagrams into full-featured diagram editors. So that our users could export our diagram into professional editor and edit it there additionaly if they would like to.
  4. We use yFiles for Java 2.14 version. It's pretty old, but its update will be uneasy as we hack into it deeply to solve some performance/UX-customizability issues. You can always use just bare yFiles wrappers we have, unlocking the full power and avoiding all the strange machinery we have, but be aware that you would likely need to write a lot of code as the API is pretty low-level.
  5. I will try to check the issue with manual positioning soon, I am sorry for the delay.

So to answer the questions you have asked:

  • > Is there in recent IntelliJ Ultimate 2021.3 (213.5744.223) a library that replaced com.intellij.openapi.graph (based on yWorks one)?

    Currently no, but it is approaching and is likely to become available in 2022.1. It will have smaller functionality but will be also in orders of magnitude easier than everything we have now. All previous API will still be available as well.

  • > I know of com.intellij.diagram library, but I would like to do some custom layout and rendering of Graph nodes/ports and Edges (by adding some JComponents).

    You may do it with diagram package as well it is that it's unobvious how and is pretty hard :c That's why we are developing the new API.
  • > I can still use that package in 2021.3, but I encountered a blocking bug that I submitted yesterday:

    I will try to check it soon, sorry for that.
  • > One more question - which version of yWorks do IntelliJ 2021.3 uses ? 

    2.14. The docs for 2.17 are here. 2.17 and 2.14 are 99% the same regarding the provided API.
Comment actions Permalink

I can still use that package in 2021.3, but i encountered a blocking bug that i submitted yesterday: https://youtrack.jetbrains.com/issue/IDEA-284561

0
Comment actions Permalink

Christoffer thank you for the example project (that helped a lot).  I can confirm that the issue you are describing is indeed reproducible on 2021.3.

0
Comment actions Permalink

You're welcome, i'm glad it helped you!

0
Comment actions Permalink

One more question - which version of yWorks do IntelliJ 2021.3 uses ?  Seeing *Layouter like names of classes may indicate 1.x series, but how can we get this info ?

0
Comment actions Permalink

Just to mention, I found that the API supports layouts by using example below, which may indicate the graph API corresponds to some between version of yWorks 1.x or 2.x .

final OrthogonalLayouter orthogonalLayouter = GraphManager.getGraphManager().createOrthogonalLayouter();
(...)
graphBuilder.getView().applyLayout(orthogonalLayouter);
0
Comment actions Permalink

@... - thank you for a clear and comprehensive answer.

0
Comment actions Permalink

@... - Thank you, i'm so happy that you have eyes on it.

0

Please sign in to leave a comment.